rename JarvisControl to SystemControl

This commit is contained in:
lxsang 2021-01-12 14:58:49 +01:00
parent 8aff7831a1
commit a9c92fcff2
23 changed files with 14158 additions and 251 deletions

View File

@ -1,22 +0,0 @@
<afx-app-window apptitle="Jarvis monitoring" width="600" height="400" data-id="JarvisControl">
<afx-vbox >
<afx-hbox>
<afx-vbox>
<afx-label data-id="bat-text" data-height="22" text="__(Battery Usage:)"></afx-label>
<div data-id="battery-area" class="epoch category10"></div>
<afx-label data-id="temp-text" data-height="22" text="__(CPU temperature:)"></afx-label>
<div data-id="temp-area" class="epoch category10" ></div>
</afx-vbox>
<afx-vbox data-width="160">
<afx-label data-id="mem-text" data-height="22" text="__(Memory:)"></afx-label>
<div data-height="90" data-id="mem-area" class="epoch gauge-tiny"></div>
<afx-label data-id="disk-text" data-height="22" text="__(Disk:)"></afx-label>
<div data-height="90" data-id="disk-area" class="epoch gauge-tiny" ></div>
<afx-label data-id="cpu-text" data-height="22" text="__(CPU:)"></afx-label>
<div data-height="90" data-id="cpu-area" class="epoch gauge-tiny" ></div>
<div></div>
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-app-window>

File diff suppressed because one or more lines are too long

View File

@ -1,22 +0,0 @@
<afx-app-window apptitle="Jarvis monitoring" width="600" height="400" data-id="JarvisControl">
<afx-vbox >
<afx-hbox>
<afx-vbox>
<afx-label data-id="bat-text" data-height="22" text="__(Battery Usage:)"></afx-label>
<div data-id="battery-area" class="epoch category10"></div>
<afx-label data-id="temp-text" data-height="22" text="__(CPU temperature:)"></afx-label>
<div data-id="temp-area" class="epoch category10" ></div>
</afx-vbox>
<afx-vbox data-width="160">
<afx-label data-id="mem-text" data-height="22" text="__(Memory:)"></afx-label>
<div data-height="90" data-id="mem-area" class="epoch gauge-tiny"></div>
<afx-label data-id="disk-text" data-height="22" text="__(Disk:)"></afx-label>
<div data-height="90" data-id="disk-area" class="epoch gauge-tiny" ></div>
<afx-label data-id="cpu-text" data-height="22" text="__(CPU:)"></afx-label>
<div data-height="90" data-id="cpu-area" class="epoch gauge-tiny" ></div>
<div></div>
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -1,90 +0,0 @@
class JarvisService extends OS.application.BaseService
constructor: (args) ->
super "JarvisService", args
@text = __("Jarvis({0}%)", 0.toString())
@iconclass = "fa fa-android"
@nodes = [
{text: __("Status"), id: 1},
{text: __("Shutdown"), id: 3},
{text: __("Reboot"), id: 4},
{text: __("Exit service"), id: 2}
]
@onchildselect = (e) => @action e
init: () ->
checklib = () =>
if not Antunnel.tunnel
@error __("The Antunnel service is not started, please start it first")
@_gui.pushService("Antunnel/AntunnelService")
.catch (e) =>
@error e.toString(), e
@quit()
else
@tunnel = Antunnel.tunnel
@sub = new Antunnel.Subscriber("notification")
@sub.onopen = () =>
#@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode("Hello")
console.log("Subscribed to notification channel")
@sub.onerror = (e) =>
@error __("Error: {0}", new TextDecoder("utf-8").decode(e.data)), e
#@sub = undefined
@sub.onmessage = (e) =>
obj = JSON.parse(new TextDecoder("utf-8").decode(e.data)) if e.data
# update the battery
@text = __("Jarvis({0}%)", Math.round(obj.battery_percent).toString())
@update()
@sub.onclose = () =>
@sub = undefined
@notify __("Unsubscribed to the notification service")
@quit()
Antunnel.tunnel.subscribe @sub
if not window.Antunnel
console.log "require Antunnel"
@_api.requires("pkg://Antunnel/main.js").then () =>
checklib()
.catch (e) =>
@error __("Unable to load Antunnel: {0}",e.toString()), e
@quit()
else
checklib()
action: (e) ->
switch e.data.item.data.id
when 1
@_gui.launch "JarvisControl", []
when 2
@quit()
when 3
@execute("poweroff")
when 4
@execute("reboot")
execute: (cmd) ->
return unless @tunnel
sub = new Antunnel.Subscriber("jarvis_control")
sub.onopen = () =>
console.log("Subscribed to jarvis_control channel. Send the command")
sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode(cmd)
sub.close()
sub.onerror = (e) =>
@error __("Error: {0}", new TextDecoder("utf-8").decode(e.data)), e
#@sub = undefined
sub.onclose = () =>
@notify __("Unsubscribed to the jarvis_control service")
@tunnel.subscribe sub
awake: () ->
cleanup: () ->
@sub.close() if @sub
this.OS.register "JarvisService", JarvisService

