Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
W
WidgetUI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WuFeiyang
WidgetUI
Commits
bc3f1ed7
Commit
bc3f1ed7
authored
Sep 19, 2019
by
WuFeiyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加了还没有经过测试的config
parent
171046b8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
48 deletions
+159
-48
src/App.vue
src/App.vue
+1
-1
src/components/Config/Config.vue
src/components/Config/Config.vue
+156
-45
src/models/WidgetRef.ts
src/models/WidgetRef.ts
+2
-2
No files found.
src/App.vue
View file @
bc3f1ed7
...
@@ -248,7 +248,7 @@ export default class App extends Vue {
...
@@ -248,7 +248,7 @@ export default class App extends Vue {
var
newWidget
=
new
WidgetRef
();
var
newWidget
=
new
WidgetRef
();
newWidget
.
widgetComponentName
=
widgetName
;
newWidget
.
widgetComponentName
=
widgetName
;
newWidget
.
ref
=
this
.
lastWidgetIndex
.
toString
();
newWidget
.
ref
=
this
.
lastWidgetIndex
.
toString
();
newWidget
.
y
=
this
.
lastWidgetIndex
*
4
;
newWidget
.
y
=
this
.
lastWidgetIndex
*
6
;
newWidget
.
i
=
Number
(
newWidget
.
ref
);
newWidget
.
i
=
Number
(
newWidget
.
ref
);
this
.
lastWidgetIndex
++
;
this
.
lastWidgetIndex
++
;
this
.
widgetList
=
[...
this
.
widgetList
,
newWidget
];
this
.
widgetList
=
[...
this
.
widgetList
,
newWidget
];
...
...
src/components/Config/Config.vue
View file @
bc3f1ed7
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
<b-container
class=
"bv-example-row"
>
<b-container
class=
"bv-example-row"
>
<b-row
style=
"margin-top:10px"
>
<b-row
style=
"margin-top:10px"
>
<b-col>
<b-col>
<span
style=
"float:left;font-size:20px"
>
path:
{{
config
.
data
.
url
}}
</span>
<span
style=
"float:left;font-size:20px"
>
getPath:
{{
config
.
data
.
get
.
url
}}
</span>
<span
style=
"float:left;font-size:20px"
>
setPath:
{{
config
.
data
.
set
.
url
}}
</span>
</b-col>
</b-col>
<b-col>
<b-col>
<b-button
@
click=
"showPathConfig"
variant=
"primary"
style=
"float:right"
><span
class=
"glyphicon glyphicon-cog"
></span></b-button>
<b-button
@
click=
"showPathConfig"
variant=
"primary"
style=
"float:right"
><span
class=
"glyphicon glyphicon-cog"
></span></b-button>
...
@@ -10,17 +11,29 @@
...
@@ -10,17 +11,29 @@
<hr
/>
<hr
/>
</b-row>
</b-row>
<div
style=
"width:100%"
>
<div
style=
"width:100%"
>
<span
style=
"float:left;font-size:20px"
>
{{
Status
Value
}}
</span>
<span
style=
"float:left;font-size:20px"
>
getConfigValue:
{{
getConfig
Value
}}
</span>
<hr
/>
<hr
/>
<!--
<span
style=
"float:left;font-size:20px"
>
setConfigValue:
{{
setConfigValue
}}
</span>
<hr
/>
-->
</div>
</div>
<b-input-group
prepend=
"path"
v-show=
"isShowPath"
>
<b-form-input
v-model=
"config.data.url"
></b-form-input>
<b-input-group
prepend=
"getPath"
v-show=
"isShowPath"
>
<b-form-input
v-model=
"config.data.get.url"
></b-form-input>
<b-input-group-append>
<b-input-group-append>
<b-button
@
click=
"updateUI"
size=
"sm"
text=
"Button"
variant=
"primary"
>
OK
</b-button>
<b-button
@
click=
"update
Get
UI"
size=
"sm"
text=
"Button"
variant=
"primary"
>
OK
</b-button>
</b-input-group-append>
</b-input-group-append>
</b-input-group>
</b-input-group>
<hr/>
<hr/>
<WidgetParams
ref=
"WidgetParams"
v-show=
"isShowParams&&isShowPath"
action=
"get"
@
updataVariables=
"viewLoad"
></WidgetParams>
<WidgetParams
ref=
"WidgetGetParams"
v-show=
"isShowGetParams&&isShowPath"
action=
"get"
@
updataVariables=
"getViewLoad"
></WidgetParams>
<hr/>
<b-input-group
prepend=
"setPath"
v-show=
"isShowPath"
>
<b-form-input
v-model=
"config.data.set.url"
></b-form-input>
<b-input-group-append>
<b-button
@
click=
"updateSetUI"
size=
"sm"
text=
"Button"
variant=
"primary"
>
OK
</b-button>
</b-input-group-append>
</b-input-group>
<hr/>
<WidgetParams
ref=
"WidgetSetParams"
v-show=
"isShowSetParams&&isShowPath"
action=
"set"
@
updataVariables=
"setViewLoad"
></WidgetParams>
</b-container>
</b-container>
</
template
>
</
template
>
...
@@ -45,35 +58,68 @@ import { map } from "d3";
...
@@ -45,35 +58,68 @@ import { map } from "d3";
WidgetParams
WidgetParams
}
}
})
})
export
default
class
Status
extends
Widget
{
export
default
class
Config
extends
Widget
{
pathProcessor
=
new
PathProcessor
();
pathProcessor
=
new
PathProcessor
();
strMapObjChange
=
new
StrMapObjChange
();
strMapObjChange
=
new
StrMapObjChange
();
WidgetComponentName
:
string
=
"
Status
"
;
WidgetComponentName
:
string
=
"
Config
"
;
StatusValue
:
string
=
""
;
getConfigValue
:
string
=
""
;
setConfigValue
:
string
=
""
;
pathId
:
string
=
""
;
pathId
:
string
=
""
;
userInputData
=
new
Map
<
string
,
string
>
();
userGetInputData
=
new
Map
<
string
,
string
>
();
pathwithVar
:
string
=
""
;
userSetInputData
=
new
Map
<
string
,
string
>
();
getPathwithVar
:
string
=
""
;
setPathwithVar
:
string
=
""
;
timer
?:
number
;
isShowPath
:
boolean
=
false
;
isShowPath
:
boolean
=
false
;
isShowParams
:
boolean
=
false
;
isShowGetParams
:
boolean
=
false
;
isShowSetParams
:
boolean
=
false
;
config
:
WidgetConfig
=
{
config
:
WidgetConfig
=
{
WidgetComponentName
:
"
Status
"
,
WidgetComponentName
:
"
Status
"
,
data
:
{
data
:
{
url
:
""
,
get
:{
url
:
""
,
userInputData
:
""
userInputData
:
""
},
set
:{
url
:
""
,
userInputData
:
""
}
}
}
};
};
created
()
{
created
()
{
// this.config.data.userInputData = this.userInputData;
// this.config.data.userInputData = this.userInputData;
this
.
config
.
data
.
userInputData
=
this
.
strMapObjChange
.
strMapToObj
(
this
.
userInputData
);
this
.
config
.
data
.
get
.
userInputData
=
this
.
strMapObjChange
.
strMapToObj
(
this
.
userGetInputData
);
this
.
config
.
data
.
set
.
userInputData
=
this
.
strMapObjChange
.
strMapToObj
(
this
.
userSetInputData
);
}
mounted
()
{
this
.
timer
=
setInterval
(
this
.
refresh
,
1000
);
}
destroyed
()
{
clearInterval
(
this
.
timer
);
}
updateUI
()
{
this
.
updateGetUI
();
this
.
updateSetUI
();
}
}
updateUI
()
{
update
Get
UI
()
{
this
.
isShowParams
=
true
;
this
.
isShow
Get
Params
=
true
;
var
url
=
this
.
config
.
data
.
url
;
var
url
=
this
.
config
.
data
.
get
.
url
;
this
.
pathId
=
url
.
slice
(
0
,
url
.
indexOf
(
"
/
"
));
this
.
pathId
=
url
.
slice
(
0
,
url
.
indexOf
(
"
/
"
));
(
this
.
$refs
.
WidgetParams
as
WidgetParams
).
setVariableList
(
(
this
.
$refs
.
WidgetGetParams
as
WidgetParams
).
setVariableList
(
this
.
pathProcessor
.
extractVarFromPath
(
url
)
);
}
updateSetUI
()
{
this
.
isShowSetParams
=
true
;
var
url
=
this
.
config
.
data
.
set
.
url
;
this
.
pathId
=
url
.
slice
(
0
,
url
.
indexOf
(
"
/
"
));
(
this
.
$refs
.
WidgetSetParams
as
WidgetParams
).
setVariableList
(
this
.
pathProcessor
.
extractVarFromPath
(
url
)
this
.
pathProcessor
.
extractVarFromPath
(
url
)
);
);
}
}
...
@@ -84,7 +130,8 @@ export default class Status extends Widget {
...
@@ -84,7 +130,8 @@ export default class Status extends Widget {
getConfig
():
WidgetConfig
{
getConfig
():
WidgetConfig
{
// this.config.data.userInputData =(this.$refs.WidgetParams as WidgetParams).getVariableValues();
// this.config.data.userInputData =(this.$refs.WidgetParams as WidgetParams).getVariableValues();
this
.
config
.
data
.
userInputData
=
this
.
strMapObjChange
.
strMapToObj
((
this
.
$refs
.
WidgetParams
as
WidgetParams
).
getVariableValues
());
this
.
config
.
data
.
get
.
userInputData
=
this
.
strMapObjChange
.
strMapToObj
((
this
.
$refs
.
WidgetGetParams
as
WidgetParams
).
getVariableValues
());
this
.
config
.
data
.
set
.
userInputData
=
this
.
strMapObjChange
.
strMapToObj
((
this
.
$refs
.
WidgetSetParams
as
WidgetParams
).
getVariableValues
());
return
this
.
config
;
return
this
.
config
;
}
}
...
@@ -92,14 +139,24 @@ export default class Status extends Widget {
...
@@ -92,14 +139,24 @@ export default class Status extends Widget {
this
.
config
=
widgetConfig
;
this
.
config
=
widgetConfig
;
this
.
updateUI
();
this
.
updateUI
();
//map不能序列化,必须要单独处理,这里的处理方法仅限map
<
string
,
string
>
类型
//map不能序列化,必须要单独处理,这里的处理方法仅限map
<
string
,
string
>
类型
var
temp
=
this
.
config
.
data
.
userInputData
;
//布置get输入参数
var
temp
=
this
.
config
.
data
.
get
.
userInputData
;
temp
=
JSON
.
parse
(
JSON
.
stringify
(
temp
));
console
.
log
(
temp
);
temp
=
this
.
strMapObjChange
.
objToStrMap
(
temp
);
console
.
log
(
temp
);
this
.
userGetInputData
=
temp
;
console
.
log
(
this
.
userGetInputData
);
/* */
(
this
.
$refs
.
WidgetGetParams
as
WidgetParams
).
setVariableInput
(
this
.
userGetInputData
);
//布置set输入参数
temp
=
this
.
config
.
data
.
set
.
userInputData
;
temp
=
JSON
.
parse
(
JSON
.
stringify
(
temp
));
temp
=
JSON
.
parse
(
JSON
.
stringify
(
temp
));
console
.
log
(
temp
);
console
.
log
(
temp
);
temp
=
this
.
strMapObjChange
.
objToStrMap
(
temp
);
temp
=
this
.
strMapObjChange
.
objToStrMap
(
temp
);
console
.
log
(
temp
);
console
.
log
(
temp
);
this
.
userInputData
=
temp
;
this
.
user
Set
InputData
=
temp
;
console
.
log
(
this
.
userInputData
);
/* */
console
.
log
(
this
.
user
Set
InputData
);
/* */
(
this
.
$refs
.
Widget
Params
as
WidgetParams
).
setVariableInput
(
this
.
user
InputData
);
(
this
.
$refs
.
Widget
SetParams
as
WidgetParams
).
setVariableInput
(
this
.
userSet
InputData
);
}
}
samplePoke
(
sample
:
ResourceInfo
[],
samplePath
:
string
)
samplePoke
(
sample
:
ResourceInfo
[],
samplePath
:
string
)
...
@@ -108,14 +165,22 @@ export default class Status extends Widget {
...
@@ -108,14 +165,22 @@ export default class Status extends Widget {
pokedPath
=
samplePath
;
pokedPath
=
samplePath
;
var
count
:
number
=
0
;
var
count
:
number
=
0
;
var
t
emp
=
sample
[
0
].
Parameters
;
var
getT
emp
=
sample
[
0
].
Parameters
;
temp
=
JSON
.
parse
(
JSON
.
stringify
(
t
emp
));
getTemp
=
JSON
.
parse
(
JSON
.
stringify
(
getT
emp
));
console
.
log
(
t
emp
);
console
.
log
(
getT
emp
);
temp
=
this
.
strMapObjChange
.
objToStrMap
(
t
emp
);
getTemp
=
this
.
strMapObjChange
.
objToStrMap
(
getT
emp
);
console
.
log
(
t
emp
);
console
.
log
(
getT
emp
);
sample
[
0
].
Parameters
=
t
emp
;
sample
[
0
].
Parameters
=
getT
emp
;
console
.
log
(
sample
[
0
].
Parameters
);
console
.
log
(
sample
[
0
].
Parameters
);
var
setTemp
=
sample
[
1
].
Parameters
;
setTemp
=
JSON
.
parse
(
JSON
.
stringify
(
setTemp
));
console
.
log
(
setTemp
);
setTemp
=
this
.
strMapObjChange
.
objToStrMap
(
setTemp
);
console
.
log
(
setTemp
);
sample
[
1
].
Parameters
=
setTemp
;
console
.
log
(
sample
[
1
].
Parameters
);
sample
[
0
].
Parameters
.
forEach
((
value
,
key
)
=>
{
sample
[
0
].
Parameters
.
forEach
((
value
,
key
)
=>
{
count
++
;
count
++
;
if
(
count
==
1
)
if
(
count
==
1
)
...
@@ -127,7 +192,23 @@ export default class Status extends Widget {
...
@@ -127,7 +192,23 @@ export default class Status extends Widget {
console
.
log
(
pokedPath
);
console
.
log
(
pokedPath
);
pokedPath
=
pokedPath
.
substring
(
0
,
pokedPath
.
length
-
1
);
pokedPath
=
pokedPath
.
substring
(
0
,
pokedPath
.
length
-
1
);
console
.
log
(
pokedPath
);
console
.
log
(
pokedPath
);
this
.
config
.
data
.
url
=
pokedPath
;
this
.
config
.
data
.
get
.
url
=
pokedPath
;
pokedPath
=
samplePath
;
count
=
0
;
sample
[
1
].
Parameters
.
forEach
((
value
,
key
)
=>
{
count
++
;
if
(
count
==
1
)
{
pokedPath
=
pokedPath
+
"
?
"
;
}
pokedPath
=
pokedPath
+
key
+
"
=$
"
+
key
+
"
$&
"
;
});
console
.
log
(
pokedPath
);
pokedPath
=
pokedPath
.
substring
(
0
,
pokedPath
.
length
-
1
);
console
.
log
(
pokedPath
);
this
.
config
.
data
.
set
.
url
=
pokedPath
;
}
}
pathPoke
()
pathPoke
()
...
@@ -143,7 +224,8 @@ export default class Status extends Widget {
...
@@ -143,7 +224,8 @@ export default class Status extends Widget {
replaceStartPath
(
startPath
:
string
):
void
replaceStartPath
(
startPath
:
string
):
void
{
{
this
.
config
.
data
.
url
.
replace
(
'
$startPath$
'
,
startPath
);
this
.
config
.
data
.
get
.
url
.
replace
(
'
$startPath$
'
,
startPath
);
this
.
config
.
data
.
set
.
url
.
replace
(
'
$startPath$
'
,
startPath
);
}
}
parentUpdate
(
payload
:
UpdatePayload
):
void
{
parentUpdate
(
payload
:
UpdatePayload
):
void
{
...
@@ -151,12 +233,19 @@ export default class Status extends Widget {
...
@@ -151,12 +233,19 @@ export default class Status extends Widget {
}
}
refresh
()
{
refresh
()
{
var
Args
:
UpdatePayload
=
{
var
Get
Args
:
UpdatePayload
=
{
action
:
"
get
"
,
action
:
"
get
"
,
variables
:
(
this
.
$refs
.
WidgetParams
as
WidgetParams
).
getVariableValues
(),
variables
:
(
this
.
$refs
.
Widget
Get
Params
as
WidgetParams
).
getVariableValues
(),
target
:
[
"
self
"
]
target
:
[
"
self
"
]
};
};
this
.
viewLoad
(
Args
);
this
.
viewGetLoad
(
GetArgs
);
var
SetArgs
:
UpdatePayload
=
{
action
:
"
set
"
,
variables
:
(
this
.
$refs
.
WidgetSetParams
as
WidgetParams
).
getVariableValues
(),
target
:
[
"
self
"
]
};
this
.
viewSetLoad
(
SetArgs
);
}
}
...
@@ -164,23 +253,45 @@ export default class Status extends Widget {
...
@@ -164,23 +253,45 @@ export default class Status extends Widget {
var
apiLoad
=
url
;
var
apiLoad
=
url
;
await
axios
.
get
(
apiLoad
).
then
(
response
=>
{
await
axios
.
get
(
apiLoad
).
then
(
response
=>
{
console
.
log
(
response
);
console
.
log
(
response
);
this
.
StatusValue
=
response
.
data
.
CFET2CORE_SAMPLE_VAL
;
this
.
getConfigValue
=
response
.
data
.
CFET2CORE_SAMPLE_VAL
;
console
.
log
(
this
.
StatusValue
);
console
.
log
(
this
.
getConfigValue
);
});
}
async
setData
(
url
:
string
)
{
var
apiLoad
=
url
;
await
axios
.
post
(
apiLoad
).
then
(
response
=>
{
console
.
log
(
response
);
this
.
setConfigValue
=
response
.
data
.
CFET2CORE_SAMPLE_VAL
;
console
.
log
(
this
.
setConfigValue
);
});
});
}
}
//called when widgetParams action clicked
//called when widgetParams action clicked
async
viewLoad
(
Args
:
UpdatePayload
)
{
async
viewGetLoad
(
Args
:
UpdatePayload
)
{
// this.config.data.userInputData = Args.variables;
this
.
userGetInputData
=
Args
.
variables
;
this
.
getPathwithVar
=
this
.
pathProcessor
.
FillPathWithVar
(
// this.config.data.userInputData,
this
.
userGetInputData
,
this
.
config
.
data
.
get
.
url
);
console
.
log
(
this
.
getConfigValue
);
console
.
log
(
this
.
getPathwithVar
);
await
this
.
getData
(
this
.
getPathwithVar
);
}
async
viewSetLoad
(
Args
:
UpdatePayload
)
{
// this.config.data.userInputData = Args.variables;
// this.config.data.userInputData = Args.variables;
this
.
userInputData
=
Args
.
variables
;
this
.
user
Set
InputData
=
Args
.
variables
;
this
.
p
athwithVar
=
this
.
pathProcessor
.
FillPathWithVar
(
this
.
setP
athwithVar
=
this
.
pathProcessor
.
FillPathWithVar
(
// this.config.data.userInputData,
// this.config.data.userInputData,
this
.
userInputData
,
this
.
user
Set
InputData
,
this
.
config
.
data
.
url
this
.
config
.
data
.
set
.
url
);
);
console
.
log
(
this
.
Status
Value
);
console
.
log
(
this
.
setConfig
Value
);
console
.
log
(
this
.
p
athwithVar
);
console
.
log
(
this
.
setP
athwithVar
);
await
this
.
getData
(
this
.
p
athwithVar
);
await
this
.
setData
(
this
.
setP
athwithVar
);
}
}
}
}
</
script
>
</
script
>
...
...
src/models/WidgetRef.ts
View file @
bc3f1ed7
...
@@ -9,7 +9,7 @@ export class WidgetRef {
...
@@ -9,7 +9,7 @@ export class WidgetRef {
//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
;
public
w
:
number
=
4
;
public
w
:
number
=
8
;
public
h
:
number
=
4
;
public
h
:
number
=
6
;
public
i
:
number
=
0
;
public
i
:
number
=
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment