Skip to content

Commit

Permalink
[BUGFIXED]-Decon template save/load CRM-240314-000581
Browse files Browse the repository at this point in the history
  • Loading branch information
ndasanayaka committed Jun 21, 2024
1 parent 7fd9394 commit 0846ab0
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 68 deletions.
155 changes: 96 additions & 59 deletions src/components/TemplateDialog.vue
Original file line number Diff line number Diff line change
@@ -1,62 +1,67 @@
<template>
<v-dialog v-model="dialog" persistent scrollable max-height="60%" max-width="50%">
<v-card>
<v-toolbar dark color="#49075e">
<v-btn icon dark @click="cancel">
<v-icon>mdi-close</v-icon>
</v-btn>
<v-card-title class="headline" v-if="!isnew">
Load an existing template
</v-card-title>
<v-card-title class="headline" v-if="isnew">
Save current template
</v-card-title>
</v-toolbar>
<div>

<v-row >
<v-col>
<v-data-table
v-model="selectedTemplate"
:headers="templateTableHeaders"
:items="templates"
:single-select="true"
:disable-pagination="true"
item-key="id"
show-select
class="elevation-1"
height="250px" width="30%"
@item-selected="templateChanged"
v-if="!isnew"
>
</v-data-table>
<v-text-field regular
label="Template name"
v-model="name"
v-if="isnew"
>
</v-text-field>
</v-col>

<TemplateOverrideDialog ref="templateoverridedialog" />
<v-dialog v-model="dialog" persistent scrollable max-height="60%" max-width="50%">
<v-card>
<v-toolbar dark color="#49075e">
<v-btn icon dark @click="cancel">
<v-icon>mdi-close</v-icon>
</v-btn>
<v-card-title class="headline" v-if="!isnew">
Load an existing template
</v-card-title>
<v-card-title class="headline" v-if="isnew">
Save current template
</v-card-title>
</v-toolbar>

<v-col height="300px" width="70%">
<json-viewer :value="options.settings" boxed></json-viewer>
</v-col>
</v-row>
<v-row >
<v-col>
<v-data-table
v-model="selectedTemplate"
:headers="templateTableHeaders"
:items="templates"
:single-select="true"
:disable-pagination="true"
item-key="id"
show-select
class="elevation-1"
height="250px" width="30%"
@item-selected="templateChanged"
v-if="!isnew"
>
</v-data-table>
<v-text-field regular
label="Template name"
v-model="name"
v-if="isnew"
>
</v-text-field>
</v-col>

<v-card-actions>
<v-row align="center" justify="center">
<v-btn class="my-1" color="success" rounded dark large @click="agree">
Ok
</v-btn>
<v-btn class="my-1" color="warning" rounded dark large @click="cancel">
Cancel
</v-btn>
<v-btn class="my-1" color="error" rounded dark large @click="deleteTemplate">
Delete
</v-btn>
<v-col height="300px" width="70%">
<json-viewer :value="options.settings" boxed></json-viewer>
</v-col>
</v-row>
</v-card-actions>
</v-card>
</v-dialog>

<v-card-actions>
<v-row align="center" justify="center">
<v-btn class="my-1" color="success" rounded dark large @click="agree">
Ok
</v-btn>
<v-btn class="my-1" color="warning" rounded dark large @click="cancel">
Cancel
</v-btn>
<v-btn class="my-1" color="error" rounded dark large @click="deleteTemplate">
Delete
</v-btn>
</v-row>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>

