refactored code to avoid relative paths
added Component and Page base classes added Clock widget (wip)
This commit is contained in:
parent
245a3ec2e3
commit
f8c2a28c47
@ -19,6 +19,7 @@
|
|||||||
"purgecss-webpack-plugin": "^4.1.3",
|
"purgecss-webpack-plugin": "^4.1.3",
|
||||||
"style-loader": "^3.3.1",
|
"style-loader": "^3.3.1",
|
||||||
"ts-loader": "^9.2.8",
|
"ts-loader": "^9.2.8",
|
||||||
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "^4.6.2",
|
||||||
"webpack": "^5.70.0",
|
"webpack": "^5.70.0",
|
||||||
"webpack-cli": "^4.9.2"
|
"webpack-cli": "^4.9.2"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import m from 'mithril';
|
import m from 'mithril';
|
||||||
|
|
||||||
import Layout from './layout';
|
import Layout from './layout';
|
||||||
import RawDataPage from './raw-data-page';
|
import { RawDataPage } from 'pages/raw-data/raw-data-page';
|
||||||
import DashboardPage from './dashboard-page';
|
import { DashboardPage } from 'pages/dashboard/dashboard-page';
|
||||||
|
|
||||||
require('../node_modules/bulma/css/bulma.css');
|
require('../node_modules/bulma/css/bulma.css');
|
||||||
|
|
||||||
|
19
WebApp/src/components/component.ts
Normal file
19
WebApp/src/components/component.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import m from 'mithril';
|
||||||
|
|
||||||
|
export abstract class Component {
|
||||||
|
abstract view(vnode: m.Vnode): m.Children;
|
||||||
|
|
||||||
|
oninit(vnode: m.Vnode) {}
|
||||||
|
|
||||||
|
oncreate(vnode: m.Vnode) {}
|
||||||
|
|
||||||
|
onbeforeupdate(newVnode: m.Vnode, oldVnode: m.Vnode) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
onupdate(vnode: m.Vnode) {}
|
||||||
|
|
||||||
|
onbeforeremove(vnode: m.Vnode): Promise<void> | void {}
|
||||||
|
|
||||||
|
onremove(vnode: m.Vnode) {}
|
||||||
|
}
|
5
WebApp/src/components/page.ts
Normal file
5
WebApp/src/components/page.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { Component } from 'components/component';
|
||||||
|
|
||||||
|
export abstract class Page extends Component {
|
||||||
|
|
||||||
|
}
|
8
WebApp/src/components/widgets/clock.tsx
Normal file
8
WebApp/src/components/widgets/clock.tsx
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import m from 'mithril';
|
||||||
|
import { Component } from 'components/component'
|
||||||
|
|
||||||
|
export default class Clock extends Component {
|
||||||
|
view(vnode: m.Vnode<{}, {}>): m.Children {
|
||||||
|
return <p>clock</p>;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
import m from 'mithril';
|
import m from 'mithril';
|
||||||
import { MonitorApi, Status } from './monitor-api';
|
import { Page } from 'components/page';
|
||||||
|
import { MonitorApi, Status } from 'monitor-api';
|
||||||
|
import Clock from 'components/widgets/clock';
|
||||||
|
|
||||||
export default class DashboardPage {
|
export class DashboardPage extends Page {
|
||||||
status: Status = null;
|
status: Status = null;
|
||||||
autoRefresh = true;
|
autoRefresh = true;
|
||||||
|
|
||||||
@ -10,8 +12,8 @@ export default class DashboardPage {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
onbeforeremove() {
|
onbeforeremove(vnode: m.Vnode<{}, {}>) {
|
||||||
this.autoRefresh = false;
|
this.autoRefresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async refresh() {
|
async refresh() {
|
||||||
@ -23,6 +25,7 @@ export default class DashboardPage {
|
|||||||
view() {
|
view() {
|
||||||
return this.status
|
return this.status
|
||||||
? <div class="dashboard-page">
|
? <div class="dashboard-page">
|
||||||
|
<Clock/>
|
||||||
</div>
|
</div>
|
||||||
: <p>Chargement...</p>;
|
: <p>Chargement...</p>;
|
||||||
}
|
}
|
@ -1,9 +1,10 @@
|
|||||||
import m from 'mithril';
|
import m from 'mithril';
|
||||||
import { MonitorApi, Status } from './monitor-api';
|
import { Page } from 'components/page';
|
||||||
|
import { MonitorApi, Status } from 'monitor-api';
|
||||||
|
|
||||||
require("./raw-data-page.css");
|
require("./raw-data-page.css");
|
||||||
|
|
||||||
export default class RawDataPage {
|
export class RawDataPage extends Page {
|
||||||
status: Status = null;
|
status: Status = null;
|
||||||
autoRefresh = true;
|
autoRefresh = true;
|
||||||
|
|
@ -1,12 +1,15 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"module": "CommonJS",
|
"module": "ES6",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"jsxFactory": "m",
|
"jsxFactory": "m",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"moduleResolution": "node"
|
"moduleResolution": "node",
|
||||||
|
"baseUrl": "./src",
|
||||||
|
"paths": {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|||||||
|
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
const PurgecssPlugin = require('purgecss-webpack-plugin');
|
const PurgecssPlugin = require('purgecss-webpack-plugin');
|
||||||
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './src/app.ts',
|
entry: './src/app.ts',
|
||||||
@ -23,6 +24,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.tsx', '.ts', '.js'],
|
extensions: ['.tsx', '.ts', '.js'],
|
||||||
|
plugins: [new TsconfigPathsPlugin({})]
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
|
Loading…
Reference in New Issue
Block a user