View File

@ -1,99 +0,0 @@
class JarvisControl extends this.OS.application.BaseApplication
constructor: ( args ) ->
super "JarvisControl", args
main: () ->
@batterychart = $(@find("battery-area")).epoch({
type: 'time.line',
axes: ['bottom', 'left', "right"],
range: [2500, 4300]
data: [{
label: "Battery",
values: []
}]
})
@tempchart = $(@find("temp-area")).epoch({
type: 'time.line',
axes: ['bottom', 'left', "right"],
range: [0, 100],
data: [{
label: "Temperature",
values: []
}]
})
@memchart = $(@find("mem-area")).epoch({
type: 'time.gauge',
value: 0
})
@diskchart = $(@find("disk-area")).epoch({
type: 'time.gauge',
value: 0
})
@cpuchart = $(@find("cpu-area")).epoch({
type: 'time.gauge',
value: 0
})
checklib = () =>
if not Antunnel.tunnel
@error __("The Antunnel service is not started, please start it first")
.catch (e) =>
@error e.toString(), e
@quit()
else
@tunnel = Antunnel.tunnel
@sub = new Antunnel.Subscriber("notification")
@sub.onopen = () =>
#@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode("Hello")
console.log("Subscribed to notification channel")
@_gui.pushService("JarvisControl/JarvisService")
@sub.onerror = (e) =>
@error __("Error: {0}", new TextDecoder("utf-8").decode(e.data)), e
#@sub = undefined
@sub.onmessage = (e) =>
obj = JSON.parse(new TextDecoder("utf-8").decode(e.data)) if e.data
# update the battery
@display obj
@sub.onclose = () =>
@sub = undefined
@notify __("Unsubscribed to the notification service")
@quit()
Antunnel.tunnel.subscribe @sub
@on "resize", () =>
el = @find("battery-area")
@batterychart.option("width", $(el).width())
@batterychart.option("height", $(el).height())
el = @find("temp-area")
@tempchart.option("width", $(el).width())
@tempchart.option("height", $(el).height())
checklib()
display: (data) ->
mem_percent = parseFloat(data.mem.match(/([0-9\.]+)%/)[1])
@memchart.push mem_percent / 100.0
@find("mem-text").text = data.mem
disk_percent = parseFloat(data.disk.match(/([0-9\.]+)%/)[1])
@diskchart.push disk_percent / 100.0
@find("disk-text").text = data.disk
cpu_percent = parseFloat(data.cpu.match(/([0-9\.]+)$/)[1])
@cpuchart.push cpu_percent / 100.0
@find("cpu-text").text = data.cpu
@batterychart.push [{time: (new Date()).timestamp(), y: data.battery}]
@find("bat-text").text = __("Battery Usage: {0} mv ({1}%)", data.battery, Math.round(data.battery_percent))
@tempchart.push [{time: (new Date()).timestamp(), y: data.temp}]
@find("temp-text").text = __("CPU temperature: {0} C", data.temp)
cleanup: () ->
return unless @sub
@sub.close()
JarvisControl.singleton = true
this.OS.register "JarvisControl", JarvisControl

View File

@ -1,7 +0,0 @@
{
"name": "JarvisControl",
"css": ["css/epoch.css"],
"javascripts": ["javascripts/d3.v3.js", "javascripts/epoch.js"],
"coffees": ["coffees/JarvisService.coffee", "coffees/main.coffee"],
"copies": ["assets/scheme.html", "package.json", "README.md"]
}

View File

