Add option to add sequence to planner as reshoot

This commit is contained in:
D. Berge
2020-10-08 16:39:29 +02:00
parent c4915e43d7
commit bc54d4ad59

View File

@@ -19,6 +19,23 @@
</v-card-title>
<v-card-text>
<v-menu
v-model="contextMenuShow"
:position-x="contextMenuX"
:position-y="contextMenuY"
absolute
offset-y
>
<v-list dense v-if="contextMenuItem">
<v-list-item @click="addToPlan(false)">
<v-list-item-title>Reshoot</v-list-item-title>
</v-list-item>
<v-list-item @click="addToPlan(true)">
<v-list-item-title>Reshoot with overlap</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<v-data-table
:headers="headers"
:items="items"
@@ -31,6 +48,7 @@
show-expand
:item-class="(item) => activeItem == item ? 'blue accent-1 elevation-3' : ''"
@click:row="setActiveItem"
@contextmenu:row="contextMenu"
>
<template v-slot:expanded-item="{ headers, item }">
@@ -243,8 +261,8 @@
<span>{{ Math.round(props.value) }} m</span>
</template>
<template v-slot:item.azimuth="props">
<span>{{ props.value.toFixed(1) }} °</span>
<template v-slot:item.azimuth="{value}">
<span>{{ value.toFixed? value.toFixed(1) : value }} °</span>
</template>
</v-data-table>
@@ -378,7 +396,17 @@ export default {
num_rows: null,
activeItem: null,
edit: null, // {sequence, key, value}
queuedReload: false
queuedReload: false,
// Planner related stuff
preplots: null,
plannerConfig: null,
// Context menu stuff
contextMenuShow: false,
contextMenuX: 0,
contextMenuY: 0,
contextMenuItem: null
}
},
@@ -438,6 +466,67 @@ export default {
methods: {
contextMenu (e, {item}) {
e.preventDefault();
this.contextMenuShow = false;
this.contextMenuX = e.clientX;
this.contextMenuY = e.clientY;
this.contextMenuItem = item;
this.$nextTick( () => this.contextMenuShow = true );
},
async getReshootEndpoints (item, overlap) {
const urlPreplot = `/project/${this.$route.params.project}/line`;
const urlPlannerConfig = `/project/${this.$route.params.project}/configuration/planner`;
if (!this.preplots) {
this.preplots = await this.api([urlPreplot]);
}
if (!this.plannerConfig) {
this.plannerConfig = await this.api([urlPlannerConfig]) || {
overlapBefore: 0,
overlapAfter: 0
};
}
const preplot = this.preplots.find(l => l.line == item.line);
const incr = item.fsp <= item.lsp;
const lim0 = incr
? Math.max : Math.min;
const lim1 = incr
? Math.min : Math.max;
const dir = incr ? 1 : -1;
const sp0 = overlap
? lim0((item.fsp_final || item.fsp) - this.plannerConfig.overlapBefore * dir, preplot.fsp)
: lim0(item.fsp_final || item.fsp, preplot.fsp);
const sp1 = overlap
? lim1((item.lsp_final || item.lsp) + this.plannerConfig.overlapAfter * dir, preplot.lsp)
: lim1(item.lsp_final || item.lsp, preplot.lsp);
return {sp0, sp1}
},
async addToPlan (overlap=false) {
const { sp0, sp1 } = await this.getReshootEndpoints(this.contextMenuItem, overlap);
const payload = {
line: this.contextMenuItem.line,
fsp: sp0,
lsp: sp1,
remarks: `Reshoot of sequence ${this.contextMenuItem.sequence}.`
}
console.log("Plan", payload);
const url = `/project/${this.$route.params.project}/plan`;
const init = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: payload
}
await this.api([url, init]);
},
editItem (item, key) {
this.edit = {
sequence: item.sequence,