aboutsummaryrefslogtreecommitdiff
path: root/src_frontend/App.svelte
blob: d9f5f924a889ff60f9eebfabc56b827354580dd7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<script>
	import Router from 'svelte-spa-router';
	import { wrap } from 'svelte-spa-router/wrap';
	import MainRoute from "./routes/MainRoute.svelte";
	import EditorRoute from "./routes/EditorRoute.svelte";
	import Updating from "./routes/Updating.svelte";
	import LoginRoute from "./routes/LoginRoute.svelte";
	import WidgetRoute from "./routes/WidgetRoute.svelte";
	import UnknownRoute from "./routes/UnknownRoute.svelte";

	import { connected, reconnecting, openSocket } from "./stores/socketStore.js";

	let main_router_routes = new Map();
	main_router_routes.set(/^\/(schedules|modes|led_config|logs|settings|)(?:\/.*)?$/, wrap({
		component: MainRoute
	}));
	main_router_routes.set("/editor/*", wrap({
		component: EditorRoute
	}));
	main_router_routes.set("/updating", wrap({
		component: Updating
	}));
	main_router_routes.set("/login", wrap({
		component: LoginRoute
	}));
	main_router_routes.set("/widget", wrap({
		component: WidgetRoute
	}));
	main_router_routes.set("*", wrap({
		component: UnknownRoute
	}));

	let updateInProgess = false;
	openSocket.on("updater", (state) => {
		if (state == "start") { updateInProgess = true; }
	});
</script>

<style>
	.no-connection {
		width: 100%;
		height: 100%;
		box-sizing: border-box;
		padding: 15px;
		background-color: #3c3b3b;
		text-align: center;
		color: white;
	}
	.lds-ellipsis {
		display: inline-block;
		position: relative;
		width: 80px;
		height: 80px;
	}
	.lds-ellipsis div {
		position: absolute;
		top: 33px;
		width: 13px;
		height: 13px;
		border-radius: 50%;
		background: #fff;
		animation-timing-function: cubic-bezier(0, 1, 1, 0);
	}
	.lds-ellipsis div:nth-child(1) {
		left: 8px;
		animation: lds-ellipsis1 0.6s infinite;
	}
	.lds-ellipsis div:nth-child(2) {
		left: 8px;
		animation: lds-ellipsis2 0.6s infinite;
	}
	.lds-ellipsis div:nth-child(3) {
		left: 32px;
		animation: lds-ellipsis2 0.6s infinite;
	}
	.lds-ellipsis div:nth-child(4) {
		left: 56px;
		animation: lds-ellipsis3 0.6s infinite;
	}
	@keyframes lds-ellipsis1 {
		0% {
			transform: scale(0);
		}
		100% {
			transform: scale(1);
		}
	}
	@keyframes lds-ellipsis3 {
		0% {
			transform: scale(1);
		}
		100% {
			transform: scale(0);
		}
	}
	@keyframes lds-ellipsis2 {
		0% {
			transform: translate(0, 0);
		}
		100% {
			transform: translate(24px, 0);
		}
	}

</style>

{#if $updateInProgess || $connected}
<Router routes={main_router_routes} />
{:else if $reconnecting}
<div class="no-connection">
	<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
	<div>Lost connection to server, attempting to reconnect...</div>
</div>
{:else}
<div class="no-connection">
	<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
	<div>No server connection, attempting to connect...</div>
</div>
{/if}