\ 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