/* global owl */ import { SingleData } from "./components/SingleData.js"; import { FooterButtons } from "./components/FooterButtons.js"; import { ServerDialog } from "./components/dialog/ServerDialog.js"; import { WifiDialog } from "./components/dialog/WifiDialog.js"; import useStore from "./hooks/useStore.js"; import { UpdateDialog } from "./components/dialog/UpdateDialog.js"; import { DeviceDialog } from "./components/dialog/DeviceDialog.js"; import { SixDialog } from "./components/dialog/SixDialog.js"; import { LoadingFullScreen } from "./components/LoadingFullScreen.js"; import { IconButton } from "./components/IconButton.js"; const { Component, xml, useState, onWillStart } = owl; export class Homepage extends Component { static props = {}; static components = { SingleData, FooterButtons, ServerDialog, WifiDialog, UpdateDialog, DeviceDialog, SixDialog, LoadingFullScreen, IconButton, }; setup() { this.store = useStore(); this.state = useState({ data: {}, loading: true, waitRestart: false }); this.store.advanced = localStorage.getItem("showAdvanced") === "true"; onWillStart(async () => { await this.loadInitialData(); }); setInterval(() => { this.loadInitialData(); }, 10000); } async loadInitialData() { try { const data = await this.store.rpc({ url: "/hw_posbox_homepage/data", }); if (data.system === "Linux") { this.store.isLinux = true; } this.state.data = data; this.store.base = data; this.state.loading = false; this.store.update = new Date().getTime(); } catch { console.warn("Error while fetching data"); } } async restartOdooService() { try { await this.store.rpc({ url: "/hw_posbox_homepage/restart_odoo_service", }); this.state.waitRestart = true; } catch { console.warn("Error while restarting Odoo Service"); } } toggleAdvanced() { this.store.advanced = !this.store.advanced; localStorage.setItem("showAdvanced", this.store.advanced); } static template = xml` Restarting IoT Box, please wait...

IoT Box -


Loading...
`; }