diff --git a/.vscode/PythonImportHelper-v2-Completion.json b/.vscode/PythonImportHelper-v2-Completion.json index 1cea0db..3203bd8 100644 --- a/.vscode/PythonImportHelper-v2-Completion.json +++ b/.vscode/PythonImportHelper-v2-Completion.json @@ -8579,7 +8579,7 @@ "kind": 5, "importPath": "back.back.settings", "description": "back.back.settings", - "peekOfCode": "CSRF_TRUSTED_ORIGINS = (\n \"https://demo.kustarshina.ru\",\n \"http://localhost\",\n \"http://localhost:3011\",\n \"http://192.168.103.159\",\n)\nCORS_ORIGIN_ALLOW_ALL = False\nCORS_ORIGIN_WHITELIST = [\n \"null\",\n \"http://localhost\",", + "peekOfCode": "CSRF_TRUSTED_ORIGINS = (\n \"https://demo.kustarshina.ru\",\n \"http://localhost\",\n \"http://localhost:3011\",\n \"http://localhost:4173\",\n \"http://localhost:5173\",\n \"http://192.168.103.159:3011\",\n \"http://192.168.103.159\",\n)\nCORS_ORIGIN_ALLOW_ALL = False", "detail": "back.back.settings", "documentation": {} }, @@ -8588,7 +8588,7 @@ "kind": 5, "importPath": "back.back.settings", "description": "back.back.settings", - "peekOfCode": "CORS_ORIGIN_ALLOW_ALL = False\nCORS_ORIGIN_WHITELIST = [\n \"null\",\n \"http://localhost\",\n \"http://localhost:3000\",\n \"http://localhost:3011\",\n \"http://localhost:4173\",\n \"http://localhost:5173\",\n \"http://localhost:8000\",\n \"http://127.0.0.1\",", + "peekOfCode": "CORS_ORIGIN_ALLOW_ALL = False\nCORS_ORIGIN_WHITELIST = [\n \"null\",\n \"http://localhost\",\n \"http://localhost:3011\",\n \"http://localhost:4173\",\n \"http://localhost:5173\",\n \"http://localhost:8000\",\n \"http://192.168.103.159:3011\",\n \"http://127.0.0.1\",", "detail": "back.back.settings", "documentation": {} }, @@ -8597,7 +8597,7 @@ "kind": 5, "importPath": "back.back.settings", "description": "back.back.settings", - "peekOfCode": "CORS_ORIGIN_WHITELIST = [\n \"null\",\n \"http://localhost\",\n \"http://localhost:3000\",\n \"http://localhost:3011\",\n \"http://localhost:4173\",\n \"http://localhost:5173\",\n \"http://localhost:8000\",\n \"http://127.0.0.1\",\n \"http://192.168.103.159\",", + "peekOfCode": "CORS_ORIGIN_WHITELIST = [\n \"null\",\n \"http://localhost\",\n \"http://localhost:3011\",\n \"http://localhost:4173\",\n \"http://localhost:5173\",\n \"http://localhost:8000\",\n \"http://192.168.103.159:3011\",\n \"http://127.0.0.1\",\n \"http://192.168.103.159\",", "detail": "back.back.settings", "documentation": {} }, diff --git a/back/back/settings.py b/back/back/settings.py index f579598..75e4a3c 100644 --- a/back/back/settings.py +++ b/back/back/settings.py @@ -44,17 +44,20 @@ CSRF_TRUSTED_ORIGINS = ( "https://demo.kustarshina.ru", "http://localhost", "http://localhost:3011", + "http://localhost:4173", + "http://localhost:5173", + "http://192.168.103.159:3011", "http://192.168.103.159", ) CORS_ORIGIN_ALLOW_ALL = False CORS_ORIGIN_WHITELIST = [ "null", "http://localhost", - "http://localhost:3000", "http://localhost:3011", "http://localhost:4173", "http://localhost:5173", "http://localhost:8000", + "http://192.168.103.159:3011", "http://127.0.0.1", "http://192.168.103.159", "http://192.168.103.159:3000", diff --git a/front/components.d.ts b/front/components.d.ts index 511f284..164e025 100644 --- a/front/components.d.ts +++ b/front/components.d.ts @@ -7,7 +7,9 @@ export {} declare module 'vue' { export interface GlobalComponents { + copy: typeof import('./src/components/Floorplan copy.vue')['default'] Floorplan: typeof import('./src/components/Floorplan.vue')['default'] + FloorplanItem: typeof import('./src/components/FloorplanItem.vue')['default'] Game: typeof import('./src/components/Game.vue')['default'] Home: typeof import('./src/components/Home.vue')['default'] IMdiFile: typeof import('~icons/mdi/file')['default'] diff --git a/front/src/components/Floorplan.vue b/front/src/components/Floorplan.vue index 8dc8bb7..8f28e22 100644 --- a/front/src/components/Floorplan.vue +++ b/front/src/components/Floorplan.vue @@ -1,133 +1,25 @@ \ No newline at end of file diff --git a/front/src/components/FloorplanItem.vue b/front/src/components/FloorplanItem.vue new file mode 100644 index 0000000..2b1ebf4 --- /dev/null +++ b/front/src/components/FloorplanItem.vue @@ -0,0 +1,130 @@ + + + + \ No newline at end of file diff --git a/front/src/main.ts b/front/src/main.ts index 405d6cd..fe8b826 100644 --- a/front/src/main.ts +++ b/front/src/main.ts @@ -9,12 +9,14 @@ import Home from './components/Home.vue' import Projects from './components/Projects.vue' import Game from './components/Game.vue' import Floorplan from './components/Floorplan.vue' +import FloorplanItem from './components/FloorplanItem.vue' const routes = [ { path: '/', component: Home }, { path: '/projects', component: Projects }, { path: '/game', component: Game }, { path: '/floorplan', component: Floorplan }, + { path: '/floorplan/:id', component: FloorplanItem }, ] const router = createRouter({ diff --git a/front/src/stores/floorplan.ts b/front/src/stores/floorplan.ts index 3001c64..727a6b0 100644 --- a/front/src/stores/floorplan.ts +++ b/front/src/stores/floorplan.ts @@ -5,34 +5,60 @@ import { chunks } from '../helpers' export const useFloorplanStore = defineStore('floorplan', { state: () => { return { + items: [] as { id: string, title: string }[], title: undefined, - chunkSize: 7, np_array: [] as number[][], - prepared_array: [] as number[][] + prepared_array: [] as number[][], + chunk_size: undefined as number | undefined, + threshold: undefined as number | undefined, } }, actions: { - async getData() { + async getList() { try { - const res = await fetch(`${SERVER_URL}/api/floorplan`) + const res = await fetch(`${SERVER_URL}/api/floorplan/`, { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + }) + const data = await res.json() + this.items = data + // this.title = data.title + // this.np_array = data.np_field + } catch (error) { + console.log(error) + } + }, + async getData(id: number) { + try { + const res = await fetch(`${SERVER_URL}/api/floorplan/${id}`, { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + }) const data = await res.json() this.title = data.title this.np_array = data.np_field - this.prepared_array = [...chunks(data.np_field, this.chunkSize)].map(line => { + this.chunk_size = data.d_size || 8 + this.threshold = data.d_border || 20 + + this.prepared_array = [...chunks(data.np_field, this.chunk_size as number)].map(line => { const line_data = [] as any[][] - line.map((item: any) => [...chunks(item, this.chunkSize)]).map((item) => { + line.map((item: any) => [...chunks(item, this.chunk_size as number)]).map((item) => { item.map((one_line, k) => { if (!line_data[k]) line_data[k] = [] line_data[k].push(...one_line) }) }) return line_data.map(el => { - return el.filter(e => e > 0).length > 20 ? 1 : 0 + return el.filter(e => e > 0).length > (this.threshold as number) ? 1 : 0 }) }); } catch (error) { - // this.list = [] + console.log(error) } - }, + } } }) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 173ff9f..57d2f00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,5 +27,5 @@ build-backend = "poetry.core.masonry.api" export_req = "poetry export --without-hashes --format=requirements.txt > back/requirements.txt" server = "back/manage.py runserver 0.0.0.0:8000" front = "cd front && npm run build && npm run preview" -front_dev = "cd front && npm run dev" +front_dev = "cd front && npm run dev -- --host" admin_front_dev = "cd admin_front && npm run dev" \ No newline at end of file