Wait
{{ duration }}
@@ -45,7 +41,7 @@ watch(
(val) => updateSeconds(val, timeUnit.value),
{
immediate: true,
- },
+ }
)
watch(
@@ -53,7 +49,7 @@ watch(
(val) => updateSeconds(time.value, val),
{
immediate: true,
- },
+ }
)
function updateSeconds(first: number, second: 'seconds' | 'minutes' | 'hours' | 'days') {
@@ -65,6 +61,6 @@ watch(
(val) => {
instruction.value = val.instruction as WaitInstruction
},
- { immediate: true },
+ { immediate: true }
)
diff --git a/src/components/tasks-automations/emptyInstructions.ts b/src/components/tasks-automations/emptyInstructions.ts
index 5824c53..69bc482 100644
--- a/src/components/tasks-automations/emptyInstructions.ts
+++ b/src/components/tasks-automations/emptyInstructions.ts
@@ -66,7 +66,9 @@ export function EmptySendNotification(): SendNotificationInstruction {
}
}
-export function defaultDevicePropertyConstantInstruction(device: Device): CreateDevicePropertyConstantInstruction {
+export function defaultDevicePropertyConstantInstruction(
+ device: Device
+): CreateDevicePropertyConstantInstruction {
return {
deviceId: device.id,
devicePropertyId: device.properties[0].id,
diff --git a/src/main.ts b/src/main.ts
index 5f2f761..21a450d 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -29,16 +29,19 @@ useNotificationsStore()
const errorPresenterStore = useErrorPresenterStore()
app.config.errorHandler = (err) => {
- if (typeof err == "object" && err != undefined) {
+ if (typeof err == 'object' && err != undefined) {
if ('__brand' in err && err.__brand === 'InvalidTokenError') {
// If the token expires or is not valid, take the user to login page
- errorPresenterStore.showError({
- message: 'The session has expired, please login again to continue',
- __brand: 'SessionExpired'
- }, () => {
- useUserInfoStore().clearUserInfo()
- router.push("/login")
- })
+ errorPresenterStore.showError(
+ {
+ message: 'The session has expired, please login again to continue',
+ __brand: 'SessionExpired',
+ },
+ () => {
+ useUserInfoStore().clearUserInfo()
+ router.push('/login')
+ }
+ )
} else {
errorPresenterStore.showError(err)
}
@@ -59,7 +62,7 @@ async function setupStores() {
useGroupsStore().updateGroups(),
useDevicesStore().updateDevices(),
useUsersStore().updateUsers(),
- useTasksStore().updateTasks()
+ useTasksStore().updateTasks(),
])
} finally {
loadingOverlay.stopLoading()
@@ -80,7 +83,7 @@ if (import.meta.env.DEV && userInfoStr) {
userInfoStore.userInfo = userInfo
}
} catch (e) {
- throw new Error("Value of VITE_USER_INFO is not valid.\n" + (e as Error).message)
+ throw new Error('Value of VITE_USER_INFO is not valid.\n' + (e as Error).message)
}
}
diff --git a/src/model/Type.ts b/src/model/Type.ts
index 56ec36a..09268cc 100644
--- a/src/model/Type.ts
+++ b/src/model/Type.ts
@@ -1,9 +1,8 @@
export enum Type {
- IntType = "IntType",
- DoubleType = "DoubleType",
- BooleanType = "BooleanType",
- ColorType = "ColorType",
- StringType = "StringType",
- VoidType = "VoidType"
+ IntType = 'IntType',
+ DoubleType = 'DoubleType',
+ BooleanType = 'BooleanType',
+ ColorType = 'ColorType',
+ StringType = 'StringType',
+ VoidType = 'VoidType',
}
-
diff --git a/src/model/devices-management/Device.ts b/src/model/devices-management/Device.ts
index bd45fb0..71913e7 100644
--- a/src/model/devices-management/Device.ts
+++ b/src/model/devices-management/Device.ts
@@ -1,12 +1,18 @@
-import type { Brand } from "@/utils"
-import type { TypeConstraints } from "./Types"
+import type { Brand } from '@/utils'
+import type { TypeConstraints } from './Types'
-export type DeviceId = Brand
-export function DeviceId(id: string): DeviceId { return id as DeviceId }
-export type DevicePropertyId = Brand
-export function DevicePropertyId(id: string): DevicePropertyId { return id as DevicePropertyId }
-export type DeviceActionId = Brand
-export function DeviceActionId(id: string): DeviceActionId { return id as DeviceActionId }
+export type DeviceId = Brand
+export function DeviceId(id: string): DeviceId {
+ return id as DeviceId
+}
+export type DevicePropertyId = Brand
+export function DevicePropertyId(id: string): DevicePropertyId {
+ return id as DevicePropertyId
+}
+export type DeviceActionId = Brand
+export function DeviceActionId(id: string): DeviceActionId {
+ return id as DeviceActionId
+}
export interface Device {
id: DeviceId
@@ -24,27 +30,27 @@ export interface DeviceAddress {
}
export enum DeviceStatus {
- Online = "Online",
- Offline = "Offline"
+ Online = 'Online',
+ Offline = 'Offline',
}
export interface DeviceProperty {
- readonly id: DevicePropertyId;
- readonly name: string;
- value: T;
+ readonly id: DevicePropertyId
+ readonly name: string
+ value: T
- readonly setter?: DeviceAction;
- readonly typeConstraints: TypeConstraints;
+ readonly setter?: DeviceAction
+ readonly typeConstraints: TypeConstraints
}
export interface DeviceAction {
- readonly id: DeviceActionId;
- readonly name: string;
- readonly description?: string;
+ readonly id: DeviceActionId
+ readonly name: string
+ readonly description?: string
- readonly inputTypeConstraints: TypeConstraints;
+ readonly inputTypeConstraints: TypeConstraints
}
export interface DeviceEvent {
- readonly name: string;
+ readonly name: string
}
diff --git a/src/model/devices-management/DeviceGroup.ts b/src/model/devices-management/DeviceGroup.ts
index 346f05e..1e9e909 100644
--- a/src/model/devices-management/DeviceGroup.ts
+++ b/src/model/devices-management/DeviceGroup.ts
@@ -1,8 +1,10 @@
-import type { Brand } from "@/utils"
-import type { Device } from "./Device"
+import type { Brand } from '@/utils'
+import type { Device } from './Device'
-export type DeviceGroupId = Brand
-export function DeviceGroupId(id: string): DeviceGroupId { return id as DeviceGroupId }
+export type DeviceGroupId = Brand
+export function DeviceGroupId(id: string): DeviceGroupId {
+ return id as DeviceGroupId
+}
export interface DeviceGroup {
id: DeviceGroupId
diff --git a/src/model/devices-management/DiscoveredDevice.ts b/src/model/devices-management/DiscoveredDevice.ts
index 38d650a..866d237 100644
--- a/src/model/devices-management/DiscoveredDevice.ts
+++ b/src/model/devices-management/DiscoveredDevice.ts
@@ -1,8 +1,10 @@
-import type { Brand } from "@/utils"
-import type { DeviceAddress } from "./Device"
+import type { Brand } from '@/utils'
+import type { DeviceAddress } from './Device'
-export type DiscoveredDeviceId = Brand
-export function DiscoveredDeviceId(id: string): DiscoveredDeviceId { return id as DiscoveredDeviceId }
+export type DiscoveredDeviceId = Brand
+export function DiscoveredDeviceId(id: string): DiscoveredDeviceId {
+ return id as DiscoveredDeviceId
+}
export interface DiscoveredDevice {
id: DiscoveredDeviceId
diff --git a/src/model/devices-management/Types.ts b/src/model/devices-management/Types.ts
index 9828f9b..cad8650 100644
--- a/src/model/devices-management/Types.ts
+++ b/src/model/devices-management/Types.ts
@@ -1,5 +1,5 @@
-import type { Brand } from "@/utils"
-import { Type } from "../Type"
+import type { Brand } from '@/utils'
+import { Type } from '../Type'
export interface Color {
readonly r: number
@@ -16,85 +16,89 @@ export function Color(r: number, g: number, b: number): Color {
return { r, g, b }
}
export function isColor(obj: unknown): obj is Color {
- return obj != undefined && typeof obj == "object" &&
- "r" in obj && typeof obj.r == "number" &&
- "g" in obj && typeof obj.g == "number" &&
- "b" in obj && typeof obj.b == "number"
+ return (
+ obj != undefined &&
+ typeof obj == 'object' &&
+ 'r' in obj &&
+ typeof obj.r == 'number' &&
+ 'g' in obj &&
+ typeof obj.g == 'number' &&
+ 'b' in obj &&
+ typeof obj.b == 'number'
+ )
}
export type TypeConstraints = Enum | IntRange | DoubleRange | None
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface TypeConstraint {
- readonly type: Type;
+ readonly type: Type
}
-export interface Enum extends Brand, "Enum"> {
- readonly values: Set;
+export interface Enum extends Brand, 'Enum'> {
+ readonly values: Set
}
class EnumImpl implements Enum {
- values: Set;
- type: Type = Type.StringType;
- __brand: "Enum";
+ values: Set
+ type: Type = Type.StringType
+ __brand: 'Enum'
constructor(values: Set) {
this.values = values
- this.__brand = "Enum"
+ this.__brand = 'Enum'
}
}
export function Enum(values: Set): Enum {
return new EnumImpl(values)
}
-export interface IntRange extends Brand, "IntRange"> {
- readonly min: number;
- readonly max: number;
+export interface IntRange extends Brand, 'IntRange'> {
+ readonly min: number
+ readonly max: number
}
class IntRangeImpl implements IntRange {
- min: number;
- max: number;
- type: Type = Type.IntType;
- __brand: "IntRange";
+ min: number
+ max: number
+ type: Type = Type.IntType
+ __brand: 'IntRange'
constructor(min: number, max: number) {
this.min = min
this.max = max
- this.__brand = "IntRange"
+ this.__brand = 'IntRange'
}
-
}
export function IntRange(min: number, max: number): IntRange {
return new IntRangeImpl(min, max)
}
-export interface DoubleRange extends Brand, "DoubleRange"> {
- readonly min: number;
- readonly max: number;
+export interface DoubleRange extends Brand, 'DoubleRange'> {
+ readonly min: number
+ readonly max: number
}
class DoubleRangeImpl implements DoubleRange {
- min: number;
- max: number;
- type: Type = Type.DoubleType;
- __brand: "DoubleRange";
+ min: number
+ max: number
+ type: Type = Type.DoubleType
+ __brand: 'DoubleRange'
constructor(min: number, max: number) {
this.min = min
this.max = max
- this.__brand = "DoubleRange"
+ this.__brand = 'DoubleRange'
}
-
}
export function DoubleRange(min: number, max: number): DoubleRange {
return new DoubleRangeImpl(min, max)
}
-export type None = Brand, "None">
+export type None = Brand, 'None'>
class NoneImpl implements None {
- __brand: "None";
- type: Type;
+ __brand: 'None'
+ type: Type
constructor(type: Type) {
this.type = type
- this.__brand = "None"
+ this.__brand = 'None'
}
}
export function NoneBoolean(): None {
diff --git a/src/model/scripts/Script.ts b/src/model/scripts/Script.ts
index b31987c..4ad969e 100644
--- a/src/model/scripts/Script.ts
+++ b/src/model/scripts/Script.ts
@@ -39,18 +39,22 @@ export interface DeviceEventTrigger {
}
export function isPeriodTrigger(o: unknown): o is PeriodTrigger {
- return o != undefined
- && typeof o === 'object'
- && 'start' in o
- && 'periodSeconds' in o
- && typeof o.periodSeconds === 'number'
+ return (
+ o != undefined &&
+ typeof o === 'object' &&
+ 'start' in o &&
+ 'periodSeconds' in o &&
+ typeof o.periodSeconds === 'number'
+ )
}
export function isDeviceEventTrigger(o: unknown): o is DeviceEventTrigger {
- return o != undefined
- && typeof o === 'object'
- && 'deviceId' in o
- && typeof o.deviceId === 'string'
- && 'eventName' in o
- && typeof o.eventName === 'string'
+ return (
+ o != undefined &&
+ typeof o === 'object' &&
+ 'deviceId' in o &&
+ typeof o.deviceId === 'string' &&
+ 'eventName' in o &&
+ typeof o.eventName === 'string'
+ )
}
diff --git a/src/model/users-management/RegistrationRequest.ts b/src/model/users-management/RegistrationRequest.ts
index be55b2f..fac0334 100644
--- a/src/model/users-management/RegistrationRequest.ts
+++ b/src/model/users-management/RegistrationRequest.ts
@@ -1,8 +1,8 @@
export interface RegistrationRequest {
- nickname: string;
- email: string;
+ nickname: string
+ email: string
}
export interface CompleteRegistrationRequest extends RegistrationRequest {
- password: string;
+ password: string
}
diff --git a/src/router/index.ts b/src/router/index.ts
index b58aa40..2ad396b 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -13,8 +13,13 @@ const router = createRouter({
path: '/devices',
children: [
{ path: '', name: 'devices', component: () => import('../views/devices/DevicesView.vue') },
- { path: ':id', name: 'device', component: () => import('../views/devices/DeviceView.vue'), props: true }
- ]
+ {
+ path: ':id',
+ name: 'device',
+ component: () => import('../views/devices/DeviceView.vue'),
+ props: true,
+ },
+ ],
},
{
path: '/admin',
@@ -22,7 +27,7 @@ const router = createRouter({
const userInfo = useUserInfoStore()
if (userInfo.role !== Role.Admin) {
return {
- name: "devices"
+ name: 'devices',
}
}
},
@@ -65,9 +70,18 @@ const router = createRouter({
{
path: 'device-groups',
children: [
- { path: '', name: 'device-groups', component: () => import('../views/admin/device-groups/DeviceGroupsView.vue') },
- { path: ':id', name: 'device-group', component: () => import('../views/admin/device-groups/DeviceGroupView.vue'), props: true },
- ]
+ {
+ path: '',
+ name: 'device-groups',
+ component: () => import('../views/admin/device-groups/DeviceGroupsView.vue'),
+ },
+ {
+ path: ':id',
+ name: 'device-group',
+ component: () => import('../views/admin/device-groups/DeviceGroupView.vue'),
+ props: true,
+ },
+ ],
},
{
path: 'automations-task-permissions',
@@ -182,15 +196,15 @@ const router = createRouter({
router.beforeEach((to) => {
const userInfo = useUserInfoStore()
if (userInfo.token) {
- if (to.name === "login" || to.name === "signin") {
+ if (to.name === 'login' || to.name === 'signin') {
return {
- name: 'devices'
+ name: 'devices',
}
}
} else {
if (to.name !== 'login' && to.name !== 'signin') {
return {
- name: 'login'
+ name: 'login',
}
}
}
diff --git a/src/stores/devices.ts b/src/stores/devices.ts
index c2eee34..4629b80 100644
--- a/src/stores/devices.ts
+++ b/src/stores/devices.ts
@@ -1,8 +1,8 @@
-import { defineStore } from "pinia"
-import { useUserInfoStore } from "./user-info"
-import { ref } from "vue"
-import type { Device, DeviceId } from "@/model/devices-management/Device";
-import { getAllDevices } from "@/api/devices-management/requests/devices";
+import { defineStore } from 'pinia'
+import { useUserInfoStore } from './user-info'
+import { ref } from 'vue'
+import type { Device, DeviceId } from '@/model/devices-management/Device'
+import { getAllDevices } from '@/api/devices-management/requests/devices'
export const useDevicesStore = defineStore('devices', () => {
const userInfo = useUserInfoStore()
@@ -13,8 +13,8 @@ export const useDevicesStore = defineStore('devices', () => {
}
function getDevice(deviceId: DeviceId) {
- return devices.value?.find(d => d.id === deviceId)
+ return devices.value?.find((d) => d.id === deviceId)
}
return { devices, updateDevices, getDevice }
-});
+})
diff --git a/src/stores/error-presenter.ts b/src/stores/error-presenter.ts
index eea2c57..8307d0d 100644
--- a/src/stores/error-presenter.ts
+++ b/src/stores/error-presenter.ts
@@ -1,4 +1,4 @@
-import { defineStore } from "pinia";
+import { defineStore } from 'pinia'
export interface Error {
__brand?: string
@@ -12,7 +12,7 @@ export const useErrorPresenterStore = defineStore('error-presenter', {
callbackAfterOkQueue: [] as ((() => void) | undefined)[],
}),
getters: {
- errorShown: (state) => state.errorsQueue.length > 0 ? state.errorsQueue[0] : undefined
+ errorShown: (state) => (state.errorsQueue.length > 0 ? state.errorsQueue[0] : undefined),
},
actions: {
/**
@@ -20,14 +20,19 @@ export const useErrorPresenterStore = defineStore('error-presenter', {
* @param afterOk callback to be called after clicking the Ok button of the error dialog, optional
*/
showError(err: Error, afterOk?: () => void) {
- if (!this.errorShown || (this.errorShown.__brand != err.__brand || this.errorShown.message != err.message || this.errorShown.cause != err.cause)) {
+ if (
+ !this.errorShown ||
+ this.errorShown.__brand != err.__brand ||
+ this.errorShown.message != err.message ||
+ this.errorShown.cause != err.cause
+ ) {
this.errorsQueue.push(err)
this.callbackAfterOkQueue.push(afterOk)
}
},
/** This function is expected to be called by the ErrorPresenter component
* and after removing the error from the queue it will call the callback put in the showError method
- */
+ */
errorWasViewed() {
this.errorsQueue.shift()
const callback = this.callbackAfterOkQueue.shift()
diff --git a/src/stores/groups-dialog.ts b/src/stores/groups-dialog.ts
index 56b0e34..14addf0 100644
--- a/src/stores/groups-dialog.ts
+++ b/src/stores/groups-dialog.ts
@@ -1,10 +1,12 @@
-import { defineStore } from "pinia"
-import { computed, ref } from "vue"
-import { useGroupsStore } from "./groups"
-import type { DeviceId } from "@/model/devices-management/Device"
+import { defineStore } from 'pinia'
+import { computed, ref } from 'vue'
+import { useGroupsStore } from './groups'
+import type { DeviceId } from '@/model/devices-management/Device'
export const useGroupsDialogStore = defineStore('groups-dialog', () => {
- const selectedDeviceGroups = computed(() => selectedDevice.value ? useGroupsStore().getGroupsOfDevice(selectedDevice.value!) : [])
+ const selectedDeviceGroups = computed(() =>
+ selectedDevice.value ? useGroupsStore().getGroupsOfDevice(selectedDevice.value!) : []
+ )
const selectedDevice = ref()
function showDeviceGroups(deviceId: DeviceId) {
diff --git a/src/stores/groups.ts b/src/stores/groups.ts
index 0475146..dea45a2 100644
--- a/src/stores/groups.ts
+++ b/src/stores/groups.ts
@@ -1,9 +1,9 @@
-import { getAllDeviceGroups } from "@/api/devices-management/requests/device-groups";
-import type { DeviceGroup } from "@/model/devices-management/DeviceGroup";
-import { defineStore } from "pinia";
-import { ref } from "vue";
-import { useUserInfoStore } from "./user-info";
-import { type DeviceId } from "@/model/devices-management/Device";
+import { getAllDeviceGroups } from '@/api/devices-management/requests/device-groups'
+import type { DeviceGroup } from '@/model/devices-management/DeviceGroup'
+import { defineStore } from 'pinia'
+import { ref } from 'vue'
+import { useUserInfoStore } from './user-info'
+import { type DeviceId } from '@/model/devices-management/Device'
export const useGroupsStore = defineStore('groups', () => {
const userInfo = useUserInfoStore()
@@ -14,9 +14,7 @@ export const useGroupsStore = defineStore('groups', () => {
}
function getGroupsOfDevice(deviceId: DeviceId) {
- return groups.value.filter((g) =>
- g.devices.map(d => d.id).includes(deviceId)
- )
+ return groups.value.filter((g) => g.devices.map((d) => d.id).includes(deviceId))
}
return { groups, updateGroups, getGroupsOfDevice }
diff --git a/src/stores/instructions.ts b/src/stores/instructions.ts
index bf52570..d974fde 100644
--- a/src/stores/instructions.ts
+++ b/src/stores/instructions.ts
@@ -9,14 +9,14 @@ import {
function isIfInstruction(
instruction: RealInstruction,
- type: InstructionType,
+ type: InstructionType
): instruction is IfInstruction {
return type === InstructionType.IfInstruction || isIfElseInstruction(instruction, type)
}
function isIfElseInstruction(
instruction: RealInstruction,
- type: InstructionType,
+ type: InstructionType
): instruction is IfElseInstruction {
return type === InstructionType.IfElseInstruction
}
@@ -24,7 +24,7 @@ function isIfElseInstruction(
function traverseAndModify(
instructions: Instruction[],
target: Instruction,
- onMatch: (instructions: Instruction[], index: number) => void,
+ onMatch: (instructions: Instruction[], index: number) => void
): boolean {
const idx = instructions.indexOf(target)
@@ -69,7 +69,7 @@ export const useInstructionsStore = defineStore('instructions-store', {
moveInstruction(target: Instruction, dir: 'up' | 'down') {
function recursiveMove(
instructions: Instruction[],
- branch: 'root' | 'then' | 'else',
+ branch: 'root' | 'then' | 'else'
): Instruction | undefined {
const idx = instructions.indexOf(target)
@@ -118,7 +118,7 @@ export const useInstructionsStore = defineStore('instructions-store', {
function handleSwapOrNest(
instructions: Instruction[],
idx: number,
- newIdx: number,
+ newIdx: number
): undefined {
const temp = instructions[idx]
const newInstr = instructions[newIdx]
@@ -148,7 +148,7 @@ export const useInstructionsStore = defineStore('instructions-store', {
function handleBoundary(
instructions: Instruction[],
dir: 'up' | 'down',
- branch: 'root' | 'then' | 'else',
+ branch: 'root' | 'then' | 'else'
): Instruction | undefined {
if (branch === 'then' || branch === 'else') {
// return the first or last elem of the branch based on movement, removing it from the current block
@@ -161,7 +161,7 @@ export const useInstructionsStore = defineStore('instructions-store', {
instructions: Instruction[],
container: Instruction,
i: number,
- target: Instruction,
+ target: Instruction
) {
if (dir === 'up') {
instructions.splice(i, 0, target) // insert before
diff --git a/src/stores/loading-overlay.ts b/src/stores/loading-overlay.ts
index 94544ba..ca75432 100644
--- a/src/stores/loading-overlay.ts
+++ b/src/stores/loading-overlay.ts
@@ -1,11 +1,11 @@
-import { defineStore } from "pinia";
+import { defineStore } from 'pinia'
export const useLoadingOverlayStore = defineStore('loading-overlay', {
state: () => ({
- tasksLoading: 0
+ tasksLoading: 0,
}),
getters: {
- isLoading: (state) => state.tasksLoading > 0
+ isLoading: (state) => state.tasksLoading > 0,
},
actions: {
startLoading() {
diff --git a/src/stores/notifications.ts b/src/stores/notifications.ts
index c9f0c7b..a08e2bb 100644
--- a/src/stores/notifications.ts
+++ b/src/stores/notifications.ts
@@ -1,21 +1,21 @@
-import type { Notification } from "@/model/notifications-management/Notification";
-import { openSocketIOForNotifications } from "@/api/notifications-management/requests";
-import { defineStore } from "pinia";
-import { useUserInfoStore } from "./user-info";
-import { ref } from "vue";
-import { Socket } from "socket.io-client";
+import type { Notification } from '@/model/notifications-management/Notification'
+import { openSocketIOForNotifications } from '@/api/notifications-management/requests'
+import { defineStore } from 'pinia'
+import { useUserInfoStore } from './user-info'
+import { ref } from 'vue'
+import { Socket } from 'socket.io-client'
export const useNotificationsStore = defineStore('notifications', () => {
- const notifications = ref(new Array())
+ const notifications = ref(new Array())
let id = 0
const stored = localStorage.getItem('notifications')
if (stored) {
try {
- const parsed = JSON.parse(stored);
- notifications.value = parsed;
- id = notifications.value.reduce((maxId, n) => n.id > maxId ? n.id : maxId, 0)
+ const parsed = JSON.parse(stored)
+ notifications.value = parsed
+ id = notifications.value.reduce((maxId, n) => (n.id > maxId ? n.id : maxId), 0)
} catch (e) {
- console.error("Failed to parse stored notifications", e);
+ console.error('Failed to parse stored notifications', e)
}
}
const socket = ref()
@@ -33,11 +33,18 @@ export const useNotificationsStore = defineStore('notifications', () => {
})
window.addEventListener('beforeunload', closeSocket)
function openSocket(email: string) {
- if (socket.value) { socket.value.close() }
+ if (socket.value) {
+ socket.value.close()
+ }
socket.value = openSocketIOForNotifications(email, (notification) => {
id = id + 1
- notifications.value.unshift({ ...notification, read: false, date: (new Date()).toUTCString(), id: id })
- localStorage.setItem('notifications', JSON.stringify(notifications.value));
+ notifications.value.unshift({
+ ...notification,
+ read: false,
+ date: new Date().toUTCString(),
+ id: id,
+ })
+ localStorage.setItem('notifications', JSON.stringify(notifications.value))
})
}
function closeSocket() {
@@ -51,14 +58,14 @@ export const useNotificationsStore = defineStore('notifications', () => {
}
function setNotificationRead(index: number, read: boolean) {
notifications.value[index].read = read
- localStorage.setItem('notifications', JSON.stringify(notifications.value));
+ localStorage.setItem('notifications', JSON.stringify(notifications.value))
}
function deleteNotification(index: number) {
notifications.value.splice(index, 1)
- localStorage.setItem('notifications', JSON.stringify(notifications.value));
+ localStorage.setItem('notifications', JSON.stringify(notifications.value))
}
function unreadNotifications() {
- return notifications.value.filter(n => !n.read).length
+ return notifications.value.filter((n) => !n.read).length
}
return { notifications, socket, setNotificationRead, deleteNotification, unreadNotifications }
})
diff --git a/src/stores/success-presenter.ts b/src/stores/success-presenter.ts
index 5912609..73c9c9b 100644
--- a/src/stores/success-presenter.ts
+++ b/src/stores/success-presenter.ts
@@ -1,18 +1,18 @@
-import { defineStore } from "pinia"
+import { defineStore } from 'pinia'
const DEFAULT_CLOSING_ANIMATION_MS = 2000
export interface SuccessPresenterInterface {
- title: string,
- msg: string,
+ title: string
+ msg: string
duration: number
}
export const useSuccessPresenterStore = defineStore('success-presenter', {
state: () => ({
- successQueue: [] as SuccessPresenterInterface[]
+ successQueue: [] as SuccessPresenterInterface[],
}),
getters: {
- successShown: (state) => state.successQueue.length > 0 ? state.successQueue[0] : undefined
+ successShown: (state) => (state.successQueue.length > 0 ? state.successQueue[0] : undefined),
},
actions: {
showSuccess(succ: SuccessPresenterInterface) {
@@ -28,7 +28,10 @@ export const useSuccessPresenterStore = defineStore('success-presenter', {
},
})
-
-export function presentSuccess(title: string, msg: string = "", duration: number = DEFAULT_CLOSING_ANIMATION_MS) {
- return {title: title, msg: msg, duration: duration} as SuccessPresenterInterface
+export function presentSuccess(
+ title: string,
+ msg: string = '',
+ duration: number = DEFAULT_CLOSING_ANIMATION_MS
+) {
+ return { title: title, msg: msg, duration: duration } as SuccessPresenterInterface
}
diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts
index 4c59ff2..de84f81 100644
--- a/src/stores/tasks.ts
+++ b/src/stores/tasks.ts
@@ -1,8 +1,8 @@
-import { getAllTasks } from "@/api/scripts/requests/tasks";
-import type { Task, TaskId } from "@/model/scripts/Script";
-import { defineStore } from "pinia";
-import { ref } from "vue";
-import { useUserInfoStore } from "./user-info";
+import { getAllTasks } from '@/api/scripts/requests/tasks'
+import type { Task, TaskId } from '@/model/scripts/Script'
+import { defineStore } from 'pinia'
+import { ref } from 'vue'
+import { useUserInfoStore } from './user-info'
export const useTasksStore = defineStore('tasks', () => {
const userInfo = useUserInfoStore()
@@ -13,8 +13,8 @@ export const useTasksStore = defineStore('tasks', () => {
}
function getTask(taskId: TaskId) {
- return tasks.value?.find(t => t.id === taskId)
+ return tasks.value?.find((t) => t.id === taskId)
}
return { tasks, updateTasks, getTask }
-});
+})
diff --git a/src/stores/user-info.ts b/src/stores/user-info.ts
index d9ad8a9..2b56f2e 100644
--- a/src/stores/user-info.ts
+++ b/src/stores/user-info.ts
@@ -1,19 +1,19 @@
-import { defineStore } from "pinia";
-import { type UserInfo } from '@/model/users-management/User';
-import { isGetUserInfoDTO } from '@/api/users-management/dtos/GetUserInfoDTO';
-import { computed, ref } from "vue";
+import { defineStore } from 'pinia'
+import { type UserInfo } from '@/model/users-management/User'
+import { isGetUserInfoDTO } from '@/api/users-management/dtos/GetUserInfoDTO'
+import { computed, ref } from 'vue'
export const useUserInfoStore = defineStore('user-info', () => {
const userInfo = ref({} as UserInfo)
- const stored = localStorage.getItem('userInfo');
+ const stored = localStorage.getItem('userInfo')
if (stored) {
try {
- const parsed = JSON.parse(stored);
+ const parsed = JSON.parse(stored)
if (isGetUserInfoDTO(parsed)) {
- userInfo.value = parsed;
+ userInfo.value = parsed
}
} catch (e) {
- console.error("Failed to parse stored user info", e);
+ console.error('Failed to parse stored user info', e)
}
}
@@ -24,18 +24,18 @@ export const useUserInfoStore = defineStore('user-info', () => {
function setUserInfo(info: UserInfo) {
if (!isGetUserInfoDTO(info)) {
- throw new Error("Invalid user info format");
+ throw new Error('Invalid user info format')
}
- userInfo.value = info;
- localStorage.setItem('userInfo', JSON.stringify(info));
+ userInfo.value = info
+ localStorage.setItem('userInfo', JSON.stringify(info))
}
function setNickname(nickname: string) {
- userInfo.value.nickname = nickname;
- localStorage.setItem('userInfo', JSON.stringify(userInfo.value));
+ userInfo.value.nickname = nickname
+ localStorage.setItem('userInfo', JSON.stringify(userInfo.value))
}
function clearUserInfo() {
- userInfo.value = {} as UserInfo;
- localStorage.removeItem('userInfo');
+ userInfo.value = {} as UserInfo
+ localStorage.removeItem('userInfo')
}
return { userInfo, email, nickname, token, role, setUserInfo, setNickname, clearUserInfo }
})
diff --git a/src/stores/users.ts b/src/stores/users.ts
index c8938d6..719b042 100644
--- a/src/stores/users.ts
+++ b/src/stores/users.ts
@@ -1,8 +1,8 @@
-import { defineStore } from "pinia";
-import { useUserInfoStore } from "./user-info";
-import { ref } from "vue";
-import type { User } from "@/model/users-management/User";
-import { getAllUsers } from "@/api/users-management/requests/users";
+import { defineStore } from 'pinia'
+import { useUserInfoStore } from './user-info'
+import { ref } from 'vue'
+import type { User } from '@/model/users-management/User'
+import { getAllUsers } from '@/api/users-management/requests/users'
export const useUsersStore = defineStore('users', () => {
const userInfo = useUserInfoStore()
@@ -13,8 +13,8 @@ export const useUsersStore = defineStore('users', () => {
}
function getUser(email: string) {
- return users.value?.find(u => u.email === email)
+ return users.value?.find((u) => u.email === email)
}
return { users, updateUsers, getUser }
-});
+})
diff --git a/src/utils.ts b/src/utils.ts
index 951d960..012f99e 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1 +1 @@
-export type Brand = T & { __brand: B; };
+export type Brand = T & { __brand: B }
diff --git a/src/views/SettingsView.vue b/src/views/SettingsView.vue
index 31b852f..2ed6b9a 100644
--- a/src/views/SettingsView.vue
+++ b/src/views/SettingsView.vue
@@ -11,10 +11,10 @@
Nickname
-
@@ -27,21 +27,21 @@