Commit 7c3a0374 authored by TOUZE Francois's avatar TOUZE Francois
Browse files

manage ouputs vs. plot options

parent e9bd4cd1
......@@ -313,6 +313,10 @@ map<string,vector<double> > pspaplot::menu2(string item,json obj)
{"xbeta",vector<double>()},
{"ybeta",vector<double>()},
{"xeta", vector<double>()} };
} else if (item == "alfas") {
mymap = {
{"xalfa",vector<double>()},
{"yalfa",vector<double>()} };
} else if (item == "phases") { // valid only for twiss
mymap = {
{"xmu",vector<double>()},
......
......@@ -146,14 +146,16 @@ def settings():
d={"id": id}
out= id + "-plot.txt"
fname= os.path.join(upath,out)
print( "fichier trouvé => ", fname)
if os.path.exists( fname ):
d['status']= 'found'
data= json.load( open(fname) )
d['software']= data['software']
d['action']= data['action']
z.append(d)
else:
d['status']= 'not found'
z.append(d)
response = {
'parameters': z
}
......
......@@ -8,18 +8,31 @@
<div class="outputs-area-body">
<div class="outputs-item">
<h2>Choose your outputs:</h2><br>
<div id="pipe-block" v-if="isPipeline">
<b-form-checkbox-group
v-model="selectedIds"
:options="simulationIds"
stacked
></b-form-checkbox-group>
<h2> </h2><br>
<h2> </h2><br>
<div>
Selected: <strong>{{ selectedIds }}</strong><br>
</div>
</div>
<div v-else>
<b-form-radio-group
v-model="selectedIds[0]"
:options="simulationIds"
stacked
></b-form-radio-group>
<h2> </h2><br>
<div>
Selected: <strong>{{ selectedIds[0] }}</strong><br>
</div>
</div>
</div>
</div>
......@@ -34,13 +47,14 @@ export default {
data () {
return {
Ids: [],
selectedIds: []
selectedIds: [],
isPipeline: false,
nameOfCase: null
}
},
created() {
console.log('OutPuts:: created')
this.$store.commit('setSimulationPlot', '')
this.$store.commit('setAnalyzeParameters', '');
this.Ids= Object.keys(this.$store.state.simulationResults);
......@@ -49,47 +63,79 @@ export default {
computed: {
simulationIds () {
this.selectedIds = []
const str= this.$store.state.projectName;
var myArray=[];
for(var i = 0; i < this.Ids.length; i++) {
if (this.Ids[i].indexOf(str) >=0 ) myArray.push( this.Ids[i] );
this.isPipeline = false
this.nameOfCase = this.$store.state.projectName;
var str1 = this.nameOfCase.concat('-')
const myArray= this.Ids.filter(id => id.indexOf(str1) == 0);
if (myArray.length > 0) {
//console.log('OutPuts::Ids retenus => ', myArray)
const nb= str1.length + 8 // + alea(8) = 8 characters
// returns the first nb characters of the first selected Id
const searchTerm = myArray[0].substring(0, nb)
const result = myArray.filter(id => id.indexOf(searchTerm) == 0); if (result.length == 1) this.isPipeline= true
} else {
var message = 'Check the project name ...'
alert( message )
}
console.log('OutPuts::Ids retenus => ', myArray)
return myArray
}
},
mounted () {
console.log('OutPuts:: mounted')
methods: {
check( items ) {
const params = this.$store.state.analyzeParameters;
var array= []
items.forEach(function(item) {
const indice = params.findIndex(a => a.id === item)
if ( params[indice].status == 'found') {
array.push( item )
} else {
var message = 'Output:: ' + item + ' was not found'
var msg = '...... Clear it from the console outputs'
alert( message + msg)
}
})
this.$store.commit('setSimulationPlot', array);
}
},
mounted () {
const path = `http://localhost:5000/api/settings`
axios.post(path, {
selectedIds: this.Ids
}).then(response => {
console.log('OutPuts:: mounted => response')
const parameters= response.data.parameters
this.$store.commit('setAnalyzeParameters', parameters);
}).then(response => {
const parameters= response.data.parameters
this.$store.commit('setAnalyzeParameters', parameters);
}).catch(error => {
console.log(error)
})
},
methods: {
})
},
watch: {
selectedIds: function(newVal, oldVal) {
console.log('Outputs:: watch =>', newVal)
this.$store.commit('setSimulationPlot', newVal);
this.check( newVal )
}
}
};
......
......@@ -11,32 +11,51 @@ import Chart from 'chart.js';
export default {
data() {
return {
pickedItem: null,
selectedSimulationId: null
selectedId: null
}
},
created() {
const ids= this.$store.state.simulationPlot.selectedIds
this.selectedSimulationId = ids
const picked= this.$store.state.simulationPlot.pickedItem
this.pickedItem = picked
this.selectedId = this.$store.state.simulationPlot.selectedIds
this.pickedItem = this.$store.state.simulationPlot.pickedItem
},
methods: {
createChart(chartId, chartData) {
const ctx = document.getElementById(chartId);
if ( Object.keys(chartData).length > 0 ) {
const ctx = document.getElementById(chartId);
const myChart = new Chart(ctx, {
type: chartData.type,
data: chartData.data,
options: chartData.options
});
type: chartData.type,
data: chartData.data,
options: chartData.options
});
} else {
var message = "Unavailable plot option => " + this.pickedItem
alert( message )
this.pickedItem = 'unavailable'
}
},
loadChartConfig () {
const path = `http://localhost:5000/api/plots`
axios.post(path, {
plotSimulation: this.selectedSimulationId,
plotSimulation: this.selectedId,
plotItem: this.pickedItem
}).then(response => {
const chartData= response.data.chartConfig
......@@ -44,26 +63,33 @@ export default {
}).catch(error => {
console.log(error)
})
}
},
mounted() {
console.log('plots=> mounted')
this.loadChartConfig();
},
watch: {
data: function() {
console.log('plots=> watch')
this._chart.destroy();
this.createChart();
},
selectedSimulationId: function(newVal, oldVal) {
console.log('nouveau: %s, ancien: %s', newVal, oldVal)
},
pickedItem: function(newVal, oldVal) {
console.log('nouveau: %s, ancien: %s', newVal, oldVal)
//console.log('pickedItem => nouveau: %s, ancien: %s', newVal, oldVal)
this.$store.commit('setPickedPlot', newVal);
}
}
};
......
......@@ -4,32 +4,30 @@
<div id="computing-menu" class="border-bottom border-light d-flex flex-row justify-content-between">
<div id="computing-title">
<h2 @click="showConfig">Plots</h2>
<p v-bind:class="showProject"></p>
<p v-bind:class="showSelectedItem"></p>
</div>
</div>
<div id="computing-block" v-if="isConfig">
<div id="select-box">
<div v-if="listOptions.length > 0">
<select class="browser-default custom-select" v-model="selectedItem">
<option disabled value="">Please select a plot</option>
<option disabled value='unavailable'>Please select a plot</option>
<option v-for="item in listOptions" v-bind:value="item.value">
{{ item.text }}
</option>
</select>
<!--span>selectedItem: {{ selectedItem }}</span-->
</div>
<div v-else>
<p>First, select an output</p>
</div>
</div>
<div class="d-flex flex-row justify-content-between mb-3">
<!--button size="md"
type="button"
class="btn new-sector border-success text-white bg-success ml-4" @click="showPlots"
v-if="isDraw">Draw</button-->
<div class="row">
<div class="col">
......@@ -60,108 +58,127 @@
import plots from '@/components/analyze-page/Plots.vue';
export default {
components: {
plots
},
data () {
return {
isConfig: true,
isPlots : false,
isDraw : true,
selectedItem: '',
selectedIds: []
}
},
created() {
},
components: {
plots
},
data () {
return {
isConfig: true,
isPlots : false,
isDraw : true,
selectedItem: 'unavailable',
selectedIds: [],
nameOfCase: ''
}
},
computed: {
listOptions: function() {
created() {
this.nameOfCase = this.$store.state.projectName;
},
computed: {
showProject: function() {
var options= [];
this.selectedItem= ''
this.showConfig()
this.nameOfCase = this.$store.state.projectName;
return this.nameOfCase
},
showSelectedItem: function() {
this.selectedItem = this.$store.state.simulationPlot.pickedItem
if (this.selectedItem == 'unavailable') {
this.showConfig()
}
return this.selectedItem
},
listOptions: function() {
var options= [];
this.selectedItem = 'unavailable'
const ids= Object.keys(this.$store.state.simulationResults);
if ( ids.length == 0 ) return options
const ids = Object.keys(this.$store.state.simulationResults);
if ( ids.length == 0 ) return options
this.selectedIds= this.$store.state.simulationPlot.selectedIds
if ( this.selectedIds.length == 0 ) return options
this.selectedIds = this.$store.state.simulationPlot.selectedIds
if ( this.selectedIds.length == 0 ) return options
const params= this.$store.state.analyzeParameters;
var actionList= [];
params.forEach((item,index) => {
var idx = this.selectedIds.indexOf(item.id)
if (idx != -1 ) actionList.push( item.action )
})
const params = this.$store.state.analyzeParameters;
var actionList= [];
params.forEach((item,index) => {
var idx = this.selectedIds.indexOf(item.id)
if (idx != -1 ) actionList.push( item.action )
})
options= [
options= [
{ text: 'β-functions', value:'betas'},
{ text: 'β & ηx functions', value:'betas&xeta'},
{ text: 'α-functions', value:'alfas'},
]
]
if (actionList.includes('twiss')) {
if (actionList.includes('twiss')) {
options.push({text:'μ-functions', value:'phases'})
options.push({text:'W-functions', value:'chromatics'})
options.push({text:'Hx invariant', value:'Hx-function'})
options.push({text:'σ-functions', value:'beam-size'})
}
if (actionList.includes('tunes')) {
}
if (actionList.includes('tunes')) {
options.push({text:'Q-tunes vs. Δp/p', value:'tunesVSdelta'})
options.push({text:'Q-tunes vs. x', value:'tunesVSx'})
options.push({text:'Q-tunes vs. y', value:'tunesVSy'})
options.push({text:'β vs. Δp/p', value:'betaVSdelta'})
options.push({text:'α vs. Δp/p', value:'alfaVSdelta'})
}
if (actionList.includes('track')) {
}
if (actionList.includes('track')) {
options.push({text:'rms-emittance', value:'rms-emittance'})
options.push({text:'bunch length', value:'bunch-length'})
options.push({text:'energy spread', value:'energy-spread'})
options.push({text:'beam size', value:'beam-size'})
}
if (actionList.includes('twiss') || actionList.includes('track')) {
}
if (actionList.includes('twiss') || actionList.includes('track')) {
options.push({text:'ellipse at z= START', value:'ellipse$START'})
options.push({text:'ellipse at z= END', value:'ellipse$END'})
}
}
console.log('Settings::listOptions => ', options)
return options
}
//console.log('Settings::listOptions => ', options)
return options
}
},
},
methods: {
say:function (option) {
console.log('say:picked => ', option)
//this.picked= option
//this.$store.commit('setPickedPlot', this.picked);
},
methods: {
showConfig: function() {
console.log('showConfig => ',this.selectedItem);
this.isConfig = true;
this.isPlots = false;
},
showConfig: function() {
this.isConfig = true;
this.isPlots = false;
},
showPlots: function() {
console.log('showPlots:: option => ',this.selectedItem);
this.isConfig = false;
this.isPlots = true;
}
showPlots: function() {
},
this.isConfig = false;
this.isPlots = true;
}
},
watch: {
selectedItem: function(newVal, oldVal) {
this.$store.commit('setPickedPlot', newVal);
}
watch: {
selectedItem: function(newVal, oldVal) {
console.log('Settings:: watch =>', newVal)
this.$store.commit('setPickedPlot', this.selectedItem);
}
}
}
};
</script>
......
......@@ -53,15 +53,15 @@ export default {
state.simulationPlot.selectedIds= ids
},
setPickedPlot (state, choice) {
console.log('2mutations =>', choice)
//console.log('2mutations =>', choice)
state.simulationPlot.pickedItem = choice
},
clearAnalyzeParameters (state) {
console.log('3mutations => clear')
//console.log('3mutations => clear')
state.analyzeParameters.splice(0, state.analyzeParameters.length)
},
setAnalyzeParameters (state, parameters) {
console.log('3mutations =>', parameters)
//console.log('3mutations =>', parameters)
state.analyzeParameters = parameters
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment