Commit fe15f2f2 authored by XieXiaohan's avatar XieXiaohan

add CustomView

parent 1d742ca8
This diff is collapsed.
...@@ -77,7 +77,8 @@ ...@@ -77,7 +77,8 @@
</nav> </nav>
<div id="appLeftClick">
<div id="appLeftClick" style="min-height: 100vh;">
...@@ -150,11 +151,14 @@ import { indexOf } from "typescript-collections/dist/lib/arrays"; ...@@ -150,11 +151,14 @@ import { indexOf } from "typescript-collections/dist/lib/arrays";
//when add more available widgets add ref to the widgets //when add more available widgets add ref to the widgets
import Status from "./components/Status/Status.vue"; import Status from "./components/Status/Status.vue";
import Navigation from "./components/Navigation/Navigation.vue";
import WaveView from "./components/WaveView/WaveView.vue"; import WaveView from "./components/WaveView/WaveView.vue";
import Method from "./components/Method/Method.vue"; import Method from "./components/Method/Method.vue";
import Config from "./components/Config/Config.vue"; import Config from "./components/Config/Config.vue";
import BoolConfig from "./components/Config/BoolConfig.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 BoolState from "./components/State/BoolState.vue";
import VarBroadcast from "./components/VarBroadcast/VarBroadcast.vue"; import VarBroadcast from "./components/VarBroadcast/VarBroadcast.vue";
import AutoBroadcast from "./components/AutoBroadcast/AutoBroadcast.vue"; import AutoBroadcast from "./components/AutoBroadcast/AutoBroadcast.vue";
import SlideShow from "./components/SlideShow/SlideShow.vue"; import SlideShow from "./components/SlideShow/SlideShow.vue";
...@@ -172,15 +176,18 @@ import Windows from "./components/Common/Windows.vue"; ...@@ -172,15 +176,18 @@ import Windows from "./components/Common/Windows.vue";
WaveView, WaveView,
Method, Method,
Config, Config,
BoolConfig,
Thing, Thing,
GridLayout, GridLayout,
GridItem, GridItem,
State, State,
BoolState,
VarBroadcast, VarBroadcast,
AutoBroadcast, AutoBroadcast,
SlideShow, SlideShow,
CardReader, CardReader,
Windows, Windows,
Navigation,
} }
}) })
...@@ -206,14 +213,17 @@ export default class App extends Vue { ...@@ -206,14 +213,17 @@ export default class App extends Vue {
availableWidgets = [ availableWidgets = [
"Status", "Status",
"Config", "Config",
"BoolConfig",
"WaveView", "WaveView",
"Method", "Method",
"Thing", "Thing",
"State", "State",
"BoolState",
"VarBroadcast", "VarBroadcast",
"AutoBroadcast", "AutoBroadcast",
"SlideShow", "SlideShow",
"CardReader" "CardReader",
"Navigation"
]; ];
...@@ -310,7 +320,9 @@ export default class App extends Vue { ...@@ -310,7 +320,9 @@ export default class App extends Vue {
}; };
var fragment = window.location.hash; var fragment = window.location.hash;
console.log("costum"+fragment);
if (fragment != "#blank" && fragment != "#Blank" && fragment != "#") { if (fragment != "#blank" && fragment != "#Blank" && fragment != "#") {
fragment = fragment.substring(1, fragment.length); fragment = fragment.substring(1, fragment.length);
var customViewURL = "/customView/template" + fragment; var customViewURL = "/customView/template" + fragment;
...@@ -339,18 +351,34 @@ export default class App extends Vue { ...@@ -339,18 +351,34 @@ export default class App extends Vue {
); );
this.widgetList = widgets.widgetList; this.widgetList = widgets.widgetList;
this.lastWidgetIndex = Number(widgets.currentRef); this.lastWidgetIndex = Number(widgets.currentRef);
this.$forceUpdate(); //this.$forceUpdate();
//替换startpath
//todo:替换startpath;判断是否存在$startpath$
/*for (var wid of this.widgetList) {
if((wid.widgetConfig[1].edit.url).search("startpath") != -1 ){
console.log("in"+(wid.widgetConfig[1].edit.url));
((this.$refs[wid.ref] as Array<Widget>)[0] as Widget).replaceStartPath( fragment as string);
}
}*/
//Defer the callback to be executed after the next DOM update cycle.
Vue.nextTick(() => { Vue.nextTick(() => {
// fragment = fragment.substring(1,fragment.length); /*fragment = fragment.substring(1,fragment.length);
// for (var wid of this.widgetList) { for (var wid of this.widgetList) {
// ((this.$refs[wid.ref] as Array<Widget>)[0] as Widget).replaceStartPath( fragment as string); ((this.$refs[wid.ref] as Array<Widget>)[0] as Widget).replaceStartPath( fragment as string);
// } }*/
//刷新值 //刷新值
this.importActiveWidgetList(); //this.importActiveWidgetList();
// for (var wid of this.widgetList) { // for (var wid of this.widgetList) {
// ((this.$refs[wid.ref] as Array<Widget>)[0] as Widget).refresh(); // ((this.$refs[wid.ref] as Array<Widget>)[0] as Widget).refresh();
// } // }
fragment = fragment.substring(1,fragment.length);
console.log(fragment);
this.importActiveWidgetList(fragment);
}); });
} }
else{ else{
...@@ -360,6 +388,7 @@ export default class App extends Vue { ...@@ -360,6 +388,7 @@ export default class App extends Vue {
}).catch(err=>{ }).catch(err=>{
var dataURL = fragment; var dataURL = fragment;
this.dataAccess(dataURL); this.dataAccess(dataURL);
console.log(dataURL);
}); });
} }
...@@ -383,9 +412,9 @@ export default class App extends Vue { ...@@ -383,9 +412,9 @@ export default class App extends Vue {
exportActiveWidgetList(): AllWidgetConfig { exportActiveWidgetList(): AllWidgetConfig {
for (var widget of this.widgetList) { for (var widget of this.widgetList) {
widget.widgetConfig = ((this.$refs[widget.ref] as Array< console.log("innn");
Widget widget.widgetConfig = ((this.$refs[widget.ref] as Array<Widget>)[0] as Widget).getConfig();
>)[0] as Widget).getConfig(); console.log(widget.widgetConfig);
} }
var widgetConfigList = new AllWidgetConfig(); var widgetConfigList = new AllWidgetConfig();
widgetConfigList.widgetList = this.widgetList; widgetConfigList.widgetList = this.widgetList;
...@@ -393,10 +422,12 @@ export default class App extends Vue { ...@@ -393,10 +422,12 @@ export default class App extends Vue {
return widgetConfigList; return widgetConfigList;
} }
importActiveWidgetList() { importActiveWidgetList(fragment:string) {
console.log(this.widgetList);
for (var wid of this.widgetList) { for (var wid of this.widgetList) {
console.log('in');
((this.$refs[wid.ref] as Array<Widget>)[0] as Widget).setConfig( ((this.$refs[wid.ref] as Array<Widget>)[0] as Widget).setConfig(
wid.widgetConfig as WidgetConfig wid.widgetConfig as WidgetConfig,fragment
); );
} }
} }
...@@ -419,13 +450,14 @@ export default class App extends Vue { ...@@ -419,13 +450,14 @@ export default class App extends Vue {
this.importActiveWidgetList(); this.importActiveWidgetList();
}); });
}; };
} }
saveWidgetList(): void { saveWidgetList(): void {
var data = JSON.stringify(this.exportActiveWidgetList()); var data = JSON.stringify(this.exportActiveWidgetList());
const blob = new Blob([data]); const blob = new Blob([data]);
/*
if (window.navigator.msSaveOrOpenBlob) { if (window.navigator.msSaveOrOpenBlob) {
// 兼容IE10 // 兼容IE10
navigator.msSaveBlob(blob, this.fileName); navigator.msSaveBlob(blob, this.fileName);
...@@ -436,7 +468,7 @@ export default class App extends Vue { ...@@ -436,7 +468,7 @@ export default class App extends Vue {
aTag.href = URL.createObjectURL(blob); aTag.href = URL.createObjectURL(blob);
aTag.click(); aTag.click();
URL.revokeObjectURL(aTag.href); URL.revokeObjectURL(aTag.href);
}*/ }
} }
addWidget(widgetName: string): void { addWidget(widgetName: string): void {
......
...@@ -20,16 +20,58 @@ ...@@ -20,16 +20,58 @@
</tr> </tr>
<tr v-if="EditData.edit.type != 'config'"> <tr v-if="EditData.edit.type == 'Navigation'">
<td><button class="button has-text-primary" style="margin-left: 15px;" @click="addInput">Add Input</button></td>
<td><table class="table">
<tbody v-for="(data,index) in EditData.edit.url">
<tr>
<input class="input has-text-primary" v-model="data.url"></tr>
<tr>
<button @click="deleteRow(index)">删除</button>
</tr>
</tbody>
</table></td>
</tr>
<tr v-if="EditData.edit.type != 'Navigation'">
<th>url:</th> <th>url:</th>
<td> <input class="input has-text-primary" v-model="EditData.edit.url" type="text"></td> <td> <input class="input has-text-primary" v-model="EditData.edit.url" type="text"></td>
<td><button class="button has-text-primary" style="margin-left: 15px;" @click="pathPoke">POKE</button></td> <td><button class="button has-text-primary" style="margin-left: 15px;" @click="pathPoke">POKE</button></td>
</tr> </tr>
<tr v-for="(prop,key) in EditData.props"> <tr v-for="(prop,key) in EditData.props" v-if="key != 'StateIndicatorFile'">
<th>{{key}}</th> <th>{{key}}</th>
<td> <input class="input has-text-primary" v-model="EditData.props[key]" type="text">{{prop}}</td> <td><input v-if="key != 'titleSize'" class="input has-text-primary" v-model="EditData.props[key]" type="text">
<td v-if="key == 'setPathPoke' || key == 'getPathPoke'"><button class="button has-text-primary" style="margin-left: 15px;" @click="pathPoke(key)">POKE</button></td> <div class="select" v-if="key == 'titleSize'">
<select v-model="EditData.props.titleSize">
<option>is-small</option>
<option>is-medium</option>
<option>is-large</option>
</select>
</div>
</td>
<!--<td v-if="key == 'setPathPoke' || key == 'getPathPoke'"><button class="button has-text-primary" style="margin-left: 15px;" @click="pathPoke(key)">POKE</button></td>-->
</tr>
<tr v-for="(prop,key) in EditData.props.StateIndicatorFile">
<th>{{key}}</th>
<td>
<input class="input has-text-primary" v-model="EditData.props.StateIndicatorFile[key]" type="text">
</td>
</tr>
<tr v-if="EditData.edit.type == 'state'">
<th>ShowStateValue</th>
<td>
<toggle-button v-model="EditData.edit.isShowStateVlaue"
width="80"
height="30"
switch-color="{checked: '#25EF02', unchecked: 'linear-gradient(red, yellow)'}"
:labels="{checked: 'show', unchecked: 'hide'}"/>
</td>
</tr> </tr>
...@@ -45,7 +87,7 @@ ...@@ -45,7 +87,7 @@
<div class="field-body"> <div class="field-body">
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<input class="input" type="text" v-model="tempUserInputData[label]"> <input class="input" type="text" v-model="EditData.params.tempUserInputData[label]">
</div> </div>
</div> </div>
</div> </div>
...@@ -65,6 +107,7 @@ ...@@ -65,6 +107,7 @@
</table> </table>
</div> </div>
...@@ -128,10 +171,6 @@ export default class WindowsApp extends Vue { ...@@ -128,10 +171,6 @@ export default class WindowsApp extends Vue {
this.EditData = data; this.EditData = data;
} }
if(this.EditData.props.StateFile != null){
this.EditData.props.StateFile = JSON.stringify(this.EditData.props.StateFile);
this.EditData.props.StateIndicatorFile = JSON.stringify(this.EditData.props.StateIndicatorFile);
}
} }
mounted(){ mounted(){
...@@ -144,15 +183,15 @@ export default class WindowsApp extends Vue { ...@@ -144,15 +183,15 @@ export default class WindowsApp extends Vue {
this.setVariableList( this.setVariableList(
this.pathProcessor.extractVarFromPath(this.EditData.params.PokedPath) this.pathProcessor.extractVarFromPath(this.EditData.params.PokedPath)
); );
if(this.EditData.edit.type == 'config'){
this.setVariableList(
this.pathProcessor.extractVarFromPath(this.EditData.params.GetPokedPath)
);
this.setVariableList(
this.pathProcessor.extractVarFromPath(this.EditData.params.SetPokedPath)
);
} }
addInput(){
this.EditData.edit.url.push({});
}
deleteRow(index) {
this.EditData.edit.url.splice(index, 1);
} }
/*loadTextFromStateFile(ev: any){ /*loadTextFromStateFile(ev: any){
...@@ -188,7 +227,7 @@ export default class WindowsApp extends Vue { ...@@ -188,7 +227,7 @@ export default class WindowsApp extends Vue {
target: ["self"] target: ["self"]
}; };
this.EditData.params.Args = Args; this.EditData.params.Args = Args;
this.EditData.params.tempUserInputData = this.tempUserInputData; //this.EditData.params.tempUserInputData = this.tempUserInputData;
window.opener.UpdateWidget(this.EditData); window.opener.UpdateWidget(this.EditData);
} }
...@@ -196,13 +235,8 @@ export default class WindowsApp extends Vue { ...@@ -196,13 +235,8 @@ export default class WindowsApp extends Vue {
pathPoke(key:string) { pathPoke() {
this.isShowParams = true; this.isShowParams = true;
if(key == 'setPathPoke'){
this.EditData.params.action = 'set';
}else if(key == 'getPathPoke'){
this.EditData.params.action = 'get';
}
window.opener.UpdateWidget(this.EditData); window.opener.UpdateWidget(this.EditData);
} }
...@@ -211,12 +245,10 @@ export default class WindowsApp extends Vue { ...@@ -211,12 +245,10 @@ export default class WindowsApp extends Vue {
setVariableList(path: string[]) { setVariableList(path: string[]) {
console.log(path);
this.userInputData.clear(); this.userInputData.clear();
path.forEach(element => { path.forEach(element => {
this.userInputData.set(element, ''); this.userInputData.set(element, '');
}); });
console.log(this.userInputData);
this.$forceUpdate(); this.$forceUpdate();
} }
...@@ -225,7 +257,7 @@ export default class WindowsApp extends Vue { ...@@ -225,7 +257,7 @@ export default class WindowsApp extends Vue {
getVariableValues(): Map<string, string> { getVariableValues(): Map<string, string> {
for(var key of this.userInputData.keys()) { for(var key of this.userInputData.keys()) {
this.userInputData.set(key, this.tempUserInputData[key]); this.userInputData.set(key, this.EditData.params.tempUserInputData[key]);
} }
return this.userInputData; return this.userInputData;
......
...@@ -5,6 +5,8 @@ import 'buefy/dist/buefy.css' ...@@ -5,6 +5,8 @@ import 'buefy/dist/buefy.css'
import 'font-awesome/css/font-awesome.min.css' import 'font-awesome/css/font-awesome.min.css'
//import hscmap from '@hscmap/vue-window' //import hscmap from '@hscmap/vue-window'
import * as VueWindow from '@hscmap/vue-window' import * as VueWindow from '@hscmap/vue-window'
import ToggleButton from 'vue-js-toggle-button'
Vue.use(ToggleButton)
import router from 'vue-router' import router from 'vue-router'
......
...@@ -5,6 +5,7 @@ export default class PathProcessor { ...@@ -5,6 +5,7 @@ export default class PathProcessor {
let str = ''; let str = '';
//取出path中的$ $,数组 //取出path中的$ $,数组
const result = path.match(urlRegExp); const result = path.match(urlRegExp);
console.log(result);
if (result != null) { if (result != null) {
//遍历map和数组 //遍历map和数组
variables.forEach((value: string, key: string) => { variables.forEach((value: string, key: string) => {
...@@ -14,6 +15,7 @@ export default class PathProcessor { ...@@ -14,6 +15,7 @@ export default class PathProcessor {
str = '\$' + label + '\$'; str = '\$' + label + '\$';
//将$xxx$替换成参数值 path为/card0/length/0 //将$xxx$替换成参数值 path为/card0/length/0
path = path.replace(str, value); path = path.replace(str, value);
console.log(path);
} }
}); });
}); });
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<template>
<div class="container" id="RightClick">
<div class="columns">
<button class="column button has-text-info is-light is-10 is-offset-1" style="padding: 4px;margin-top: 25px;" @click="isShowParams = true">Navigation</button>
</div>
<div v-for="url in EditData.edit.url" v-if="isShowParams">
<a v-bind:href="url.url" target="_blank">{{url.url}}</a>
</div>
</div>
</template>
<script lang="ts">
import Component from "vue-class-component";
import { Prop, Watch } from "vue-property-decorator";
import { WidgetConfig } from "@/models/WidgetConfig";
import { UpdatePayload } from "@/models/UpdatePayload";
import { Widget } from "@/models/widget";
import { ResourceInfo } from "@/models/Customview";
import { WidgetRef } from "@/models/WidgetRef";
import PathProcessor from "@/models/PathProcessor";
import StrMapObjChange from "@/models/StrMapObjChange";
@Component({
components: {
}
})
export default class Navigation extends Widget {
@Prop() index!:number;
@Prop() refIndex!:number;
@Prop() widgetList:WidgetRef[] = [];
pathProcessor = new PathProcessor();
strMapObjChange = new StrMapObjChange();
WidgetComponentName: string = "Navigation";
pathId: string = "";
userInputData = new Map<string, string>();
isShowParams: boolean = false;
config: WidgetConfig = {
WidgetComponentName: "Navigation",
data: {
url: "",
displayname:"",
userInputData: ""
}
};
EditData = {
edit:{
url:[],
type:'Navigation',
index:this.refIndex,
},
props:{
},
params:{
action:'get',
Args : {},
tempUserInputData:{},
},
};
created() {
this.config.data.userInputData = this.strMapObjChange.strMapToObj(
this.userInputData
);
}
mounted() {
let containerlist = document.getElementsByClassName('container');
//CreateContainerId
var self = this;
let RightClickField = containerlist[this.index];
RightClickField.oncontextmenu = function (e) {
e.preventDefault();//demo区域停止原鼠标右击菜单
//this.popMenu('itemMenu',100,"100");
let menu = document.querySelector('.menu');//获取盒子menu。
if(menu) menu.remove();//判断清除初始盒子
menu = document.createElement('div');//创建盒子。
menu.classList.add('menu');//添加类
let menu1 = document.createElement('BUTTON');//创建盒子menu1。
menu1.innerHTML = 'del';//盒子menu1添加文本XXXX
menu1.onclick = self.del;
menu.appendChild(menu1);//menu末尾添加新的节点menu1
let menu2 = document.createElement('BUTTON');//创建盒子menu1。
menu2.innerHTML = 'edit';//盒子menu1添加文本XXXX
menu2.onclick = self.openWindows;
//menu2.setAttribute("onclick", this.openWindows);
menu.appendChild(menu2);//menu末尾添加新的节点menu1
RightClickField.appendChild(menu);//body末尾添加新的节点menu
//盒子跟随鼠标光标。
//menu.style.top = $('#RightClick').offset().top;
menu.style.left = e.offsetX +"px";
menu.style.top = e.offsetY +"px";
menu.style.position = 'absolute';
//menu.style.top = '${e.clientY}px';
//menu.style.left = '${e.clientX}px';
console.log(menu.style.top);
console.log(menu);
};
//全局点击时消失。
RightClickField.onclick = e => {
let menu = document.querySelector('.menu')
if (menu && !menu.contains(e.target))
menu.remove()
}
}
del(){
this.$emit('del', this.index);
}
openWindows(){
//windows.open -> another single page application
var JsonData = JSON.stringify(this.EditData);
var url ="http://localhost:8080/WindowsAppIndex.html/?";
window.open(url+JsonData, "WidgetWindow",'height=100, width=100, top=10, left=10, toolbar=no');
}
//app
updateUI() {
this.openWindows();
}
//app
getConfig(): [WidgetConfig,object] {
return [this.config,this.EditData];
}
//app
setConfig(setConfigData: [WidgetConfig,object],fragment:string): void {
console.log(setConfigData);
this.config = setConfigData[0];
console.log(this.config);
this.EditData = setConfigData[1];
}
}
</script>
<style scoped>
.waveView {
width: 100%;
height: auto;
}
.hflex{
display: flex;
flex-direction: row-reverse;
align-items: center;
}
</style>
This diff is collapsed.
<template> <template>
<div class="container"> <div class="container">
<div class="columns content " v-bind:class="EditData.props.titleSize" style="margin-bottom: 0px;">
<div class="columns" style="margin-top:10px"> <div class="column content-table-cell-heading-color is-narrow" style="margin: 0px;">
<h3>{{EditData.props.title}}</h3>
<span style="float:left;" v-show = "!isShowPath" class="largeFont" v-if = "config.data.displayname != ''">{{ config.data.displayname }}</span> </div>
<span style="float:left;" v-show = "!isShowPath" class="largeFont" v-if = "config.data.displayname == ''">{{ config.data.url }}</span>
<input class="input colmumn is-8" type="text" v-show="isShowPath" v-model="config.data.displayname">
</div> </div>
<div class="columns" style="margin-top:5px"> <div class="columns" style="padding: 5px;margin-top: 5px;">
<span style="background-color: #bbb;border-radius: 50%;display: inline-block;" <span style="background-color: #bbb;border-radius: 50%;display: inline-block;"
v-bind:style="{ backgroundColor: activeColor, height: fontSize + 'px' ,width: fontSize + 'px'}"></span> v-bind:style="{ backgroundColor: activeColor, height: EditData.props.fontSize + 'px' ,width: EditData.props.fontSize + 'px'}"></span>
<div class="column is-2" v-bind:style="{ fontColor: activeColor}" v-if="EditData.edit.isShowStateVlaue">{{stateKey}}</div>
</div> </div>
...@@ -71,8 +70,9 @@ export default class State extends Widget { ...@@ -71,8 +70,9 @@ export default class State extends Widget {
isShowPath: boolean = false; isShowPath: boolean = false;
isShowParams: boolean = false; isShowParams: boolean = false;
EditPathPoke : string = ""; EditPathPoke : string = "";
fontSize:number = 40; fontSize:number = 60;
activeColor:string = '#bbb'; activeColor:string = '#bbb';
stateKey:string = '';
config: WidgetConfig = { config: WidgetConfig = {
WidgetComponentName: "State", WidgetComponentName: "State",
...@@ -84,18 +84,18 @@ export default class State extends Widget { ...@@ -84,18 +84,18 @@ export default class State extends Widget {
}; };
EditData = { EditData = {
props:{ edit:{
type:'state', type:'state',
url:this.config.data.url, url:this.config.data.url,
index:this.refIndex, index:this.refIndex,
fontSize:this.fontSize, isShowStateVlaue:false,
StateFile:{
"0":"yellow",
"1":"orange",
"2":"green",
"255":"red"
}, },
StateIndicatorFile:null, props:{
fontSize:this.fontSize,
title:'',
titleSize:'',
StateFile:'{"Idle":"yellow","prepare":"orange","run":"green","error":"red" }' ,
StateIndicator:'{"0":"Idle","1":"prepare","2":"run","255":"error"}',
}, },
params:{ params:{
PokedPath:this.EditPathPoke, PokedPath:this.EditPathPoke,
...@@ -145,10 +145,6 @@ export default class State extends Widget { ...@@ -145,10 +145,6 @@ export default class State extends Widget {
menu.style.left = e.offsetX +"px"; menu.style.left = e.offsetX +"px";
menu.style.top = e.offsetY +"px"; menu.style.top = e.offsetY +"px";
menu.style.position = 'absolute'; menu.style.position = 'absolute';
//menu.style.top = '${e.clientY}px';
//menu.style.left = '${e.clientX}px';
console.log(menu.style.top);
console.log(menu);
}; };
...@@ -176,14 +172,13 @@ export default class State extends Widget { ...@@ -176,14 +172,13 @@ export default class State extends Widget {
del() del()
{ {
this.$emit('del', this.index); this.$emit('del', this.index);
console.log("del"+this.index);
} }
updateUI() { updateUI() {
this.isShowPath = false; this.isShowPath = false;
this.EditData.params.PokedPath = this.config.data.url; this.EditData.params.PokedPath = this.config.data.url;
this.EditData.props.url = this.config.data.url; this.EditData.edit.url = this.config.data.url;
this.openWindows(); this.openWindows();
} }
...@@ -191,35 +186,39 @@ export default class State extends Widget { ...@@ -191,35 +186,39 @@ export default class State extends Widget {
this.isShowPath = !this.isShowPath; this.isShowPath = !this.isShowPath;
} }
getConfig(): WidgetConfig { getConfig(): [WidgetConfig,object] {
// this.config.data.userInputData =(this.$refs.WidgetParams as WidgetParams).getVariableValues(); return [this.config,this.EditData];
this.config.data.userInputData = this.strMapObjChange.strMapToObj(
(this.$refs.WidgetParams as WidgetParams).getVariableValues()
);
return this.config;
} }
setConfig(widgetConfig: WidgetConfig): void { setConfig(setConfigData: [WidgetConfig,object],fragment:string): void {
this.config = widgetConfig; this.config = setConfigData[0];
//this.updateUI(); this.EditData = setConfigData[1];
(this.$refs.WidgetParams as WidgetParams).setVariableList(
this.pathProcessor.extractVarFromPath(this.config.data.url) if(this.EditData.edit.url.search("startpath") != -1 ){this.replaceStartPath(fragment)}
);
//map不能序列化,必须要单独处理,这里的处理方法仅限map<string,string>类型
var temp = this.config.data.userInputData; var temp = this.EditData.params.tempUserInputData;
temp = JSON.parse(JSON.stringify(temp)); temp = JSON.parse(JSON.stringify(temp));
temp = this.strMapObjChange.objToStrMap(temp); temp = this.strMapObjChange.objToStrMap(temp);
this.userInputData = temp; //this.EditData.params.tempUserInputData = temp;
(this.$refs.WidgetParams as WidgetParams).setVariableInput(
this.userInputData
); var Args: UpdatePayload = {
action: this.EditData.params.action,
variables: temp,
target: ["self"]
};
this.EditData.params.Args = Args;
this.viewLoad(Args);
} }
pathPoke(url:string) { pathPoke() {
this.config.data.url = url; this.config.data.url = this.EditData.edit.url;
this.EditPathPoke = url; this.EditPathPoke = this.EditData.edit.url;
console.log("dddd"); var pokepath = this.EditData.edit.url;
var pokepath = url;
//todo:config文件 //todo:config文件
axios.defaults.timeout = 1000; axios.defaults.timeout = 1000;
axios.get(pokepath, { axios.get(pokepath, {
...@@ -228,13 +227,14 @@ export default class State extends Widget { ...@@ -228,13 +227,14 @@ export default class State extends Widget {
'Cache-Control': 'no-cache' 'Cache-Control': 'no-cache'
} }
}).then(response => { }).then(response => {
console.log("update");
this.samplePoke(response.data); this.samplePoke(response.data);
this.updateUI(); this.updateUI();
//test
//this.colourViewLoad();
}).catch(err => { }).catch(err => {
console.log('catch'); this.colourViewLoad();
this.EditData.params.PokedPath = this.config.data.url; this.EditData.params.PokedPath = this.config.data.url;
this.openWindows(); //this.openWindows();
}); });
//var url = this.config.data.url; //var url = this.config.data.url;
...@@ -269,7 +269,8 @@ export default class State extends Widget { ...@@ -269,7 +269,8 @@ export default class State extends Widget {
replaceStartPath(startPath: string): void { replaceStartPath(startPath: string): void {
this.config.data.url.replace("$startPath$", startPath); this.config.data.url = this.config.data.url.replace("$startpath$", startPath);
this.EditData.edit.url = this.EditData.edit.url.replace("$startpath$", startPath);
} }
parentUpdate(payload: UpdatePayload): void { parentUpdate(payload: UpdatePayload): void {
...@@ -312,25 +313,20 @@ export default class State extends Widget { ...@@ -312,25 +313,20 @@ export default class State extends Widget {
} }
}).then(response => { }).then(response => {
this.StatusValue = response.data.CFET2CORE_SAMPLE_VAL; this.StatusValue = response.data.CFET2CORE_SAMPLE_VAL;
switch (this.StatusValue.toString()) { //this.colourViewLoad();
case "0": {
this.activeColor = this.EditData.props.StateFile['0']; });
break;
}
case "1": {
this.activeColor = this.EditData.props.StateFile['1'];
break;
}
case "2": {
this.activeColor = this.EditData.props.StateFile['2'];
break;
}
case "255": {
this.activeColor = this.EditData.props.StateFile['255'];
break;
} }
colourViewLoad(){
var stateFile = JSON.parse(this.EditData.props.StateFile);
var stateIndicator = JSON.parse(this.EditData.props.StateIndicator);
this.stateKey = stateIndicator[this.StatusValue];
this.activeColor = stateFile[this.stateKey];
if(this.activeColor == undefined){
this.activeColor = '#bbb';
} }
});
} }
//called when widgetParams action clicked //called when widgetParams action clicked
...@@ -343,6 +339,7 @@ export default class State extends Widget { ...@@ -343,6 +339,7 @@ export default class State extends Widget {
this.config.data.url this.config.data.url
); );
await this.getData(this.pathwithVar); await this.getData(this.pathwithVar);
this.colourViewLoad();
} }
} }
</script> </script>
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ export class WidgetRef { ...@@ -5,7 +5,7 @@ export class WidgetRef {
// the parameters of a resource should be probed by the widget itself // the parameters of a resource should be probed by the widget itself
public widgetComponentName: string = ''; public widgetComponentName: string = '';
public ref: string = ''; public ref: string = '';
public widgetConfig?: WidgetConfig; public widgetConfig?: [WidgetConfig,object];
//below is for grid layout //below is for grid layout
public x:number=0; public x:number=0;
public y:number=0; public y:number=0;
......
...@@ -11,7 +11,7 @@ export interface PokePath { ...@@ -11,7 +11,7 @@ export interface PokePath {
export abstract class Widget extends Vue { export abstract class Widget extends Vue {
public WidgetComponentName?: string; public WidgetComponentName?: string;
public abstract setConfig(wid: WidgetConfig): void; public abstract setConfig(wid: WidgetConfig,fragment:string): void;
public abstract getConfig(): WidgetConfig; public abstract getConfig(): WidgetConfig;
public abstract parentUpdate(payload: UpdatePayload): void; public abstract parentUpdate(payload: UpdatePayload): void;
public abstract refresh(): void; public abstract refresh(): void;
......
{ {
"compilerOptions": { "compilerOptions": {
//"declaration": true, //// xjl add
//"resolveJsonModule": true,
//"declarationDir": "src/types",
"target": "esnext", "target": "esnext",
//"target": "es5", //"target": "es5",
"module": "esnext", "module": "esnext",
//"module": "commonjs", //"module": "commonjs",
...@@ -14,9 +19,10 @@ ...@@ -14,9 +19,10 @@
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"noEmit": true,
"typeRoots": ["./src/types"], "typeRoots": ["./src/types"],
"types": [ "types": [
"webpack-env" "webpack-env",
], ],
"paths": { "paths": {
"@/*": [ "@/*": [
...@@ -30,12 +36,18 @@ ...@@ -30,12 +36,18 @@
"scripthost" "scripthost"
] ]
}, },
"include": [ "include": [
"src/**/*.ts", "src/**/*.ts",
"src/**/*.tsx", "src/**/*.tsx",
"src/**/*.vue", "src/**/*.vue",
"tests/**/*.ts", "tests/**/*.ts",
"tests/**/*.tsx", "node_modules/vue-grid-layout/dist/vue-grid-item.d.ts" "tests/**/*.tsx",
"node_modules/vue-grid-layout/dist/vue-grid-item.d.ts",
"/node_modules/@antv/g2plot/lib/index.d.ts",
"src/types/g2plot/g2plot.d.ts",
"src/types/g2plot/global.d.ts"
], ],
"exclude": [ "exclude": [
"node_modules" "node_modules"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
//"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ //"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
// "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ //"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */ // "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
// "outDir": "./js", /* Redirect output structure to the directory. */ // "outDir": "./js", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */ // "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ //"tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */ //"removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */ // "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
......
...@@ -16,7 +16,7 @@ module.exports = { ...@@ -16,7 +16,7 @@ module.exports = {
devServer: { devServer: {
proxy: { proxy: {
"/": { "/": {
target: "http://192.168.0.195:8001", target: "http://192.168.0.197:8001",
secure: false, secure: false,
changeOrigin: true changeOrigin: true
} }
......
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