Commit ff152bde authored by WuFeiyang's avatar WuFeiyang

varBroadcast

parent 8202bda1
...@@ -82,6 +82,7 @@ import Method from "./components/Method/Method.vue"; ...@@ -82,6 +82,7 @@ import Method from "./components/Method/Method.vue";
import Config from "./components/Config/Config.vue"; import Config from "./components/Config/Config.vue";
import Thing from "./components/Thing/Thing.vue"; import Thing from "./components/Thing/Thing.vue";
import State from "./components/State/State.vue"; import State from "./components/State/State.vue";
import VarBroadcast from "./components/VarBroadcast/VarBroadcast.vue";
// import Gauge from "./components/Gauge/Gauge.vue"; // import Gauge from "./components/Gauge/Gauge.vue";
//this is the view selecotr class //this is the view selecotr class
...@@ -95,7 +96,8 @@ import State from "./components/State/State.vue"; ...@@ -95,7 +96,8 @@ import State from "./components/State/State.vue";
Thing, Thing,
GridLayout, GridLayout,
GridItem, GridItem,
State State,
VarBroadcast
} }
}) })
export default class App extends Vue { export default class App extends Vue {
...@@ -112,7 +114,8 @@ export default class App extends Vue { ...@@ -112,7 +114,8 @@ export default class App extends Vue {
"WaveView", "WaveView",
"Method", "Method",
"Thing", "Thing",
"State" "State",
"VarBroadcast"
]; ];
toggleShowAddWidget(): void { toggleShowAddWidget(): void {
...@@ -206,6 +209,14 @@ export default class App extends Vue { ...@@ -206,6 +209,14 @@ export default class App extends Vue {
this.dataAccess(dataURL); 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 { exportActiveWidgetList(): AllWidgetConfig {
......
...@@ -80,7 +80,7 @@ import Navigation from "@/components/Common/Navigation.vue"; ...@@ -80,7 +80,7 @@ import Navigation from "@/components/Common/Navigation.vue";
Navigation Navigation
} }
}) })
export default class VarBroadcast extends Widget { export default class Status extends Widget {
pathProcessor = new PathProcessor(); pathProcessor = new PathProcessor();
strMapObjChange = new StrMapObjChange(); strMapObjChange = new StrMapObjChange();
WidgetComponentName: string = "Status"; WidgetComponentName: string = "Status";
......
...@@ -192,7 +192,30 @@ export default class Status extends Widget { ...@@ -192,7 +192,30 @@ export default class Status extends Widget {
this.config.data.url.replace("$startPath$", startPath); 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() { refresh() {
var Args: UpdatePayload = { var Args: UpdatePayload = {
......
...@@ -13,18 +13,6 @@ ...@@ -13,18 +13,6 @@
<br /> <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-row>
<b-col> <b-col>
<b-input-group size="lg" prepend="path" v-show="isShowPath"> <b-input-group size="lg" prepend="path" v-show="isShowPath">
...@@ -78,7 +66,7 @@ import Navigation from "@/components/Common/Navigation.vue"; ...@@ -78,7 +66,7 @@ import Navigation from "@/components/Common/Navigation.vue";
export default class VarBroadcast extends Widget { export default class VarBroadcast extends Widget {
pathProcessor = new PathProcessor(); pathProcessor = new PathProcessor();
strMapObjChange = new StrMapObjChange(); strMapObjChange = new StrMapObjChange();
WidgetComponentName: string = "Status"; WidgetComponentName: string = "VarBroadcast";
StatusValue: string = ""; StatusValue: string = "";
pathId: string = ""; pathId: string = "";
userInputData = new Map<string, string>(); userInputData = new Map<string, string>();
...@@ -88,7 +76,7 @@ export default class VarBroadcast extends Widget { ...@@ -88,7 +76,7 @@ export default class VarBroadcast extends Widget {
isShowParams: boolean = false; isShowParams: boolean = false;
config: WidgetConfig = { config: WidgetConfig = {
WidgetComponentName: "Status", WidgetComponentName: "VarBroadcast",
data: { data: {
url: "", url: "",
userInputData: "" userInputData: ""
...@@ -101,14 +89,6 @@ export default class VarBroadcast extends Widget { ...@@ -101,14 +89,6 @@ export default class VarBroadcast extends Widget {
); );
} }
mounted() {
this.timer = setInterval(this.refresh, 1000);
}
destroyed() {
clearInterval(this.timer);
}
updateUI() { updateUI() {
this.isShowPath = false; this.isShowPath = false;
this.isShowParams = true; this.isShowParams = true;
...@@ -220,6 +200,7 @@ export default class VarBroadcast extends Widget { ...@@ -220,6 +200,7 @@ export default class VarBroadcast extends Widget {
viewLoad(Args: UpdatePayload) { viewLoad(Args: UpdatePayload) {
// this.config.data.userInputData = Args.variables; // this.config.data.userInputData = Args.variables;
PubSub.publish('VarBroadcast',Args); PubSub.publish('VarBroadcast',Args);
console.log(Args);
} }
} }
</script> </script>
......
...@@ -13,7 +13,7 @@ export abstract class Widget extends Vue { ...@@ -13,7 +13,7 @@ export abstract class Widget extends Vue {
public WidgetComponentName?: string; public WidgetComponentName?: string;
public abstract setConfig(wid: WidgetConfig): void; public abstract setConfig(wid: WidgetConfig): void;
public abstract getConfig(): WidgetConfig; public abstract getConfig(): WidgetConfig;
public abstract parentUpdate(paylosd: UpdatePayload): void; public abstract parentUpdate(payload: UpdatePayload): void;
public abstract refresh(): void; public abstract refresh(): void;
public abstract updateUI(): void; public abstract updateUI(): void;
public abstract replaceStartPath(startPath:string):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