From 9af80cda06b3b767f1d95acbbd5da8d08691367c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Mon, 25 Mar 2024 21:59:55 +0100 Subject: [PATCH] draft planovace --- .../flightPlans/FlightPlansList.vue | 27 +++++++ src/components/inputs/MapGPSInput.vue | 3 +- src/components/poi/POIList.vue | 1 - src/graphql/fragments/flightPlan.js | 21 +++++ src/graphql/mutations/flightPlan.js | 28 +++++++ src/graphql/queries/flightPlan.js | 12 +++ src/pages/profile/flight/NewFlightPage.vue | 22 +++--- .../flightPlanner/FlightPlanEditPage.vue | 76 +++++++++++++++++++ .../profile/flightPlanner/FlightPlansPage.vue | 38 ++++++++++ .../NewFlightPlanPage.vue} | 57 ++++++++------ src/router/routes.js | 5 +- src/stores/FlightPlans.js | 29 +++---- 12 files changed, 262 insertions(+), 57 deletions(-) create mode 100644 src/components/flightPlans/FlightPlansList.vue create mode 100644 src/pages/profile/flightPlanner/FlightPlanEditPage.vue create mode 100644 src/pages/profile/flightPlanner/FlightPlansPage.vue rename src/pages/profile/{flight/PlannerPage.vue => flightPlanner/NewFlightPlanPage.vue} (85%) diff --git a/src/components/flightPlans/FlightPlansList.vue b/src/components/flightPlans/FlightPlansList.vue new file mode 100644 index 0000000..faf07ce --- /dev/null +++ b/src/components/flightPlans/FlightPlansList.vue @@ -0,0 +1,27 @@ + + + diff --git a/src/components/inputs/MapGPSInput.vue b/src/components/inputs/MapGPSInput.vue index 9531e16..0ab4b39 100644 --- a/src/components/inputs/MapGPSInput.vue +++ b/src/components/inputs/MapGPSInput.vue @@ -1,7 +1,6 @@ + + diff --git a/src/pages/profile/flightPlanner/FlightPlansPage.vue b/src/pages/profile/flightPlanner/FlightPlansPage.vue new file mode 100644 index 0000000..58daa90 --- /dev/null +++ b/src/pages/profile/flightPlanner/FlightPlansPage.vue @@ -0,0 +1,38 @@ + + + diff --git a/src/pages/profile/flight/PlannerPage.vue b/src/pages/profile/flightPlanner/NewFlightPlanPage.vue similarity index 85% rename from src/pages/profile/flight/PlannerPage.vue rename to src/pages/profile/flightPlanner/NewFlightPlanPage.vue index d8ee45a..d0d11ff 100644 --- a/src/pages/profile/flight/PlannerPage.vue +++ b/src/pages/profile/flightPlanner/NewFlightPlanPage.vue @@ -10,6 +10,7 @@ import MapWrapper from "components/map/MapWrapper.vue"; import {useGeocode} from "src/composables/geocoding"; import {errorObject} from "src/composables/dialog"; import {useAirportsStore} from "stores/Airports"; +import {useFlightPlansStore} from "stores/FlightPlans"; const place = ref(""); @@ -29,20 +30,24 @@ onMounted(() => { const markers = ref([]); watch(() => markers.value, (newVal) => { -}); +}, {deep: true}); const addPoint = async (point) => { - markers.value.push({ - label: point.name, - type: point.type, - position: { - lat: point.gpsLatitude, - lng: point.gpsLongitude - } - }) + if (!point) return; + + markers.value.push(point); + // { + // label: point.name, + // type: point.type, + // + // position: { + // lat: point.gpsLatitude, + // lng: point.gpsLongitude + // } + // }) } const track = computed(() => { - return markers.value.map(m => m.position); + return markers.value.map(m => ({lat: m.gpsLatitude, lng: m.gpsLongitude})); }) const removeMarker = (idx) => { @@ -58,19 +63,11 @@ const {airports} = storeToRefs(useAirportsStore()); const placesOptions = ref(null); const allPlacesOptions = computed(() => { return [ - ...pointsOfInterest.value.map(poi => ({ - name: poi.name, - type: "poi", - id: poi.id, - gpsLatitude: poi.gpsLatitude, - gpsLongitude: poi.gpsLongitude - })), + ...pointsOfInterest.value.map(poi => ({...poi, type: "poi"})), ...airports.value.map(airport => ({ + ...airport, name: `${airport.icaoCode} - ${airport.name}`, type: "airport", - id: airport.id, - gpsLatitude: airport.gpsLatitude, - gpsLongitude: airport.gpsLongitude })) ].map(i => ({...i, disabled: !i.gpsLatitude || !i.gpsLongitude})); }); @@ -103,6 +100,20 @@ watch(() => place.value, (newVal) => { addPoint(newVal); place.value = null; }); + + +const saveMarkers = () => { + useFlightPlansStore().create({ + name: "", + isPublic: false, + markers: markers.value.map(m => ({ + name: m.name, + type: m.type, + gpsLatitude: m.gpsLatitude, + gpsLongitude: m.gpsLongitude, + })) + }); +} - @@ -168,6 +178,9 @@ watch(() => place.value, (newVal) => { + Save + + diff --git a/src/router/routes.js b/src/router/routes.js index 3125bb7..2e049a6 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -47,7 +47,10 @@ const routes = [ {path: 'lety/novy', name: "addFlight", component: () => import('pages/profile/flight/NewFlightPage.vue')}, {path: 'lety/:id', name: "flightDetail", component: () => import('pages/profile/flight/FlightDetailPage.vue')}, {path: 'lety/:id/edit/:step?', name: "flightEdit", component: () => import('pages/profile/flight/EditFlightPage.vue')}, - {path: 'planovani', name: "flightPlanner", component: () => import('pages/profile/flight/PlannerPage.vue')}, + + {path: 'plany', name: "flightPlans", component: () => import('pages/profile/flightPlanner/FlightPlansPage.vue')}, + {path: 'plany/novy', name: "newFlightPlan", component: () => import('pages/profile/flightPlanner/NewFlightPlanPage.vue')}, + {path: 'plany/:id', name: "flightPlan", component: () => import('pages/profile/flightPlanner/FlightPlanEditPage.vue')}, {path: 'poi', name: "poi", component: () => import('pages/profile/poi/PointsOfInterestPage.vue')}, {path: 'poi/novy', name: "addPOI", component: () => import('pages/profile/poi/NewPointOfInterestPage.vue')}, diff --git a/src/stores/FlightPlans.js b/src/stores/FlightPlans.js index 0fad587..5b53de6 100644 --- a/src/stores/FlightPlans.js +++ b/src/stores/FlightPlans.js @@ -1,5 +1,5 @@ import {defineStore} from 'pinia' -import {FLIGHT_PLAN_DETAIL, FLIGHT_PLAN_PUBLIC_DETAIL, FLIGHT_PLAN_LIST} from "src/graphql/queries/flightPlans"; +import {FLIGHT_PLANS_LIST} from "src/graphql/queries/flightPlan"; import {CREATE_FLIGHT_PLAN, EDIT_FLIGHT_PLAN} from "src/graphql/mutations/flightPlan"; import {mutate, query, updateInItems} from "stores/helpers"; import {ref} from "vue"; @@ -10,24 +10,13 @@ export const useFlightPlansStore = defineStore('FlightPlans', () => { const isMutationRunning = ref(false); const isQueryRunning = ref(false); - const fetchDetail = (id) => { - return query({ - isQueryRunning, - query: FLIGHT_PLAN_DETAIL, - variables: {id}, - }).then(item => flightPlan.value = item); - }; - - const fetchPublicDetail = ({urlSlug, username, uploadToken, uploadFlightSlug}) => { - return query({ - isQueryRunning, - query: FLIGHT_PLAN_PUBLIC_DETAIL, - variables: {urlSlug, pilotUsername: username, uploadToken, uploadFlightSlug}, - }).then(item => { - flightPlan.value = item; - return item; - }); - }; + // const fetchDetail = (id) => { + // return query({ + // isQueryRunning, + // query: FLIGHT_PLAN_DETAIL, + // variables: {id}, + // }).then(item => flightPlan.value = item); + // }; const fetch = () => { return query({ @@ -61,6 +50,6 @@ export const useFlightPlansStore = defineStore('FlightPlans', () => { return { flightPlan, flightPlans, isMutationRunning, isQueryRunning, - fetch, fetchDetail, create, update, fetchPublicDetail + fetch, create, update } })