update MarketPlace

This commit is contained in:
Xuan Sang LE 2018-03-05 23:49:25 +01:00
parent 8ae2f529f7
commit d9bd567271
2 changed files with 43 additions and 13 deletions

View File

@ -9,18 +9,54 @@ class RepositoryDialog extends this.OS.GUI.BaseDialog
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
@list.set "onlistdbclick", (e) ->
selidx = me.list.get "selidx"
return unless selidx >= 0
sel = me.systemsetting.system.repositories[selidx]
me.openDialog "PromptDialog", (e) ->
m = e.match /\[([^\]]*)\]\s*(.*)/
return me.error "Wrong format: it should be [name] url" if not m or m.length isnt 3
sel.name = m[1]
sel.text = sel.name
sel.url = m[2]
me.refreshList()
, "Edit repository", { label: "Format : [name]url", value: "[#{e.data.text}] #{e.data.url}" }
(@find "btadd").set "onbtclick", (e) ->
me.openDialog "PromptDialog", (e) ->
m = e.match /\[([^\]]*)\]\s*(.*)/
return me.error "Wrong format: it should be [name] url" if not m or m.length isnt 3
me.systemsetting.system.repositories.push {
name: m[1],
url: m[2],
text: m[1],
i: me.systemsetting.system.repositories.length
}
me.refreshList()
, "Add repository", { label: "Format : [name]url" }
(@find "btdel").set "onbtclick", (e) ->
selidx = me.list.get "selidx"
return unless selidx >= 0
me.systemsetting.system.repositories.splice selidx, selidx
me.refreshList()
(@find "btquit").set "onbtclick", (e) -> me.quit()
@refreshList()
refreshList: () ->
ls = ({
text: v.name,
iconclass: "fa fa-link",
url: v.url,
complex: true,
detail: [{ text: v.url }]
} for v in @systemsetting.system.repositories)
@list.set "items", ls
onexit: (e) ->
@parent.repo.set "items", @systemsetting.system.repositories
@parent.dialog = undefined if @parent
RepositoryDialog.scheme = """
<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>

View File

@ -7,12 +7,6 @@ class MarketPlace extends this.OS.GUI.BaseApplication
me = @
@installdir = @systemsetting.system.pkgpaths.user
# test repository
@systemsetting.system.repositories.push {
text: "Antos repository"
url: "https://os.localhost:9195/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