add Files package features

This commit is contained in:
Xuan Sang LE
2018-01-25 00:49:02 +01:00
parent 7e62d71913
commit d998ac4b66
5 changed files with 67 additions and 9 deletions

View File

@ -46,7 +46,7 @@ class BasicDialog extends BaseDialog
init: () ->
html = "<afx-app-window data-id = 'dia-window' apptitle='#{@name}' width='#{@conf.width}' height='#{@conf.height}'>
<afx-hbox>"
html += "<#{@conf.tag} data-id = 'content'></#{@conf.tag}>"
html += "<#{@conf.tag} #{@conf.att} data-id = 'content'></#{@conf.tag}>"
html += "<div data-height = '40' 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 += "</div></afx-hbox></afx-app-window>"
@ -64,6 +64,33 @@ class BasicDialog extends BaseDialog
this.OS.GUI.BasicDialog = BasicDialog
class PromptDialog extends BasicDialog
constructor: () ->
super "PromptDialog", {
tag: "input",
width: 200,
height: 90,
resizable: false,
buttons: [
{
label: "0k",
onclick: (d) ->
txt = (d.find "content").value
return d.quit() if txt is ""
d.handler txt if d.handler
d.quit()
},
{
label: "Cancel",
onclick: (d) -> d.quit()
}
],
filldata: (d) ->
d.scheme.set "apptitle", d.data if d.data
}
this.OS.register "PromptDialog", PromptDialog
class CalendarDialog extends BasicDialog
constructor: () ->
super "CalendarDialog", {
@ -129,6 +156,7 @@ class InfoDialog extends BasicDialog
rows = []
rows.push [ { value: k }, { value: v } ] for k, v of d.data
(d.find "content").set "rows", rows
d.scheme.set "apptitle", d.data.filename
}
this.OS.register "InfoDialog", InfoDialog

View File

@ -18,6 +18,11 @@ self.OS.API.handler =
_API.get path + p, c, (e, s) ->
_courrier.osfail "Fail to read file: #{p}",e , s
write: (p, d , c) ->
path = "lua-api/fs/write"
_API.post path, { path: p, data: d }, c, (e, s) ->
_courrier.osfail "Fail to write to file: #{p}", e, s
scanapp: (p, c ) ->
path = "lua-api/system/application"
auth: (c) ->

View File

@ -135,7 +135,7 @@
event.preventUpdate = true
return
}
if(self.selidx != -1)
if(self.selidx != -1 && self.selidx < self.items.length)
self.items[self.selidx].selected =false
event.item.item.selected = true
}

View File

@ -101,6 +101,8 @@ class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler
when "mk"
return f { error: "#{@path} is not a directory" } if @meta.type is "file"
_API.handler.mkdir "#{@path}/#{p}", f
when "write"
_API.handler.write @path, p, f
else
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n