add frontend pseudo device add form

This commit is contained in:
Oliver Gorwits
2013-05-05 23:53:20 +01:00
parent 3271c01931
commit f0899e16b3
4 changed files with 82 additions and 10 deletions

View File

@@ -11,14 +11,17 @@ register_admin_task({
label => 'Manage Pseudo Devices', label => 'Manage Pseudo Devices',
}); });
#ajax '/ajax/content/report/duplexmismatch' => sub { ajax '/ajax/content/admin/pseudodevice' => sub {
# my $set = schema('netdisco')->resultset('Virtual::DuplexMismatch'); my $set = schema('netdisco')->resultset('Device')
# return unless $set->count; ->search(
# {vendor => 'netdisco'},
# content_type('text/html'); {order_by => { -desc => 'last_discover' }},
# template 'ajax/report/duplexmismatch.tt', { );
# results => $set,
# }, { layout => undef }; content_type('text/html');
#}; template 'ajax/admintask/pseudodevice.tt', {
results => $set,
}, { layout => undef };
};
true; true;

View File

@@ -191,6 +191,11 @@ td {
text-align: center; text-align: center;
} }
/* manage pseudo devices table form */
.center_cell input {
margin-bottom: 2px;
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* tabs */ /* tabs */

View File

@@ -0,0 +1,32 @@
<table class="table-bordered table-condensed table-striped">
<thead>
<tr>
<th class="center_cell">Device Name</th>
<th class="center_cell">Device IP</th>
<th class="center_cell">Number of Ports</th>
<th class="center_cell">Action</th>
</tr>
</thead>
</tbody>
<tr>
<form name="add">
<td class="center_cell"><input name="dns" type="text"></td>
<td class="center_cell"><input name="ip" type="text"></td>
<td class="center_cell"><input name="ports" type="number"></td>
<td class="center_cell">
<button class="btn btn-small" name="add" type="submit"><i class="icon-plus-sign"></i> Add</button>
</td>
</form>
</tr>
[% WHILE (row = results.next) %]
<tr>
<td class="center_cell"><a class="nd_linkcell"
href="[% device_ports %]&q=[% row.dns | uri %]">[% row.dns | html_entity %]</a></td>
<td class="center_cell">[% row.ip | html_entity %]</td>
<td class="center_cell">[% row.ports.count | html_entity %]</td>
<td class="center_cell"><a class="btn btn-small" href="#"><i class="icon-plus-sign"></i> Add</a></td>
</tr>
[% END %]
</tbody>
</table>

View File

@@ -4,7 +4,39 @@
// this is called by do_search to support local code // this is called by do_search to support local code
// here, when tab changes need to strike/unstrike the navbar search // here, when tab changes need to strike/unstrike the navbar search
function inner_view_processing(tab) { } function inner_view_processing(tab) {
var target = '#pseudodevice_pane';
// activity for add pseudo device
// dynamically bind to all forms in the table
$(target).on('submit', 'form', function() {
// stop form from submitting normally
event.preventDefault();
// submit the query and put results into the tab pane
$.ajax({
type: 'POST'
,async: false
,dataType: 'html'
,url: uri_base + '/ajax/content/admin/pseudodevice/' + $(this).attr('name')
,data: $(this).serializeArray()
,beforeSend: function() {
$(target).html(
'<div class="span2 alert">Waiting for results...</div>'
);
}
,success: function(content) {
$(target).html(content);
}
,error: function() {
$(target).html(
'<div class="span5 alert alert-error">' +
'Update failed! Please contact your site administrator.</div>'
);
}
});
});
}
// on load, check initial Device Search Options form state, // on load, check initial Device Search Options form state,
// and on each change to the form fields // and on each change to the form fields