add application manager

This commit is contained in:
Xuan Sang LE 2018-02-01 19:36:09 +01:00
parent f5ff434152
commit 5d91cc99f3
22 changed files with 305 additions and 80 deletions

View File

@ -20,7 +20,7 @@ coffees= src/core/core.coffee\
packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn MarketPlace
main: build_coffees build_tags build_themes schemes libs build_packages main: build_coffees build_tags build_themes schemes libs build_packages
- cp src/index.html $(BUILDDIR)/ - cp src/index.html $(BUILDDIR)/

View File

@ -26,7 +26,7 @@ class BaseApplication extends this.OS.GUI.BaseModel
when "#{me.name}-about" then me.openDialog "AboutDialog", ()-> when "#{me.name}-about" then me.openDialog "AboutDialog", ()->
when "#{me.name}-exit" then me.trigger "exit" when "#{me.name}-exit" then me.trigger "exit"
#now load the scheme #now load the scheme
path = "packages/#{@name}/scheme.html" path = "#{@meta().path}/scheme.html"
@.render path @.render path
applySetting: (k) -> applySetting: (k) ->

View File

@ -1,15 +1,14 @@
class BaseDialog extends this.OS.GUI.BaseModel class SubWindow extends this.OS.GUI.BaseModel
constructor: (name) -> constructor: (name) ->
super name, null super name, null
@parent = undefined @parent = undefined
@modal = false @modal = false
@handler = undefined
quit: () -> quit: () ->
evt = new _GUI.BaseEvent("exit") evt = new _GUI.BaseEvent("exit")
@onexit(evt) @onexit(evt)
if not evt.prevent if not evt.prevent
delete @.observable delete @.observable
@parent.dialog = undefined if @parent
($ @scheme).remove() if @scheme ($ @scheme).remove() if @scheme
@dialog.quit() if @dialog @dialog.quit() if @dialog
init: () -> init: () ->
@ -22,7 +21,17 @@ class BaseDialog extends this.OS.GUI.BaseModel
hide: () -> hide: () ->
@trigger 'hide' @trigger 'hide'
BaseDialog.type = 3 SubWindow.type = 3
this.OS.GUI.SubWindow = SubWindow
class BaseDialog extends SubWindow
constructor: (name) ->
super name
@handler = undefined
onexit: (e) ->
@parent.dialog = undefined if @parent
this.OS.GUI.BaseDialog = BaseDialog this.OS.GUI.BaseDialog = BaseDialog
### ###
this dialog rende a tag as main content this dialog rende a tag as main content
@ -47,8 +56,8 @@ class BasicDialog extends BaseDialog
@title = @name if not @title @title = @name if not @title
html = "<afx-app-window data-id = 'dia-window' apptitle='#{@title}' width='#{@conf.width}' height='#{@conf.height}'> html = "<afx-app-window data-id = 'dia-window' apptitle='#{@title}' width='#{@conf.width}' height='#{@conf.height}'>
<afx-vbox>" <afx-vbox>"
html += "<#{@conf.tag} #{@conf.att} data-id = 'content'></#{@conf.tag}>" html += "<#{v.tag} #{v.att} data-id = 'content#{k}'></#{v.tag}>" for k,v of @conf.tags
html += "<div data-height = '40' style=' text-align:right;padding-top:3px;'>" html += "<div data-height = '35' style=' text-align:right;padding-top:3px;'>"
html += "<afx-button data-id = 'bt#{k}' text = '#{v.label}' style='margin-right:5px;'></afx-button>" for k,v of @conf.buttons html += "<afx-button data-id = 'bt#{k}' text = '#{v.label}' style='margin-right:5px;'></afx-button>" for k,v of @conf.buttons
html += "</div></afx-vbox></afx-app-window>" html += "</div></afx-vbox></afx-app-window>"
#render the html #render the html
@ -69,16 +78,18 @@ this.OS.GUI.BasicDialog = BasicDialog
class PromptDialog extends BasicDialog class PromptDialog extends BasicDialog
constructor: () -> constructor: () ->
super "PromptDialog", { super "PromptDialog", {
tag: "input", tags: [
{ tag: "afx-label", att: "data-height = '20'" },
{ tag: "input", att: "type = 'text'" }
],
width: 200, width: 200,
height: 90, height: 100,
att: "type = 'text'"
resizable: false, resizable: false,
buttons: [ buttons: [
{ {
label: "0k", label: "0k",
onclick: (d) -> onclick: (d) ->
txt = (d.find "content").value txt = (d.find "content1").value
return d.quit() if txt is "" return d.quit() if txt is ""
d.handler txt if d.handler d.handler txt if d.handler
d.quit() d.quit()
@ -90,9 +101,10 @@ class PromptDialog extends BasicDialog
], ],
filldata: (d) -> filldata: (d) ->
return unless d.data return unless d.data
(d.find "content").value = d.data (d.find "content0").set "text", d.data.label
(d.find "content1").value = d.data.value if d.data.value
xtra: (d) -> xtra: (d) ->
$( d.find "content" ).keyup (e) -> $( d.find "content0" ).keyup (e) ->
(d.find "bt0").trigger() if e.which is 13 (d.find "bt0").trigger() if e.which is 13
} }
@ -101,7 +113,7 @@ this.OS.register "PromptDialog", PromptDialog
class CalendarDialog extends BasicDialog class CalendarDialog extends BasicDialog
constructor: () -> constructor: () ->
super "CalendarDialog", { super "CalendarDialog", {
tag: 'afx-calendar-view', tags: [{ tag: 'afx-calendar-view' }],
width: 300, width: 300,
height: 220, height: 220,
resizable: false, resizable: false,
@ -109,7 +121,7 @@ class CalendarDialog extends BasicDialog
{ {
label: 'Ok', label: 'Ok',
onclick: (d) -> onclick: (d) ->
date = (d.find "content").get "selectedDate" date = (d.find "content0").get "selectedDate"
if date if date
d.handler date if d.handler d.handler date if d.handler
d.quit() d.quit()
@ -127,7 +139,7 @@ this.OS.register "CalendarDialog", CalendarDialog
class ColorPickerDialog extends BasicDialog class ColorPickerDialog extends BasicDialog
constructor: () -> constructor: () ->
super "ColorPickerDialog", { super "ColorPickerDialog", {
tag: 'afx-color-picker', tags: [{ tag: 'afx-color-picker' }],
width: 313, width: 313,
height: 220, height: 220,
resizable: false, resizable: false,
@ -135,7 +147,7 @@ class ColorPickerDialog extends BasicDialog
{ {
label: 'Ok', label: 'Ok',
onclick: (d) -> onclick: (d) ->
c = (d.find "content").get "selectedColor" c = (d.find "content0").get "selectedColor"
if c if c
d.handler c if d.handler d.handler c if d.handler
d.quit() d.quit()
@ -153,7 +165,7 @@ this.OS.register "ColorPickerDialog", ColorPickerDialog
class InfoDialog extends BasicDialog class InfoDialog extends BasicDialog
constructor: () -> constructor: () ->
super "InfoDialog", { super "InfoDialog", {
tag: 'afx-grid-view', tags: [{ tag: 'afx-grid-view' }],
width: 250, width: 250,
height: 300, height: 300,
resizable: true, resizable: true,
@ -161,8 +173,8 @@ class InfoDialog extends BasicDialog
filldata: (d) -> filldata: (d) ->
return unless d.data return unless d.data
rows = [] rows = []
rows.push [ { value: k }, { value: v } ] for v, k in d.data rows.push [ { value: k }, { value: v } ] for k, v of d.data
(d.find "content").set "rows", rows (d.find "content0").set "rows", rows
} }
this.OS.register "InfoDialog", InfoDialog this.OS.register "InfoDialog", InfoDialog
@ -170,10 +182,9 @@ this.OS.register "InfoDialog", InfoDialog
class YesNoDialog extends BasicDialog class YesNoDialog extends BasicDialog
constructor: () -> constructor: () ->
super "YesNoDialog", { super "YesNoDialog", {
tag: "afx-label", tags: [{ tag: "afx-label", att: "style = 'padding:10px;'" }],
width: 300, width: 300,
height: 100, height: 100,
att:"style = 'padding:10px;'"
resizable: true, resizable: true,
buttons: [ buttons: [
{ {
@ -189,7 +200,7 @@ class YesNoDialog extends BasicDialog
], ],
filldata: (d) -> filldata: (d) ->
return unless d.data return unless d.data
l = d.find "content" l = d.find "content0"
for k, v of d.data for k, v of d.data
l.set k, v l.set k, v
} }
@ -198,15 +209,14 @@ this.OS.register "YesNoDialog", YesNoDialog
class SelectionDialog extends BasicDialog class SelectionDialog extends BasicDialog
constructor: () -> constructor: () ->
super "SelectionDialog", { super "SelectionDialog", {
tag: "afx-list-view", tags: [{ tag: "afx-list-view" }],
att: "",
width: 250, width: 250,
height: 300, height: 300,
resizable: false, resizable: false,
buttons: [ buttons: [
{ {
label: "Ok", onclick: (d) -> label: "Ok", onclick: (d) ->
el = d.find "content" el = d.find "content0"
it = el.get "selected" it = el.get "selected"
return unless it return unless it
d.handler it if d.handler d.handler it if d.handler
@ -216,9 +226,9 @@ class SelectionDialog extends BasicDialog
], ],
filldata: (d) -> filldata: (d) ->
return unless d.data return unless d.data
(d.find "content").set "items", d.data (d.find "content0").set "items", d.data
xtra: (d) -> xtra: (d) ->
( d.find "content" ).set "onlistdbclick", (e) -> ( d.find "content0" ).set "onlistdbclick", (e) ->
(d.find "bt0").trigger() (d.find "bt0").trigger()
} }
@ -229,7 +239,7 @@ class AboutDialog extends BaseDialog
super "AboutDialog" super "AboutDialog"
init: () -> init: () ->
@render "resources/schemes/about.html" @render "os:///resources/schemes/about.html"
main: () -> main: () ->
mt = @meta() mt = @meta()
@ -249,7 +259,7 @@ class FileDiaLog extends BaseDialog
super "FileDiaLog" super "FileDiaLog"
init: () -> init: () ->
@render "resources/schemes/filedialog.html" @render "os:///resources/schemes/filedialog.html"
main: () -> main: () ->
fileview = @find "fileview" fileview = @find "fileview"

View File

@ -37,10 +37,10 @@ class BaseModel
if @dialog if @dialog
@dialog.show() @dialog.show()
return return
if not _GUI.dialogs[d] if not _GUI.subwindows[d]
@error "Dialog #{d} not found" @error "Dialog #{d} not found"
return return
@dialog = new _GUI.dialogs[d]() @dialog = new _GUI.subwindows[d]()
@dialog.parent = @ @dialog.parent = @
@dialog.handler = f @dialog.handler = f
@dialog.pid = @pid @dialog.pid = @pid

View File

@ -12,7 +12,7 @@ class BaseService extends this.OS.GUI.BaseModel
# event registe, etc # event registe, etc
# scheme loader # scheme loader
meta: () -> meta: () ->
@ _OS.APP[@name].meta
attach: (h) -> attach: (h) ->
@holder = h @holder = h

View File

@ -120,6 +120,10 @@ self.OS.API =
_API.handler.packages { _API.handler.packages {
command: "list", args: { paths: _OS.setting.system.pkgpaths } command: "list", args: { paths: _OS.setting.system.pkgpaths }
}, f }, f
cache: (f) ->
_API.handler.packages {
command: "cache", args: { paths: _OS.setting.system.pkgpaths }
}, f
throwe: (n) -> throwe: (n) ->
err = undefined err = undefined

View File

@ -38,7 +38,7 @@ self.OS or=
_courrier.quota += 1 _courrier.quota += 1
_courrier.quota _courrier.quota
register: (name, x) -> register: (name, x) ->
if x.type is 3 then self.OS.GUI.dialogs[name] = x else _OS.APP[name] = x if x.type is 3 then self.OS.GUI.subwindows[name] = x else _OS.APP[name] = x
PM: PM:
pidalloc: 0 pidalloc: 0

View File

@ -1,5 +1,5 @@
self.OS.GUI = self.OS.GUI =
dialogs: new Object() subwindows: new Object()
dialog: undefined dialog: undefined
htmlToScheme: (html, app, parent) -> htmlToScheme: (html, app, parent) ->
scheme = $.parseHTML html scheme = $.parseHTML html
@ -9,12 +9,11 @@ self.OS.GUI =
app.main() app.main()
app.show() app.show()
loadScheme: (path, app, parent) -> loadScheme: (path, app, parent) ->
_API.get path, path.asFileHandler().read (x) ->
(x) ->
return null unless x return null unless x
_GUI.htmlToScheme x, app, parent _GUI.htmlToScheme x, app, parent
, (e, s) -> #, (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: () -> clearTheme: () ->
$ "head link#ostheme" $ "head link#ostheme"
@ -37,10 +36,10 @@ self.OS.GUI =
if _GUI.dialog if _GUI.dialog
_GUI.dialog.show() _GUI.dialog.show()
return return
if not _GUI.dialogs[d] if not _GUI.subwindows[d]
ex = _API.throwe "Dialog" ex = _API.throwe "Dialog"
return _courrier.oserror "Dialog #{d} not found", ex, null return _courrier.oserror "Dialog #{d} not found", ex, null
_GUI.dialog = new _GUI.dialogs[d]() _GUI.dialog = new _GUI.subwindows[d]()
_GUI.dialog.parent = _GUI _GUI.dialog.parent = _GUI
_GUI.dialog.handler = f _GUI.dialog.handler = f
_GUI.dialog.pid = -1 _GUI.dialog.pid = -1
@ -105,6 +104,7 @@ self.OS.GUI =
path = "os:///packages/#{app}" path = "os:///packages/#{app}"
path = _OS.setting.system.packages[app].path if _OS.setting.system.packages[app].path path = _OS.setting.system.packages[app].path if _OS.setting.system.packages[app].path
js = path + "/main.js" js = path + "/main.js"
js.asFileHandler().read (d) -> js.asFileHandler().read (d) ->
#load css file #load css file
css = "#{path}/main.css" css = "#{path}/main.css"
@ -113,15 +113,14 @@ self.OS.GUI =
.appendTo 'head' .appendTo 'head'
, () -> , () ->
#launch #launch
if _OS.APP[app] # load app meta data
# load app meta data "#{path}/package.json".asFileHandler().read (data) ->
"#{path}/package.json".asFileHandler().read (data) -> data.path = path
data.path = path _OS.APP[app].meta = data if _OS.APP[app]
_OS.APP[app].meta = data _OS.APP[v].meta = data for v in data.services if data.services
ok app
, "json"
else
ok app ok app
, "json"
#ok app
, "script" , "script"
launch: (app, args) -> launch: (app, args) ->
if not _OS.APP[app] if not _OS.APP[app]
@ -340,7 +339,7 @@ self.OS.GUI =
"os:///packages" "os:///packages"
] unless _OS.setting.system.pkgpaths ] unless _OS.setting.system.pkgpaths
_OS.setting.system.menu = {} unless _OS.setting.system.menu _OS.setting.system.menu = {} unless _OS.setting.system.menu
_OS.setting.system.repositories = [] unless _OS.setting.system.repositories
_OS.setting.appearance.theme = "antos" unless _OS.setting.appearance.theme _OS.setting.appearance.theme = "antos" unless _OS.setting.appearance.theme
# load theme # load theme
_GUI.loadTheme _OS.setting.appearance.theme _GUI.loadTheme _OS.setting.appearance.theme
@ -348,23 +347,25 @@ self.OS.GUI =
_GUI.initDM() _GUI.initDM()
_courrier.observable.one "syspanelloaded", () -> _courrier.observable.one "syspanelloaded", () ->
# TODO load packages list then build system menu # TODO load packages list then build system menu
_API.packages.fetch (r) -> _API.packages.cache (ret) ->
if r.result if ret.result
for k, v of r.result _API.packages.fetch (r) ->
v.text = v.name if r.result
v.filename = k for k, v of r.result
v.type = "app" v.text = v.name
v.mime = "antos/app" v.filename = k
v.iconclass = "fa fa-adn" unless v.iconclass or v.icon v.type = "app"
_OS.setting.system.packages = if r.result then r.result else v.mime = "antos/app"
_GUI.buildSystemMenu() v.iconclass = "fa fa-adn" unless v.iconclass or v.icon
# push startup services _OS.setting.system.packages = if r.result then r.result else
# TODO: get services list from user setting _GUI.buildSystemMenu()
_GUI.pushServices [ # push startup services
"CoreServices/PushNotification", # TODO: get services list from user setting
"CoreServices/Spotlight", _GUI.pushServices [
"CoreServices/Calendar" "CoreServices/PushNotification",
] "CoreServices/Spotlight",
"CoreServices/Calendar"
]
#_GUI.launch "DummyApp" #_GUI.launch "DummyApp"
# startup application here # startup application here

View File

@ -4,6 +4,7 @@
</div> </div>
<script> <script>
var self = this var self = this
this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1
this.on('mount', function(){ this.on('mount', function(){
$(self.refs.container) $(self.refs.container)
.css("display","flex") .css("display","flex")
@ -18,7 +19,6 @@
calibrate_size() calibrate_size()
}) })
self.root.observable.on("calibrate", function(){ self.root.observable.on("calibrate", function(){
console.log("calibrate")
calibrate_size() calibrate_size()
}) })
} }
@ -41,6 +41,7 @@
var dw = $(this).attr("data-width") var dw = $(this).attr("data-width")
if(dw) if(dw)
{ {
if(dw == "grow") return
$(this).css("width",dw + "px") $(this).css("width",dw + "px")
ocwidth += Number(dw) ocwidth += Number(dw)
} }
@ -54,8 +55,8 @@
{ {
$(v).css("width", csize + "px") $(v).css("width", csize + "px")
}) })
self.root.observable.trigger("vboxchange", self.root.observable.trigger("hboxchange",
{id:$(self.root).attr("data-id"), w:csize, h:avaiheight}) {id:self.rid, w:csize, h:avaiheight})
} }
</script> </script>
</afx-hbox> </afx-hbox>

View File

@ -98,6 +98,11 @@
.css("display","none") .css("display","none")
.css("top","100%") .css("top","100%")
.css("left","0") .css("left","0")
self.root.observable.on("vboxchange", function(e){
if(e.id == self.parent.rid)
$(self.refs.container).css("width", $(self.root).parent().innerWidth() + "px" )
})
} }
}) })
show_list(event) show_list(event)

