add dashboard

This commit is contained in:
jr-k 2024-07-30 18:20:12 +02:00
parent bb236ff1be
commit 9e20bb65bd
10 changed files with 125 additions and 1 deletions

2
.gitignore vendored
View File

@ -20,6 +20,6 @@ var/run/*
venv/ venv/
node_modules node_modules
tmp.py tmp.py
!/plugins/user/Dashboard/* !/plugins/user/Dashboard
data/www/plugins/* data/www/plugins/*
!data/www/plugins/.gitkeep !data/www/plugins/.gitkeep

View File

@ -0,0 +1,29 @@
from src.interface.ObPlugin import ObPlugin
from typing import List, Dict
from src.model.entity.Variable import Variable
from src.model.enum.HookType import HookType
from src.model.hook.HookRegistration import HookRegistration
class Dashboard(ObPlugin):
def use_id(self):
return 'dashboard'
def use_title(self):
return self.translate('plugin_title')
def use_description(self):
return self.translate('plugin_description')
def use_variables(self) -> List[Variable]:
return []
def use_hooks_registrations(self) -> List[HookRegistration]:
return [
super().add_functional_hook_registration(hook=HookType.H_ROOT_NAV_ELEMENT_START, priority=10, function=self.hook_navigation),
]
def hook_navigation(self) -> str:
return self.render_view('@hook_navigation.jinja.html')

View File

@ -0,0 +1,15 @@
from flask import Flask, render_template
from src.interface.ObController import ObController
class DashboardController(ObController):
def register(self):
self._app.add_url_rule('/dashboard', 'dashboard', self._auth(self.dashboard), methods=['GET'])
def dashboard(self):
return self.render_view(
'@dashboard.jinja.html',
count_players=len(self._model_store.node_player().get_node_players())
)

View File

@ -0,0 +1,5 @@
{
"plugin_title": "Dashboard",
"plugin_description": "Adds a dashboard reachable from navigation (has no use - developer demo plugin only)",
"menu_title": "Dashboard"
}

View File

@ -0,0 +1,5 @@
{
"plugin_title": "Panel de control",
"plugin_description": "Agrega un panel de control accesible desde la navegación (no utilizado, solo complemento de demostración para desarrolladores)",
"menu_title": "Panel de control"
}

View File

@ -0,0 +1,5 @@
{
"plugin_title": "Tableau de bord",
"plugin_description": "Ajoute un tableau de bord accessible depuis la navigation (n'a aucune utilisé - plugin de démo développeur seulement)",
"menu_title": "Tableau de bord"
}

View File

@ -0,0 +1,5 @@
{
"plugin_title": "Dashboard",
"plugin_description": "Aggiunge una dashboard raggiungibile dalla navigazione (non utilizzato - solo plug-in demo per sviluppatori)",
"menu_title": "Dashboard"
}

View File

@ -0,0 +1,3 @@
.inner h3 {
color: red !important;
}

View File

@ -0,0 +1,52 @@
{% extends '::base.jinja.html' %}
{% block page_title %}
{{ l.dashboard_menu_title }}
{% endblock %}
{% block add_css %}
<link rel="stylesheet" href="{{ STATIC_PLUGIN_PREFIX }}css/dashboard.css"/>
{% endblock %}
{% block add_js %}
{% endblock %}
{% block body_class %}view-dashboard{% endblock %}
{% block pill_menu %}
{% with pills=[
{"name": l.dashboard_menu_title, "route": "dashboard", "icon": "fa-dashboard"},
] %}
{% include '::core/pill-menu.jinja.html' %}
{% endwith %}
{% endblock %}
{% block page %}
<div class="top-content">
<div class="top-actions">
<button type="button" class="btn btn-neutral">
<i class="fa fa-hand"></i>
</button>
</div>
</div>
<div class="bottom-content">
<div class="page-content">
<div class="inner">
<div class="vertical">
<h3>
{{ l.dashboard_menu_title }}
</h3>
<p>Hello world ! You have {{ count_players }} player(s)</p>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,5 @@
<li class="{{ 'active' if request.url_rule.endpoint == 'dashboard' }}">
<a href="{{ url_for('dashboard') }}">
<i class="fa fa-dashboard"></i> {{ l.dashboard_menu_title }}
</a>
</li>