-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring dashboard state management
- Loading branch information
1 parent
c146154
commit 987c0b5
Showing
19 changed files
with
243 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
<template> | ||
<vue-json-pretty :data="event" /> | ||
<vue-json-pretty :data="events[props.event_id]" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import VueJsonPretty from 'vue-json-pretty'; | ||
import 'vue-json-pretty/lib/styles.css'; | ||
const props = defineProps(['event', "wc_state"]) | ||
/// <reference path="../store.d.ts" /> | ||
import { events } from "@/store"; | ||
const props = defineProps(['event_id']) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
export { }; | ||
|
||
declare module "store" { | ||
|
||
export interface Store{ | ||
campaigns: any; | ||
campaigns_url: string; | ||
experiment_keys: any; | ||
experiment_objects: any; | ||
experiments: any; | ||
experiments_url: string; | ||
main_url: string; | ||
state_url: string; | ||
wc_info: any; | ||
wc_state: any; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
import { ref, watchEffect } from 'vue'; | ||
|
||
const main_url = ref() | ||
const state_url = ref() | ||
const workcell_info_url = ref() | ||
const wfs = ref(['']) | ||
const experiments = ref() | ||
const experiments_url = ref() | ||
const events_url = ref() | ||
const events = ref() | ||
const wc_state = ref() | ||
const wc_info = ref() | ||
const campaigns = ref() | ||
const campaigns_url = ref() | ||
const experiment_keys = ref() | ||
const experiment_objects: any = ref([]) | ||
main_url.value = "http://".concat(window.location.host) | ||
class ExperimentInfo { | ||
experiment_id?: string; | ||
experiment_workflows: any; | ||
experiment_name?: string; | ||
num_wfs?: any; | ||
num_events?: any; | ||
events?: any | ||
} | ||
async function get_events(experiment_id: string) { | ||
return Object.values(await ((await fetch(main_url.value.concat("/experiments/".concat(experiment_id).concat("/events"))))).json()); | ||
} | ||
watchEffect(async () => { | ||
state_url.value = main_url.value.concat("/wc/state") | ||
|
||
experiments_url.value = main_url.value.concat("/experiments/all") | ||
campaigns_url.value = main_url.value.concat("/campaigns/all") | ||
workcell_info_url.value = main_url.value.concat("/wc/") | ||
events_url.value = main_url.value.concat("/events/all") | ||
|
||
setInterval(updateWorkcellState, 1000) | ||
setInterval(updateWorkflows, 1000) | ||
setInterval(updateExperiments, 10000) | ||
setInterval(updateCampaigns, 10000); | ||
setInterval(updateEvents, 10000); | ||
|
||
async function updateExperiments() { | ||
experiments.value = await ((await fetch(experiments_url.value)).json()); | ||
experiment_objects.value = Object.values(experiments.value); | ||
|
||
} | ||
|
||
async function updateCampaigns() { | ||
campaigns.value = await ((await fetch(campaigns_url.value)).json()); | ||
} | ||
|
||
async function updateEvents() { | ||
events.value = await ((await fetch(events_url.value)).json()); | ||
} | ||
|
||
async function updateWorkcellState() { | ||
wc_state.value = await (await fetch(state_url.value)).json(); | ||
} | ||
|
||
async function updateWorkflows() { | ||
wfs.value = Object.keys(wc_state.value.workflows).sort().reverse(); | ||
} | ||
}) | ||
|
||
export { campaigns, campaigns_url, events, experiment_keys, experiment_objects, experiments, experiments_url, main_url, state_url, wc_info, wc_state, wfs, workcell_info_url }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.