<script>
Expand All @@ -65,11 +70,13 @@
import TemplateAPI from "@/api/TemplateAPI.js"
import JsonViewer from 'vue-json-viewer'
import 'vue-json-viewer/style.css'
import TemplateOverrideDialog from '@/components/TemplateOverrideDialog.vue'
export default {
name: 'TemplateDialog',
components: {
JsonViewer,
TemplateOverrideDialog
},
data() {
return {
Expand Down Expand Up @@ -97,8 +104,13 @@
this.isnew = isnew
this.options.settings = settings
this.options.success = false
this.templates = await TemplateAPI.list_templates()
if(!isnew) {
this.templates = await TemplateAPI.list_templates()
console.log("selectedTemplate")
console.log(this.selectedTemplate)
this.selectedTemplate=[]
//this.templates = await TemplateAPI.list_templates()
console.log("this.templates")
console.log(this.templates)
}
return new Promise((resolve, reject) => {
Expand All @@ -117,11 +129,36 @@
text: 'Name cannot be empty'
})
return
}
if(this.name) {
let same =false
console.log(this.name)
for(let i=0; i<this.templates.length;i++){
if(this.name == this.templates[i].name) {
console.log(this.name)
same=true
let options = await this.$refs.templateoverridedialog.open(this.name)
console.log(options)
if(!options.cancelled) {
if(options.success) {
await TemplateAPI.delete_template(this.templates[i].id)
await TemplateAPI.create_template(this.name, this.options.settings.setting)
}
}
}else {
same = false
}
}
if(!same) {
console.log(same)
await TemplateAPI.create_template(this.name, this.options.settings.setting)
}
this.options.success = true
}
// save
// console.log(this.options.settings.setting)
await TemplateAPI.create_template(this.name, this.options.settings.setting)
this.options.success = true
}
this.resolve(this.options)
this.dialog = false
Expand Down
72 changes: 72 additions & 0 deletions src/components/TemplateOverrideDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<v-dialog v-model="dialog" persistent max-height="20% !important" max-width="30%">
<v-card>
<v-toolbar dark color="#49075e">
<v-btn icon dark @click="cancel">
<v-icon>mdi-close</v-icon>
</v-btn>
<v-card-title class="headline" >
Confirm Save
</v-card-title>
</v-toolbar>

<v-row style="margin:15px">
<p> Template {{ name }} already exists.
Do you want to overwite it?</p>

</v-row>

<v-card-actions>
<v-row align="center" justify="center">
<v-btn class="my-1" color="success" rounded dark small @click="agree">
Ok
</v-btn>
<v-btn class="my-1" color="warning" rounded dark small @click="cancel">
Cancel
</v-btn>
</v-row>
</v-card-actions>
</v-card>
</v-dialog>
</template>

<script>
import 'vue-json-viewer/style.css'
export default {
name: 'TemplateOverrideDialog',
data () {
return {
dialog: false,
name:'',
resolve: null,
reject: null,
options:{
success: false,
cancelled: false,
},
}
},
methods: {
async open(name) {
this.dialog = true
console.log(" override dialog"+name)
this.name = name
return new Promise((resolve, reject) => {
this.resolve = resolve
this.reject = reject
});
},
async agree() {
this.options.cancelled = false
this.options.success = true
this.resolve(this.options)
this.dialog = false
},
cancel(){
console.log("Cancel operation")
this.dialog = false
}
}
}
</script>
2 changes: 2 additions & 0 deletions src/components/deconvolution/Metadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
this.serie.outputPath = ''
else
this.serie.outputPath = this.outputBasePath + "/" + this.outputFolderName
console.log("output folder changed "+this.serie.outputPath)
console.log(this.serie.outputPath)
},
/**
* choose output folder: saved to all selected series
Expand Down
12 changes: 12 additions & 0 deletions src/components/vuetify-file-browser/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,21 @@ export default {
this.selectedItems.map( item => {
_copiedItems.push(item.path)
})
let destination = options.path
console.log("Destination outside if")
console.log(destination)
if ( options.selectedItems.length > 0 ) {
destination = destination + options.selectedItems[0].name
console.log("Destination in if")
console.log(destination)
}
let copiedItemPath = _copiedItems.lastIndexOf('/');
let directoryPath2 = _copiedItems.substring(0, copiedItemPath + 1);
console.log(directoryPath2)
if (directoryPath2 == destination ) {
_copiedItems = _copiedItems.replace(/(\.[^.]+)$/, '_copy$1')
}
Vue.$log.info("Copying" + _copiedItems + " to "+ destination)
let confirmOptions = await this.$refs.copyconfirm.open(_copiedItems, destination)
Expand Down
12 changes: 12 additions & 0 deletions src/views/AdminJobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@
this.jobs[i].submitted = localTimeString
console.log("job submitted "+ this.jobs[i].submitted)
}
if(job.start) {
let utcdate = new Date(job.start);
let localTimeString = utcdate.toLocaleString();
this.jobs[i].start = localTimeString
console.log(localTimeString);
}
if(job.end) {
let utcdate = new Date(job.end);
let localTimeString = utcdate.toLocaleString();
this.jobs[i].end = localTimeString
console.log(localTimeString);
}
}
this.loading = false
Expand Down
12 changes: 9 additions & 3 deletions src/views/Deconvolution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1282,10 +1282,15 @@
*/
async loadTemplate(){
let options = await this.$refs.templatedialog.open(false, '')
console.log("load template options")
console.log(options)
if (!options.cancelled) {
Vue.$log.info("Template loaded")
Vue.$log.info(options.settings)
let outputpath = this.workingItem.setting.outputPath
console.log("output path previous - "+outputpath)
this.workingItem.setting = Object.assign({}, options.settings)
this.workingItem.setting.outputPath = outputpath
this.saveSettings()
// update the current display
this.display_decon(this.workingItem, false)
Expand Down Expand Up @@ -1462,6 +1467,7 @@
let flag = false
let tempID = -1
for(let i=0; i<this.outputpath.length; i++){
console.log(this.outputpath.length)
if((this.outputpath[i].id !== this.workingItem.id) && (this.outputpath[i].outputpath === this.workingItem.setting.outputPath)){
Vue.notify({
group: 'errornotif',
Expand Down Expand Up @@ -1497,7 +1503,7 @@
}
}
console.log(this.outputpath)
}
if(this.workingItem.step === 4) {
Expand Down Expand Up @@ -1548,7 +1554,7 @@
}
}
/* validate devices in device tab */
if(this.workingItem.step === 7) {
/* if(this.workingItem.step === 7) {
let msg
let jobs = this.workingItem.setting.instances
let mem = this.workingItem.setting.mem
Expand Down Expand Up @@ -1583,7 +1589,7 @@
return
}
}
}
} */
if(this.workingItem.step === 8)
return
//even if current step is invalid, next will allow it to go if it has been visited
Expand Down
18 changes: 12 additions & 6 deletions src/views/Jobshistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@
this.jobs[i].submitted = localTimeString
console.log("job submitted "+ this.jobs[i].submitted)
/* console.log(job.submitted)
let utctime = new Date(Date.parse(job.submitted))
console.log(utctime)
this.jobs[i].submitted = utctime.toLocaleString('en-GB', {timeZone:'UTC'})
console.log(this.jobs[i].submitted) */
}
if(job.start) {
let utcdate = new Date(job.start);
let localTimeString = utcdate.toLocaleString();
this.jobs[i].start = localTimeString
console.log(localTimeString);
}
if(job.end) {
let utcdate = new Date(job.end);
let localTimeString = utcdate.toLocaleString();
this.jobs[i].end = localTimeString
console.log(localTimeString);
}
Expand Down

0 comments on commit 0846ab0

Please sign in to comment.