fix: delete button, decription field not working; add ui response to clicking the clock

This commit is contained in:
Fabian Franz
2018-04-01 18:07:16 +02:00
committed by Franco Fichtner
parent a77e6ad333
commit d988835e17
4 changed files with 37 additions and 20 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
PLUGIN_NAME= wol
PLUGIN_VERSION= 2.0.d
PLUGIN_REVISION= 1
PLUGIN_REVISION= 2
PLUGIN_DEPENDS= wol
PLUGIN_COMMENT= Wake on LAN Service
PLUGIN_MAINTAINER= franco@opnsense.org
@@ -63,7 +63,7 @@ class WolController extends ApiMutableModelControllerBase
}
public function delHostAction($uuid) {
$this->delBase('host', $uuid);
$this->delBase('wolentry', $uuid);
}
public function searchHostAction()
{
@@ -12,7 +12,7 @@
<help>Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx</help>
</field>
<field>
<id>host.description</id>
<id>host.descr</id>
<label>Description</label>
<type>text</type>
<help>You may enter a description here for your reference (not parsed).</help>
@@ -1,16 +1,41 @@
<script>
function show_wake_result(data) {
BootstrapDialog.show({
type: data.status == 'OK' ? BootstrapDialog.TYPE_SUCCESS : BootstrapDialog.TYPE_DANGER,
title: "{{ lang._("Result") }}",
message: (data.status == 'OK' ?
'{{ lang._('Magic packet was sent successfully.') }}' :
'{{ lang._('The packet was not sent due to an error. Please consult the logs.') }}<br />' +
$('<pre>').text(data.error_msg).html()
),
buttons: [{
label: '{{ lang._('Close') }}',
action: function(dialog){
dialog.close();
}
}]
});
}
$( document ).ready(function() {
// delete host action
$("#act_wake_all").click(function(event){
event.preventDefault();
$.post('/api/wol/wol/wakeall', {}, function(data) {
BootstrapDialog.show({
type:BootstrapDialog.TYPE_INFO,
title: "{{ lang._("Result") }}",
message: '<ul>' + (data['results'].map(function(element) {
return `<li>${element.mac}: ${element.status}</li>`
}).join('')) + '</ul>'
})
BootstrapDialog.show({
type: BootstrapDialog.TYPE_INFO,
title: "{{ lang._("Result") }}",
message: '<ul>' + (data['results'].map(function(element) {
return `<li>${element.mac}: ${element.status}</li>`
}).join('')) + '</ul>',
buttons: [{
label: '{{ lang._('Close') }}',
action: function(dialog){
dialog.close();
}
}]
});
});
});
@@ -39,6 +64,7 @@ $( document ).ready(function() {
grid.find('.command-wake').click(function(event) {
event.preventDefault();
$.post('/api/wol/wol/set', {'uuid': this.dataset['rowId']}, function(data) {
show_wake_result(data);
});
});
});
@@ -63,16 +89,7 @@ $( document ).ready(function() {
// link save button to API set action
$("#wakeAct").click(function(){
ajaxCall(url="/api/wol/wol/set", data=getFormData('frm_wol_wake'),callback=function(data, status){
BootstrapDialog.show({
type: data.status == 'OK' ? BootstrapDialog.TYPE_SUCCESS : BootstrapDialog.TYPE_DANGER,
title: "{{ lang._("Result") }}",
message: (data.status == 'OK' ?
'{{ lang._('Magic packet was sent successfully.') }}' :
'{{ lang._('The packet was not sent due to an error. Please consult the logs.') }}<br />' +
$('<pre>').text(data.error_msg).html()
)
});
show_wake_result(data);
}, true);
});
});