mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-04-08 09:36:45 +02:00
add Files package features
This commit is contained in:
parent
7e62d71913
commit
d998ac4b66
@ -46,7 +46,7 @@ class BasicDialog extends BaseDialog
|
|||||||
init: () ->
|
init: () ->
|
||||||
html = "<afx-app-window data-id = 'dia-window' apptitle='#{@name}' width='#{@conf.width}' height='#{@conf.height}'>
|
html = "<afx-app-window data-id = 'dia-window' apptitle='#{@name}' width='#{@conf.width}' height='#{@conf.height}'>
|
||||||
<afx-hbox>"
|
<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 += "<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 += "<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>"
|
html += "</div></afx-hbox></afx-app-window>"
|
||||||
@ -64,6 +64,33 @@ class BasicDialog extends BaseDialog
|
|||||||
|
|
||||||
this.OS.GUI.BasicDialog = BasicDialog
|
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
|
class CalendarDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "CalendarDialog", {
|
super "CalendarDialog", {
|
||||||
@ -129,6 +156,7 @@ class InfoDialog extends BasicDialog
|
|||||||
rows = []
|
rows = []
|
||||||
rows.push [ { value: k }, { value: v } ] for k, v of d.data
|
rows.push [ { value: k }, { value: v } ] for k, v of d.data
|
||||||
(d.find "content").set "rows", rows
|
(d.find "content").set "rows", rows
|
||||||
|
d.scheme.set "apptitle", d.data.filename
|
||||||
}
|
}
|
||||||
this.OS.register "InfoDialog", InfoDialog
|
this.OS.register "InfoDialog", InfoDialog
|
||||||
|
|
||||||
|
@ -18,6 +18,11 @@ self.OS.API.handler =
|
|||||||
_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
|
||||||
|
|
||||||
|
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 ) ->
|
scanapp: (p, c ) ->
|
||||||
path = "lua-api/system/application"
|
path = "lua-api/system/application"
|
||||||
auth: (c) ->
|
auth: (c) ->
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
event.preventUpdate = true
|
event.preventUpdate = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(self.selidx != -1)
|
if(self.selidx != -1 && self.selidx < self.items.length)
|
||||||
self.items[self.selidx].selected =false
|
self.items[self.selidx].selected =false
|
||||||
event.item.item.selected = true
|
event.item.item.selected = true
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,8 @@ class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler
|
|||||||
when "mk"
|
when "mk"
|
||||||
return f { error: "#{@path} is not a directory" } if @meta.type is "file"
|
return f { error: "#{@path} is not a directory" } if @meta.type is "file"
|
||||||
_API.handler.mkdir "#{@path}/#{p}", f
|
_API.handler.mkdir "#{@path}/#{p}", f
|
||||||
|
when "write"
|
||||||
|
_API.handler.write @path, p, f
|
||||||
else
|
else
|
||||||
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
|
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
|
||||||
|
|
||||||
|
@ -17,18 +17,18 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
#@on "fileselect", (d) -> console.log d
|
#@on "fileselect", (d) -> console.log d
|
||||||
@on "filedbclick", (e) ->
|
@on "filedbclick", (e) ->
|
||||||
#if e.data.type is 'dir' then me.chdir e.data.path, true
|
#if e.data.type is 'dir' then me.chdir e.data.path, true
|
||||||
@favo.set "onlistselect", (e) -> me.chdir e.data.path, true
|
@favo.set "onlistselect", (e) -> me.chdir e.data.path
|
||||||
|
|
||||||
($ @find "btback").click () ->
|
($ @find "btback").click () ->
|
||||||
return if me.currdir.isRoot()
|
return if me.currdir.isRoot()
|
||||||
p = me.currdir.parent()
|
p = me.currdir.parent()
|
||||||
me.favo.set "selected", -1
|
me.favo.set "selected", -1
|
||||||
me.chdir p, false
|
me.chdir p
|
||||||
|
|
||||||
($ @navinput).keyup (e) ->
|
($ @navinput).keyup (e) ->
|
||||||
me.chdir ($ me.navinput).val() if e.keyCode is 13 #enter
|
me.chdir ($ me.navinput).val() if e.keyCode is 13 #enter
|
||||||
|
|
||||||
@view.set "chdir", (p) -> me.chdir p, true
|
@view.set "chdir", (p) -> me.chdir p
|
||||||
@view.set "fetch", (e, f) ->
|
@view.set "fetch", (e, f) ->
|
||||||
return unless e.child
|
return unless e.child
|
||||||
me._api.handler.scandir e.child.path,
|
me._api.handler.scandir e.child.path,
|
||||||
@ -56,7 +56,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
|
|
||||||
chdir: (p, push) ->
|
chdir: (p, push) ->
|
||||||
me = @
|
me = @
|
||||||
dir = p.asFileHandler()
|
dir = if p then p.asFileHandler() else me.currdir
|
||||||
dir.read (d) ->
|
dir.read (d) ->
|
||||||
if(d.error)
|
if(d.error)
|
||||||
return me.error "Resource not found #{p}"
|
return me.error "Resource not found #{p}"
|
||||||
@ -66,13 +66,14 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
me.view.set "data", d.result
|
me.view.set "data", d.result
|
||||||
|
|
||||||
mnFile:() ->
|
mnFile:() ->
|
||||||
|
me = @
|
||||||
{
|
{
|
||||||
text: "File",
|
text: "File",
|
||||||
child: [
|
child: [
|
||||||
{ text: "New file", dataid: "#{@name}-mkf" },
|
{ text: "New file", dataid: "#{@name}-mkf" },
|
||||||
{ text: "New folder", dataid: "#{@name}-mkdir" },
|
{ text: "New folder", dataid: "#{@name}-mkdir" },
|
||||||
{ text: "Upload", dataid: "#{@name}-upload" }
|
{ text: "Upload", dataid: "#{@name}-upload" }
|
||||||
]
|
], onmenuselect: (e) -> me.actionFile e
|
||||||
}
|
}
|
||||||
mnEdit: () ->
|
mnEdit: () ->
|
||||||
me = @
|
me = @
|
||||||
@ -126,7 +127,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@registry "showhidden",e.item.data.checked
|
@registry "showhidden",e.item.data.checked
|
||||||
#@.setting.showhidden = e.item.data.checked
|
#@.setting.showhidden = e.item.data.checked
|
||||||
when "#{@name}-refresh"
|
when "#{@name}-refresh"
|
||||||
@.chdir ($ @.navinput).val(), false
|
@.chdir ($ @.navinput).val()
|
||||||
when "#{@name}-side"
|
when "#{@name}-side"
|
||||||
@registry "sidebar",e.item.data.checked
|
@registry "sidebar",e.item.data.checked
|
||||||
#@setting.sidebar = e.item.data.checked
|
#@setting.sidebar = e.item.data.checked
|
||||||
@ -138,11 +139,33 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
|
|
||||||
actionEdit: (e) ->
|
actionEdit: (e) ->
|
||||||
switch e.item.data.dataid
|
switch e.item.data.dataid
|
||||||
when "#{@.name}-info"
|
when "#{@name}-info"
|
||||||
file = @view.get "selectedFile"
|
file = @view.get "selectedFile"
|
||||||
return unless file
|
return unless file
|
||||||
@openDialog "InfoDialog", null, file
|
@openDialog "InfoDialog", null, file
|
||||||
|
when "#{@name}-mkdir"
|
||||||
|
console.log "mkdir"
|
||||||
|
@openDialog "PromptDialog", (d) -> console.log d
|
||||||
else
|
else
|
||||||
@_api.handler.setting()
|
@_api.handler.setting()
|
||||||
|
|
||||||
|
actionFile: (e) ->
|
||||||
|
me = @
|
||||||
|
switch e.item.data.dataid
|
||||||
|
when "#{@name}-mkdir"
|
||||||
|
@openDialog "PromptDialog",
|
||||||
|
(d) ->
|
||||||
|
me.currdir.mk d, (r) ->
|
||||||
|
if r.result then me.chdir null else me.error "Fail to create #{d}"
|
||||||
|
, "New folder"
|
||||||
|
when "#{@name}-mkf"
|
||||||
|
@openDialog "PromptDialog",
|
||||||
|
(d) ->
|
||||||
|
fp = "#{me.currdir.path}/#{d}".asFileHandler()
|
||||||
|
fp.write "", (r) ->
|
||||||
|
if r.result then me.chdir null else me.error "Fail to create #{d}"
|
||||||
|
, "New file"
|
||||||
|
else
|
||||||
|
console.log e
|
||||||
|
|
||||||
this.OS.register "Files", Files
|
this.OS.register "Files", Files
|
Loading…
x
Reference in New Issue
Block a user