forked from openwrt/luci
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
luci-app-keepalived: add notification tab
This commit adds a tab to modify keepalived.user file. With this commit it is possible to issue custom commands. Signed-off-by: Christian Korber <ckorber@tdt.de>
- Loading branch information
1 parent
a4a5cf6
commit 03f37cf
Showing
3 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ications/luci-app-keepalived/htdocs/luci-static/resources/view/keepalived/notification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
'require view'; | ||
'require fs'; | ||
'require ui'; | ||
|
||
var isReadonlyView = !L.hasViewPermission() || null; | ||
|
||
return view.extend({ | ||
load: function() { | ||
return L.resolveDefault(fs.read('/etc/keepalived.user'), ''); | ||
}, | ||
|
||
handleSave: function(ev) { | ||
var value = (document.querySelector('textarea').value || '').trim().replace(/\r\n/g, '\n') + '\n'; | ||
|
||
return fs.write('/etc/keepalived.user', value).then(function(rc) { | ||
document.querySelector('textarea').value = value; | ||
ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'); | ||
|
||
return fs.exec('/etc/init.d/keepalived', [ 'reload' ]); | ||
}).catch(function(e) { | ||
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); | ||
}); | ||
}, | ||
|
||
render: function(keepalived) { | ||
return E([ | ||
E('h2', _('Keepalived.user')), | ||
E('p', { 'class': 'cbi-section-descr' }, _('This is the /etc/keepalived.user file in which custom commands can be defined.')), | ||
E('p', {}, E('textarea', { 'style': 'width:100%', 'rows': 25, 'disabled': isReadonlyView }, [ keepalived != null ? keepalived : '' ])) | ||
]); | ||
}, | ||
|
||
handleSaveApply: null, | ||
handleReset: null | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters