Commit ff152bde authored by WuFeiyang's avatar WuFeiyang

varBroadcast

parent 8202bda1
......@@ -82,6 +82,7 @@ import Method from "./components/Method/Method.vue";
import Config from "./components/Config/Config.vue";
import Thing from "./components/Thing/Thing.vue";
import State from "./components/State/State.vue";
import VarBroadcast from "./components/VarBroadcast/VarBroadcast.vue";
// import Gauge from "./components/Gauge/Gauge.vue";
//this is the view selecotr class
......@@ -95,7 +96,8 @@ import State from "./components/State/State.vue";
Thing,
GridLayout,
GridItem,
State
State,
VarBroadcast
}
})
export default class App extends Vue {
......@@ -112,7 +114,8 @@ export default class App extends Vue {
"WaveView",
"Method",
"Thing",
"State"
"State",
"VarBroadcast"
];
toggleShowAddWidget(): void {
......@@ -206,6 +209,14 @@ export default class App extends Vue {
this.dataAccess(dataURL);
});
}
PubSub.subscribe("VarBroadcast",(messageName, Args)=>{
console.log(Args);
//接收到消息调用全部widget的parentUpdate函数
for (var widget of this.widgetList) {
((this.$refs[widget.ref] as Array<Widget>)[0] as Widget).parentUpdate(Args);}
console.log(this.$refs[widget.ref]);
});
}
exportActiveWidgetList(): AllWidgetConfig {
......
......@@ -80,7 +80,7 @@ import Navigation from "@/components/Common/Navigation.vue";
Navigation
}
})
export default class VarBroadcast extends Widget {
export default class Status extends Widget {
pathProcessor = new PathProcessor();
strMapObjChange = new StrMapObjChange();
WidgetComponentName: string = "Status";
......
......@@ -192,7 +192,30 @@ export default class Status extends Widget {
this.config.data.url.replace("$startPath$", startPath);
}
parentUpdate(payload: UpdatePayload): void {}
parentUpdate(payload: UpdatePayload): void {
this.userInputData = this.strMapObjChange.strMapToObj(
(this.$refs.WidgetParams as WidgetParams).getVariableValues());
var temp = this.userInputData;
temp = JSON.parse(JSON.stringify(temp));
temp = this.strMapObjChange.objToStrMap(temp);
this.userInputData = temp;
console.log(this.userInputData);
console.log(payload.variables);
this.userInputData.forEach((value , key) =>{
console.log("进来了");
console.log(key);
payload.variables.forEach((valueofpayload,keyofpayload)=>{
console.log(key);
console.log(keyofpayload);
if(key == keyofpayload)
{
this.userInputData.set(key,payload.variables.get(keyofpayload) as string);
}
});
});
(this.$refs.WidgetParams as WidgetParams).setVariableInput(this.userInputData);
this.updateUI();
}
refresh() {
var Args: UpdatePayload = {
......
......@@ -13,18 +13,6 @@
<br />
<b-row>
<b-col>
<div
style="width:100%;overflow:auto;border-style: solid; border-width: 1px;"
>
<p style="float:left;margin:0px" class="largeFont">{{ StatusValue }}</p>
</div>
</b-col>
</b-row>
<br />
<b-row>
<b-col>
<b-input-group size="lg" prepend="path" v-show="isShowPath">
......@@ -78,7 +66,7 @@ import Navigation from "@/components/Common/Navigation.vue";
export default class VarBroadcast extends Widget {
pathProcessor = new PathProcessor();
strMapObjChange = new StrMapObjChange();
WidgetComponentName: string = "Status";
WidgetComponentName: string = "VarBroadcast";
StatusValue: string = "";
pathId: string = "";
userInputData = new Map<string, string>();
......@@ -88,7 +76,7 @@ export default class VarBroadcast extends Widget {
isShowParams: boolean = false;
config: WidgetConfig = {
WidgetComponentName: "Status",
WidgetComponentName: "VarBroadcast",
data: {
url: "",
userInputData: ""
......@@ -101,14 +89,6 @@ export default class VarBroadcast extends Widget {
);
}
mounted() {
this.timer = setInterval(this.refresh, 1000);
}
destroyed() {
clearInterval(this.timer);
}
updateUI() {
this.isShowPath = false;
this.isShowParams = true;
......@@ -220,6 +200,7 @@ export default class VarBroadcast extends Widget {
viewLoad(Args: UpdatePayload) {
// this.config.data.userInputData = Args.variables;
PubSub.publish('VarBroadcast',Args);
console.log(Args);
}
}
</script>
......
......@@ -13,7 +13,7 @@ export abstract class Widget extends Vue {
public WidgetComponentName?: string;
public abstract setConfig(wid: WidgetConfig): void;
public abstract getConfig(): WidgetConfig;
public abstract parentUpdate(paylosd: UpdatePayload): void;
public abstract parentUpdate(payload: UpdatePayload): void;
public abstract refresh(): void;
public abstract updateUI(): void;
public abstract replaceStartPath(startPath:string):void;
......
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