frontend support for port poe enable/disable
This commit is contained in:
@@ -137,6 +137,17 @@ __PACKAGE__->belongs_to( neighbor_alias => 'Netdisco::DB::Result::DeviceIp',
|
|||||||
{ join_type => 'LEFT' },
|
{ join_type => 'LEFT' },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
=head2 power
|
||||||
|
|
||||||
|
Returns a row from the C<device_port_power> table if one refers to this
|
||||||
|
device port.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
__PACKAGE__->might_have( power => 'Netdisco::DB::Result::DevicePortPower', {
|
||||||
|
'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port',
|
||||||
|
});
|
||||||
|
|
||||||
=head2 port_vlans_tagged
|
=head2 port_vlans_tagged
|
||||||
|
|
||||||
Returns a set of rows from the C<device_port_vlan> table relating to this
|
Returns a set of rows from the C<device_port_vlan> table relating to this
|
||||||
|
|||||||
@@ -31,6 +31,16 @@ __PACKAGE__->set_primary_key("port", "ip");
|
|||||||
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02
|
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02
|
||||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sHcdItRUFUOAtIZQjdWbcg
|
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sHcdItRUFUOAtIZQjdWbcg
|
||||||
|
|
||||||
|
=head1 RELATIONSHIPS
|
||||||
|
|
||||||
|
=head2 port
|
||||||
|
|
||||||
|
Returns the entry from the C<port> table for which this Power entry applies.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
__PACKAGE__->belongs_to( port => 'Netdisco::DB::Result::DevicePort', {
|
||||||
|
'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port',
|
||||||
|
});
|
||||||
|
|
||||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ hook 'before' => sub {
|
|||||||
{ name => 'c_mac', label => 'Port MAC', default => '' },
|
{ name => 'c_mac', label => 'Port MAC', default => '' },
|
||||||
{ name => 'c_mtu', label => 'MTU', default => '' },
|
{ name => 'c_mtu', label => 'MTU', default => '' },
|
||||||
{ name => 'c_vlan', label => 'Native VLAN', default => 'on' },
|
{ name => 'c_vlan', label => 'Native VLAN', default => 'on' },
|
||||||
{ name => 'c_vmember', label => 'VLAN Membership', default => 'on' },
|
{ name => 'c_vmember', label => 'Tagged VLANs', default => 'on' },
|
||||||
|
{ name => 'c_power', label => 'PoE', default => '' },
|
||||||
{ name => 'c_nodes', label => 'Connected Nodes', default => '' },
|
{ name => 'c_nodes', label => 'Connected Nodes', default => '' },
|
||||||
{ name => 'c_neighbors', label => 'Connected Devices', default => 'on' },
|
{ name => 'c_neighbors', label => 'Connected Devices', default => 'on' },
|
||||||
{ name => 'c_stp', label => 'Spanning Tree', default => '' },
|
{ name => 'c_stp', label => 'Spanning Tree', default => '' },
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ ajax '/ajax/portcontrol' => sub {
|
|||||||
'c_port' => 'portcontrol',
|
'c_port' => 'portcontrol',
|
||||||
'c_name' => 'portname',
|
'c_name' => 'portname',
|
||||||
'c_vlan' => 'vlan',
|
'c_vlan' => 'vlan',
|
||||||
|
'c_power' => 'power',
|
||||||
);
|
);
|
||||||
|
|
||||||
my $action = $action_map{ param('field') };
|
my $action = $action_map{ param('field') };
|
||||||
my $subaction = ($action eq 'portcontrol'
|
my $subaction = ($action =~ m/^(?:power|portcontrol)/
|
||||||
? (param('action') ."-other")
|
? (param('action') ."-other")
|
||||||
: param('value'));
|
: param('value'));
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,19 @@ body {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nd_power_icon {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-off {
|
||||||
|
vertical-align: middle;
|
||||||
|
color: darkRed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nd_power_on {
|
||||||
|
color: darkGreen;
|
||||||
|
}
|
||||||
|
|
||||||
/* placement of port link when port admin hint is enabled */
|
/* placement of port link when port admin hint is enabled */
|
||||||
.nd_editable_cell > .nd_this_port_only {
|
.nd_editable_cell > .nd_this_port_only {
|
||||||
margin-left: 18px;
|
margin-left: 18px;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// user clicked or asked for port changes to be submitted via ajax
|
// user clicked or asked for port changes to be submitted via ajax
|
||||||
function port_control (e) {
|
function port_control (e) {
|
||||||
var td = $(e).closest('.nd_editable_cell');
|
var td = $(e).closest('td');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
@@ -30,6 +30,17 @@ function port_control (e) {
|
|||||||
$(e).data('tooltip').options.title = 'Click to Disable';
|
$(e).data('tooltip').options.title = 'Click to Disable';
|
||||||
td.attr('data-action', 'down');
|
td.attr('data-action', 'down');
|
||||||
}
|
}
|
||||||
|
else if ($.trim(td.attr('data-action')) == 'false') {
|
||||||
|
$(e).next('span').text('');
|
||||||
|
$(e).toggleClass('nd_power_on');
|
||||||
|
$(e).data('tooltip').options.title = 'Click to Enable';
|
||||||
|
td.attr('data-action', 'true');
|
||||||
|
}
|
||||||
|
else if ($.trim(td.attr('data-action')) == 'true') {
|
||||||
|
$(e).toggleClass('nd_power_on');
|
||||||
|
$(e).data('tooltip').options.title = 'Click to Disable';
|
||||||
|
td.attr('data-action', 'false');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
,error: function() {
|
,error: function() {
|
||||||
toastr.error('Failed to submit change request');
|
toastr.error('Failed to submit change request');
|
||||||
|
|||||||
@@ -71,11 +71,11 @@
|
|||||||
|
|
||||||
[% IF params.c_name %]
|
[% IF params.c_name %]
|
||||||
[% IF vars.user.port_control AND params.c_admin %]
|
[% IF vars.user.port_control AND params.c_admin %]
|
||||||
<td class="center_cell nd_editable_cell" contenteditable="true"
|
<td nowrap class="center_cell nd_editable_cell" contenteditable="true"
|
||||||
data-field="c_name" data-for-device="[% device %]" data-for-port="[% row.port | html_entity %]">
|
data-field="c_name" data-for-device="[% device %]" data-for-port="[% row.port | html_entity %]">
|
||||||
<i class="icon-edit nd_edit_icon"></i>
|
<i class="icon-edit nd_edit_icon"></i>
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
<td class="center_cell">
|
<td nowrap class="center_cell">
|
||||||
[% END %]
|
[% END %]
|
||||||
<div class="nd_editable_cell_content">
|
<div class="nd_editable_cell_content">
|
||||||
[% row.name | html_entity %]
|
[% row.name | html_entity %]
|
||||||
@@ -135,6 +135,48 @@
|
|||||||
</td>
|
</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
[% IF params.c_power %]
|
||||||
|
[% IF row.power %]
|
||||||
|
[% IF row.power.admin == 'true' %]
|
||||||
|
[% IF vars.user.port_control AND params.c_admin %]
|
||||||
|
<td nowrap data-action="false"
|
||||||
|
data-field="c_power" data-for-device="[% device %]"
|
||||||
|
data-for-port="[% row.port | html_entity %]">
|
||||||
|
|
||||||
|
<i class="icon-off nd_power_icon nd_power_on"
|
||||||
|
rel="tooltip" data-placement="top" data-offset="3"
|
||||||
|
data-animation="" data-title="Click to Disable"></i>
|
||||||
|
[% ELSE %]
|
||||||
|
<td nowrap>
|
||||||
|
<i class="icon-off nd_power_on"></i>
|
||||||
|
[% END %]
|
||||||
|
<span>
|
||||||
|
[% IF row.power.power > 0 %]
|
||||||
|
[% row.power.power %] mW
|
||||||
|
[% ELSE %]
|
||||||
|
([% row.power.status %])
|
||||||
|
[% END %]
|
||||||
|
</span>
|
||||||
|
[% ELSE %]
|
||||||
|
[% IF vars.user.port_control AND params.c_admin %]
|
||||||
|
<td nowrap data-action="true"
|
||||||
|
data-field="c_power" data-for-device="[% device %]"
|
||||||
|
data-for-port="[% row.port | html_entity %]">
|
||||||
|
|
||||||
|
<i class="icon-off nd_power_icon"
|
||||||
|
rel="tooltip" data-placement="top" data-offset="3"
|
||||||
|
data-animation="" data-title="Click to Enable"></i>
|
||||||
|
[% ELSE %]
|
||||||
|
<td>
|
||||||
|
<i class="icon-off"></i>
|
||||||
|
[% END %]
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
|
[% ELSE %]
|
||||||
|
<td></td>
|
||||||
|
[% END %]
|
||||||
|
[% END %]
|
||||||
|
|
||||||
[% IF params.c_nodes OR params.c_neighbors %]
|
[% IF params.c_nodes OR params.c_neighbors %]
|
||||||
<td>
|
<td>
|
||||||
[% IF params.c_neighbors AND row.remote_ip %]
|
[% IF params.c_neighbors AND row.remote_ip %]
|
||||||
|
|||||||
@@ -52,6 +52,11 @@
|
|||||||
port_control(this); // save
|
port_control(this); // save
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// activity for power enable/disable control
|
||||||
|
$('.nd_power_icon').click(function() {
|
||||||
|
port_control(this); // save
|
||||||
|
});
|
||||||
|
|
||||||
var dirty = false;
|
var dirty = false;
|
||||||
|
|
||||||
// activity for contenteditable control
|
// activity for contenteditable control
|
||||||
|
|||||||
Reference in New Issue
Block a user