Exemplo n.º 1
0
def plugin_route(plugin):
    """ Route to the plugin pane template """
    js_folder = os.path.abspath(os.path.join(template_folder, '..', 'static', 'js'))
    style_folder = os.path.abspath(os.path.join(template_folder, '..', 'static', 'css', 'dist'))
    template_file = os.path.join(template_folder, 'plugins', plugin, 'index.html')
    script_file = os.path.join(js_folder, 'plugins', plugin, 'index.js')
    style_file = os.path.join(style_folder, 'webpanel', 'plugins', plugin+'.css')

    conf = Config.get(plugin) or {}
    if os.path.isfile(template_file):
        conf['_template_file'] = '/' + '/'.join(template_file.split(os.sep)[-3:])

    if os.path.isfile(script_file):
        conf['_script_file'] = '/'.join(script_file.split(os.sep)[-4:])

    if os.path.isfile(style_file):
        conf['_style_file'] = 'css/dist/' + style_file[len(style_folder)+1:]

    http_conf = Config.get('backend.http')
    return render_template('plugin.html',
                           plugin=plugin,
                           conf=conf,
                           template=conf.get('_template_file', {}),
                           script=conf.get('_script_file', {}),
                           style=conf.get('_style_file', {}),
                           utils=HttpUtils,
                           token=Config.get('token'),
                           websocket_port=get_websocket_port(),
                           template_folder=template_folder,
                           static_folder=static_folder,
                           has_ssl=http_conf.get('ssl_cert') is not None)
Exemplo n.º 2
0
def dashboard():
    """ Route for the fullscreen dashboard """
    http_conf = Config.get('backend.http')
    dashboard_conf = http_conf.get('dashboard', {})

    return render_template('dashboard.html',
                           config=dashboard_conf,
                           utils=HttpUtils,
                           token=Config.get('token'),
                           static_folder=static_folder,
                           template_folder=template_folder,
                           websocket_port=get_websocket_port(),
                           has_ssl=http_conf.get('ssl_cert') is not None)
Exemplo n.º 3
0
def index():
    """ Route to the main web panel """
    configured_plugins = Config.get_plugins()
    enabled_templates = {}
    enabled_scripts = {}
    enabled_styles = {}

    js_folder = os.path.abspath(
        os.path.join(template_folder, '..', 'static', 'js'))
    style_folder = os.path.abspath(
        os.path.join(template_folder, '..', 'static', 'css', 'dist'))

    for plugin, conf in configured_plugins.items():
        template_file = os.path.join(template_folder, 'plugins', plugin,
                                     'index.html')

        script_file = os.path.join(js_folder, 'plugins', plugin, 'index.js')
        style_file = os.path.join(style_folder, 'webpanel', 'plugins',
                                  plugin + '.css')

        if os.path.isfile(template_file):
            conf['_template_file'] = '/' + '/'.join(
                template_file.split(os.sep)[-3:])
            enabled_templates[plugin] = conf

        if os.path.isfile(script_file):
            conf['_script_file'] = '/'.join(script_file.split(os.sep)[-4:])
            enabled_scripts[plugin] = conf

        if os.path.isfile(style_file):
            conf['_style_file'] = 'css/dist/' + style_file[len(style_folder) +
                                                           1:]
            enabled_styles[plugin] = conf

    http_conf = Config.get('backend.http')
    return render_template('index.html',
                           templates=enabled_templates,
                           scripts=enabled_scripts,
                           styles=enabled_styles,
                           utils=HttpUtils,
                           token=Config.get('token'),
                           websocket_port=get_websocket_port(),
                           template_folder=template_folder,
                           static_folder=static_folder,
                           plugins=Config.get_plugins(),
                           backends=Config.get_backends(),
                           has_ssl=http_conf.get('ssl_cert') is not None)
Exemplo n.º 4
0
def render_dashboard(name):
    """ Route for the dashboard """
    return render_template('index.html',
                           utils=HttpUtils,
                           websocket_port=get_websocket_port())
Exemplo n.º 5
0
def index():
    """ Route to the main web panel """
    configured_plugins = Config.get_plugins()
    enabled_templates = {}
    enabled_scripts = {}
    enabled_styles = {}

    enabled_plugins = set(request.args.get('enabled_plugins', '').split(','))
    for plugin in enabled_plugins:
        if plugin not in configured_plugins:
            configured_plugins[plugin] = {}

    configured_plugins['execute'] = {}
    disabled_plugins = set(request.args.get('disabled_plugins', '').split(','))

    js_folder = os.path.abspath(
        os.path.join(template_folder, '..', 'static', 'js'))
    style_folder = os.path.abspath(
        os.path.join(template_folder, '..', 'static', 'css', 'dist'))

    for plugin, conf in configured_plugins.copy().items():
        if plugin in disabled_plugins:
            if plugin == 'execute':
                configured_plugins.pop('execute')
            continue

        template_file = os.path.join(template_folder, 'plugins', plugin,
                                     'index.html')

        script_file = os.path.join(js_folder, 'plugins', plugin, 'index.js')
        style_file = os.path.join(style_folder, 'webpanel', 'plugins',
                                  plugin + '.css')

        if os.path.isfile(template_file):
            conf['_template_file'] = '/' + '/'.join(
                template_file.split(os.sep)[-3:])
            enabled_templates[plugin] = conf

        if os.path.isfile(script_file):
            conf['_script_file'] = '/'.join(script_file.split(os.sep)[-4:])
            enabled_scripts[plugin] = conf

        if os.path.isfile(style_file):
            conf['_style_file'] = 'css/dist/' + style_file[len(style_folder) +
                                                           1:]
            enabled_styles[plugin] = conf

    http_conf = Config.get('backend.http')
    return render_template('index.html',
                           templates=enabled_templates,
                           scripts=enabled_scripts,
                           styles=enabled_styles,
                           utils=HttpUtils,
                           token=Config.get('token'),
                           websocket_port=get_websocket_port(),
                           template_folder=template_folder,
                           static_folder=static_folder,
                           plugins=Config.get_plugins(),
                           backends=Config.get_backends(),
                           procedures=json.dumps(Config.get_procedures(),
                                                 cls=Message.Encoder),
                           has_ssl=http_conf.get('ssl_cert') is not None)