diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/processo/components/processo.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/processo/components/processo.ts index 6ef542f7..e7c0ed7c 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/processo/components/processo.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/processo/components/processo.ts @@ -21,7 +21,9 @@ export default class Processo extends Vue { @Prop({ default: 145 }) tot: number; - blocks: server.Modblock[] = []; + get blocks(): server.Modblock[] { + return store.state.modules.blocks; + } zoomFactor: number = 1; @@ -38,16 +40,11 @@ export default class Processo extends Vue { showAllBlocks: boolean = false; async mounted() { - let result = await moduleService.GetCurrent(); let c = await CONFIGURATION; this.showAllBlocks = c.allUIVisible; - for (const key in result) { - if (result.hasOwnProperty(key)) { - this.blocks.push(result[key]); - } - } + } } \ No newline at end of file diff --git a/Thermo.Active/wwwroot/src/services/hub.ts b/Thermo.Active/wwwroot/src/services/hub.ts index 32cb597d..eacd40d8 100644 --- a/Thermo.Active/wwwroot/src/services/hub.ts +++ b/Thermo.Active/wwwroot/src/services/hub.ts @@ -3,7 +3,7 @@ import Vue from "vue"; import { AlarmsModelActionsInterface } from "../store/alarms.store" import iziToast, { IziToastSettings } from "izitoast"; -import { store, alarmsModelActions, machineStatusActions, machineInfoActions, AppModel, appModelActions } from "@/store"; +import { store, alarmsModelActions, machineStatusActions, machineInfoActions, AppModel, appModelActions, modulesActions } from "@/store"; import { Factory, messageService } from "@/_base"; import { signalr_alarms } from "@/@types/signalr.alarms"; import { AuthToken } from "@/_base/baseRestService"; @@ -104,7 +104,7 @@ export class Hub { this._hub.client.recipeFullData = Hub.recipeFullData; this._hub.client.recipeOverData = Hub.recipeOverData; this._hub.client.prodInfoData = Hub.prodData; - // this._hub.client.modulesData = Hub.modulesData; + this._hub.client.modulesData = Hub.modulesData; // this._hub.client.warmersData = Hub.warmersData; this._hub.client.gaugeData = Hub.gaugeData; @@ -148,17 +148,19 @@ export class Hub { } + public static modulesData(data) { + modulesActions.set(store, data); + } + public static recipeFullData(data) { recipeActions.setCurrent(store, data); } public static recipeOverData(data) { - console.log('recipeOverData', data) recipeActions.setOverview(store, data); } public static prodData(data) { - console.log('prodData', data) prodActions.setProd(store, data); } diff --git a/Thermo.Active/wwwroot/src/store/app.store.ts b/Thermo.Active/wwwroot/src/store/app.store.ts index 72b72fb7..0e67791b 100644 --- a/Thermo.Active/wwwroot/src/store/app.store.ts +++ b/Thermo.Active/wwwroot/src/store/app.store.ts @@ -20,6 +20,7 @@ import { recipeStore, RecipeStoreModel } from "./recipe.store"; import { prodStore, ProdStoreModel } from "./prod.store"; import { usersStore, UsersStoreModel } from "./users.store"; import { warmersStore, WarmersStoreModel } from "./warmers.store"; +import { modulesStore, ModulesStoreModel } from "./modules.store"; Vue.use(Vuex); @@ -48,6 +49,7 @@ export interface AppModel { prod: ProdStoreModel; users: UsersStoreModel; warmers: WarmersStoreModel; + modules: ModulesStoreModel; } // Mutations Name @@ -98,6 +100,7 @@ const _store = { prod: prodStore, users: usersStore, warmers: warmersStore, + modules: modulesStore }, mutations: { diff --git a/Thermo.Active/wwwroot/src/store/index.ts b/Thermo.Active/wwwroot/src/store/index.ts index ae0074e5..f8411e72 100644 --- a/Thermo.Active/wwwroot/src/store/index.ts +++ b/Thermo.Active/wwwroot/src/store/index.ts @@ -8,6 +8,7 @@ import { LocalizationModel, languageModel, localizationModelActions } from "./lo import { jobEditorStoreActions } from "./jobEditor.store"; import { UsersStoreModel, UsersActions } from "./users.store"; import { WarmersStoreModel, warmersActions } from "./warmers.store"; +import { ModulesStoreModel, modulesActions } from "./modules.store"; export { store, @@ -28,6 +29,7 @@ export { localizationModelActions, AlarmModel, buttonStatus, + ModulesStoreModel, modulesActions, jobEditorStoreActions, UsersActions, UsersStoreModel, diff --git a/Thermo.Active/wwwroot/src/store/modules.store.ts b/Thermo.Active/wwwroot/src/store/modules.store.ts new file mode 100644 index 00000000..4341c7e4 --- /dev/null +++ b/Thermo.Active/wwwroot/src/store/modules.store.ts @@ -0,0 +1,50 @@ +import Vue from "vue"; +import { CONFIGURATION } from "@/config"; + +export interface ModulesStoreModel { + blocks: server.Modblock[]; +} + + +export interface ModulesActions { + set(context, model: { [id: string]: server.Modblock }); +} + +export interface ModulesGetters { +} + +export const modulesStore = { + + state: { + blocks: [], + } as ModulesStoreModel, + + getters: { + }, + + mutations: { + + SetCurrent(state: ModulesStoreModel, model: { [id: string]: server.Modblock }) { + for (const key in model) { + let result = state.blocks.find(i => i.id.toString() == key.toString()) + if (result) + Object.assign(result, model[key]) + else + state.blocks.push(model[key]); + } + }, + + + }, + + actions: { + + async set(context, model: { [id: string]: server.Modblock }) { + context.commit("SetCurrent", model); + }, + + } as ModulesActions + +} + +export const modulesActions = modulesStore.actions as ModulesActions;