Pridani tabulky s necim jako navigacni stitek do planovace

This commit is contained in:
Michal Kváček
2024-06-10 16:42:00 +02:00
parent aa6bed6f7f
commit 852d00b932
10 changed files with 215 additions and 67 deletions
@@ -1,19 +1,14 @@
<script setup>
import {computed, ref, watch} from "vue";
import {minutesToHumanReadable} from "src/composables/datetimeUtils";
import {useFlightPlanUtils} from "src/composables/flightPlan";
import {useFlightPlanCalculations, useFlightPlanUtils} from "src/composables/flightPlan";
const props = defineProps({
flightPlan: {
type: Object,
required: true
},
plannedSpeed: {
type: Number,
required: false,
default: 150
},
isFullscreen: {
isFullscreen: {
type: Boolean,
default: false,
},
@@ -25,19 +20,8 @@ const props = defineProps({
const emits = defineEmits(["open", "change-insert-position", "fullscren-toggle"])
const getDuration = (distance, speed) => Math.round(distance / speed * 60)
const totalDistance = computed(() => {
if (!props.flightPlan.track.length) return null;
return Math.round(props.flightPlan.track.map(t => t.distance).reduce((a, b) => a + b));
});
const totalTime = computed(() => {
if (!props.flightPlan.track.length) return null;
return props.flightPlan.track.map(t => getDuration(t.distance, props.plannedSpeed)).reduce((a, b) => a + b)
});
const {getDuration, getTotalDistance, getTotalTime} = useFlightPlanCalculations();
const totalDistance = computed(() => getTotalDistance(props.flightPlan));
</script>
@@ -73,13 +57,15 @@ const totalTime = computed(() => {
<q-item-label caption class="q-py-sm" v-if="segment.distance">
{{ segment.bearing }}°,
{{ segment.distance }} km,
{{ minutesToHumanReadable(getDuration(segment.distance, props.plannedSpeed)) }}
{{ minutesToHumanReadable(getDuration(segment.distance, props.flightPlan.plannedSpeed)) }}
</q-item-label>
<q-item-label>
<q-btn
@click="emits('change-insert-position', i+1)"
icon="add"
size="sm"
size="xs"
:round="insertPosition !== i+1"
outline
class="q-ml-lg q-mb-sm"
:color="insertPosition === i+1 ? 'primary' : 'grey'"
>
@@ -123,7 +109,7 @@ const totalTime = computed(() => {
<q-item-section>
Celková vzdálenost: {{ totalDistance }} km
<br>
Plánovaná doba letu: {{ minutesToHumanReadable(totalTime) }}
Plánovaná doba letu: {{ minutesToHumanReadable(getTotalTime(props.flightPlan, props.flightPlan.plannedSpeed)) }}
</q-item-section>
</q-item>
</template>