mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-02-22 09:52: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
|
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
|
Some error in event handle using observable
|
@ -13,7 +13,7 @@ self.OS.API =
|
|||||||
url: p,
|
url: p,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify d,
|
data: JSON.stringify d,
|
||||||
dataType: 'json', # data type need to be configurable
|
dataType: 'json',
|
||||||
success: null
|
success: null
|
||||||
}
|
}
|
||||||
#$.getJSON p, d
|
#$.getJSON p, d
|
||||||
@ -86,10 +86,15 @@ self.OS.API =
|
|||||||
_courrier.trigger "loading", { id: q, data: { m: "#{p}", s: true }, name: "OS" }
|
_courrier.trigger "loading", { id: q, data: { m: "#{p}", s: true }, name: "OS" }
|
||||||
loaded: (q, p, m ) ->
|
loaded: (q, p, m ) ->
|
||||||
_courrier.trigger "loaded", { id: q, data: { m: "#{m}: #{p}", s: false }, name: "OS" }
|
_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()
|
q = _courrier.getMID()
|
||||||
_API.loading q, p
|
_API.loading q, p
|
||||||
$.get p # TODO add return type setting support
|
$.ajax conf
|
||||||
.done (data) ->
|
.done (data) ->
|
||||||
_API.loaded q, p, "OK"
|
_API.loaded q, p, "OK"
|
||||||
c(data)
|
c(data)
|
||||||
@ -110,6 +115,12 @@ self.OS.API =
|
|||||||
path = "resources/#{r}"
|
path = "resources/#{r}"
|
||||||
_API.get path, c, f
|
_API.get path, c, f
|
||||||
|
|
||||||
|
packages:
|
||||||
|
fetch: (f) ->
|
||||||
|
_API.handler.packages {
|
||||||
|
command: "list", args: { paths: _OS.setting.system.pkgpaths }
|
||||||
|
}, f
|
||||||
|
|
||||||
throwe: (n) ->
|
throwe: (n) ->
|
||||||
err = undefined
|
err = undefined
|
||||||
try
|
try
|
||||||
|
@ -11,6 +11,7 @@ self.OS or=
|
|||||||
desktop: {}
|
desktop: {}
|
||||||
appearance: {}
|
appearance: {}
|
||||||
VFS: {}
|
VFS: {}
|
||||||
|
system: {}
|
||||||
courrier:
|
courrier:
|
||||||
observable: riot.observable()
|
observable: riot.observable()
|
||||||
quota: 0
|
quota: 0
|
||||||
|
@ -244,6 +244,43 @@ self.OS.GUI =
|
|||||||
riot.mount desktop
|
riot.mount desktop
|
||||||
, (e, s) ->
|
, (e, s) ->
|
||||||
alert "System fall: Cannot init desktop manager"
|
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: () ->
|
login: () ->
|
||||||
_OS.cleanup()
|
_OS.cleanup()
|
||||||
@ -269,13 +306,20 @@ self.OS.GUI =
|
|||||||
_OS.setting.appearance = conf.appearance if conf.appearance
|
_OS.setting.appearance = conf.appearance if conf.appearance
|
||||||
_OS.setting.user = conf.user
|
_OS.setting.user = conf.user
|
||||||
_OS.setting.VFS = conf.VFS if conf.VFS
|
_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: "Applications", path: 'app:///', iconclass: "fa fa-adn", type: "app" },
|
||||||
{ text: "Home", path: 'home:///', iconclass: "fa fa-home", type: "fs" },
|
{ text: "Home", path: 'home:///', iconclass: "fa fa-home", type: "fs" },
|
||||||
{ text: "OS", path: 'os:///', iconclass: "fa fa-inbox", 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
|
] 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.desktop.path = "home:///.desktop" unless _OS.setting.desktop.path
|
||||||
_OS.setting.appearance.theme = "antos" unless _OS.setting.appearance.theme
|
_OS.setting.appearance.theme = "antos" unless _OS.setting.appearance.theme
|
||||||
# load theme
|
# load theme
|
||||||
@ -286,9 +330,14 @@ self.OS.GUI =
|
|||||||
# TODO load packages list then build system menu
|
# TODO load packages list then build system menu
|
||||||
# push startup services
|
# push startup services
|
||||||
# TODO: get services list from user setting
|
# 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
|
# startup application here
|
||||||
_courrier.observable.one "desktoploaded", () ->
|
_courrier.observable.one "desktoploaded", () ->
|
||||||
#_GUI.launch "DummyApp"
|
#_GUI.launch "DummyApp"
|
||||||
_GUI.launch "NotePad"
|
#_GUI.launch "NotePad"
|
@ -17,6 +17,7 @@ self.OS.API.handler =
|
|||||||
path = "lua-api/fs/get/"
|
path = "lua-api/fs/get/"
|
||||||
_API.get path + p, c, (e, s) ->
|
_API.get path + p, c, (e, s) ->
|
||||||
_courrier.osfail "Fail to read file: #{p}", e, s
|
_courrier.osfail "Fail to read file: #{p}", e, s
|
||||||
|
, "text"
|
||||||
|
|
||||||
move: (s, d, c) ->
|
move: (s, d, c) ->
|
||||||
path = "lua-api/fs/move"
|
path = "lua-api/fs/move"
|
||||||
@ -33,6 +34,11 @@ self.OS.API.handler =
|
|||||||
_API.blob path + p, c, (e, s) ->
|
_API.blob path + p, c, (e, s) ->
|
||||||
_courrier.osfail "Fail to read file: #{p}", 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) ->
|
upload: (d, c) ->
|
||||||
path = "lua-api/fs/upload"
|
path = "lua-api/fs/upload"
|
||||||
_API.upload path, d, c, (e, s) ->
|
_API.upload path, d, c, (e, s) ->
|
||||||
|
@ -6,33 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
this.osmenu = {child:[
|
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.appmenu = { child: [] }
|
this.appmenu = { child: [] }
|
||||||
this.systray = {
|
this.systray = {
|
||||||
child: [],
|
child: [],
|
||||||
|
@ -103,8 +103,7 @@ class NotePad extends this.OS.GUI.BaseApplication
|
|||||||
return @tabarea.set "selected", i if i isnt -1
|
return @tabarea.set "selected", i if i isnt -1
|
||||||
return @newtab file if file.path.toString() is "Untitled"
|
return @newtab file if file.path.toString() is "Untitled"
|
||||||
me = @
|
me = @
|
||||||
file.read (_d) ->
|
file.read (d) ->
|
||||||
d = if typeof _d is "string" then _d else JSON.stringify _d #TODO
|
|
||||||
file.cache = d or ""
|
file.cache = d or ""
|
||||||
me.newtab file
|
me.newtab file
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user