запуск компилятора

This commit is contained in:
IoT Manager
2023-10-05 14:38:57 +02:00
parent dd77fe249d
commit ba10b3bc55
4 changed files with 190 additions and 77 deletions

View File

@@ -1,9 +1,9 @@
import svelte from 'rollup-plugin-svelte'; import svelte from "rollup-plugin-svelte";
import commonjs from '@rollup/plugin-commonjs'; import commonjs from "@rollup/plugin-commonjs";
import resolve from '@rollup/plugin-node-resolve'; import resolve from "@rollup/plugin-node-resolve";
import livereload from 'rollup-plugin-livereload'; import livereload from "rollup-plugin-livereload";
import { terser } from 'rollup-plugin-terser'; import { terser } from "rollup-plugin-terser";
import css from 'rollup-plugin-css-only'; import css from "rollup-plugin-css-only";
import sveltePreprocess from "svelte-preprocess"; import sveltePreprocess from "svelte-preprocess";
const production = !process.env.ROLLUP_WATCH; const production = !process.env.ROLLUP_WATCH;
@@ -18,30 +18,46 @@ function serve() {
return { return {
writeBundle() { writeBundle() {
if (server) return; if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { server = require("child_process").spawn(
stdio: ['ignore', 'inherit', 'inherit'], "npm",
shell: true ["run", "start", "--", "--dev"],
}); {
stdio: ["ignore", "inherit", "inherit"],
process.on('SIGTERM', toExit); shell: true,
process.on('exit', toExit);
} }
);
process.on("SIGTERM", toExit);
process.on("exit", toExit);
},
}; };
} }
export default { export default {
input: 'src/main.js', input: "src/main.js",
output: { output: {
sourcemap: true, sourcemap: true,
format: 'iife', format: "iife",
name: 'app', name: "app",
file: 'public/build/bundle.js' file: "public/build/bundle.js",
}, },
plugins: [ 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({ svelte({
compilerOptions: { compilerOptions: {
// enable run-time checks when not in production // enable run-time checks when not in production
dev: !production dev: !production,
}, },
preprocess: sveltePreprocess({ preprocess: sveltePreprocess({
sourceMap: !production, sourceMap: !production,
@@ -50,7 +66,7 @@ export default {
}), }),
// we'll extract any component CSS out into // we'll extract any component CSS out into
// a separate file - better for performance // a separate file - better for performance
css({ output: 'bundle.css' }), css({ output: "bundle.css" }),
// If you have external dependencies installed from // If you have external dependencies installed from
// npm, you'll most likely need these plugins. In // npm, you'll most likely need these plugins. In
@@ -59,7 +75,7 @@ export default {
// https://github.com/rollup/plugins/tree/master/packages/commonjs // https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({ resolve({
browser: true, browser: true,
dedupe: ['svelte'] dedupe: ["svelte"],
}), }),
commonjs(), commonjs(),
@@ -69,13 +85,13 @@ export default {
// Watch the `public` directory and refresh the // Watch the `public` directory and refresh the
// browser on changes when not in production // browser on changes when not in production
!production && livereload('public'), !production && livereload("public"),
// If we're building for production (npm run build // If we're building for production (npm run build
// instead of npm run dev), minify // instead of npm run dev), minify
production && terser() production && terser(),
], ],
watch: { watch: {
clearScreen: false clearScreen: false,
} },
}; };

View File

@@ -48,8 +48,9 @@
const rebootingTimeout = 30000; const rebootingTimeout = 30000;
const updatingTimeout = 130000; const updatingTimeout = 130000;
let rebootTimer; let rebootTimer;
let opened = false; let opened = true;
let preventMove = false; let preventMove = false;
let screenSize;
const blobDebug = false; const blobDebug = false;
const devMode = true; const devMode = true;
@@ -182,6 +183,9 @@
onMount(async () => { onMount(async () => {
console.log("[i]", "mounted"); console.log("[i]", "mounted");
await getUser(); await getUser();
onCheck();
opened = screenSize > 900 ? true : false;
selectedDeviceDataRefresh(); selectedDeviceDataRefresh();
//флаг первого запроса списка устройств //флаг первого запроса списка устройств
firstDevListRequest = true; firstDevListRequest = true;
@@ -1125,14 +1129,10 @@
//**********************************************************modal*************************************************************************/ //**********************************************************modal*************************************************************************/
function onCheck() { function onCheck() {
let width = screen.width; if (screenSize < 900) {
//console.log("width", width);
if (width < 900) {
preventMove = true; preventMove = true;
//opened = false;
} else { } else {
preventMove = false; preventMove = false;
//opened = true;
} }
} }
@@ -1244,6 +1244,8 @@
} }
</script> </script>
<svelte:window bind:innerWidth={screenSize} />
<div class="flex flex-col h-screen bg-gray-50"> <div class="flex flex-col h-screen bg-gray-50">
{#if showAwaitingCircle} {#if showAwaitingCircle}
<Progress /> <Progress />

View File

@@ -3,7 +3,7 @@ export default {
"login.email": "Email", "login.email": "Email",
"login.pass": "Пароль", "login.pass": "Пароль",
"login.login": "Вход", "login.login": "Вход",
"profile.update": "Обновить", "profile.update": "Собрать прошивку",
ok_success: "Задача запущена", ok_success: "Задача запущена",
err_order_exist: "Ваша задача выполняется! Cледующию задачу можно будет запустить после завершения", err_order_exist: "Ваша задача выполняется! Cледующию задачу можно будет запустить после завершения",
err_of_login: "Ошибка входа в систему", err_of_login: "Ошибка входа в систему",
@@ -20,7 +20,7 @@ export default {
"login.email": "Email", "login.email": "Email",
"login.pass": "Password", "login.pass": "Password",
"login.login": "Login", "login.login": "Login",
"profile.update": "Update", "profile.update": "Собрать прошивку",
ok_success: "Задача запущена", ok_success: "Задача запущена",
err_order_exist: "Ваша задача выполняется! Cледующию задачу можно будет запустить после завершения", err_order_exist: "Ваша задача выполняется! Cледующию задачу можно будет запустить после завершения",
err_of_login: "Ошибка входа в систему", err_of_login: "Ошибка входа в систему",

View File

@@ -8,15 +8,40 @@
export let show; export let show;
export let myProfileJson; export let myProfileJson;
export let userdata; export let userdata;
let errors = []; let errors = [];
let allmodeinfo = null; let allmodeinfo = null;
let userBuilds = null;
var updateInterval;
onMount(async () => { onMount(async () => {
await getModInfo(); 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 () => { const getModInfo = async () => {
try { try {
let res = await fetch("https://portal.iotmanager.org/compiler/allmodinfo", { 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 update = async () => {
const JWT = Cookies.get("token_iotm2"); const JWT = Cookies.get("token_iotm2");
try { try {
@@ -49,6 +96,7 @@
//console.log(content); //console.log(content);
if (res.ok) { if (res.ok) {
errors = [{ msg: "ok_success" }]; errors = [{ msg: "ok_success" }];
await getUserBuilds();
console.log(content.message); console.log(content.message);
} else { } else {
errors = content.message; errors = content.message;
@@ -63,6 +111,8 @@
router.goto("/login"); router.goto("/login");
location.reload(); location.reload();
}; };
const showLog = async (ord, file) => {};
</script> </script>
{#if show} {#if show}
@@ -71,8 +121,8 @@
<div class="grd-1col1"> <div class="grd-1col1">
<Card title=""> <Card title="">
<div class="grid grid-cols-2"> <div class="grid grid-cols-2">
<p class="text-center">{myProfileJson.projectProp.platformio.default_envs}</p> <p class="text-center text-gray-500 font-bold">{myProfileJson.projectProp.platformio.default_envs}</p>
<p class="text-center">{userdata.username}</p> <p class="text-center text-gray-500 font-bold">{userdata.username}</p>
</div> </div>
<div class="grid my-4 grid-cols-2 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-12 2xl:grid-cols-12 gap-4"> <div class="grid my-4 grid-cols-2 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-12 2xl:grid-cols-12 gap-4">
{#each myProfileJson.modules.virtual_elments as m, i} {#each myProfileJson.modules.virtual_elments as m, i}
@@ -112,6 +162,51 @@
<p class="text-red-500 p-0 m-0 font-bold text-xs italic">{$t(e.msg)}</p> <p class="text-red-500 p-0 m-0 font-bold text-xs italic">{$t(e.msg)}</p>
{/each} {/each}
<button class="btn-lg mt-6" on:click={() => update()}>{$t("profile.update")}</button> <button class="btn-lg mt-6" on:click={() => update()}>{$t("profile.update")}</button>
{#if userBuilds}
<table class="tbl mt-6 mb-0">
<thead class="bg-gray-100">
<tr class="txt-sz txt-pad">
<th class="tbl-hd">Название</th>
<th class="tbl-hd">Версия</th>
<th class="tbl-hd">Время</th>
<th class="tbl-hd">Подготовка</th>
<th class="tbl-hd">Сборка build</th>
<th class="tbl-hd">Сборка fs</th>
</tr>
</thead>
<tbody class="bg-white">
{#each userBuilds as build, i}
{#if build.projectProp.platformio.default_envs === myProfileJson.projectProp.platformio.default_envs}
<tr class="txt-sz txt-pad">
<td class="tbl-bdy-lg ipt-lg w-full">{build.projectProp.platformio.default_envs}</td>
<td class="tbl-bdy-lg ipt-lg w-full">{build.ver}</td>
<td class="tbl-bdy-lg ipt-lg w-full">{new Date(build.dateAdded).toLocaleString("ru", { timeZone: "Europe/Vienna" })}</td>
{#if build.status.preparation === 0 && build.status.build === 0 && build.status.fs === 0}
<td class="tbl-bdy-lg ipt-lg w-full">
<p class="text-green-700">{"Ожидание очереди..."}</p>
</td>
{:else}
<td class="tbl-bdy-lg ipt-lg w-full">
<div onClick={() => showLog(build, "py.txt")}>
{st[build.status.preparation]}
</div>
</td>
<td class="tbl-bdy-lg ipt-lg w-full">
<div onClick={() => showLog(build, "build.txt")}>
{st[build.status.build]}
</div>
</td>
<td class="tbl-bdy-lg ipt-lg w-full">
<div onClick={() => showLog(build, "fs.txt")}>{st[build.status.fs]}</div>
</td>
{/if}
</tr>
{/if}
{/each}
</tbody>
</table>
{/if}
<button class="btn-lg mt-6" on:click={() => exit()}>{$t("profile.exit")}</button> <button class="btn-lg mt-6" on:click={() => exit()}>{$t("profile.exit")}</button>
</Card> </Card>
</div> </div>