View File

@ -64,7 +64,7 @@
w = Math.round(e.clientX - offset.left) w = Math.round(e.clientX - offset.left)
if(w < self.minsize) w = self.minsize if(w < self.minsize) w = self.minsize
$(self.resizable).attr("data-width", w.toString()) $(self.resizable).attr("data-width", w.toString())
self.parent.root.observable.trigger("calibrate") self.parent.root.observable.trigger("calibrate", self.resizable)
} }
var verticalResize = function(e) var verticalResize = function(e)
@ -77,7 +77,7 @@
h = Math.round(e.clientY - offset.top) h = Math.round(e.clientY - offset.top)
if(h < self.minsize) h = minsize if(h < self.minsize) h = minsize
$(self.resizable).attr("data-height", h.toString()) $(self.resizable).attr("data-height", h.toString())
self.parent.root.observable.trigger("calibrate") self.parent.root.observable.trigger("calibrate", self.resizable)
} }
</script> </script>
</afx-resizer> </afx-resizer>

View File

@ -4,6 +4,7 @@
</div> </div>
<script> <script>
var self = this var self = this
this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1
this.on('mount', function(){ this.on('mount', function(){
$(self.refs.container) $(self.refs.container)
.css("display","flex") .css("display","flex")
@ -43,6 +44,7 @@
var dw = $(this).attr("data-height") var dw = $(this).attr("data-height")
if(dw) if(dw)
{ {
if(dw == "grow") return
$(this).css("height",dw + "px") $(this).css("height",dw + "px")
ocheight += Number(dw) ocheight += Number(dw)
} }
@ -56,8 +58,8 @@
{ {
$(v).css("height", csize + "px") $(v).css("height", csize + "px")
}) })
self.root.observable.trigger("hboxchange", self.root.observable.trigger("vboxchange",
{id:$(self.root).attr("data-id"), w:avaiwidth, h:csize}) {id:self.rid, w:avaiwidth, h:csize})
} }
</script> </script>
</afx-vbox> </afx-vbox>

