Files
dougal-software/lib/www/client/source/src/views/ProjectList.vue

125 lines
2.3 KiB
Vue
Raw Normal View History

2020-08-08 23:59:13 +02:00
<template>
<v-container fluid>
<v-data-table
:headers="headers"
:items="items"
:options.sync="options"
:loading="loading"
>
<template v-slot:item.pid="{item, value}">
<a :href="`/projects/${item.pid}`">{{value}}</a>
2020-08-08 23:59:13 +02:00
</template>
<template v-slot:item.shots="{item}">
{{ item.total ? (item.prime + item.other) : "" }}
</template>
<template v-slot:item.progress="{item}">
{{
item.total
? ((1 - (item.remaining / item.total))*100).toFixed(1)+"%"
: ""
}}
<v-progress-linear v-if="item.total"
2020-08-08 23:59:13 +02:00
height="2"
:value="((1 - (item.remaining / item.total))*100)"
2020-08-08 23:59:13 +02:00
/>
</template>
</v-data-table>
</v-container>
</template>
<style>
td p:last-of-type {
margin-bottom: 0;
}
</style>
<script>
import { mapActions, mapGetters } from 'vuex';
2020-08-08 23:59:13 +02:00
export default {
name: "ProjectList",
data () {
return {
headers: [
{
value: "pid",
text: "Project ID"
},
{
value: "name",
text: "Name"
},
{
value: "lines",
text: "Lines"
},
{
value: "seq_final",
2020-08-08 23:59:13 +02:00
text: "Sequences"
},
{
value: "total",
text: "Preplot points"
},
{
value: "shots",
text: "Shots acquired"
2020-08-08 23:59:13 +02:00
},
{
value: "progress",
text: "% Complete"
},
],
items: [],
options: {},
}
},
computed: {
...mapGetters(['loading'])
},
2020-08-08 23:59:13 +02:00
methods: {
async list () {
this.items = await this.api(["/project/"]) || [];
},
async summary (item) {
const details = await this.api([`/project/${item.pid}/summary`]);
if (details) {
return Object.assign({}, details, item);
}
},
async load () {
await this.list();
const promises = [];
for (const key in this.items) {
const item = this.items[key];
const promise = this.summary(item)
.then( expanded => {
if (expanded) {
this.$set(this.items, key, expanded);
}
});
promises.push(promise);
}
},
...mapActions(["api"])
},
mounted () {
this.load();
}
}
</script>