core for app development

This commit is contained in:
Xuan Sang LE
2017-08-14 00:20:19 +02:00
parent f4c54c712d
commit 2985689217
43 changed files with 1414 additions and 172 deletions

View File

@ -0,0 +1,33 @@
coffee_files = main.coffee
jsfiles =
cssfiles = main.css
copyfiles = scheme.html package.json
BLUE=\033[1;34m
NC=\033[0m
main: title clean js css copy
title:
@echo "$(BLUE)======= Package ActivityMonitor =======$(NC)"
coffee:
- mkdir build
for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done
for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done
- rm build/*.coffee.js
js: coffee
for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done
css:
for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done
copy:
cp -rf $(copyfiles) build/
clean:
- rm -rf build/*

View File

@ -0,0 +1,56 @@
_PM = this.OS.PM
_APP = this.OS.APP
class ActivityMonitor extends this.OS.GUI.BaseApplication
constructor: () ->
super "ActivityMonitor"
main: () ->
me = @
@scheme.set "apptitle", "Activity Monitor"
@grid = @find "mygrid"
@on "btclick", (e)->
return unless e.id == "btkill"
item = me.grid.get "selected"
return unless item
app = _PM.appByPid item[0].value
app.quit() if app
header = [{width:50,value:"Pid"},{value:"Name"},{width:100,value:"Alive (ms)"}]
@gdata =
processes:{}
alive:[]
@grid.set "header",header
@monitor()
monitor: () ->
me = @
#get all current running process
me.gdata.alive = []
now = (new Date).getTime()
$.each _PM.processes, (i,d)->
$.each d , (j,a)->
if me.gdata.processes[a.pid] #update it
me.gdata.processes[a.pid][2].value = now - a.birth
else #add it
me.gdata.processes[a.pid] = [
{value:a.pid},
{icon:_APP[a.name].meta.icon,iconclass:_APP[a.name].meta.iconclass,value:a.name},
{value: now - a.birth}
]
me.gdata.alive.push a.pid
@refreshGrid()
@timer = setTimeout (()-> me.monitor()),500#one second
refreshGrid: ()->
activeList = []
me = @
$.each @gdata.processes, (i,e) ->
if ($.inArray (Number i),me.gdata.alive) >= 0
activeList.push e
else
me.gdata.processes[i] = undefined
@grid.set "rows",activeList
exit: (e) ->
clearTimeout @timer if @timer
ActivityMonitor.singleton = true
this.OS.register "ActivityMonitor",ActivityMonitor

View File

@ -0,0 +1,8 @@
afx-app-window[data-id="am-window"] afx-button{
margin: 3px;
}
afx-app-window[data-id="am-window"] afx-grid-view{
padding-left:10px;
padding-right: 10px;
}

View File

@ -0,0 +1,12 @@
{
"app":"ActivityMonitor",
"name":"Activity monitor",
"description":"Processes monitor and manager",
"author":{
"name": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"category":"System",
"iconclass":"fa fa-heartbeat",
"mimes":["*"]
}

View File

@ -0,0 +1,7 @@
<afx-app-window data-id = "am-window" apptitle="" width="400" height="300">
<afx-vbox>
<afx-hbox>
<afx-grid-view data-id = "mygrid"></afx-grid-view>
<afx-button data-height="30" data-id = "btkill" text = "Kill process" iconclass="fa fa-times"></afx-button>
</afx-hbox>
</afx-app-window>