mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-02-21 17:32:47 +01:00
dynamic system menu
This commit is contained in:
parent
ad22c6e356
commit
33ab53dddb
1
TODO
1
TODO
@ -1,3 +1,2 @@
|
||||
VFS mountpoints object (selected) is changed between apps, which is not a good ideal
|
||||
API handler readfile function return JSON object in reading JSON file, need to be text
|
||||
Some error in event handle using observable
|
@ -13,7 +13,7 @@ self.OS.API =
|
||||
url: p,
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify d,
|
||||
dataType: 'json', # data type need to be configurable
|
||||
dataType: 'json',
|
||||
success: null
|
||||
}
|
||||
#$.getJSON p, d
|
||||
@ -86,10 +86,15 @@ self.OS.API =
|
||||
_courrier.trigger "loading", { id: q, data: { m: "#{p}", s: true }, name: "OS" }
|
||||
loaded: (q, p, m ) ->
|
||||
_courrier.trigger "loaded", { id: q, data: { m: "#{m}: #{p}", s: false }, name: "OS" }
|
||||
get: (p, c, f) ->
|
||||
get: (p, c, f, t) ->
|
||||
conf =
|
||||
type: 'GET',
|
||||
url: p,
|
||||
conf.dataType = t if t
|
||||
|
||||
q = _courrier.getMID()
|
||||
_API.loading q, p
|
||||
$.get p # TODO add return type setting support
|
||||
$.ajax conf
|
||||
.done (data) ->
|
||||
_API.loaded q, p, "OK"
|
||||
c(data)
|
||||
@ -109,6 +114,12 @@ self.OS.API =
|
||||
resource: (r, c, f) ->
|
||||
path = "resources/#{r}"
|
||||
_API.get path, c, f
|
||||
|
||||
packages:
|
||||
fetch: (f) ->
|
||||
_API.handler.packages {
|
||||
command: "list", args: { paths: _OS.setting.system.pkgpaths }
|
||||
}, f
|
||||
|
||||
throwe: (n) ->
|
||||
err = undefined
|
||||
|
@ -11,6 +11,7 @@ self.OS or=
|
||||
desktop: {}
|
||||
appearance: {}
|
||||
VFS: {}
|
||||
system: {}
|
||||
courrier:
|
||||
observable: riot.observable()
|
||||
quota: 0
|
||||
@ -33,7 +34,7 @@ self.OS or=
|
||||
_courrier.observable.off i.e, i.f for i in _courrier.listeners[app.pid]
|
||||
delete _courrier.listeners[app.pid]
|
||||
_courrier.listeners[app.pid] = []
|
||||
getMID: () ->
|
||||
getMID: () ->
|
||||
_courrier.quota += 1
|
||||
_courrier.quota
|
||||
register: (name, x) ->
|
||||
|
@ -14,7 +14,7 @@ self.OS.GUI =
|
||||
return null unless x
|
||||
_GUI.htmlToScheme x, app, parent
|
||||
, (e, s) ->
|
||||
_courrier.osfail "Cannot load scheme file: #{path} for #{app.name} (#{app.pid})",e,s
|
||||
_courrier.osfail "Cannot load scheme file: #{path} for #{app.name} (#{app.pid})", e, s
|
||||
|
||||
clearTheme: () ->
|
||||
$ "head link#ostheme"
|
||||
@ -244,7 +244,44 @@ self.OS.GUI =
|
||||
riot.mount desktop
|
||||
, (e, s) ->
|
||||
alert "System fall: Cannot init desktop manager"
|
||||
|
||||
console.log s, e
|
||||
|
||||
|
||||
buildSystemMenu: () ->
|
||||
|
||||
menu =
|
||||
text: ""
|
||||
iconclass: "fa fa-eercast"
|
||||
dataid: "sys-menu-root"
|
||||
child: [
|
||||
{
|
||||
text: "Application",
|
||||
child: [],
|
||||
dataid: "sys-apps"
|
||||
iconclass: "fa fa-adn",
|
||||
onmenuselect: (d) ->
|
||||
_GUI.launch d.item.data.app
|
||||
}
|
||||
]
|
||||
menu.child = menu.child.concat _OS.setting.system.menu
|
||||
menu.child.push
|
||||
text: "Log out",
|
||||
dataid: "sys-logout",
|
||||
iconclass: "fa fa-user-times"
|
||||
menu.onmenuselect = (d) ->
|
||||
console.log d
|
||||
return _API.handler.logout() if d.item.data.dataid is "sys-logout"
|
||||
_GUI.launch d.item.data.app unless d.item.data.dataid
|
||||
|
||||
#now get app list
|
||||
_API.packages.fetch (r) ->
|
||||
if r.result
|
||||
v.text = v.name for k, v of r.result
|
||||
menu.child[0].child = r.result if r.result
|
||||
($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", [menu]
|
||||
#console.log menu
|
||||
|
||||
|
||||
login: () ->
|
||||
_OS.cleanup()
|
||||
_API.resource "schemes/login.html", (x) ->
|
||||
@ -269,13 +306,20 @@ self.OS.GUI =
|
||||
_OS.setting.appearance = conf.appearance if conf.appearance
|
||||
_OS.setting.user = conf.user
|
||||
_OS.setting.VFS = conf.VFS if conf.VFS
|
||||
_OS.setting.VFS.mountpoints = [ #TODO: multi app try to write to this object, it neet to be cloned
|
||||
_OS.setting.VFS.mountpoints = [
|
||||
#TODO: multi app try to write to this object, it neet to be cloned
|
||||
{ text: "Applications", path: 'app:///', iconclass: "fa fa-adn", type: "app" },
|
||||
{ text: "Home", path: 'home:///', iconclass: "fa fa-home", type: "fs" },
|
||||
{ text: "OS", path: 'os:///', iconclass: "fa fa-inbox", type: "fs" },
|
||||
{ text: "Desktop", path: 'home:///.desktop', iconclass: "fa fa-desktop", type: "fs"},
|
||||
{ text: "Desktop", path: 'home:///.desktop', iconclass: "fa fa-desktop", type: "fs" },
|
||||
] if not _OS.setting.VFS.mountpoints
|
||||
|
||||
_OS.setting.system = conf.system if conf.system
|
||||
_OS.setting.system.pkgpaths = [
|
||||
"home:///.packages",
|
||||
"os:///packages"
|
||||
] unless _OS.setting.system.pkgpaths
|
||||
_OS.setting.system.menu = [] unless _OS.setting.system.menu
|
||||
_OS.setting.desktop.path = "home:///.desktop" unless _OS.setting.desktop.path
|
||||
_OS.setting.appearance.theme = "antos" unless _OS.setting.appearance.theme
|
||||
# load theme
|
||||
@ -286,9 +330,14 @@ self.OS.GUI =
|
||||
# TODO load packages list then build system menu
|
||||
# push startup services
|
||||
# TODO: get services list from user setting
|
||||
_GUI.pushServices ["CoreServices/PushNotification", "CoreServices/Spotlight", "CoreServices/Calendar"]
|
||||
_GUI.buildSystemMenu()
|
||||
_GUI.pushServices [
|
||||
"CoreServices/PushNotification",
|
||||
"CoreServices/Spotlight",
|
||||
"CoreServices/Calendar"
|
||||
]
|
||||
|
||||
# startup application here
|
||||
_courrier.observable.one "desktoploaded", () ->
|
||||
#_GUI.launch "DummyApp"
|
||||
_GUI.launch "NotePad"
|
||||
#_GUI.launch "NotePad"
|
@ -17,6 +17,7 @@ self.OS.API.handler =
|
||||
path = "lua-api/fs/get/"
|
||||
_API.get path + p, c, (e, s) ->
|
||||
_courrier.osfail "Fail to read file: #{p}", e, s
|
||||
, "text"
|
||||
|
||||
move: (s, d, c) ->
|
||||
path = "lua-api/fs/move"
|
||||
@ -33,6 +34,11 @@ self.OS.API.handler =
|
||||
_API.blob path + p, c, (e, s) ->
|
||||
_courrier.osfail "Fail to read file: #{p}", e, s
|
||||
|
||||
packages: (d, c) ->
|
||||
path = "lua-api/system/packages"
|
||||
_API.post path, d, c, (e, s) ->
|
||||
_courrier.osfail "Fail to #{d.command} package", e, s
|
||||
|
||||
upload: (d, c) ->
|
||||
path = "lua-api/fs/upload"
|
||||
_API.upload path, d, c, (e, s) ->
|
||||
|
@ -6,33 +6,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
this.osmenu = {child:[
|
||||
{text:"",iconclass:"fa fa-eercast", child:[
|
||||
{text:"About", radio:true},
|
||||
{text:"App Store", radio:true},
|
||||
{text:"System Preferences", switch:true, iconclass:"fa fa-commenting"},
|
||||
{text:"Applications",child:[
|
||||
{text:"wTerm",type:"app"},
|
||||
{text:"NotePad",type:"app", iconclass:"fa fa-commenting"},
|
||||
{text:"ActivityMonitor",type:"app"},
|
||||
{text:"DummyApp",type:"app"},
|
||||
{text:"Files",type:"app"}
|
||||
],
|
||||
onmenuselect: function(d)
|
||||
{
|
||||
if(d.e.item.data.type == "app")
|
||||
window.OS.GUI.launch(d.e.item.data.text, null)
|
||||
}
|
||||
},
|
||||
{text:"Logout", dataid: "sys-logout"}
|
||||
]}
|
||||
],
|
||||
onmenuselect: function(d)
|
||||
{
|
||||
if(d.e.item.data.dataid == "sys-logout")
|
||||
window.OS.API.handler.logout()
|
||||
}
|
||||
}
|
||||
this.osmenu = { child: [] }
|
||||
this.appmenu = { child: [] }
|
||||
this.systray = {
|
||||
child: [],
|
||||
|
@ -103,8 +103,7 @@ class NotePad extends this.OS.GUI.BaseApplication
|
||||
return @tabarea.set "selected", i if i isnt -1
|
||||
return @newtab file if file.path.toString() is "Untitled"
|
||||
me = @
|
||||
file.read (_d) ->
|
||||
d = if typeof _d is "string" then _d else JSON.stringify _d #TODO
|
||||
file.read (d) ->
|
||||
file.cache = d or ""
|
||||
me.newtab file
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user