+
diff --git a/src/helpers/index.ts b/src/helpers/index.ts
index a36d3f01254a8fa62183ec0e92402578e20caf89..7b5ac9c0ee54d338ac46782b2c5b271f091f3b90 100644
--- a/src/helpers/index.ts
+++ b/src/helpers/index.ts
@@ -1,6 +1,7 @@
import { useInterfaceStore } from '@/stores/interface';
import type { IEntity } from '@/interfaces/environment';
import { useDataStore } from '@/stores/data';
+import { useWebsocketStore } from '@/stores/websocket';
export async function uploadFile($event: Event) {
const target = $event.target as HTMLInputElement;
@@ -26,36 +27,34 @@ export function setDefaultHomeBackground() {
}
export const editEntity = (newState: IEntity, entityUuid: string) => {
- const dataStore = useDataStore();
- let prevState = dataStore.homeEntities;
- prevState = prevState.map((entity: IEntity) => {
- if (entity.uuid !== entityUuid) return entity;
- return newState;
- });
- dataStore.editHomeEntities(prevState);
+ const websocketStore = useWebsocketStore();
+ const data = {
+ event: 'editHomeEntity',
+ body: { ...newState }
+ };
+ websocketStore.sendData(data);
};
export const deleteEntity = (entityUuid: string) => {
const dataStore = useDataStore();
- let prevState = dataStore.homeEntities;
- prevState = prevState.filter((entity: IEntity) => entity.uuid !== entityUuid);
- dataStore.editHomeEntities(prevState);
+ const websocketStore = useWebsocketStore();
+ const entities = dataStore.homeEntities;
+ const entityToDelete = entities.find((entity) => entity.entity_uuid === entityUuid);
+ const data = {
+ event: 'deleteHomeEntity',
+ body: { ...entityToDelete }
+ };
+ websocketStore.sendData(data);
};
export const changeOrderHomeEntity = (entityUuid: string, direction: 'up' | 'down') => {
- const dataStore = useDataStore();
- const prevState = dataStore.homeEntities;
- const entityIndex = prevState.findIndex((entity: IEntity) => entity.uuid === entityUuid);
- if (direction === 'up') {
- [prevState[entityIndex], prevState[entityIndex - 1]] = [
- prevState[entityIndex - 1],
- prevState[entityIndex]
- ];
- } else {
- [prevState[entityIndex], prevState[entityIndex + 1]] = [
- prevState[entityIndex + 1],
- prevState[entityIndex]
- ];
- }
- dataStore.editHomeEntities(prevState);
+ const websocketStore = useWebsocketStore();
+ const data = {
+ event: 'changeOrderHomeEntity',
+ body: {
+ entity_uuid: entityUuid,
+ direction
+ }
+ };
+ websocketStore.sendData(data);
};
diff --git a/src/interfaces/authorization.ts b/src/interfaces/authorization.ts
index eba19e4706254349e4b40be8a3be7dea760f93ad..f9ae4f51e6c998f3e471349c2391c5ae12616dae 100644
--- a/src/interfaces/authorization.ts
+++ b/src/interfaces/authorization.ts
@@ -1,13 +1,14 @@
-import type { IImage, TThemes } from '@/interfaces/environment';
+import type { TThemes } from '@/interfaces/environment';
+import type {IImage } from "@/interfaces/entities";
export interface IUserData {
- uuid: string;
- nickName: string;
- firstName: string;
- lastName: string;
- middleName: string;
+ user_uuid: string;
+ nick_name: string;
+ first_name: string;
+ last_name: string;
+ middle_name: string;
email: string;
- phoneNumber: string;
+ phone_number: string;
settings: IUserSettings;
}
interface IUserSettings {
diff --git a/src/interfaces/entities.ts b/src/interfaces/entities.ts
index fffff4dcf2cac2f6a843421db30a48da282a1cce..d82328a355af046582734b3740ad43d255e79216 100644
--- a/src/interfaces/entities.ts
+++ b/src/interfaces/entities.ts
@@ -1,15 +1,18 @@
export interface ITable {
- type: 'table';
- uuid: string;
+ entity_type: 'table';
+ entity_uuid: string;
title?: string;
- columns: ITableColumn[];
- data: {
+ text?: string;
+ table_columns: ITableColumn[];
+ table_data: {
[key: string]: any;
}[];
}
interface ITableColumn {
+ column_uuid: string;
name: string;
type: ITableColumnTypes;
+ data: any;
}
type ITableColumnTypes =
| 'text'
@@ -22,18 +25,19 @@ type ITableColumnTypes =
| 'knob';
export interface IText {
- type: 'text';
- uuid: string;
- text: string;
+ entity_type: 'text';
+ entity_uuid: string;
title?: string;
+ text: string;
}
export interface IImage {
- type: 'image';
- uuid: string;
- title: string;
- url: string;
- width: number;
- height: number;
- position: 'left' | 'center' | 'right';
+ entity_type: 'image';
+ entity_uuid: string;
+ title?: string;
+ text?: string;
+ image_data: string;
+ image_width: number;
+ image_height: number;
+ image_position: 'left' | 'center' | 'right';
}
diff --git a/src/interfaces/environment.ts b/src/interfaces/environment.ts
index ceb35952c7485adc304c03801effee747c151c69..4c9536e839800da8d9bac6d3c4bb6c9389b76ba4 100644
--- a/src/interfaces/environment.ts
+++ b/src/interfaces/environment.ts
@@ -1,7 +1,7 @@
import type { IImage, ITable, IText } from '@/interfaces/entities';
export interface ISheet {
- uuid: string;
+ sheet_uuid: string;
title: string;
address: string;
entities: IEntity[];
diff --git a/src/modules/EntityItem.vue b/src/modules/EntityItem.vue
index 01fb2f80f28637dcba4f31243172626a9f71e6c0..f040b9f4fba86ee22f19a52396ab4a462e7b4852 100644
--- a/src/modules/EntityItem.vue
+++ b/src/modules/EntityItem.vue
@@ -11,8 +11,11 @@ defineProps
();
diff --git a/src/output.css b/src/output.css
index 122ecf845c4ef1d5443e37ef08d273b2d2775984..94f42e4f9560584909e1f4e43bf1b6d7c9c553c7 100644
--- a/src/output.css
+++ b/src/output.css
@@ -608,6 +608,10 @@ video {
position: relative;
}
+.-left-2 {
+ left: -0.5rem;
+}
+
.-left-full {
left: -100%;
}
@@ -616,6 +620,10 @@ video {
top: -100%;
}
+.bottom-0 {
+ bottom: 0px;
+}
+
.left-0 {
left: 0px;
}
@@ -632,6 +640,10 @@ video {
top: 0px;
}
+.top-12 {
+ top: 3rem;
+}
+
.top-16 {
top: 4rem;
}
@@ -640,6 +652,14 @@ video {
top: 0.5rem;
}
+.left-4 {
+ left: 1rem;
+}
+
+.bottom-2 {
+ bottom: 0.5rem;
+}
+
.z-50 {
z-index: 50;
}
@@ -653,6 +673,11 @@ video {
margin-bottom: -0.5rem;
}
+.mx-16 {
+ margin-left: 4rem;
+ margin-right: 4rem;
+}
+
.-mb-2 {
margin-bottom: -0.5rem;
}
@@ -661,22 +686,10 @@ video {
margin-left: -0.5rem;
}
-.-ml-4 {
- margin-left: -1rem;
-}
-
.-mr-\[135px\] {
margin-right: -135px;
}
-.mb-12 {
- margin-bottom: 3rem;
-}
-
-.mb-2 {
- margin-bottom: 0.5rem;
-}
-
.mb-4 {
margin-bottom: 1rem;
}
@@ -701,6 +714,10 @@ video {
margin-right: 0.5rem;
}
+.mt-2 {
+ margin-top: 0.5rem;
+}
+
.mt-4 {
margin-top: 1rem;
}
@@ -735,6 +752,10 @@ video {
height: 3rem;
}
+.h-\[1px\] {
+ height: 1px;
+}
+
.h-full {
height: 100%;
}
@@ -751,6 +772,10 @@ video {
min-height: 148px;
}
+.w-12 {
+ width: 3rem;
+}
+
.w-2 {
width: 0.5rem;
}
@@ -767,21 +792,12 @@ video {
width: 100%;
}
-.w-16 {
- width: 4rem;
-}
-
.min-w-\[100px\] {
min-width: 100px;
}
-.-translate-y-full {
- --tw-translate-y: -100%;
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
-}
-
-.-translate-y-16 {
- --tw-translate-y: -4rem;
+.-translate-x-full {
+ --tw-translate-x: -100%;
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}
@@ -860,18 +876,10 @@ video {
border-width: 1px;
}
-.border-0 {
- border-width: 0px;
-}
-
.border-2 {
border-width: 2px;
}
-.border-l-4 {
- border-left-width: 4px;
-}
-
.border-solid {
border-style: solid;
}
@@ -881,11 +889,6 @@ video {
border-color: rgb(0 0 0 / var(--tw-border-opacity));
}
-.border-l-blue-400 {
- --tw-border-opacity: 1;
- border-left-color: rgb(96 165 250 / var(--tw-border-opacity));
-}
-
.bg-black {
--tw-bg-opacity: 1;
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
@@ -901,6 +904,11 @@ video {
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
}
+.bg-gray-500 {
+ --tw-bg-opacity: 1;
+ background-color: rgb(107 114 128 / var(--tw-bg-opacity));
+}
+
.bg-sky-900 {
--tw-bg-opacity: 1;
background-color: rgb(12 74 110 / var(--tw-bg-opacity));
@@ -932,9 +940,9 @@ video {
padding: 1.5rem;
}
-.px-4 {
- padding-left: 1rem;
- padding-right: 1rem;
+.px-16 {
+ padding-left: 4rem;
+ padding-right: 4rem;
}
.py-2 {
@@ -947,6 +955,11 @@ video {
padding-bottom: 1rem;
}
+.py-8 {
+ padding-top: 2rem;
+ padding-bottom: 2rem;
+}
+
.pl-0 {
padding-left: 0px;
}
@@ -955,10 +968,6 @@ video {
padding-left: 0.5rem;
}
-.pl-4 {
- padding-left: 1rem;
-}
-
.pr-2 {
padding-right: 0.5rem;
}
@@ -967,8 +976,12 @@ video {
padding-right: 135px;
}
-.pt-8 {
- padding-top: 2rem;
+.pl-24 {
+ padding-left: 6rem;
+}
+
+.pr-16 {
+ padding-right: 4rem;
}
.text-center {
@@ -1025,6 +1038,10 @@ video {
opacity: 0;
}
+.outline-0 {
+ outline-width: 0px;
+}
+
.transition-all {
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
diff --git a/src/pages/HomePage.vue b/src/pages/HomePage.vue
index f372c6dde70ec1ebbdfddc437c9154ede3c3b814..f5ceea240ce3089246b5ebc462d49a72f445bf7d 100644
--- a/src/pages/HomePage.vue
+++ b/src/pages/HomePage.vue
@@ -6,6 +6,8 @@ import { setDefaultHomeBackground, uploadFile } from '@/helpers';
import { useInterfaceStore } from '@/stores/interface';
import type { IEntity } from '@/interfaces/environment';
import { useDataStore } from '@/stores/data';
+import { useAuthorizationStore } from '@/stores/authorization';
+import { useWebsocketStore } from '@/stores/websocket';
const backgroundImage = ref();
const { height: backgroundImageHeight } = useElementSize(backgroundImage);
@@ -14,13 +16,23 @@ const { height: entitiesHeight } = useElementSize(entitiesContainer);
const dataStore = useDataStore();
const interfaceStore = useInterfaceStore();
+const authorizationStore = useAuthorizationStore();
+const websocketStore = useWebsocketStore();
const entities = computed(() => dataStore.homeEntities);
+
const backgroundUrl = computed(() => interfaceStore.homeBackgroundUrl);
+const defaultBackgroundUrl = computed(() => interfaceStore.defaultHomeBackgroundUrl);
const addEntity = (newEntity: IEntity) => {
- const prevState = [...entities.value];
- prevState.push(newEntity);
- dataStore.editHomeEntities(prevState);
+ const data = {
+ event: 'createHomeEntity',
+ body: {
+ ...newEntity,
+ nickName: authorizationStore.userNickName
+ }
+ };
+ console.log('data.body?.image_data: ', data.body?.image_data);
+ websocketStore.sendData(data);
};
@@ -41,32 +53,32 @@ const addEntity = (newEntity: IEntity) => {
class="splitterPanelBackground"
>
Change image
+ class="w-2 pr-[135px] -mr-[135px] py-2 -my-2 pl-2 -ml-2 opacity-0"
+ />Change image
+ >
-
@@ -90,4 +102,9 @@ const addEntity = (newEntity: IEntity) => {
.splitterPanelBackground:hover > .returnDefaultImageBlock {
opacity: 100;
}
+input[type=file], /* FF, IE7+, chrome (except button) */
+input[type=file]::-webkit-file-upload-button {
+ /* chromes and blink button */
+ cursor: pointer;
+}
diff --git a/src/stores/data.ts b/src/stores/data.ts
index 3e8b0b815f0aad1904c238f6953405daf56153ff..27b1f4004d2ed9d1a31568c8d6c042320f61d6a7 100644
--- a/src/stores/data.ts
+++ b/src/stores/data.ts
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia';
-import type { ISheet } from '@/interfaces/environment';
+import type {IEntity, ISheet} from '@/interfaces/environment';
export const useDataStore = defineStore('dataStore', () => {
const sheets = ref([
@@ -53,11 +53,14 @@ export const useDataStore = defineStore('dataStore', () => {
}
]);
- const homeEntities = ref(JSON.parse(localStorage.getItem('homeEntities') || '[]'));
+ const homeEntities = ref
([]);
- function editHomeEntities(newState) {
+ function editHomeEntities(newState: IEntity) {
homeEntities.value = newState;
- localStorage.setItem('homeEntities', JSON.stringify(newState));
}
- return { sheets, homeEntities, editHomeEntities };
+
+ function setHomeEntities(entities: IEntity[]) {
+ homeEntities.value = entities;
+ }
+ return { sheets, homeEntities, editHomeEntities, setHomeEntities };
});
diff --git a/src/stores/interface.ts b/src/stores/interface.ts
index b59fc34aba7a900f597d1e11723a2f6ba6189c3c..d834a66ad88590150042def97b59a265740394e8 100644
--- a/src/stores/interface.ts
+++ b/src/stores/interface.ts
@@ -4,14 +4,16 @@ export const useInterfaceStore = defineStore('interfaceStore', () => {
const homeBackgroundUrl = ref(
'https://wallpapers.com/images/featured/minimalist-7xpryajznty61ra3.jpg'
);
+ const defaultHomeBackgroundUrl = ref(
+ 'https://wallpapers.com/images/featured/minimalist-7xpryajznty61ra3.jpg'
+ );
onMounted(() => {
homeBackgroundUrl.value =
- localStorage.getItem('homeBackgroundUrl') ||
- 'https://wallpapers.com/images/featured/minimalist-7xpryajznty61ra3.jpg';
+ localStorage.getItem('homeBackgroundUrl') || defaultHomeBackgroundUrl.value;
});
function changeHomeBackgroundUrl(newUrl: string) {
homeBackgroundUrl.value = newUrl;
}
- return { homeBackgroundUrl, changeHomeBackgroundUrl };
+ return { homeBackgroundUrl, defaultHomeBackgroundUrl, changeHomeBackgroundUrl };
});
diff --git a/src/stores/websocket.ts b/src/stores/websocket.ts
new file mode 100644
index 0000000000000000000000000000000000000000..26d0dfca4898806218d3abfef710a3f9d480dbd9
--- /dev/null
+++ b/src/stores/websocket.ts
@@ -0,0 +1,81 @@
+import { defineStore } from 'pinia';
+import { useDataStore } from '@/stores/data';
+import type { IEntity } from '@/interfaces/environment';
+
+export const useWebsocketStore = defineStore('websocketStore', () => {
+ const socket = ref();
+ const dataStore = useDataStore();
+ const homeEntities = computed(() => dataStore.homeEntities);
+
+ onMounted(() => {
+ socket.value = new WebSocket('ws://localhost:5000');
+ socket.value.onopen = () => {
+ console.log('Websocket opened');
+ const data = {
+ event: 'getHomeEntities'
+ };
+ socket.value.send(JSON.stringify(data));
+ };
+ socket.value.onmessage = (event: any) => {
+ const response = JSON.parse(event.data);
+ console.log('response: ', response);
+ switch (response.event) {
+ case 'getHomeEntities':
+ dataStore.editHomeEntities(response.data);
+ break;
+ case 'createHomeEntity': {
+ const entities = [...homeEntities.value];
+ entities.push(response.data);
+ dataStore.editHomeEntities([...entities]);
+ break;
+ }
+ case 'editHomeEntity': {
+ let entities = [...dataStore.homeEntities];
+ entities = entities.map((entity: IEntity) => {
+ if (entity.entity_uuid !== response.data.entity_uuid) return entity;
+ return response.data;
+ });
+ dataStore.editHomeEntities(entities);
+ break;
+ }
+ case 'deleteHomeEntity': {
+ let newState = [...dataStore.homeEntities];
+ newState = newState.filter(
+ (entity: IEntity) => entity.entity_uuid !== response.data.entity_uuid
+ );
+ dataStore.editHomeEntities(newState);
+ break;
+ }
+ case 'changeOrderHomeEntity': {
+ const newState = dataStore.homeEntities;
+ const entityIndex = newState.findIndex(
+ (entity: IEntity) => entity.entity_uuid === response.data.entity_uuid
+ );
+ if (response.data.direction === 'up') {
+ [newState[entityIndex], newState[entityIndex - 1]] = [
+ newState[entityIndex - 1],
+ newState[entityIndex]
+ ];
+ } else {
+ [newState[entityIndex], newState[entityIndex + 1]] = [
+ newState[entityIndex + 1],
+ newState[entityIndex]
+ ];
+ }
+ dataStore.editHomeEntities(newState);
+ }
+ }
+ };
+ socket.value.onclose = () => {
+ console.log('Websocket connection closed');
+ };
+ socket.value.onerror = () => {
+ console.log('Websocket caught an error');
+ };
+ });
+
+ function sendData(data: any) {
+ socket.value.send(JSON.stringify(data));
+ }
+ return { sendData };
+});
diff --git a/tsconfig.json b/tsconfig.json
index 66b5e5703e83c352671ce094731e9e861ada6924..f7ea2202ebcca2b68fc8571c54d0e56dcedb883a 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,18 @@
{
- "files": [],
+ "include": [
+ "*.d.ts",
+ "src/**/*.ts",
+ "src/**/*.d.ts",
+ "src/**/*.vue",
+ ],
+ "exclude": [
+ "node_modules"
+ ],
+ "compilerOptions": {
+ "paths": {
+ "@/*": ["./src/*"]
+ },
+ },
"references": [
{
"path": "./tsconfig.node.json"
diff --git a/vite.config.ts b/vite.config.ts
index ed0c7caac29d0910011458aa23da52c164377547..69321b5e6cc48db509a79be55f5df53e4fe9343e 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -72,7 +72,7 @@ export default defineConfig({
// Filepath to generate corresponding .d.ts file.
// Defaults to './auto-imports.d.ts' when `typescript` is installed locally.
// Set `false` to disable.
- dts: true,
+ dts: 'src/auto-imports.d.ts',
// Array of strings of regexes that contains imports meant to be ignored during
// the declaration file generation. You may find this useful when you need to provide