Browse Source

small ui init state fix

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
e76c94451d
  1. 14
      client/src/store/index.ts
  2. 20
      client/src/views/Home.vue

14
client/src/store/index.ts

@ -37,6 +37,11 @@ const store = createStore<State>({
} }
}, },
actions: { actions: {
async initData() {
this.dispatch('fetchConfig');
this.dispatch('_runStatusGenerator');
},
async _runStatusGenerator({commit, state}) { async _runStatusGenerator({commit, state}) {
// notify({ // notify({
// title: "Authorization", // title: "Authorization",
@ -49,11 +54,10 @@ const store = createStore<State>({
const g = getStatusGenerator(); const g = getStatusGenerator();
commit(_SET_STATUS_GENERATOR, g); commit(_SET_STATUS_GENERATOR, g);
for await (const data of state._statusGenerator) { for await (const data of state._statusGenerator) {
const st = data.toLocaleLowerCase(); // const st = data.toLocaleLowerCase();
if(state.analyticStatus.toLocaleLowerCase() != 'ready' && st == 'ready') { // if(state.analyticStatus.toLocaleLowerCase() != 'ready' && st == 'ready') {
this.dispatch('fetchConfig');
// TODO: update segments from here // TODO: update segments from here
} // }
// this.status = data.toLowerCase(); // this.status = data.toLowerCase();
commit(SET_ANALYTICS_STATUS, data); commit(SET_ANALYTICS_STATUS, data);
} }
@ -68,6 +72,6 @@ const store = createStore<State>({
} }
}) })
store.dispatch('_runStatusGenerator'); store.dispatch('initData');
export default store; export default store;

20
client/src/views/Home.vue

@ -4,6 +4,9 @@
<graph ref="graph" /> <graph ref="graph" />
<analytic-status /> <analytic-status />
<div>
<v-select :options="analyticUnitTypes"></v-select>
</div>
<div id="controls"> <div id="controls">
<div v-if="analyticUnitType == analyticUnitTypes[1]"> <div v-if="analyticUnitType == analyticUnitTypes[1]">
Hold <pre>S</pre> to label patterns <br/> Hold <pre>S</pre> to label patterns <br/>
@ -13,7 +16,6 @@
<button @click="clearAllLabeling"> clear all labeling </button> <button @click="clearAllLabeling"> clear all labeling </button>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
@ -33,17 +35,25 @@ export default defineComponent({
methods: { methods: {
clearAllLabeling() { clearAllLabeling() {
this.$refs.graph.deleteAllSegments(); this.$refs.graph.deleteAllSegments();
},
changeAnalyticUnitType(e) {
console.log(e);
} }
}, },
data: function () { data: function () {
return { return {
analyticUnitTypes: [AnalyticUnitType.THRESHOLD, AnalyticUnitType.PATTERN, AnalyticUnitType.ANOMALY], analyticUnitTypes: [
AnalyticUnitType.THRESHOLD,
AnalyticUnitType.PATTERN,
AnalyticUnitType.ANOMALY,
],
analyticUnitType: AnalyticUnitType.PATTERN
} }
}, },
computed: { computed: {
analyticUnitType() { // analyticUnitType() {
return this.$store.state.analyticUnitType; // return { id: 1, name: this.$store.state.analyticUnitType }
} // }
} }
}); });
</script> </script>

Loading…
Cancel
Save