@ -0,0 +1,33 @@
<afx-app-window apptitle="System monitoring" width="700" height="450" data-id="SystemControl">
<afx-vbox >
<afx-hbox>
<afx-vbox>
<div data-height="5"></div>
<div data-id="cpu-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="cpu-area" class="epoch category10"></div>
<div data-id="memory-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="memory-area" class="epoch category10"></div>
<div data-id="network-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="network-area" class="epoch category10"></div>
<div data-height="5"></div>
</afx-vbox>
<afx-vbox data-width="300">
<div data-height="5"></div>
<div data-id="temp-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="temp-area" class="epoch category10"></div>
<div data-id="battery-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="battery-area" class="epoch category10"></div>
<afx-label data-id="disk-text" data-height="22" text="__(Disk:)"></afx-label>
<div data-id="disk-area" class="epoch gauge-tiny" ></div>
<div data-height="5"></div>
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -1493,3 +1493,42 @@ div#_canvas_css_reference svg { position: absolute; width: 0; height: 0; top: -1
.epoch-theme-dark .epoch.category20c .arc.category20 path { fill: #52447F; } .epoch-theme-dark .epoch.category20c .arc.category20 path { fill: #52447F; }
.epoch-theme-dark .epoch.category20c .bar.category20 { fill: #52447F; } .epoch-theme-dark .epoch.category20c .bar.category20 { fill: #52447F; }
afx-app-window[data-id="SystemControl"] .legend-color {
display: block;
height: 20px;
width: 20px;
border-radius: 25px;
}
afx-app-window[data-id="SystemControl"] .afx-window-content {
color: black;
background-color: whitesmoke;
}
afx-app-window[data-id="SystemControl"] afx-label[data-id="disk-text"] i.label-text
{
font-weight: bold;
padding-left: 10px;
}
afx-app-window[data-id="SystemControl"] .legend
{
padding-left: 20px;
}
afx-app-window[data-id="SystemControl"] .legend div {
float: left;
font-size: 12px;
margin-right: 3px;
}
afx-app-window[data-id="SystemControl"] .legend div.legend-label {
padding-top: 3px;
font-weight: bold;
}
afx-app-window[data-id="SystemControl"] .legend div.legend-value {
padding-top: 4px;
margin-right: 5px;
min-width: 30px;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,19 @@
{ {
"pkgname": "JarvisControl", "pkgname": "SystemMonitor",
"app":"JarvisControl", "app":"SystemMonitor",
"name":"Jarvis monitoring", "name":"Jarvis monitoring",
"services": [ "services": [
"JarvisService" "SysmondService"
], ],
"description":"JarvisControl", "description":"System monitoring",
"info":{ "info":{
"author": "", "author": "",
"email": "" "email": ""
}, },
"version":"0.1.3-a", "dependencies": [
"Antunnel@0.1.8-a"
],
"version":"0.1.4-a",
"category":"Other", "category":"Other",
"iconclass":"fa fa-android", "iconclass":"fa fa-android",
"mimes":["none"], "mimes":["none"],

View File

@ -0,0 +1,33 @@
<afx-app-window apptitle="System monitoring" width="700" height="450" data-id="SystemControl">
<afx-vbox >
<afx-hbox>
<afx-vbox>
<div data-height="5"></div>
<div data-id="cpu-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="cpu-area" class="epoch category10"></div>
<div data-id="memory-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="memory-area" class="epoch category10"></div>
<div data-id="network-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="network-area" class="epoch category10"></div>
<div data-height="5"></div>
</afx-vbox>
<afx-vbox data-width="300">
<div data-height="5"></div>
<div data-id="temp-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="temp-area" class="epoch category10"></div>
<div data-id="battery-text" data-height="22" class = "epoch category10 legend"></div>
<div data-id="battery-area" class="epoch category10"></div>
<afx-label data-id="disk-text" data-height="22" text="__(Disk:)"></afx-label>
<div data-id="disk-area" class="epoch gauge-tiny" ></div>
<div data-height="5"></div>
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -0,0 +1,77 @@
class SysmondService extends OS.application.BaseService
constructor: (args) ->
super "SysmondService", args
@text = __("{0}%", 0.toString())
@iconclass = "fa fa-android"
@app = undefined
#@nodes = [
# {text: __("Status"), id: 1},
# {text: __("Shutdown"), id: 3},
# {text: __("Reboot"), id: 4},
# {text: __("Exit service"), id: 2}
#]
@onmenuselect = (e) => @openApp()
init: () ->
checklib = () =>
if not Antunnel.tunnel
@error __("The Antunnel service is not started, please start it first")
@_gui.pushService("Antunnel/AntunnelService")
.catch (e) =>
@error e.toString(), e
@quit()
else
@tunnel = Antunnel.tunnel
@sub = new Antunnel.Subscriber("fbf070ddea3ea90d07f456540b405d302554ec82")
@sub.onopen = () =>
#@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode("Hello")
console.log("Subscribed to notification channel")
@sub.onerror = (e) =>
@error __("Error: {0}", new TextDecoder("utf-8").decode(e.data)), e
#@sub = undefined
@sub.onmessage = (e) =>
obj = JSON.parse(new TextDecoder("utf-8").decode(e.data)) if e.data
# update the battery
@text = __("{0}%", Math.round(obj.battery_percent).toString())
@app.feed obj if @app
@update()
@sub.onclose = () =>
@sub = undefined
@notify __("Unsubscribed to the notification service")
@quit()
Antunnel.tunnel.subscribe @sub
checklib()
openApp: () ->
return if @app
@_gui.launch "SystemControl", []
execute: (cmd) ->
#return unless @tunnel
#sub = new Antunnel.Subscriber("jarvis_control")
#sub.onopen = () =>
# console.log("Subscribed to jarvis_control channel. Send the command")
# sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode(cmd)
# sub.close()
#sub.onerror = (e) =>
# @error __("Error: {0}", new TextDecoder("utf-8").decode(e.data)), e
#@sub = undefined
#sub.onclose = () =>
# @notify __("Unsubscribed to the jarvis_control service")
#@tunnel.subscribe sub
awake: () ->
cleanup: () ->
@sub.close() if @sub
this.OS.register "SysmondService", SysmondService

View File

@ -0,0 +1,146 @@
class SystemControl extends this.OS.application.BaseApplication
constructor: ( args ) ->
super "SystemControl", args
main: () ->
@diskchart = $(@find("disk-area")).epoch({
type: 'time.gauge',
value: 0
});
@on "resize", () =>
el = @find("cpu-area")
if @cpu
$(el).children().hide()
@cpu.option("width", $(el).width())
@cpu.option("height", $(el).height())
$(el).children().show()
el = @find("battery-area")
el = @find("memory-area")
if @memory
$(el).children().hide()
@memory.option("width", $(el).width())
@memory.option("height", $(el).height())
$(el).children().show()
el = @find("network-area")
if @network
$(el).children().hide()
@network.option("width", $(el).width())
@network.option("height", $(el).height())
$(el).children().show()
el = @find("temp-area")
if @temp
$(el).children().hide()
@temp.option("width", $(el).width())
@temp.option("height", $(el).height())
$(el).children().show()
el = @find("battery-area")
if @battery
$(el).children().hide()
@battery.option("width", $(el).width())
@battery.option("height", $(el).height())
$(el).children().show()
@_gui.pushService("SystemControl/SysmondService", [])
.then (p) =>
@service = p
p.app = @
.catch (e) =>
@error __("Unable to start sysmond service"), e
streamline: (name, data, range, labels) ->
i = 0
legend = $(@find("#{name}-text"))
if not @[name]
options = {
type: 'time.line',
axes: ['bottom', 'left', "right"]
}
options.range = range if range
dobj = []
for item in data
dobj.push { label: "label-#{i}", values: [] }
$("<div>")
.addClass('legend-color')
.addClass('ref')
.addClass('category' + (i+1))
.appendTo(legend)
$("<div>")
.addClass('legend-label')
.appendTo(legend)
.text(if labels then labels[i] else "#{name}-#{i}")
$("<div>")
.addClass('legend-value')
.appendTo(legend)
i = i + 1
options.data =dobj
@[name] = $(@find("#{name}-area")).epoch(options)
for item in data
$(legend.children()[i*3 + 2]).text( item.y.toString() )
i = i + 1
@[name].push data
feed: (data) ->
#mem_percent = parseFloat(data.mem.match(/([0-9\.]+)%/)[1])
#@memchart.push mem_percent / 100.0
#@find("mem-text").text = data.mem
disk_used = data.disk_total - data.disk_free
@diskchart.push(disk_used / data.disk_total)
@find("disk-text").text = "Disk: " + (Math.round(disk_used / 1024 / 1024 / 1024)) + "/" + (Math.round(data.disk_total / 1024 / 1024 / 1024)) + " GB"
now = data.stamp_sec
data.cpu_usages.shift()
cpu_data = ({ time: now, y: v.toFixed(2) } for v in data.cpu_usages)
@streamline "cpu", cpu_data, [0, 100]
total_mem = data.mem_total / 1024.0 / 1024.0
used_mem = data.mem_used / 1024.0 / 1024.0
total_swap = data.mem_swap_total / 1024.0 / 1024.0
used_swap = (data.mem_swap_total - data.mem_swap_free) / 1024.0 / 1024.0
mem_data = [
{ time: now, y: used_mem.toFixed(3)},
{ time: now, y: used_swap.toFixed(3)}
]
mem_range = [0, if total_mem > total_swap then total_mem else total_swap]
@streamline "memory", mem_data, mem_range, ["RAM (GB)", "SWAP (GB)"]
net_rx = 0
net_tx = 0
net_rx = net_rx + v.rx_rate for v in data.net
net_tx = net_tx + v.tx_rate for v in data.net
net_data = [
{ time: now, y: (net_rx / 1024.0).toFixed(3)},
{ time: now, y: (net_tx / 1024.0).toFixed(3)}
]
@streamline "network", net_data, undefined, ["RX (Kb/s)", "TX (Kb/s)"]
temp_data = [
{ time: now, y: (data.cpu_temp / 1000.0).toFixed(2)},
{ time: now, y: (data.gpu_temp / 1000.0).toFixed(2)}
]
@streamline "temp", temp_data, undefined, ["CPU temp (C)", "GPU temp (C)"]
battery_range = [
(data.battery_min_voltage / 1000.0).toFixed(2),
(data.battery_max_voltage / 1000.0).toFixed(2)]
@streamline "battery", [ { time: now, y: (data.battery/ 1000.0).toFixed(2)} ], battery_range, ["Baterry (v)"]
cleanup: () ->
return unless @service
@service.app = undefined
@service = undefined
SystemControl.singleton = true
SystemControl.dependencies = [
"pkg://Antunnel/main.js"
]
this.OS.register "SystemControl", SystemControl

View File

@ -0,0 +1,38 @@
afx-app-window[data-id="SystemControl"] .legend-color {
display: block;
height: 20px;
width: 20px;
border-radius: 25px;
}
afx-app-window[data-id="SystemControl"] .afx-window-content {
color: black;
background-color: whitesmoke;
}
afx-app-window[data-id="SystemControl"] afx-label[data-id="disk-text"] i.label-text
{
font-weight: bold;
padding-left: 10px;
}
afx-app-window[data-id="SystemControl"] .legend
{
padding-left: 20px;
}
afx-app-window[data-id="SystemControl"] .legend div {
float: left;
font-size: 12px;
margin-right: 3px;
}
afx-app-window[data-id="SystemControl"] .legend div.legend-label {
padding-top: 3px;
font-weight: bold;
}
afx-app-window[data-id="SystemControl"] .legend div.legend-value {
padding-top: 4px;
margin-right: 5px;
min-width: 30px;
}

View File

@ -1,16 +1,19 @@
{ {
"pkgname": "JarvisControl", "pkgname": "SystemMonitor",
"app":"JarvisControl", "app":"SystemMonitor",
"name":"Jarvis monitoring", "name":"Jarvis monitoring",
"services": [ "services": [
"JarvisService" "SysmondService"
], ],
"description":"JarvisControl", "description":"System monitoring",
"info":{ "info":{
"author": "", "author": "",
"email": "" "email": ""
}, },
"version":"0.1.3-a", "dependencies": [
"Antunnel@0.1.8-a"
],
"version":"0.1.4-a",
"category":"Other", "category":"Other",
"iconclass":"fa fa-android", "iconclass":"fa fa-android",
"mimes":["none"], "mimes":["none"],

View File

@ -0,0 +1,7 @@
{
"name": "SystemControl",
"css": ["css/epoch.css", "css/main.css"],
"javascripts": ["javascripts/d3.v3.js", "javascripts/epoch.js"],
"coffees": ["coffees/SysmondService.coffee", "coffees/main.coffee"],
"copies": ["assets/scheme.html", "package.json", "README.md"]
}