Youen Toupin
3 years ago
10 changed files with 104 additions and 16 deletions
@ -1,4 +1,12 @@
|
||||
import m from 'mithril'; |
||||
import MainPage from './main-page'; |
||||
|
||||
m.mount(document.body, MainPage); |
||||
import Layout from './layout'; |
||||
import RawDataPage from './raw-data-page'; |
||||
import DashboardPage from './dashboard-page'; |
||||
|
||||
require('../node_modules/bulma/css/bulma.css'); |
||||
|
||||
m.route(document.body, "/raw", { |
||||
"/dashboard": { render: () => m(Layout, m(DashboardPage)) }, |
||||
"/raw": { render: () => m(Layout, m(RawDataPage)) }, |
||||
}); |
||||
|
@ -0,0 +1,29 @@
|
||||
import m from 'mithril'; |
||||
import { MonitorApi, Status } from './monitor-api'; |
||||
|
||||
export default class DashboardPage { |
||||
api = new MonitorApi(); |
||||
status?: Status; |
||||
autoRefresh = true; |
||||
|
||||
oninit() { |
||||
this.refresh(); |
||||
} |
||||
|
||||
onbeforeremove() { |
||||
this.autoRefresh = false; |
||||
} |
||||
|
||||
async refresh() { |
||||
this.status = await this.api.getStatus(); |
||||
if(this.autoRefresh) |
||||
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500); |
||||
} |
||||
|
||||
view() { |
||||
return this.status |
||||
? <div class="dashboard-page"> |
||||
</div> |
||||
: <p>Chargement...</p>; |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
import m from 'mithril'; |
||||
|
||||
require("./layout.css"); |
||||
|
||||
export default class Layout { |
||||
private menuActive = false; |
||||
|
||||
view(vnode: m.Vnode) { |
||||
return [ |
||||
<nav class="navbar" role="navigation" aria-label="main navigation"> |
||||
<div class="navbar-brand"> |
||||
<a class="navbar-item" href='#!/dashboard'>Tableau de bord</a> |
||||
|
||||
<a role="button" class={'navbar-burger ' + (this.menuActive ? 'is-active' : '')} onclick={() => this.menuActive = !this.menuActive} aria-label="menu" aria-expanded="false" data-target="mainMenu"> |
||||
<span aria-hidden="true"></span> |
||||
<span aria-hidden="true"></span> |
||||
<span aria-hidden="true"></span> |
||||
</a> |
||||
</div> |
||||
|
||||
<div id="mainMenu" class={'navbar-menu ' + (this.menuActive ? 'is-active' : '')}> |
||||
<div class="navbar-start" onclick={() => { this.menuActive = false; return true; }}> |
||||
<a class="navbar-item" href='#!/raw'>Données brutes</a> |
||||
</div> |
||||
</div> |
||||
</nav>, |
||||
|
||||
<section> |
||||
{vnode.children} |
||||
</section> |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
.raw-data-page p { |
||||
font-size: 2rem; |
||||
} |
Loading…
Reference in new issue