diff --git a/rollup.config.js b/rollup.config.js index 1b03a2e..a832614 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,81 +1,97 @@ -import svelte from 'rollup-plugin-svelte'; -import commonjs from '@rollup/plugin-commonjs'; -import resolve from '@rollup/plugin-node-resolve'; -import livereload from 'rollup-plugin-livereload'; -import { terser } from 'rollup-plugin-terser'; -import css from 'rollup-plugin-css-only'; +import svelte from "rollup-plugin-svelte"; +import commonjs from "@rollup/plugin-commonjs"; +import resolve from "@rollup/plugin-node-resolve"; +import livereload from "rollup-plugin-livereload"; +import { terser } from "rollup-plugin-terser"; +import css from "rollup-plugin-css-only"; import sveltePreprocess from "svelte-preprocess"; const production = !process.env.ROLLUP_WATCH; function serve() { - let server; + let server; - function toExit() { - if (server) server.kill(0); - } + function toExit() { + if (server) server.kill(0); + } - return { - writeBundle() { - if (server) return; - server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { - stdio: ['ignore', 'inherit', 'inherit'], - shell: true - }); + return { + writeBundle() { + if (server) return; + server = require("child_process").spawn( + "npm", + ["run", "start", "--", "--dev"], + { + stdio: ["ignore", "inherit", "inherit"], + shell: true, + } + ); - process.on('SIGTERM', toExit); - process.on('exit', toExit); - } - }; + process.on("SIGTERM", toExit); + process.on("exit", toExit); + }, + }; } export default { - input: 'src/main.js', - output: { - sourcemap: true, - format: 'iife', - name: 'app', - file: 'public/build/bundle.js' - }, - plugins: [ - svelte({ - compilerOptions: { - // enable run-time checks when not in production - dev: !production - }, - preprocess: sveltePreprocess({ - sourceMap: !production, - postcss: true, - }), - }), - // we'll extract any component CSS out into - // a separate file - better for performance - css({ output: 'bundle.css' }), + input: "src/main.js", + output: { + sourcemap: true, + format: "iife", + name: "app", + file: "public/build/bundle.js", + }, + plugins: [ + terser({ + ecma: 2020, + mangle: { toplevel: true }, + compress: { + module: true, + toplevel: true, + unsafe_arrows: true, + drop_console: false, + drop_debugger: true, + }, + output: { quote_style: 1 }, + }), + svelte({ + compilerOptions: { + // enable run-time checks when not in production + dev: !production, + }, + preprocess: sveltePreprocess({ + sourceMap: !production, + postcss: true, + }), + }), + // we'll extract any component CSS out into + // a separate file - better for performance + css({ output: "bundle.css" }), - // If you have external dependencies installed from - // npm, you'll most likely need these plugins. In - // some cases you'll need additional configuration - - // consult the documentation for details: - // https://github.com/rollup/plugins/tree/master/packages/commonjs - resolve({ - browser: true, - dedupe: ['svelte'] - }), - commonjs(), + // If you have external dependencies installed from + // npm, you'll most likely need these plugins. In + // some cases you'll need additional configuration - + // consult the documentation for details: + // https://github.com/rollup/plugins/tree/master/packages/commonjs + resolve({ + browser: true, + dedupe: ["svelte"], + }), + commonjs(), - // In dev mode, call `npm run start` once - // the bundle has been generated - !production && serve(), + // In dev mode, call `npm run start` once + // the bundle has been generated + !production && serve(), - // Watch the `public` directory and refresh the - // browser on changes when not in production - !production && livereload('public'), + // Watch the `public` directory and refresh the + // browser on changes when not in production + !production && livereload("public"), - // If we're building for production (npm run build - // instead of npm run dev), minify - production && terser() - ], - watch: { - clearScreen: false - } + // If we're building for production (npm run build + // instead of npm run dev), minify + production && terser(), + ], + watch: { + clearScreen: false, + }, }; diff --git a/src/App.svelte b/src/App.svelte index a51ecb6..4753a35 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -48,8 +48,9 @@ const rebootingTimeout = 30000; const updatingTimeout = 130000; let rebootTimer; - let opened = false; + let opened = true; let preventMove = false; + let screenSize; const blobDebug = false; const devMode = true; @@ -182,6 +183,9 @@ onMount(async () => { console.log("[i]", "mounted"); await getUser(); + onCheck(); + + opened = screenSize > 900 ? true : false; selectedDeviceDataRefresh(); //флаг первого запроса списка устройств firstDevListRequest = true; @@ -1125,14 +1129,10 @@ //**********************************************************modal*************************************************************************/ function onCheck() { - let width = screen.width; - //console.log("width", width); - if (width < 900) { + if (screenSize < 900) { preventMove = true; - //opened = false; } else { preventMove = false; - //opened = true; } } @@ -1244,6 +1244,8 @@ } + +
{#if showAwaitingCircle} diff --git a/src/lang.js b/src/lang.js index 2074372..6144b4a 100644 --- a/src/lang.js +++ b/src/lang.js @@ -3,7 +3,7 @@ export default { "login.email": "Email", "login.pass": "Пароль", "login.login": "Вход", - "profile.update": "Обновить", + "profile.update": "Собрать прошивку", ok_success: "Задача запущена", err_order_exist: "Ваша задача выполняется! Cледующию задачу можно будет запустить после завершения", err_of_login: "Ошибка входа в систему", @@ -20,7 +20,7 @@ export default { "login.email": "Email", "login.pass": "Password", "login.login": "Login", - "profile.update": "Update", + "profile.update": "Собрать прошивку", ok_success: "Задача запущена", err_order_exist: "Ваша задача выполняется! Cледующию задачу можно будет запустить после завершения", err_of_login: "Ошибка входа в систему", diff --git a/src/pages/Profile.svelte b/src/pages/Profile.svelte index 51b8575..796d41a 100644 --- a/src/pages/Profile.svelte +++ b/src/pages/Profile.svelte @@ -8,15 +8,40 @@ export let show; export let myProfileJson; export let userdata; - let errors = []; - let allmodeinfo = null; + let userBuilds = null; + var updateInterval; onMount(async () => { await getModInfo(); + await getUserBuilds(); }); + const st = { + 0: "", + 1: "В процессе", + 2: "Ок", + 3: "Ошибка", + }; + + function checkStatus(userBuilds) { + if (userBuilds[0].processed) { + clearInterval(updateInterval); + console.log("no interval - all task done"); + } else { + console.log("non completed task exist!"); + if (!updateInterval) { + console.log("interval checking started"); + updateInterval = setInterval(periodicTask, 10000); + } + } + } + + const periodicTask = async () => { + await getUserBuilds(); + }; + const getModInfo = async () => { try { let res = await fetch("https://portal.iotmanager.org/compiler/allmodinfo", { @@ -34,6 +59,28 @@ } }; + const getUserBuilds = async () => { + try { + const JWT = Cookies.get("token_iotm2"); + let res = await fetch("https://portal.iotmanager.org/compiler/userorders", { + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${JWT}`, + }, + mode: "cors", + method: "GET", + }); + if (res.ok) { + userBuilds = await res.json(); + checkStatus(userBuilds); + } else { + console.log("error", res.statusText); + } + } catch (e) { + console.log("error", e); + } + }; + const update = async () => { const JWT = Cookies.get("token_iotm2"); try { @@ -49,6 +96,7 @@ //console.log(content); if (res.ok) { errors = [{ msg: "ok_success" }]; + await getUserBuilds(); console.log(content.message); } else { errors = content.message; @@ -63,6 +111,8 @@ router.goto("/login"); location.reload(); }; + + const showLog = async (ord, file) => {}; {#if show} @@ -71,8 +121,8 @@
-

{myProfileJson.projectProp.platformio.default_envs}

-

{userdata.username}

+

{myProfileJson.projectProp.platformio.default_envs}

+

{userdata.username}

{#each myProfileJson.modules.virtual_elments as m, i} @@ -112,6 +162,51 @@

{$t(e.msg)}

{/each} + {#if userBuilds} + + + + + + + + + + + + + + {#each userBuilds as build, i} + {#if build.projectProp.platformio.default_envs === myProfileJson.projectProp.platformio.default_envs} + + + + + {#if build.status.preparation === 0 && build.status.build === 0 && build.status.fs === 0} + + {:else} + + + + {/if} + + {/if} + {/each} + +
НазваниеВерсияВремяПодготовкаСборка buildСборка fs
{build.projectProp.platformio.default_envs}{build.ver}{new Date(build.dateAdded).toLocaleString("ru", { timeZone: "Europe/Vienna" })} +

{"Ожидание очереди..."}

+
+
showLog(build, "py.txt")}> + {st[build.status.preparation]} +
+
+
showLog(build, "build.txt")}> + {st[build.status.build]} +
+
+
showLog(build, "fs.txt")}>{st[build.status.fs]}
+
+ {/if}