Commit 8dd644d4 authored by WuFeiyang's avatar WuFeiyang

broadcast ok

parent ff152bde
...@@ -83,6 +83,7 @@ import Config from "./components/Config/Config.vue"; ...@@ -83,6 +83,7 @@ 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 VarBroadcast from "./components/VarBroadcast/VarBroadcast.vue";
import AutoBroadcast from "./components/AutoBroadcast/AutoBroadcast.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
...@@ -97,7 +98,8 @@ import VarBroadcast from "./components/VarBroadcast/VarBroadcast.vue"; ...@@ -97,7 +98,8 @@ import VarBroadcast from "./components/VarBroadcast/VarBroadcast.vue";
GridLayout, GridLayout,
GridItem, GridItem,
State, State,
VarBroadcast VarBroadcast,
AutoBroadcast
} }
}) })
export default class App extends Vue { export default class App extends Vue {
...@@ -115,7 +117,8 @@ export default class App extends Vue { ...@@ -115,7 +117,8 @@ export default class App extends Vue {
"Method", "Method",
"Thing", "Thing",
"State", "State",
"VarBroadcast" "VarBroadcast",
"AutoBroadcast"
]; ];
toggleShowAddWidget(): void { toggleShowAddWidget(): void {
...@@ -211,11 +214,9 @@ export default class App extends Vue { ...@@ -211,11 +214,9 @@ export default class App extends Vue {
} }
PubSub.subscribe("VarBroadcast",(messageName, Args)=>{ PubSub.subscribe("VarBroadcast",(messageName, Args)=>{
console.log(Args);
//接收到消息调用全部widget的parentUpdate函数 //接收到消息调用全部widget的parentUpdate函数
for (var widget of this.widgetList) { for (var widget of this.widgetList) {
((this.$refs[widget.ref] as Array<Widget>)[0] as Widget).parentUpdate(Args);} ((this.$refs[widget.ref] as Array<Widget>)[0] as Widget).parentUpdate(Args);}
console.log(this.$refs[widget.ref]);
}); });
} }
......
...@@ -48,6 +48,16 @@ ...@@ -48,6 +48,16 @@
</b-col> </b-col>
</b-row> </b-row>
<br />
<b-row>
<b-col>
<b-input-group size="lg" prepend="BroadcastName" v-show="isShowPath">
<b-form-input v-model="autoUpdateName" ></b-form-input>
</b-input-group>
</b-col>
</b-row>
<br /> <br />
<b-row> <b-row>
<b-col> <b-col>
...@@ -59,6 +69,7 @@ ...@@ -59,6 +69,7 @@
<script lang="ts"> <script lang="ts">
import Vue from "vue"; import Vue from "vue";
import PubSub from 'pubsub-js';
import { VueSvgGauge } from "vue-svg-gauge"; import { VueSvgGauge } from "vue-svg-gauge";
import Component from "vue-class-component"; import Component from "vue-class-component";
import { Prop, Watch } from "vue-property-decorator"; import { Prop, Watch } from "vue-property-decorator";
...@@ -80,10 +91,10 @@ import Navigation from "@/components/Common/Navigation.vue"; ...@@ -80,10 +91,10 @@ import Navigation from "@/components/Common/Navigation.vue";
Navigation Navigation
} }
}) })
export default class Status extends Widget { export default class AutoBroadcast extends Widget {
pathProcessor = new PathProcessor(); pathProcessor = new PathProcessor();
strMapObjChange = new StrMapObjChange(); strMapObjChange = new StrMapObjChange();
WidgetComponentName: string = "Status"; WidgetComponentName: string = "AutoBroadcast";
StatusValue: string = ""; StatusValue: string = "";
pathId: string = ""; pathId: string = "";
userInputData = new Map<string, string>(); userInputData = new Map<string, string>();
...@@ -91,9 +102,10 @@ export default class Status extends Widget { ...@@ -91,9 +102,10 @@ export default class Status extends Widget {
timer?: number; timer?: number;
isShowPath: boolean = false; isShowPath: boolean = false;
isShowParams: boolean = false; isShowParams: boolean = false;
autoUpdateName: string = "";
config: WidgetConfig = { config: WidgetConfig = {
WidgetComponentName: "Status", WidgetComponentName: "AutoBroadcast",
data: { data: {
url: "", url: "",
userInputData: "" userInputData: ""
...@@ -231,6 +243,18 @@ export default class Status extends Widget { ...@@ -231,6 +243,18 @@ export default class Status extends Widget {
this.config.data.url this.config.data.url
); );
await this.getData(this.pathwithVar); await this.getData(this.pathwithVar);
if(this.autoUpdateName != "")
{
var autoUpdateData= new Map<string, string>();
autoUpdateData.set(this.autoUpdateName,this.StatusValue);
var autoUpdate:UpdatePayload = {
action: "AutoBroadcast",
variables: autoUpdateData,
target:['self']
}
PubSub.publish('VarBroadcast',autoUpdate);
}
} }
} }
</script> </script>
......
...@@ -292,7 +292,39 @@ export default class Config extends Widget { ...@@ -292,7 +292,39 @@ export default class Config extends Widget {
this.config.data.set.url.replace("$startPath$", startPath); this.config.data.set.url.replace("$startPath$", startPath);
} }
parentUpdate(payload: UpdatePayload): void {} parentUpdate(payload: UpdatePayload): void {
this.userGetInputData = this.strMapObjChange.strMapToObj(
(this.$refs.WidgetGetParams as WidgetParams).getVariableValues());
var temp = this.userGetInputData;
temp = JSON.parse(JSON.stringify(temp));
temp = this.strMapObjChange.objToStrMap(temp);
this.userGetInputData = temp;
this.userGetInputData.forEach((value , key) =>{
payload.variables.forEach((valueofpayload,keyofpayload)=>{
if(key == keyofpayload)
{
this.userGetInputData.set(key,payload.variables.get(keyofpayload) as string);
}
});
});
(this.$refs.WidgetGetParams as WidgetParams).setVariableInput(this.userGetInputData);
this.userSetInputData = this.strMapObjChange.strMapToObj(
(this.$refs.WidgetSetParams as WidgetParams).getVariableValues());
temp = this.userSetInputData;
temp = JSON.parse(JSON.stringify(temp));
temp = this.strMapObjChange.objToStrMap(temp);
this.userSetInputData = temp;
this.userSetInputData.forEach((value , key) =>{
payload.variables.forEach((valueofpayload,keyofpayload)=>{
if(key == keyofpayload)
{
this.userSetInputData.set(key,payload.variables.get(keyofpayload) as string);
}
});
});
(this.$refs.WidgetSetParams as WidgetParams).setVariableInput(this.userSetInputData);
}
refresh() { refresh() {
var GetArgs: UpdatePayload = { var GetArgs: UpdatePayload = {
......
...@@ -185,7 +185,26 @@ export default class Method extends Widget { ...@@ -185,7 +185,26 @@ export default class Method 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) =>{
payload.variables.forEach((valueofpayload,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 = {
......
...@@ -194,7 +194,26 @@ export default class State extends Widget { ...@@ -194,7 +194,26 @@ export default class State 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) =>{
payload.variables.forEach((valueofpayload,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 = {
......
...@@ -202,11 +202,7 @@ export default class Status extends Widget { ...@@ -202,11 +202,7 @@ export default class Status extends Widget {
console.log(this.userInputData); console.log(this.userInputData);
console.log(payload.variables); console.log(payload.variables);
this.userInputData.forEach((value , key) =>{ this.userInputData.forEach((value , key) =>{
console.log("进来了");
console.log(key);
payload.variables.forEach((valueofpayload,keyofpayload)=>{ payload.variables.forEach((valueofpayload,keyofpayload)=>{
console.log(key);
console.log(keyofpayload);
if(key == keyofpayload) if(key == keyofpayload)
{ {
this.userInputData.set(key,payload.variables.get(keyofpayload) as string); this.userInputData.set(key,payload.variables.get(keyofpayload) as string);
...@@ -214,7 +210,7 @@ export default class Status extends Widget { ...@@ -214,7 +210,7 @@ export default class Status extends Widget {
}); });
}); });
(this.$refs.WidgetParams as WidgetParams).setVariableInput(this.userInputData); (this.$refs.WidgetParams as WidgetParams).setVariableInput(this.userInputData);
this.updateUI(); // this.updateUI();
} }
refresh() { refresh() {
......
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