diff --git a/public/favicon.ico b/public/favicon.ico index 894d8a32e682da490dfdb1bca0e8ebe3a7f8148a..5406214e0c6c62890b9f83823a051792c31fb888 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/src/app/assets/ShelfNote.svg b/src/app/assets/ShelfNote.svg deleted file mode 100644 index a51145e952f004c36dc87ffff45382f8b88fbbc3..0000000000000000000000000000000000000000 --- a/src/app/assets/ShelfNote.svg +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/app/assets/ShelfNoteLogoCircle.png b/src/app/assets/ShelfNoteLogoCircle.png new file mode 100644 index 0000000000000000000000000000000000000000..f6539dfd68a7199213bbd22b195d5f1a27303ab9 Binary files /dev/null and b/src/app/assets/ShelfNoteLogoCircle.png differ diff --git a/src/app/assets/main.css b/src/app/assets/main.css index 0932c7d841603dcf520d95b766f2db03f91745ce..98c331161a8e15b5729e5b1ddc5d962ceec9b3f9 100644 --- a/src/app/assets/main.css +++ b/src/app/assets/main.css @@ -153,7 +153,7 @@ body { display: flex; flex-flow: column; } -#pageContainer { +#sheetContainer { padding-top: 80px; } #app > main { @@ -173,6 +173,7 @@ body { box-sizing: border-box; user-select: none; color: white; + font-weight: 500; } /* Links */ diff --git a/src/app/components.d.ts b/src/app/components.d.ts index 1128b7dafbe76045943ec66e6138aaa3b3d2c4d4..4b614661cefd5d8725675a8e1ed79582838f88c2 100644 --- a/src/app/components.d.ts +++ b/src/app/components.d.ts @@ -15,60 +15,67 @@ declare module 'vue' { BaseLoader: typeof import('./../shared/BaseLoader.vue')['default'] Button: typeof import('./../shared/ui/Button.vue')['default'] CloseCircle: typeof import('./../shared/icons/CloseCircle.vue')['default'] - ConfirmDeleteEntityModal: typeof import('./../modules/ConfirmDeleteEntityModal.vue')['default'] - CreateEntityMenu: typeof import('./../components/CreateEntityMenu.vue')['default'] + CloseCircleIcon: typeof import('./../shared/icons/CloseCircleIcon.vue')['default'] + CreateEntityMenu: typeof import('./../components/common/CreateEntityMenu.vue')['default'] CropIcon: typeof import('./../shared/icons/CropIcon.vue')['default'] - CropImageModal: typeof import('./../modules/CropImageModal.vue')['default'] + CropImageModal: typeof import('./../modules/common/CropImageModal.vue')['default'] DashedIcon: typeof import('./../shared/icons/DashedIcon.vue')['default'] + DeleteEntityConfirmModal: typeof import('./../modules/common/DeleteEntityConfirmModal.vue')['default'] Divider: typeof import('./../shared/ui/Divider.vue')['default'] - DividerItem: typeof import('./../modules/entities/DividerItem.vue')['default'] - DividerSettings: typeof import('./../components/entities/settings/DividerSettings.vue')['default'] - DividerSettingsList: typeof import('./../components/entities/settings/lists/DividerSettingsList.vue')['default'] + DividerEntity: typeof import('./../modules/sheets/entities/items/DividerEntity.vue')['default'] + DividerSettings: typeof import('./../components/sheets/entities/settings/DividerSettings.vue')['default'] + DividerSettingsList: typeof import('./../components/sheets/entities/settings/lists/DividerSettingsList.vue')['default'] DottedIcon: typeof import('./../shared/icons/DottedIcon.vue')['default'] Drawer: typeof import('./../shared/ui/Drawer.vue')['default'] - EntitiesList: typeof import('./../modules/entities/EntitiesList.vue')['default'] - EntityItem: typeof import('./../modules/entities/EntityItem.vue')['default'] - EntityPositionSettings: typeof import('./../components/entities/settings/EntityPositionSettings.vue')['default'] - EntityTitle: typeof import('./../components/entities/share/EntityTitle.vue')['default'] + EntitiesList: typeof import('./../modules/sheets/entities/EntitiesList.vue')['default'] + EntityItem: typeof import('./../modules/sheets/entities/EntityItem.vue')['default'] + EntityPositionSettings: typeof import('./../components/sheets/entities/settings/EntityPositionSettings.vue')['default'] + EntitySettingsModalHeader: typeof import('./../components/sheets/entities/settings/common/EntitySettingsModalHeader.vue')['default'] + EntityTitle: typeof import('./../components/sheets/entities/share/EntityTitle.vue')['default'] ExitIcon: typeof import('./../shared/icons/ExitIcon.vue')['default'] HamburgerIcon: typeof import('./../shared/icons/HamburgerIcon.vue')['default'] HomeIcon: typeof import('./../shared/icons/HomeIcon.vue')['default'] HorizontalLineIcon: typeof import('./../shared/icons/HorizontalLineIcon.vue')['default'] + ImageEditIcon: typeof import('./../shared/icons/ImageEditIcon.vue')['default'] + ImageEntity: typeof import('./../modules/sheets/entities/items/ImageEntity.vue')['default'] + ImageEntityImageWithText: typeof import('./../components/sheets/entities/content/ImageEntityImageWithText.vue')['default'] ImageIcon: typeof import('./../shared/icons/ImageIcon.vue')['default'] - ImageItem: typeof import('./../modules/entities/ImageItem.vue')['default'] - ImageSettings: typeof import('./../components/entities/settings/ImageSettings.vue')['default'] - ImageSettingsList: typeof import('./../components/entities/settings/lists/ImageSettingsList.vue')['default'] - LogoAndLabel: typeof import('./../components/LogoAndLabel.vue')['default'] + ImageSettings: typeof import('./../components/sheets/entities/settings/ImageSettings.vue')['default'] + ImageSettingsEntityBlock: typeof import('./../components/sheets/entities/settings/entityBlock/ImageSettingsEntityBlock.vue')['default'] + ImageSettingsList: typeof import('./../components/sheets/entities/settings/lists/ImageSettingsList.vue')['default'] MenuDial: typeof import('./../shared/ui/MenuDial.vue')['default'] Modal: typeof import('./../shared/ui/Modal.vue')['default'] NavigationIcon: typeof import('./../shared/icons/NavigationIcon.vue')['default'] - PageBackgroundMenu: typeof import('./../modules/PageBackgroundMenu.vue')['default'] - PageHeader: typeof import('./../modules/PageHeader.vue')['default'] - PageMenuButton: typeof import('./../components/PageMenuButton.vue')['default'] + ParagraphEntity: typeof import('./../modules/sheets/entities/items/ParagraphEntity.vue')['default'] ParagraphIcon: typeof import('./../shared/icons/ParagraphIcon.vue')['default'] - ParagraphItem: typeof import('./../modules/entities/ParagraphItem.vue')['default'] - ParagraphSettings: typeof import('./../components/entities/settings/ParagraphSettings.vue')['default'] - ParagraphSettingsList: typeof import('./../components/entities/settings/lists/ParagraphSettingsList.vue')['default'] + ParagraphSettings: typeof import('./../components/sheets/entities/settings/ParagraphSettings.vue')['default'] + ParagraphSettingsList: typeof import('./../components/sheets/entities/settings/lists/ParagraphSettingsList.vue')['default'] PlusIcon: typeof import('./../shared/icons/PlusIcon.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] SaveIcon: typeof import('./../shared/icons/SaveIcon.vue')['default'] SettingsIcon: typeof import('./../shared/icons/SettingsIcon.vue')['default'] + SheetBackgroundMenu: typeof import('./../modules/sheets/SheetBackgroundMenu.vue')['default'] + SheetHeader: typeof import('./../modules/sheets/SheetHeader.vue')['default'] SheetPage: typeof import('./../pages/[uuid]/SheetPage.vue')['default'] - SidebarMenuContent: typeof import('./../modules/SidebarMenuContent.vue')['default'] + SheetPageContent: typeof import('./../modules/sheets/SheetPageContent.vue')['default'] + SheetTelegramSection: typeof import('./../modules/sheets/SheetTelegramSection.vue')['default'] + SidebarMenu: typeof import('./../modules/common/SidebarMenu.vue')['default'] + SidebarMenuButton: typeof import('./../components/common/SidebarMenuButton.vue')['default'] SignIn: typeof import('./../pages/authorization/signIn.vue')['default'] SignUp: typeof import('./../pages/authorization/signUp.vue')['default'] Slider: typeof import('./../shared/ui/Slider.vue')['default'] SolidIcon: typeof import('./../shared/icons/SolidIcon.vue')['default'] TableIcon: typeof import('./../shared/icons/TableIcon.vue')['default'] - TelegramSection: typeof import('./../modules/TelegramSection.vue')['default'] - TextFontMenu: typeof import('./../components/entities/share/TextFontMenu.vue')['default'] - TextPositionMenu: typeof import('./../components/entities/text/TextPositionMenu.vue')['default'] - TextStateMenu: typeof import('./../components/entities/text/TextStateMenu.vue')['default'] + TextFontMenu: typeof import('@/components/sheets/entities/share/TextFontMenu.vue')['default'] + TextPositionMenu: typeof import('@/components/sheets/entities/text/TextPositionMenu.vue')['default'] + TextStateMenu: typeof import('@/components/sheets/entities/text/TextStateMenu.vue')['default'] ToggleButton: typeof import('./../shared/ui/ToggleButton.vue')['default'] ToggleSwitch: typeof import('./../shared/ui/ToggleSwitch.vue')['default'] TrashIcon: typeof import('./../shared/icons/TrashIcon.vue')['default'] Tree: typeof import('./../shared/ui/Tree.vue')['default'] + TriangleOpenIcon: typeof import('./../shared/ui/icons/TriangleOpenIcon.vue')['default'] + UploadIcon: typeof import('./../shared/icons/UploadIcon.vue')['default'] VerticalArrowsIcon: typeof import('./../shared/icons/VerticalArrowsIcon.vue')['default'] } } diff --git a/src/app/helpers/entities.ts b/src/app/helpers/entities.ts new file mode 100644 index 0000000000000000000000000000000000000000..c96bd0328de3c1cb4e57ed7de297e63fb8151b8f --- /dev/null +++ b/src/app/helpers/entities.ts @@ -0,0 +1,117 @@ +import { useInterfaceStore } from '@/app/stores/interface'; +import { useDataStore } from '@/app/stores/data'; +import { useWebsocketStore } from '@/app/stores/websocket'; +import type { IEntity } from '@/app/interfaces/environment'; +import { calcImageWidth, checkIsImage } from '@/app/helpers/images'; +import { useFilesWebsocketStore } from '@/app/stores/filesWebsocket'; +import cookies from '@/app/plugins/Cookie'; + +export const fetchForEntities = (sheet_uuid: string) => { + const dataStore = useDataStore(); + const interfaceStore = useInterfaceStore(); + const websocketStore = useWebsocketStore(); + const filesWebsocketStore = useFilesWebsocketStore(); + const filesBuffer = filesWebsocketStore.filesBuffer; + if (filesBuffer.length) { + filesBuffer[0] = new Blob([filesBuffer[0].data], { type: 'image/jpeg' }); + interfaceStore.setSheetBackgroundFromDB(URL.createObjectURL(filesBuffer[0])); + } + if (!dataStore.entities.length) { + const getEntitiesData = { + event: 'getSheetEntities', + body: { sheet_uuid } + }; + websocketStore.sendData(getEntitiesData); + } + filesWebsocketStore.removeFirstFilesBuffer(); +}; + +export const createEntity = (newEntity: IEntity) => { + const websocketStore = useWebsocketStore(); + const sheet_uuid = cookies.get('current_sheet_uuid'); + if (newEntity.image_buffer) { + websocketStore.setFileData(newEntity); + const filesWebsocketStore = useFilesWebsocketStore(); + return filesWebsocketStore.sendData(newEntity.image_buffer); + } + const data = { + event: 'createEntity', + body: { ...newEntity, sheet_uuid } + }; + websocketStore.sendData(data); +}; + +export const addImageOnLoad = async (image, url: string, entitiesCount: number) => { + const filesWebsocketStore = useFilesWebsocketStore(); + const dataStore = useDataStore(); + filesWebsocketStore.saveImageUrl(url); + const response = await fetch(url); + const blob = await response.blob(); + const buffer = await blob.arrayBuffer(); + const windowWidth = computed(() => dataStore.windowWidth); + const maxHeight = 1000; + const initWidth = image.width; + if (image.height > maxHeight) { + const coefficient = maxHeight / image.height; + image.width *= coefficient; + } + const imageWidth = calcImageWidth(image.width, windowWidth.value); + createEntity({ + entity_type: 'image', + entity_order: entitiesCount + 1, + image_buffer: buffer, + entity_position: 'left', + entity_title_position: 'center', + font_size: '24', + text_position: 'right', + paragraph_size: 'full', + image_width: imageWidth, + image_width_initial: imageWidth, + file_width: initWidth, + file_height: image.height, + file_width_initial: initWidth, + file_height_initial: image.height, + image_scale: 'x1' + }); +}; + +export const editEntity = (newState: IEntity) => { + newState = checkIsImage(newState); + const websocketStore = useWebsocketStore(); + const data = { + event: 'editEntity', + body: { ...newState } + }; + websocketStore.sendData(data); +}; + +export const deleteEntity = (entityUuid: string) => { + const dataStore = useDataStore(); + const websocketStore = useWebsocketStore(); + const sheet_uuid = cookies.get('current_sheet_uuid'); + const entities = dataStore.entities; + const entityToDelete = entities.find((entity) => entity.entity_uuid === entityUuid); + const data = { + event: 'deleteEntity', + body: { ...entityToDelete, sheet_uuid } + }; + websocketStore.sendData(data); +}; + +export const changeEntitiesOrder = (entityUuid: string, direction: 'up' | 'down') => { + const websocketStore = useWebsocketStore(); + const dataStore = useDataStore(); + const entities = dataStore.entities; + const mainEntity = entities.find((entity: IEntity) => entity.entity_uuid === entityUuid)!; + const mainEntityIndex = entities.indexOf(mainEntity); + const targetEntityIndex = direction === 'up' ? mainEntityIndex - 1 : mainEntityIndex + 1; + const targetEntity = entities[targetEntityIndex]; + const data = { + event: 'changeEntitiesOrder', + body: { + main: mainEntity, + target: targetEntity + } + }; + websocketStore.sendData(data); +}; diff --git a/src/app/helpers/images.ts b/src/app/helpers/images.ts index 4aa5cd235b6908b0769d45dfe3e0766e411e247c..006023d972c411e6c38228cfe13c7440fa434a75 100644 --- a/src/app/helpers/images.ts +++ b/src/app/helpers/images.ts @@ -3,11 +3,54 @@ import { useFilesWebsocketStore } from '@/app/stores/filesWebsocket'; import type { IImage } from '@/app/interfaces/entities'; import { useWebsocketStore } from '@/app/stores/websocket'; import { useInterfaceStore } from '@/app/stores/interface'; -import { imageScaleOptions } from '@/components/entities/settings/lists/constants/options'; +import { imageScaleOptions } from '@/components/sheets/entities/settings/lists/constants/options'; -export const setDefaultPageBackground = () => { +export const calcImageWidth = (fileWidth: number, windowWidth: number) => { + let imageWidth = Math.ceil((fileWidth / (windowWidth - 128)) * 100); + if (imageWidth > 100) { + imageWidth = 100; + } + if (imageWidth < 5) { + imageWidth = 5; + } + return imageWidth; +}; + +export const sendReturnOriginalSize = (newState: IEntity) => { + const websocketStore = useWebsocketStore(); + const data = { + event: 'returnOriginalImageSize', + body: { ...newState } + }; + websocketStore.sendData(data); +}; + +export const uploadImage = ($event) => { + const target = $event.target as HTMLInputElement; + const image = new Image(); + const file = target.files![0]; + image.src = URL.createObjectURL(file); + return image; +}; + +export const backgroundImageOnLoad = (image, windowWidth: number) => { + const backgroundImageInfo = { + image_url: '', + image_width: 0, + file_width: 0, + file_height: 0 + }; + const imageWidth = calcImageWidth(image.width, windowWidth); + backgroundImageInfo.image_url = image.src; + backgroundImageInfo.image_width = imageWidth; + backgroundImageInfo.file_width = image.width; + backgroundImageInfo.file_height = image.height; + return backgroundImageInfo; +}; + +export const setDefaultSheetBackground = () => { const interfaceStore = useInterfaceStore(); - interfaceStore.resetPageBackground(); + interfaceStore.resetSheetBackground(); }; export const addUrlsToImageEntities = (entities: IEntity[]) => { @@ -46,17 +89,6 @@ export const checkIsImage = (entity: IEntity) => { return entityToReturn; }; -export const calcImageWidth = (fileWidth: number, windowWidth: number) => { - let imageWidth = Math.ceil((fileWidth / (windowWidth - 128)) * 100); - if (imageWidth > 100) { - imageWidth = 100; - } - if (imageWidth < 5) { - imageWidth = 5; - } - return imageWidth; -}; - export const sendCropImage = async (newUrl: string, entity: IImage) => { const filesWebsocketStore = useFilesWebsocketStore(); filesWebsocketStore.saveImageUrl(newUrl); @@ -168,3 +200,31 @@ export const scaleImage = (entityData: IImage, prevScale: string) => { entityData.image_width = Math.ceil(initialWidth * +scale); return entityData; }; + +export const updateEntityDataTextOnSave = ( + newEntityData: T, + prevEntityData: IEntity, + isEntityWidthFull: boolean, + isTitle: boolean, + isText?: boolean +) => { + const paragraphSize = isEntityWidthFull ? 'full' : 'half'; + if (paragraphSize !== prevEntityData.paragraph_size) { + newEntityData.paragraph_size = paragraphSize; + } + if (isTitle !== !!prevEntityData.title) { + if (isTitle) { + newEntityData.title = 'Title'; + } else { + newEntityData.title = null; + } + } + if (isText !== !!prevEntityData.text) { + if (isText) { + newEntityData.text = 'Text'; + } else { + newEntityData.text = null; + } + } + return newEntityData; +}; diff --git a/src/app/helpers/index.ts b/src/app/helpers/index.ts index db01ef4efe55d3af677aa884d23af716a2cf7a66..4089011bfe5ca306f9727cbf0abafb6ebe0b6c85 100644 --- a/src/app/helpers/index.ts +++ b/src/app/helpers/index.ts @@ -1,96 +1,3 @@ -import { useInterfaceStore } from '@/app/stores/interface'; -import { useDataStore } from '@/app/stores/data'; -import { useWebsocketStore } from '@/app/stores/websocket'; -import type { IEntity, TTheme } from '@/app/interfaces/environment'; -import { checkIsImage } from '@/app/helpers/images'; -import { useFilesWebsocketStore } from '@/app/stores/filesWebsocket'; -import cookies from '@/app/plugins/Cookie'; - -export const fetchForEntities = (page_uuid: string) => { - const dataStore = useDataStore(); - const interfaceStore = useInterfaceStore(); - const websocketStore = useWebsocketStore(); - const filesWebsocketStore = useFilesWebsocketStore(); - const filesBuffer = filesWebsocketStore.filesBuffer; - if (filesBuffer.length) { - filesBuffer[0] = new Blob([filesBuffer[0].data], { type: 'image/jpeg' }); - interfaceStore.setPageBackgroundFromDB(URL.createObjectURL(filesBuffer[0])); - } - if (!dataStore.entities.length) { - const getEntitiesData = { - event: 'getPageEntities', - body: { page_uuid } - }; - websocketStore.sendData(getEntitiesData); - } - filesWebsocketStore.removeFirstFilesBuffer(); -}; - -export const createEntity = (newEntity: IEntity) => { - const websocketStore = useWebsocketStore(); - const page_uuid = cookies.get('current_page_uuid'); - if (newEntity.image_buffer) { - websocketStore.setFileData(newEntity); - const filesWebsocketStore = useFilesWebsocketStore(); - return filesWebsocketStore.sendData(newEntity.image_buffer); - } - const data = { - event: 'createEntity', - body: { ...newEntity, page_uuid } - }; - websocketStore.sendData(data); -}; - -export const editEntity = (newState: IEntity) => { - newState = checkIsImage(newState); - const websocketStore = useWebsocketStore(); - const data = { - event: 'editEntity', - body: { ...newState } - }; - websocketStore.sendData(data); -}; - -export const sendReturnOriginalSize = (newState: IEntity) => { - const websocketStore = useWebsocketStore(); - const data = { - event: 'returnOriginalImageSize', - body: { ...newState } - }; - websocketStore.sendData(data); -}; - -export const deleteEntity = (entityUuid: string) => { - const dataStore = useDataStore(); - const websocketStore = useWebsocketStore(); - const page_uuid = cookies.get('current_page_uuid'); - const entities = dataStore.entities; - const entityToDelete = entities.find((entity) => entity.entity_uuid === entityUuid); - const data = { - event: 'deleteEntity', - body: { ...entityToDelete, page_uuid } - }; - websocketStore.sendData(data); -}; - -export const changeEntitiesOrder = (entityUuid: string, direction: 'up' | 'down') => { - const websocketStore = useWebsocketStore(); - const dataStore = useDataStore(); - const entities = dataStore.entities; - const mainEntity = entities.find((entity: IEntity) => entity.entity_uuid === entityUuid)!; - const mainEntityIndex = entities.indexOf(mainEntity); - const targetEntityIndex = direction === 'up' ? mainEntityIndex - 1 : mainEntityIndex + 1; - const targetEntity = entities[targetEntityIndex]; - const data = { - event: 'changeEntitiesOrder', - body: { - main: mainEntity, - target: targetEntity - } - }; - websocketStore.sendData(data); -}; - export const convertThemeToColorWhiteDefault = (theme: string | undefined) => { if (!theme) return '#ffffff'; switch (theme) { diff --git a/src/app/interfaces/entities.ts b/src/app/interfaces/entities.ts index 96afa4f83134389fd900164e806a2b83db9f54ec..62416d2dc9bfc6083b842b599796e73fd13e0045 100644 --- a/src/app/interfaces/entities.ts +++ b/src/app/interfaces/entities.ts @@ -11,10 +11,10 @@ export interface ITable extends IEntity { }[]; } export interface ITableColumn { - column_uuid: string; + column_uuid?: string; name: string; type: ITableColumnTypes; - data: never; + data?: never; } type ITableColumnTypes = | 'text' diff --git a/src/app/interfaces/environment.ts b/src/app/interfaces/environment.ts index 08052ba4d66f8642bc45b736c052f4208fd514b0..59549b7c10e7a03c38287ec924f4198d04b8178b 100644 --- a/src/app/interfaces/environment.ts +++ b/src/app/interfaces/environment.ts @@ -1,10 +1,10 @@ import type { ITableColumn } from '@/app/interfaces/entities'; -export interface IPageInfo { - page_uuid: string; - page_title: string; - page_icon: string; - page_navigation_order: string; +export interface ISheetInfo { + sheet_uuid: string; + sheet_title: string; + sheet_icon: string; + sheet_navigation_order: string; entities?: { entity_uuid: string; entity_type: 'divider' | 'paragraph' | 'image' | 'table'; @@ -12,7 +12,7 @@ export interface IPageInfo { } export interface IEntity { - entity_uuid: string; + entity_uuid?: string; entity_user?: string; user_nick_name?: string; entity_order?: number; @@ -24,7 +24,7 @@ export interface IEntity { font_size?: string | null; paragraph_size?: string | null; text_position?: string | null; - image_buffer?: string; + image_buffer?: string | ArrayBuffer; image_url_initial?: string; image_width_initial?: number; file_width_initial?: number; diff --git a/src/app/stores/authorization.ts b/src/app/stores/authorization.ts index 01a931ccb0dc678492e355e67c434d54e19c0299..e64f4c9da3a65f3d131a7f10e475d3cf9ecfc43d 100644 --- a/src/app/stores/authorization.ts +++ b/src/app/stores/authorization.ts @@ -23,7 +23,7 @@ export const useAuthorizationStore = defineStore('authorizationStore', () => { userNickName.value = ''; userData.value = null; cookies.remove('user_uuid'); - cookies.remove('current_page_uuid'); + cookies.remove('current_sheet_uuid'); cookies.remove('home_uuid'); cookies.remove('favorite_color'); router.push('/signUp'); diff --git a/src/app/stores/data.ts b/src/app/stores/data.ts index ea60bfd0633ba7bb8abce53a970a0f6c191030e8..58d74cdc6888e34097972ac7b91b03d1aa7b5050 100644 --- a/src/app/stores/data.ts +++ b/src/app/stores/data.ts @@ -1,6 +1,7 @@ import { defineStore } from 'pinia'; -import type { IEntity, IPageInfo } from '@/app/interfaces/environment'; +import type { IEntity, ISheetInfo } from '@/app/interfaces/environment'; import cookies from '@/app/plugins/Cookie'; +import { useWindowSize } from '@vueuse/core'; export const useDataStore = defineStore('dataStore', () => { const sheets = ref([ @@ -36,22 +37,23 @@ export const useDataStore = defineStore('dataStore', () => { } ]); - const pagesData = ref([]); - const currentPage = computed(() => - pagesData.value.find((page) => page.page_uuid === cookies.get('current_page_uuid')) + const sheetsData = ref([]); + const currentSheet = computed(() => + sheetsData.value.find((sheet) => sheet.sheet_uuid === cookies.get('current_sheet_uuid')) ); const entities = ref([]); - function setCurrentPageUuid(uuid: string) { - cookies.set('current_page_uuid', uuid); + const { width: windowWidth, height: windowHeight } = useWindowSize(); + function setCurrentSheetUuid(uuid: string) { + cookies.set('current_sheet_uuid', uuid); } - function setCurrentPageData(data: IPageInfo) { - currentPage.value = data; + function setCurrentSheetData(data: ISheetInfo) { + // currentSheet.value = data; } - function setPagesData(data: IPageInfo[]) { - pagesData.value = data; + function setSheetsData(data: ISheetInfo[]) { + sheetsData.value = data; } - function addPageData(data: IPageInfo) { - pagesData.value.push(data); + function addSheetData(data: ISheetInfo) { + sheetsData.value.push(data); } function editEntities(newState: IEntity[]) { entities.value = newState.sort( @@ -59,14 +61,16 @@ export const useDataStore = defineStore('dataStore', () => { ); } return { + windowWidth, + windowHeight, sheets, entities, - pagesData, - currentPage, - setCurrentPageUuid, - setCurrentPageData, - setPagesData, - addPageData, + sheetsData, + currentSheet, + setCurrentSheetUuid, + setCurrentSheetData, + setSheetsData, + addSheetData, editEntities }; }); diff --git a/src/app/stores/interface.ts b/src/app/stores/interface.ts index 34f2f4aa9298b4416fccd1790a98f3d11cdddc27..899bef5248614a1e605a26458c749e1810a6a161 100644 --- a/src/app/stores/interface.ts +++ b/src/app/stores/interface.ts @@ -5,31 +5,31 @@ export const useInterfaceStore = defineStore('interfaceStore', () => { const websocketStore = useWebsocketStore(); const isDarkMode = ref(true); - const defaultPageBackground = ref( + const defaultSheetBackground = ref( 'https://t3.ftcdn.net/jpg/05/01/28/98/360_F_501289843_4ITbthNCydFQGgJmoZe4IQKchItBubqZ.jpg' ); - const pageBackground = ref(defaultPageBackground.value); + const sheetBackground = ref(defaultSheetBackground.value); const isFetchedForBackground = ref(false); function setIsFetchedForBackground() { isFetchedForBackground.value = true; } - function resetPageBackground() { - pageBackground.value = defaultPageBackground.value; + function resetSheetBackground() { + sheetBackground.value = defaultSheetBackground.value; const data = { - event: 'deletePageBackground' + event: 'deleteSheetBackground' }; websocketStore.sendData(data); } - function editPageBackground(newUrl: string) { - pageBackground.value = newUrl; + function editSheetBackground(newUrl: string) { + sheetBackground.value = newUrl; const image = new Image(); image.src = newUrl; image.onload = async () => { const response = await fetch(newUrl); const blob = await response.blob(); const data = { - event: 'editPageBackground', + event: 'editSheetBackground', body: { background_url: newUrl, extension: blob.type @@ -38,20 +38,20 @@ export const useInterfaceStore = defineStore('interfaceStore', () => { websocketStore.sendData(data); }; } - function setPageBackgroundFromDB(url: string | null) { + function setSheetBackgroundFromDB(url: string | null) { if (!url) { return; } - pageBackground.value = url; + sheetBackground.value = url; } return { isDarkMode, - pageBackground, - defaultPageBackground, + sheetBackground, + defaultSheetBackground, isFetchedForBackground, setIsFetchedForBackground, - resetPageBackground, - editPageBackground, - setPageBackgroundFromDB + resetSheetBackground, + editSheetBackground, + setSheetBackgroundFromDB }; }); diff --git a/src/app/stores/websocket.ts b/src/app/stores/websocket.ts index a67488edc35d888c3564ab2059fb7c06f85c3cbe..fdde38259be2cee82a3c44b04580b0fa3121ce95 100644 --- a/src/app/stores/websocket.ts +++ b/src/app/stores/websocket.ts @@ -6,7 +6,7 @@ import { addUrlsToImageEntities } from '@/app/helpers/images'; import { useFilesWebsocketStore } from '@/app/stores/filesWebsocket'; import { useAuthorizationStore } from '@/app/stores/authorization'; import cookies from '@/app/plugins/Cookie'; -import { editEntity } from '@/app/helpers'; +import { editEntity } from '@/app/helpers/entities'; export const useWebsocketStore = defineStore('websocketStore', () => { const dataStore = useDataStore(); @@ -39,14 +39,14 @@ export const useWebsocketStore = defineStore('websocketStore', () => { } }; sendData(getUserData); - const pageUuid = cookies.get('current_page_uuid'); - const getPageData = { - event: 'getPage', + const sheetUuid = cookies.get('current_sheet_uuid'); + const getSheetData = { + event: 'getSheet', body: { - page_uuid: pageUuid + sheet_uuid: sheetUuid } }; - sendData(getPageData); + sendData(getSheetData); } if (initialDataToSend.value) socket.value.send(JSON.stringify(initialDataToSend.value)); }; @@ -57,11 +57,11 @@ export const useWebsocketStore = defineStore('websocketStore', () => { // create case 'createUser': { cookies.set('user_uuid', response.data.user_uuid); - const pagesUuid = response.data.pages_uuid; - const homePageUuid = pagesUuid[0]; + const sheetsUuid = response.data.sheets_uuid; + const homeSheetUuid = sheetsUuid[0]; const userSettings = response.data.settings; cookies.set('favorite_color', userSettings.favorite_color); - cookies.set('home_uuid', homePageUuid); + cookies.set('home_uuid', homeSheetUuid); const getUserData = { event: 'getUser', body: { @@ -69,18 +69,18 @@ export const useWebsocketStore = defineStore('websocketStore', () => { } }; sendData(getUserData); - const getPageData = { - event: 'getPage', + const getSheetData = { + event: 'getSheet', body: { - page_uuid: homePageUuid + sheet_uuid: homeSheetUuid } }; - sendData(getPageData); - await router.push(`/${homePageUuid}`); + sendData(getSheetData); + await router.push(`/${homeSheetUuid}`); break; } - case 'createPage': { - dataStore.addPageData(response.data); + case 'createSheet': { + dataStore.addSheetData(response.data); break; } case 'createEntity': { @@ -96,12 +96,12 @@ export const useWebsocketStore = defineStore('websocketStore', () => { } case 'createImageEntity': { if (!file.value) break; - const page_uuid = cookies.get('current_page_uuid'); + const sheet_uuid = cookies.get('current_sheet_uuid'); const data = { event: 'createEntity', body: { ...file.value, - page_uuid + sheet_uuid } }; file.value = null; @@ -112,15 +112,15 @@ export const useWebsocketStore = defineStore('websocketStore', () => { case 'getUser': { authorizationStore.setUserNickName(response.data.nick_name); authorizationStore.setUserData(response.data); - dataStore.setPagesData(response.data.pages_uuid); + dataStore.setSheetsData(response.data.sheets_uuid); break; } - case 'getPage': { - dataStore.setCurrentPageUuid(response.data.page_uuid); - dataStore.setCurrentPageData(response.data); + case 'getSheet': { + dataStore.setCurrentSheetUuid(response.data.sheet_uuid); + // dataStore.setCurrentSheetData(response.data); break; } - case 'getPageEntities': { + case 'getSheetEntities': { const newState = response.data; if (imageEntitiesCount.value && filesBufferLength.value === imageEntitiesCount.value) { const entitiesAddedUrls = addUrlsToImageEntities(newState); @@ -130,12 +130,12 @@ export const useWebsocketStore = defineStore('websocketStore', () => { } break; } - case 'getPageBackground': { + case 'getSheetBackground': { const blob = new Blob([response.data.setting_value.data], { type: `image/jpeg` }); const url = URL.createObjectURL(blob); - interfaceStore.setPageBackgroundFromDB(url); + interfaceStore.setSheetBackgroundFromDB(url); break; } // update diff --git a/src/components/LogoAndLabel.vue b/src/components/LogoAndLabel.vue deleted file mode 100644 index b69b570d8681b9655a9239ea0bc7624d9c5cd3e5..0000000000000000000000000000000000000000 --- a/src/components/LogoAndLabel.vue +++ /dev/null @@ -1,14 +0,0 @@ - - - - - diff --git a/src/components/CreateEntityMenu.vue b/src/components/common/CreateEntityMenu.vue similarity index 64% rename from src/components/CreateEntityMenu.vue rename to src/components/common/CreateEntityMenu.vue index 66a54f558a639eb7d23dcd61558bcc76d1f043ab..0f1db3285cef58a03a30106806d420e840265f42 100644 --- a/src/components/CreateEntityMenu.vue +++ b/src/components/common/CreateEntityMenu.vue @@ -1,12 +1,9 @@