View File

@ -7,7 +7,7 @@ class PushNotification extends this.OS.GUI.BaseService
@pending = [] @pending = []
init: -> init: ->
@view = false @view = false
path = path = "packages/CoreServices/notifications.html" path = path = "#{@meta().path}/notifications.html"
@render path @render path
spin: (b) -> spin: (b) ->

View File

@ -1,6 +1,6 @@
{ {
"app":null, "app":null,
"services": [ "Calendar", "PushNotification", "Spotlight" ] "services": [ "Calendar", "PushNotification", "Spotlight" ],
"name":"CoreServices", "name":"CoreServices",
"description":"This is the core services", "description":"This is the core services",
"info":{ "info":{

View File

@ -181,7 +181,7 @@ class Files extends this.OS.GUI.BaseApplication
file.path.asFileHandler() file.path.asFileHandler()
.move "#{me.currdir.path}/#{d}", (r) -> .move "#{me.currdir.path}/#{d}", (r) ->
me.error "Fail to rename to #{d}: #{r.error}" if r.error me.error "Fail to rename to #{d}: #{r.error}" if r.error
, "Rename", file.filename , "Rename", { label: "File name:", value: file.filename }
when "#{@name}-rm" when "#{@name}-rm"
return unless file return unless file
@ -232,7 +232,7 @@ class Files extends this.OS.GUI.BaseApplication
(d) -> (d) ->
me.currdir.mk d, (r) -> me.currdir.mk d, (r) ->
me.error "Fail to create #{d}: #{r.error}" if r.error me.error "Fail to create #{d}: #{r.error}" if r.error
, "New folder" , "New folder", { label: "Folder name:" }
when "#{@name}-mkf" when "#{@name}-mkf"
@openDialog "PromptDialog", @openDialog "PromptDialog",
@ -240,7 +240,7 @@ class Files extends this.OS.GUI.BaseApplication
fp = "#{me.currdir.path}/#{d}".asFileHandler() fp = "#{me.currdir.path}/#{d}".asFileHandler()
fp.write "", (r) -> fp.write "", (r) ->
me.error "Fail to create #{d}: #{r.error}" if r.error me.error "Fail to create #{d}: #{r.error}" if r.error
, "New file" , "New file", { label: "File name:" }
when "#{@name}-info" when "#{@name}-info"
return unless file return unless file

View File

@ -0,0 +1,11 @@
coffee_files = dialog.coffee main.coffee
jsfiles =
cssfiles = main.css
copyfiles = repositorydia.html scheme.html package.json
PKG_NAME=MarketPlace
include ../pkg.mk

View File

@ -0,0 +1,18 @@
class RepositoryDialog extends this.OS.GUI.BaseDialog
constructor: () ->
super "RepositoryDialog"
init: () ->
@render "#{@meta().path}/repositorydia.html"
main: () ->
me = @
@list = @find "repo-list"
ls = ({ text: v.name, iconclass: "fa fa-link", url: v.url
} for v in @systemsetting.system.repositories)
@url = @find "repo-url"
@list.set "onlistselect", (e) ->
($ me.url).html e.data.url
@list.set "items", ls
this.OS.register "RepositoryDialog", RepositoryDialog

View File

@ -0,0 +1,66 @@
class MarketPlace extends this.OS.GUI.BaseApplication
constructor: (args) ->
super "MarketPlace", args
main: () ->
me = @
# test repository
@systemsetting.system.repositories.push {
text: "Antos repository"
url: "http://127.0.0.1:9191/repo/packages.json"
name: "Antos repository"
selected:true
} if @systemsetting.system.repositories.length is 0
@repo = @find "repo"
@repo.set "onlistselect", (e) ->
return unless e.data
me.fetchApps e.data.url
@repo.set "items", @systemsetting.system.repositories
@applist = @find "applist"
@applist.set "onlistselect", (e) ->
return unless e.data
me.appDetail e.data
@container = @find "container"
@appname = @find "appname"
@appdesc = @find "app-desc"
@appdetail = @find "app-detail"
@btinstall = @find "bt-install"
@btremove = @find "bt-remove"
@btexec = @find "bt-exec"
($ @container ).css "visibility", "hidden"
@btexec.set "onbtclick", (e) ->
app = me.applist.get "selected"
return unless app
me._gui.launch app.className if app.className
@btinstall.set "onbtclick", (e) ->
me.openDialog "RepositoryDialog"
fetchApps: (url) ->
me = @
@_api.get url, ( d ) ->
for v in d
v.text = v.name
v.iconclass = "fa fa-adn"
me.applist.set "items", d
, (e, s) ->
me.error "Fail to fetch packages list from: #{url}"
appDetail: (d) ->
($ @container).css "visibility", "visible"
( $ @appname ).html d.name
($ @appdesc).html d.description if d.description
if @systemsetting.system.packages[d.className]
($ @btinstall).hide()
($ @btremove).show()
($ @btexec).show()
else
($ @btinstall).show()
($ @btremove).hide()
($ @btexec).hide()
($ @appdetail).empty()
for k, v of d when k isnt "name" and k isnt "description"
($ @appdetail).append $("<li>").append(($ "<span class= 'info-header'>").html k).append $("<span>").html v
this.OS.register "MarketPlace", MarketPlace

View File

@ -0,0 +1,59 @@
afx-app-window[data-id ='marketplace-win'] afx-resizer{
background-color: transparent;
border-left: 1px solid #cbcbcb;
}
afx-app-window[data-id ='marketplace-win'] afx-list-view[data-id='applist']{
background-color: #f6F6F6;
padding:0;
}
afx-app-window[data-id="marketplace-win"] afx-list-view[data-id='repo'] div.list-container{
z-index: 10;
}
afx-app-window[data-id="marketplace-win"] afx-vbox[data-id='container'] {
color: #414339;
overflow-y: auto;
}
afx-app-window[data-id="marketplace-win"] afx-vbox[data-id='container'] afx-hbox {
padding-left: 10px;
}
afx-app-window[data-id="marketplace-win"] div[data-id='appname'] {
font-weight: bold;
font-size: 20px;
padding: 10px;
color: #414339;
}
afx-app-window[data-id="marketplace-win"] div[data-id='appname']:before {
content: "\f085";
font-family: "FontAwesome";
font-size: 25px;
font-style: normal;
margin-right: 10px;
color: #414339;
}
afx-app-window[data-id="marketplace-win"] p[data-id='app-desc'] {
text-align: justify;
padding:10px;
padding-top: 0;
}
afx-app-window[data-id="marketplace-win"] ul[data-id='app-detail'] {
padding:0;
padding-left:10px;
display: table;
margin: 0;
}
afx-app-window[data-id="marketplace-win"] ul[data-id='app-detail'] li{
padding:0;
margin: 0;
display: table-row;
}
afx-app-window[data-id="marketplace-win"] ul[data-id='app-detail'] span{
display: table-cell;
padding: 5px;
padding-bottom: 2px;
padding-top: 2px;
}
afx-app-window[data-id="marketplace-win"] span.info-header{
font-weight: bold;
}

View File

@ -0,0 +1,13 @@
{
"app":"MarketPlace",
"name":"Application store",
"description":"Application store and repository management",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.1a",
"category":"System",
"iconclass":"fa fa-adn",
"mimes":["none"]
}

View File

@ -0,0 +1,12 @@
<afx-app-window data-id = "repository-dialog-win" apptitle="Repositories" width="250" height="250">
<afx-vbox >
<afx-list-view data-id="repo-list"></afx-list-view>
<div data-id="repo-url" data-height="grow"></div>
<afx-hbox data-height = "30">
<afx-button data-id = "btadd" text = "[+]" data-width="30"></afx-button>
<afx-button data-id = "btdel" text = "[-]" data-width="30"></afx-button>
<div></div>
<afx-button data-id = "btquit" text = "Cancel" data-width="50"></afx-button>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -0,0 +1,23 @@
<afx-app-window data-id = "marketplace-win" apptitle="MarketPlace" width="500" height="400">
<afx-hbox >
<afx-vbox data-width = "172" data-id = "sidebar" min-width="172">
<afx-list-view data-id = "repo" dropdown = "true" data-height= "30" width = "150"></afx-list-view>
<afx-list-view data-id = "applist" dropdown = "false" width = "150"></afx-list-view>
</afx-vbox>
<afx-resizer data-width = "3" ></afx-resizer>
<afx-vbox data-id = "container">
<div data-id = "appname" data-height = "25"></div>
<afx-hbox data-height = "25">
<afx-button data-id = "bt-remove" text = "Uninstall" data-width = "65"></afx-button>
<afx-button data-id = "bt-exec" text = "Launch" data-width = "50"></afx-button>
<afx-button data-id = "bt-install" text = "Install" data-width = "50"></afx-button>
<div></div>
</afx-hbox>
<div>
<p data-id = "app-desc"></p>
<ul data-id = "app-detail"></ul>
</div>
</afx-vbox>
</afx-hbox>
</afx-app-window>