Skip to content

Commit

Permalink
[FEATURE]- Save metadata to csv file
Browse files Browse the repository at this point in the history
  • Loading branch information
ndasanayaka committed Nov 24, 2023
1 parent f96a6ac commit ef6e930
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 27 deletions.
5 changes: 3 additions & 2 deletions src/api/ConfigurationAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import request from '@/utils/request'
import Vue from 'vue'

export default {
async execute_metedata_script(fileslist, confid, validate) {
async execute_metedata_script(fileslist, confid, validate, savecsv) {
let _requestUrl =`${Vue.prototype.$Config.endpoints.wiener}/api/execute/imageMetadataBase64`
const { data } = await request.get(_requestUrl, {
params: {
fileslist : fileslist,
confid : confid,
validate : validate
validate : validate,
savecsv: savecsv
}
})
return data
Expand Down
9 changes: 5 additions & 4 deletions src/api/PreferenceAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,13 @@ export default {

//configuration

async save_api_option(api) {
const { data }= await request.post(`${Vue.prototype.$Config.endpoints.pref}/preferences/configuration?api=${api}`)
return data
async save_config_data(api, metadata) {
const { data }= await request.post(`${Vue.prototype.$Config.endpoints.pref}/preferences/configuration?api=${api}&metadata=${metadata}`)
return data
},


async get_api_option() {
async get_config() {
const { data }= await request.get(`${Vue.prototype.$Config.endpoints.pref}/preferences/configuration`)
return data
},
Expand Down
4 changes: 3 additions & 1 deletion src/components/deconvolution/Devices.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
positiveNumber: value => value && value > 0 || 'Must be a positive number',
},
api:"",
selectedtag: null,
/* positiveInteger: [
value => value && value > 0 && Number.isInteger(parseFloat(value)) || 'Must be a positive integer'
],
Expand Down Expand Up @@ -159,8 +160,9 @@
this.serie = serie_devices
this.inimem = this.serie.mem
this.message = null
let _current_api = await PreferenceAPI.get_api_option()
let _current_api = await PreferenceAPI.get_config()
this.api=_current_api.apiname
this.selectedtag = _current_api.metadatatag
},
is_valid(){
Expand Down
4 changes: 3 additions & 1 deletion src/components/deconvolution/Iterations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
},
api:"",
selectedtag: null,
}
},
Expand All @@ -230,8 +231,9 @@
async load_serie(serie){
this.serie = serie
this.psfTypeChanged()
let _current_api = await PreferenceAPI.get_api_option()
let _current_api = await PreferenceAPI.get_config()
this.api=_current_api.apiname
this.selectedtag = _current_api.metadatatag
},
// psf type changed --> called from load serie
Expand Down
4 changes: 3 additions & 1 deletion src/components/deconvolution/PSF.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
psfSerie: {},
loading: false,
api:"",
selectedtag: null,
psfModels: [
{label: 'Scalar', value: 0},
{label: 'Vectorial', value: 1},
Expand Down Expand Up @@ -286,8 +287,9 @@
console.log("inside psf load serie")
this.serie = serie
let _current_api = await PreferenceAPI.get_api_option()
let _current_api = await PreferenceAPI.get_config()
this.api=_current_api.apiname
this.selectedtag = _current_api.metadatatag
if(this.serie.psfFile){
let _storedSeries = await PreferenceAPI.get_serie(this.serie.psfFile)
Expand Down
6 changes: 4 additions & 2 deletions src/components/deconvolution/Review.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@
panelId: 0,
serie: series.formatSeries(null),
panel: this.$refs.revdeconmetadata,
api:''
api:'',
selectedtag: null
}
},
methods: {
Expand Down Expand Up @@ -159,8 +160,9 @@
},
mounted: async function() {
let _current_api = await PreferenceAPI.get_api_option()
let _current_api = await PreferenceAPI.get_config()
this.api=_current_api.apiname
this.selectedtag = _current_api.metadatatag
for (let i=0; i<7 ; i++){
this.panel = this.getPanel(i)
if(this.panel ) {
Expand Down
35 changes: 25 additions & 10 deletions src/views/Configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</v-col>

<v-col cols="4" sm="3" md="4" lg="4">
<v-btn class="my-1" color="success" rounded dark large @click="saveOption" >
<v-btn class="my-1" color="success" rounded dark large @click="saveOption(true,false, api)" >
Save
</v-btn>
</v-col>
Expand Down Expand Up @@ -122,14 +122,15 @@
loading: false,
tags: [],
selectedtag: null,
selectedtag: "meta_23_002",
message: null,
error: null,
isError: false,
api:"Microvolution",
messageSave: null,
errorSave:null,
}
},
created: async function () {
Expand All @@ -152,8 +153,11 @@
},
mounted: async function () {
let _current_api = await PreferenceAPI.get_api_option()
let _current_api = await PreferenceAPI.get_config()
this.api=_current_api.apiname
this.selectedtag = _current_api.metadatatag
console.log(this.api)
console.log(this.selectedtag)
},
methods: {
Expand All @@ -163,7 +167,7 @@
let files =""
console.log(confid)
try{
const response= await ConfigurationAPI.execute_metedata_script(files, confid, validate)
const response= await ConfigurationAPI.execute_metedata_script(files, confid, validate, false)
console.log(response)
Vue.notify({
group: 'datanotif',
Expand All @@ -185,6 +189,7 @@
} else {
this.isError = false
this.message = "Validation Succeeded!"
this.saveOption(false, true, confid)
}
}
Expand All @@ -203,13 +208,23 @@
}
},
async saveOption() {
async saveOption(api, metadata, value) {
try{
console.log(this.api)
const response= await PreferenceAPI.save_api_option(this.api)
this.messageSave = "The API updated successfully!"
this.isError = false
console.log(response)
if (api) {
console.log(this.api)
console.log(this.selectedtag)
console.log("inside api update")
const response= await PreferenceAPI.save_config_data(value, this.selectedtag)
this.messageSave = "The API updated successfully!"
this.isError = false
console.log(response)
} else if (metadata){
console.log(value)
console.log(this.api)
const response= await PreferenceAPI.save_config_data(this.api, value)
console.log(response)
}
}
catch(err) {
this.errorSave = "The API update was unsuccessful"
Expand Down
87 changes: 81 additions & 6 deletions src/views/Deconvolution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,50 @@
<v-col >
<h4 v-if="mloading">Loading metadata</h4>
<h4 v-if="!mloading">Metadata</h4>
<h5 v-if="csvloading">Exporting to a CSV file</h5>
<v-progress-linear
color="primary"
indeterminate
rounded
height="5"
:active="mloading"
></v-progress-linear>
<v-progress-linear
color="primary"
indeterminate
rounded
height="3"
:active="csvloading"
></v-progress-linear>

</v-col>
<v-col>
<v-card class="metdata-card" >
<div>
<v-expansion-panels accordion>
<v-expansion-panel v-for="item in metedataResults" :key="item.file">
<v-expansion-panel-header >{{ item.file }} </v-expansion-panel-header>
<v-expansion-panel-header >
<v-row align="center" justify="center">

<v-col class="d-flex" cols="1" >
<v-tooltip bottom>
<template v-slot:activator="{ on, attrs }">
<v-btn
class="my-3"
style="min-width:1px !important;width:2px"
color="primary"
@click.stop="downloadToCSV(item)"
v-bind="attrs"
v-on="on">
<v-icon>mdi-download</v-icon>
</v-btn>
</template>
<span>Download CSV</span>
</v-tooltip>
</v-col>
<v-col cols="11" >{{ item.file }}</v-col>
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content >

<v-row >
Expand All @@ -155,8 +185,11 @@
<v-table fixed-header >
<thead>
<tr>
<th class="text-left">Paramater</th>
<th class="text-left">Value</th>
<th class="text-left">
Parameter</th>
<th class="text-left">Value

</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -507,6 +540,8 @@
metedataResults:[],
mloading:false,
dateTime:"",
selectedtag: null,
csvloading:false,
// -- selected files table
Expand Down Expand Up @@ -570,8 +605,10 @@
}
},
mounted: async function() {
let _current_api = await PreferenceAPI.get_api_option()
let _current_api = await PreferenceAPI.get_config()
this.api=_current_api.apiname
this.selectedtag = _current_api.metadatatag
console.log(this.api)
let initialItems = []
let _decons = await PreferenceAPI.get_decons(null,this.api)
Expand Down Expand Up @@ -660,6 +697,39 @@
},
async downloadToCSV(metadataResult){
//let json_data = JSON.stringify(metadataResult)
let file_name = metadataResult.file.split("/").slice(-1)[0].split(".")[0]
console.log(file_name)
console.log(metadataResult.file)
try{
this.csvloading = true
const response= await ConfigurationAPI.execute_metedata_script(btoa(metadataResult.file), this.selectedtag, false, true)
this.csvloading = false
console.log(response)
//if(response)
Vue.notify({
group: 'sysnotif',
type: 'info',
title: 'Save Metadata to CSV File',
text: this.workingItem.setting.outputPath+"/"+file_name+".csv" + ' saved!'
});
}
catch(err){
Vue.notify({
group: 'sysnotif',
type: 'error',
title: 'Save Metadata to CSV File',
text: 'Fail to save ' + this.workingItem.setting.outputPath+"/"+file_name+".csv" + ' .Error:' + String(err)
});
console.log(String(err))
}
console.log(this.workingItem.setting.outputPath)
},
/****************************************************************************** */
/** this part loads files/folders **/
Expand Down Expand Up @@ -1010,8 +1080,13 @@
}
fileslistbase64 = btoa(fileslistbase64.substring(0,fileslistbase64.length-1))
}
console.log("file list base")
console.log(fileslistbase64)
try{
const response= await ConfigurationAPI.execute_metedata_script(fileslistbase64, '', false)
console.log(this.selectedtag)
const response= await ConfigurationAPI.execute_metedata_script(fileslistbase64, this.selectedtag, false, false)
console.log(response)
let output = response.commandResult
if (output.length > 0) {
let json_output = JSON.parse(output[0].out)
Expand Down Expand Up @@ -1086,7 +1161,7 @@
/** submit job */
async submitSingleJob(item){
let _current_api = await PreferenceAPI.get_api_option()
let _current_api = await PreferenceAPI.get_config()
let _numberOfJobs = parseInt(item.setting.instances)
Expand Down

0 comments on commit ef6e930

Please sign in to comment.