Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanli
evm-store
Commits
e1bc1a28
Commit
e1bc1a28
authored
Sep 09, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat: 更新监视器
parent
4842c1df
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
205 additions
and
462 deletions
+205
-462
backend/controller/monitor.py
backend/controller/monitor.py
+16
-13
frontend/src/utils/eventBus.js
frontend/src/utils/eventBus.js
+3
-11
frontend/src/views/system/bytecode-tool.vue
frontend/src/views/system/bytecode-tool.vue
+1
-1
frontend/src/views/system/components/EvmChart.vue
frontend/src/views/system/components/EvmChart.vue
+3
-28
frontend/src/views/system/components/LvglChart.vue
frontend/src/views/system/components/LvglChart.vue
+18
-94
frontend/src/views/system/components/SystemChart.vue
frontend/src/views/system/components/SystemChart.vue
+29
-61
frontend/src/views/system/monitor.vue
frontend/src/views/system/monitor.vue
+135
-254
No files found.
backend/controller/monitor.py
View file @
e1bc1a28
...
@@ -10,6 +10,7 @@ import jwt
...
@@ -10,6 +10,7 @@ import jwt
import
json
import
json
import
time
import
time
import
logging
import
logging
from
copy
import
deepcopy
from
app
import
config
from
app
import
config
from
model.monitor
import
session
,
System
,
Lvgl
,
Evm
,
Image
,
Device
,
Request
,
User
from
model.monitor
import
session
,
System
,
Lvgl
,
Evm
,
Image
,
Device
,
Request
,
User
...
@@ -71,7 +72,7 @@ class EvmResource(object):
...
@@ -71,7 +72,7 @@ class EvmResource(object):
result
=
Evm
(
**
data
)
result
=
Evm
(
**
data
)
session
.
add
(
result
)
session
.
add
(
result
)
return
session
.
commit
()
return
session
.
commit
()
def
put
(
self
):
def
put
(
self
):
pass
pass
...
@@ -237,26 +238,31 @@ class MonitorManager(object):
...
@@ -237,26 +238,31 @@ class MonitorManager(object):
return
None
return
None
if
msg
.
get
(
"request"
):
if
msg
.
get
(
"request"
):
msg
.
get
(
"request"
)
.
update
({
"watch"
:
watch_id
})
obj
=
deepcopy
(
msg
.
get
(
"request"
))
result
=
Request
(
**
msg
.
get
(
"request"
))
obj
.
update
({
"watch"
:
watch_id
})
result
=
Request
(
**
obj
)
session
.
add
(
result
)
session
.
add
(
result
)
session
.
flush
()
session
.
flush
()
session
.
commit
()
session
.
commit
()
if
msg
.
get
(
"system"
):
if
msg
.
get
(
"system"
):
msg
.
get
(
"system"
)
.
update
({
"watch"
:
watch_id
})
obj
=
deepcopy
(
msg
.
get
(
"system"
))
systemResource
.
post
(
msg
.
get
(
"system"
))
obj
.
update
({
"watch"
:
watch_id
})
systemResource
.
post
(
obj
)
if
msg
.
get
(
"lvgl"
):
if
msg
.
get
(
"lvgl"
):
msg
.
get
(
"lvgl"
)
.
update
({
"watch"
:
watch_id
})
obj
=
deepcopy
(
msg
.
get
(
"lvgl"
))
lvglResource
.
post
(
msg
.
get
(
"lvgl"
))
obj
.
update
({
"watch"
:
watch_id
})
lvglResource
.
post
(
obj
)
if
msg
.
get
(
"evm"
):
if
msg
.
get
(
"evm"
):
msg
.
get
(
"evm"
)
.
update
({
"watch"
:
watch_id
})
obj
=
deepcopy
(
msg
.
get
(
"evm"
))
evmResource
.
post
(
msg
.
get
(
"evm"
))
obj
.
update
({
"watch"
:
watch_id
})
evmResource
.
post
(
obj
)
if
msg
.
get
(
"image"
):
if
msg
.
get
(
"image"
):
imageResource
.
post_array
(
msg
.
get
(
"image"
),
watch_id
)
obj
=
deepcopy
(
msg
.
get
(
"image"
))
imageResource
.
post_array
(
obj
,
watch_id
)
def
check_client
(
self
,
instance
):
def
check_client
(
self
,
instance
):
index
=
-
1
index
=
-
1
...
@@ -267,7 +273,6 @@ class MonitorManager(object):
...
@@ -267,7 +273,6 @@ class MonitorManager(object):
return
index
return
index
def
receive_message
(
self
,
instance
,
message
):
def
receive_message
(
self
,
instance
,
message
):
print
(
instance
.
_clients
,
message
)
if
message
.
get
(
"type"
)
and
message
.
get
(
"token"
):
if
message
.
get
(
"type"
)
and
message
.
get
(
"token"
):
# 获取token值,检验正确与否,获取uuid
# 获取token值,检验正确与否,获取uuid
payload
=
jwt
.
decode
(
message
.
get
(
"token"
),
config
[
'SECRET_KEY'
],
verify
=
True
,
algorithms
=
[
'HS256'
],
options
=
{
'verify_aud'
:
False
})
payload
=
jwt
.
decode
(
message
.
get
(
"token"
),
config
[
'SECRET_KEY'
],
verify
=
True
,
algorithms
=
[
'HS256'
],
options
=
{
'verify_aud'
:
False
})
...
@@ -297,8 +302,6 @@ class MonitorManager(object):
...
@@ -297,8 +302,6 @@ class MonitorManager(object):
return
json
.
dumps
({
'code'
:
200
,
'data'
:
None
,
'msg'
:
'unkonw message packet, disconnect by server'
})
return
json
.
dumps
({
'code'
:
200
,
'data'
:
None
,
'msg'
:
'unkonw message packet, disconnect by server'
})
def
broadcast_message
(
self
,
clients
,
message
):
def
broadcast_message
(
self
,
clients
,
message
):
print
(
clients
,
message
)
if
not
message
.
get
(
"imei"
):
if
not
message
.
get
(
"imei"
):
return
False
return
False
...
...
frontend/src/utils/eventBus.js
View file @
e1bc1a28
/*
* @Author: your name
* @Date: 2021-07-01 15:02:16
* @LastEditTime: 2021-08-07 18:29:02
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \evm-store\frontend\src\utils\eventBus.js
*/
import
Vue
from
"
vue
"
;
import
Vue
from
"
vue
"
;
// import store from "@/store";
// import store from "@/store";
export
let
wsNotify
=
new
WebSocket
(
export
let
wsNotify
=
new
WebSocket
(
`ws://
${
window
.
location
.
hostname
}
:3000/ws/v1/notify`
`ws://
localhost
:3000/ws/v1/notify`
);
);
window
.
wsNotify
=
wsNotify
;
window
.
wsNotify
=
wsNotify
;
...
@@ -19,9 +11,9 @@ wsNotify.eventBus = new Vue();
...
@@ -19,9 +11,9 @@ wsNotify.eventBus = new Vue();
wsNotify
.
eventBus
.
$on
(
"
reconnect
"
,
()
=>
{
wsNotify
.
eventBus
.
$on
(
"
reconnect
"
,
()
=>
{
wsNotify
=
new
WebSocket
(
wsNotify
=
new
WebSocket
(
`ws://
${
window
.
location
.
hostname
}
:3000/ws/v1/notify`
`ws://
localhost
:3000/ws/v1/notify`
);
);
})
})
;
// let timer = null;
// let timer = null;
...
...
frontend/src/views/system/bytecode-tool.vue
View file @
e1bc1a28
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<div
class=
"el-upload__text"
>
<div
class=
"el-upload__text"
>
将文件拖到此处,或
<em>
点击上传
</em>
将文件拖到此处,或
<em>
点击上传
</em>
</div>
</div>
<div
class=
"el-upload__tip"
slot=
"tip"
>
请选择
evue文件
</div>
<div
class=
"el-upload__tip"
slot=
"tip"
>
请选择
文件(目前支持.js/.evue格式)
</div>
</el-upload>
</el-upload>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
...
...
frontend/src/views/system/components/EvmChart.vue
View file @
e1bc1a28
...
@@ -9,40 +9,15 @@ import resize from "./mixins/resize";
...
@@ -9,40 +9,15 @@ import resize from "./mixins/resize";
import
{
getDateTimeString
}
from
"
@/utils/utils
"
;
import
{
getDateTimeString
}
from
"
@/utils/utils
"
;
import
{
wsNotify
}
from
"
@/utils/eventBus.js
"
;
import
{
wsNotify
}
from
"
@/utils/eventBus.js
"
;
// function randomData() {
// now = new Date(+now + oneDay);
// value = value + Math.random() * 21 - 10;
// return {
// name: "EVM",
// value: [
// [now.getFullYear(), now.getMonth() + 1, now.getDate()].join("/") +
// " " +
// [now.getHours(), now.getMinutes() + 1, now.getSeconds()].join(":"),
// Math.round(value),
// ],
// };
// }
// const dataList = [];
// let now = +new Date(1997, 9, 3);
// const oneDay = 24 * 3600 * 1000;
// var value = Math.random() * 1000;
// for (var i = 0; i
<
1000
;
i
++
)
{
// dataList.push(randomData());
// }
let
chart
=
null
;
let
chart
=
null
;
const
seriesData
=
{
const
seriesData
=
{
evue_free_size
:
[],
evue_free_size
:
[],
evue_total_size
:
[],
evue_used_size
:
[],
evue_used_size
:
[],
ext_total_size
:
[],
ext_used_size
:
[],
heap_total_size
:
[],
heap_used_size
:
[],
heap_used_size
:
[],
stack_total_size
:
[],
stack_used_size
:
[],
stack_used_size
:
[]
ext_used_size
:
[],
app_size
:
[]
};
};
export
default
{
export
default
{
...
...
frontend/src/views/system/components/LvglChart.vue
View file @
e1bc1a28
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<
script
>
<
script
>
import
*
as
echarts
from
"
echarts
"
;
import
*
as
echarts
from
"
echarts
"
;
require
(
"
echarts/theme/macarons
"
);
// echarts theme
require
(
"
echarts/theme/macarons
"
);
import
resize
from
"
./mixins/resize
"
;
import
resize
from
"
./mixins/resize
"
;
import
{
getDateTimeString
}
from
"
@/utils/utils
"
;
import
{
getDateTimeString
}
from
"
@/utils/utils
"
;
import
{
wsNotify
}
from
"
@/utils/eventBus.js
"
;
import
{
wsNotify
}
from
"
@/utils/eventBus.js
"
;
...
@@ -44,96 +44,11 @@ export default {
...
@@ -44,96 +44,11 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
dataList
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
data
()
{
data
()
{
return
{
return
{
series
:
[
series
:
[],
{
legendData
:
Object
.
keys
(
seriesData
),
name
:
"
frag_pct
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
scale
:
false
,
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
frag_pct
,
},
{
name
:
"
free_biggest_size
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
free_biggest_size
,
},
{
name
:
"
free_cnt
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
free_cnt
,
},
{
name
:
"
free_size
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
free_size
,
},
{
name
:
"
total_size
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
total_size
,
},
{
name
:
"
used_cnt
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
used_cnt
,
},
{
name
:
"
used_pct
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
used_pct
,
},
],
legendData
:
[
"
frag_pct
"
,
"
free_biggest_size
"
,
"
free_cnt
"
,
"
free_size
"
,
"
total_size
"
,
"
used_cnt
"
,
"
used_pct
"
,
],
};
};
},
},
watch
:
{
watch
:
{
...
@@ -143,14 +58,23 @@ export default {
...
@@ -143,14 +58,23 @@ export default {
this
.
handleMessage
(
val
);
this
.
handleMessage
(
val
);
},
},
},
},
dataList
:
{
deep
:
true
,
handler
(
val
)
{
if
(
val
.
length
>
0
)
this
.
handleData
(
val
);
},
},
},
},
mounted
()
{
mounted
()
{
let
array
=
[];
Object
.
keys
(
seriesData
).
forEach
((
k
)
=>
{
array
.
push
({
name
:
k
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
[
k
],
});
});
this
.
series
=
array
;
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
initChart
();
this
.
initChart
();
});
});
...
...
frontend/src/views/system/components/SystemChart.vue
View file @
e1bc1a28
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<
script
>
<
script
>
import
*
as
echarts
from
"
echarts
"
;
import
*
as
echarts
from
"
echarts
"
;
require
(
"
echarts/theme/macarons
"
);
// echarts theme
require
(
"
echarts/theme/macarons
"
);
import
resize
from
"
./mixins/resize
"
;
import
resize
from
"
./mixins/resize
"
;
import
{
getDateTimeString
}
from
"
@/utils/utils
"
;
import
{
getDateTimeString
}
from
"
@/utils/utils
"
;
import
{
wsNotify
}
from
"
@/utils/eventBus.js
"
;
import
{
wsNotify
}
from
"
@/utils/eventBus.js
"
;
...
@@ -15,7 +15,7 @@ const seriesData = {
...
@@ -15,7 +15,7 @@ const seriesData = {
used_space_size
:
[],
used_space_size
:
[],
};
};
let
chart
=
null
let
chart
=
null
;
export
default
{
export
default
{
mixins
:
[
resize
],
mixins
:
[
resize
],
...
@@ -40,47 +40,10 @@ export default {
...
@@ -40,47 +40,10 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
dataList
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
data
()
{
data
()
{
return
{
return
{
series
:
[
series
:
[],
{
name
:
"
free_size
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
scale
:
false
,
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
free_size
,
},
{
name
:
"
free_space_size
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
free_space_size
,
},
{
name
:
"
used_space_size
"
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
.
used_space_size
,
},
],
legendData
:
Object
.
keys
(
seriesData
),
legendData
:
Object
.
keys
(
seriesData
),
};
};
},
},
...
@@ -91,14 +54,23 @@ export default {
...
@@ -91,14 +54,23 @@ export default {
this
.
handleMessage
(
val
);
this
.
handleMessage
(
val
);
},
},
},
},
dataList
:
{
deep
:
true
,
handler
(
val
)
{
if
(
val
.
length
>
0
)
this
.
handleData
(
val
);
},
},
},
},
mounted
()
{
mounted
()
{
let
array
=
[];
Object
.
keys
(
seriesData
).
forEach
((
k
)
=>
{
array
.
push
({
name
:
k
,
type
:
"
line
"
,
showSymbol
:
false
,
emphasis
:
{
focus
:
"
series
"
,
blurScope
:
"
coordinateSystem
"
,
},
data
:
seriesData
[
k
],
});
});
this
.
series
=
array
;
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
initChart
();
this
.
initChart
();
});
});
...
@@ -113,13 +85,13 @@ export default {
...
@@ -113,13 +85,13 @@ export default {
});
});
wsNotify
.
eventBus
.
$on
(
"
resize
"
,
()
=>
{
wsNotify
.
eventBus
.
$on
(
"
resize
"
,
()
=>
{
if
(
chart
)
chart
.
resize
()
if
(
chart
)
chart
.
resize
()
;
});
});
wsNotify
.
eventBus
.
$on
(
"
clear-system-chart
"
,
()
=>
{
wsNotify
.
eventBus
.
$on
(
"
clear-system-chart
"
,
()
=>
{
chart
.
clear
()
chart
.
clear
()
;
this
.
setOptions
()
this
.
setOptions
()
;
})
})
;
},
},
beforeDestroy
()
{
beforeDestroy
()
{
if
(
!
chart
)
{
if
(
!
chart
)
{
...
@@ -130,11 +102,11 @@ export default {
...
@@ -130,11 +102,11 @@ export default {
},
},
methods
:
{
methods
:
{
handleData
(
data
)
{
handleData
(
data
)
{
Object
.
keys
(
seriesData
).
forEach
(
key
=>
{
Object
.
keys
(
seriesData
).
forEach
(
(
key
)
=>
{
seriesData
[
key
]
=
[]
seriesData
[
key
]
=
[]
;
});
});
this
.
series
.
forEach
(
item
=>
{
this
.
series
.
forEach
(
(
item
)
=>
{
item
.
data
=
[]
item
.
data
=
[]
;
});
});
// chart.dispose();
// chart.dispose();
chart
.
setOption
({
series
:
this
.
series
});
chart
.
setOption
({
series
:
this
.
series
});
...
@@ -180,9 +152,7 @@ export default {
...
@@ -180,9 +152,7 @@ export default {
},
},
xAxis
:
{
xAxis
:
{
type
:
"
time
"
,
type
:
"
time
"
,
splitLine
:
{
splitLine
:
{},
},
axisLabel
:
{
axisLabel
:
{
formatter
:
"
{HH}:{mm}:{ss}
"
,
formatter
:
"
{HH}:{mm}:{ss}
"
,
},
},
...
@@ -190,9 +160,7 @@ export default {
...
@@ -190,9 +160,7 @@ export default {
yAxis
:
{
yAxis
:
{
type
:
"
value
"
,
type
:
"
value
"
,
// boundaryGap: [0, "100%"],
// boundaryGap: [0, "100%"],
splitLine
:
{
splitLine
:
{},
},
},
},
tooltip
:
{
tooltip
:
{
trigger
:
"
axis
"
,
trigger
:
"
axis
"
,
...
@@ -207,7 +175,7 @@ export default {
...
@@ -207,7 +175,7 @@ export default {
selected
:
{
selected
:
{
free_size
:
true
,
free_size
:
true
,
free_space_size
:
true
,
free_space_size
:
true
,
used_space_size
:
false
used_space_size
:
false
,
},
},
},
},
series
:
this
.
series
,
series
:
this
.
series
,
...
...
frontend/src/views/system/monitor.vue
View file @
e1bc1a28
This diff is collapsed.
Click to expand it.
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