2020-08-08 23:59:13 +02:00
< template >
< v-container fluid >
2023-10-29 13:25:37 +01:00
2020-08-08 23:59:13 +02:00
< v-data-table
: headers = "headers"
2023-10-29 13:25:37 +01:00
: items = "displayItems"
2020-08-08 23:59:13 +02:00
: options . sync = "options"
: loading = "loading"
2023-10-29 15:25:45 +01:00
@ contextmenu : row = "contextMenu"
2020-08-08 23:59:13 +02:00
>
2020-08-26 20:19:59 +02:00
< template v -slot : item.pid = " { item , value } " >
2023-10-29 13:25:37 +01:00
< template v-if = "item.archived" >
< a class = "secondary--text" title = "This project has been archived" :href = "`/projects/${item.pid}`" > { { value } } < / a >
< v-icon
class = "ml-1 secondary--text"
small
title = "This project has been archived"
> mdi - archive - outline < / v-icon >
< / template >
< template v-else >
< a :href = "`/projects/${item.pid}`" > { { value } } < / a >
< / template >
2020-08-08 23:59:13 +02:00
< / template >
2020-08-26 20:19:59 +02:00
< 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"
2020-08-26 20:19:59 +02:00
: value = "((1 - (item.remaining / item.total))*100)"
2020-08-08 23:59:13 +02:00
/ >
< / template >
2023-10-29 13:25:37 +01:00
< template v -slot : footer.prepend >
< v-checkbox
class = "mr-3"
v - model = "showArchived"
dense
hide - details
title = "Projects that have been marked as archived by an administrator no longer receive updates from external sources, such as the project's file repository or the navigation system, but they may still be interacted with via Dougal, including adding or editing log comments."
>
< template v -slot : label >
< span class = "subtitle-2" > Show archived projects < / span >
< / template >
< / v-checkbox >
< / template >
2020-08-08 23:59:13 +02:00
< / v-data-table >
2023-10-29 15:25:45 +01:00
< v-menu v-if = "adminaccess"
v - model = "contextMenuShow"
: position - x = "contextMenuX"
: position - y = "contextMenuY"
absolute
offset - y
>
< v-list dense v-if = "contextMenuItem" >
< v-list-item :href = "`${contextMenuItem.pid}/configuration`" >
< v-list-item-icon > < v-icon > mdi - file - document - edit - outline < / v-icon > < / v-list-item-icon >
< v-list-item-title class = "warning--text" > Edit project settings < / v-list-item-title >
< / v-list-item >
< / v-list >
< / v-menu >
2020-08-08 23:59:13 +02:00
< / v-container >
< / template >
< style >
td p : last - of - type {
margin - bottom : 0 ;
}
< / style >
< script >
2020-08-26 17:48:55 +02:00
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"
} ,
{
2020-08-26 20:19:59 +02:00
value : "seq_final" ,
2020-08-08 23:59:13 +02:00
text : "Sequences"
} ,
{
2020-08-26 20:19:59 +02:00
value : "total" ,
text : "Preplot points"
} ,
{
value : "shots" ,
text : "Shots acquired"
2020-08-08 23:59:13 +02:00
} ,
{
value : "progress" ,
text : "% Complete"
} ,
] ,
items : [ ] ,
options : { } ,
2023-10-29 13:25:37 +01:00
showArchived : true ,
2023-10-29 15:25:45 +01:00
// Context menu stuff
contextMenuShow : false ,
contextMenuX : 0 ,
contextMenuY : 0 ,
contextMenuItem : null
2020-08-08 23:59:13 +02:00
}
} ,
2020-08-26 17:48:55 +02:00
computed : {
2023-10-29 13:25:37 +01:00
displayItems ( ) {
return this . showArchived
? this . items
: this . items . filter ( i => ! i . archived ) ;
} ,
2023-10-29 20:19:06 +01:00
... mapGetters ( [ 'loading' , 'serverEvent' , 'adminaccess' , 'projects' ] )
2023-08-23 19:35:12 +02:00
} ,
watch : {
async serverEvent ( event ) {
if ( event . channel == "project" && event . payload ? . schema == "public" ) {
if ( event . payload ? . operation == "DELETE" || event . payload ? . operation == "INSERT" ) {
await this . load ( ) ;
}
}
}
2020-08-26 17:48:55 +02:00
} ,
2020-08-08 23:59:13 +02:00
methods : {
async list ( ) {
2023-09-09 20:39:49 +02:00
this . items = await this . api ( [ "/project" ] ) || [ ] ;
2020-08-08 23:59:13 +02:00
} ,
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 ) ;
}
} ,
2023-10-29 15:25:45 +01:00
contextMenu ( e , { item } ) {
e . preventDefault ( ) ;
this . contextMenuShow = false ;
this . contextMenuX = e . clientX ;
this . contextMenuY = e . clientY ;
this . contextMenuItem = item ;
this . $nextTick ( ( ) => this . contextMenuShow = true ) ;
} ,
2020-08-08 23:59:13 +02:00
... mapActions ( [ "api" ] )
} ,
mounted ( ) {
this . load ( ) ;
}
}
< / script >