#luci-app-alpha-config

1 messages · Page 1 of 1 (latest)

leaden spoke
#

Izin untuk RPC
Lokasi File = /usr/share/rpcd/acl.d/luci-app-alpha-config.json

{
        "luci-app-alpha-config": {
                "description": "Grant access to alpha config",
                "write": {
                        "file": {
                                "/www/luci-static/alpha/background/*": [ "write" ],
                                "/bin/chmod *": [ "exec" ]
                        }
                }
        }
}
#

Menu
Lokasi File = /usr/share/luci/menu.d/luci-app-alpha-config.json

{
        "admin/system/alpha-config": {
                "title": "Alpha Config",
                "order": 89,
                "action": {
                        "type": "view",
                        "path": "alpha"
                },
                "depends": {
                        "acl": [ "luci-app-alpha-config" ]
                }
        }
}
#

File menu JS

'use strict';
'require view';
'require form';
'require fs';
'require ui';

return view.extend({
    handleSaveApply: null,
    handleSave: null,
    handleReset: null,
    render: function () {
        var m, s, o;
        var bg_path = '/www/luci-static/alpha/background/';
        m = new form.Map('alpha', _('Alpha theme configuration'), _('Here you can set background login and dashboard themes. Chrome is recommended.'));
        s = m.section(form.TypedSection, 'alpha');
        s.anonymous = true;

        o = s.option(form.Button, 'login', _('Login background'),
            _('Files will be uploaded to <code>%s</code>.').format(bg_path));
        o.inputstyle = 'action';
        o.inputtitle = _('Upload...');
        o.onclick = function(ev, section_id) {
            var file = bg_path + 'login.png';
            return ui.uploadFile(file, ev.target).then(function(res) {
                return fs.exec('/bin/chmod', ['0644', file]).then(function() {
                    return location.reload();
                });
            })
            .catch(function(e) { ui.addNotification(null, E('p', e.message)); });
        };
        o.modalonly = true;

        o = s.option(form.Button, 'dashboard', _('Dashboard background'),
            _('Files will be uploaded to <code>%s</code>.').format(bg_path));
        o.inputstyle = 'action';
        o.inputtitle = _('Upload...');
        o.onclick = function(ev, section_id) {
            var file = bg_path + 'dashboard.png';
            return ui.uploadFile(file, ev.target).then(function(res) {
                return fs.exec('/bin/chmod', ['0644', file]).then(function() {
                    return location.reload();
                });
            })
            .catch(function(e) { ui.addNotification(null, E('p', e.message)); });
        };
        o.modalonly = true;

        return m.render();
    },
});