From 8c279aef077022815dcbb12942abd0e7abdb9442 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Tue, 30 May 2023 18:41:18 -0700 Subject: [PATCH] feat: server state component --- _data/serverState.ts | 51 ++++++++++++++++++++++++++++++++++++++ components/ServerState.vue | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 _data/serverState.ts create mode 100644 components/ServerState.vue diff --git a/_data/serverState.ts b/_data/serverState.ts new file mode 100644 index 000000000..379f59072 --- /dev/null +++ b/_data/serverState.ts @@ -0,0 +1,51 @@ +import type { Server, ServerState } from '~/types/server'; + +function makeid(length: number) { + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; + const charactersLength = characters.length; + let result = ''; + for (let i = 0; i < length; i++) result += characters.charAt(Math.floor(Math.random() * charactersLength)); + return result; +} + +const registeredGuid = `1111-1111-${makeid(4)}-123412341234`; // this guid is registered in key server +const newGuid = `1234-1234-${makeid(4)}-123412341234`; // this is a new USB, not registered +const regWizTime = `1616711990500_${registeredGuid}`; +const blacklistedGuid = '154B-00EE-0700-9B50CF819816'; + +// ENOKEYFILE +// TRIAL +// BASIC +// PLUS +// PRO +// EEXPIRED +// EGUID +// EGUID1 +// ETRIAL +// ENOKEYFILE2 +// ENOKEYFILE1 +// ENOFLASH +// EBLACKLISTED +// EBLACKLISTED1 +// EBLACKLISTED2 +// ENOCONN +const state: string = 'TRIAL'; + +const uptime = Date.now() - 60 * 60 * 1000; // 1 hour ago +let expireTime = 0; +if (state === 'TRIAL') expireTime = Date.now() + 60 * 60 * 1000; // in 1 hour +if (state === 'EEXPIRED') expireTime = uptime; // 1 hour ago + +const serverState = { + name: 'DevServer9000', + description: 'Fully automated media server and lab rig', + guid: '9292-1111-BITE-444444444444', + deviceCount: 8, + site: 'http://localhost:4321', + state, + locale: 'en', + expireTime, + uptime, +}; + +export default serverState; \ No newline at end of file diff --git a/components/ServerState.vue b/components/ServerState.vue new file mode 100644 index 000000000..5392cfcb3 --- /dev/null +++ b/components/ServerState.vue @@ -0,0 +1,46 @@ + + + + + + \ No newline at end of file