mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 09:48:21 +01:00
shared file enable
This commit is contained in:
parent
564df6c815
commit
e50cdc3620
@ -332,6 +332,7 @@ self.OS.GUI =
|
|||||||
{ 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: _OS.setting.desktop.path , iconclass: "fa fa-desktop", type: "fs" },
|
{ text: "Desktop", path: _OS.setting.desktop.path , iconclass: "fa fa-desktop", type: "fs" },
|
||||||
|
{ text: "Shared", path: 'shared:///' , iconclass: "fa fa-share-square", 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 = conf.system if conf.system
|
||||||
|
@ -3,7 +3,10 @@ self.OS.API.REST = "#{self.location.protocol}//#{self.OS.API.HOST}/lua-api"
|
|||||||
|
|
||||||
_REST = self.OS.API.REST
|
_REST = self.OS.API.REST
|
||||||
self.OS.API.handler =
|
self.OS.API.handler =
|
||||||
get: "#{_REST}/fs/get/"
|
# get file, require authentification
|
||||||
|
get: "#{_REST}/fs/get"
|
||||||
|
# get shared file with publish
|
||||||
|
shared: "#{_REST}/fs/shared"
|
||||||
scandir: (p, c ) ->
|
scandir: (p, c ) ->
|
||||||
path = "#{_REST}/fs/scandir"
|
path = "#{_REST}/fs/scandir"
|
||||||
_API.post path, { path: p }, c, (e, s) ->
|
_API.post path, { path: p }, c, (e, s) ->
|
||||||
@ -12,7 +15,10 @@ self.OS.API.handler =
|
|||||||
path = "#{_REST}/fs/mkdir"
|
path = "#{_REST}/fs/mkdir"
|
||||||
_API.post path, { path: p }, c, (e, s) ->
|
_API.post path, { path: p }, c, (e, s) ->
|
||||||
_courrier.osfail "Fail to create directory: #{p}", e, s
|
_courrier.osfail "Fail to create directory: #{p}", e, s
|
||||||
|
sharefile: (p, c) ->
|
||||||
|
path = "#{_REST}/fs/publish"
|
||||||
|
_API.post path, { path: p }, c, (e, s) ->
|
||||||
|
_courrier.osfail "Fail to publish file: #{p}", e, s
|
||||||
fileinfo: (p, c) ->
|
fileinfo: (p, c) ->
|
||||||
path = "#{_REST}/fs/fileinfo"
|
path = "#{_REST}/fs/fileinfo"
|
||||||
_API.post path, { path: p }, c, (e, s) ->
|
_API.post path, { path: p }, c, (e, s) ->
|
||||||
|
@ -90,7 +90,11 @@ class BaseFileHandler
|
|||||||
@onready (() -> me.action "upload", null, (r) ->
|
@onready (() -> me.action "upload", null, (r) ->
|
||||||
_courrier.ostrigger "VFS", { m: "upload", file: me } if r.result
|
_courrier.ostrigger "VFS", { m: "upload", file: me } if r.result
|
||||||
f r)
|
f r)
|
||||||
|
publish: (f) ->
|
||||||
|
me = @
|
||||||
|
@onready (() -> me.action "publish", null, (r) ->
|
||||||
|
_courrier.ostrigger "VFS", { m: "publish", file: me } if r.result
|
||||||
|
f r)
|
||||||
download: (f) ->
|
download: (f) ->
|
||||||
me = @
|
me = @
|
||||||
@onready (() -> me.action "download", null, f)
|
@onready (() -> me.action "download", null, f)
|
||||||
@ -142,6 +146,8 @@ class RemoteFileHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
_API.handler.upload @path, f
|
_API.handler.upload @path, f
|
||||||
when "remove"
|
when "remove"
|
||||||
_API.handler.delete @path, f
|
_API.handler.delete @path, f
|
||||||
|
when "publish"
|
||||||
|
_API.handler.sharefile @path, f
|
||||||
when "download"
|
when "download"
|
||||||
return if @info.type is "dir"
|
return if @info.type is "dir"
|
||||||
_API.handler.fileblob @path, (d) ->
|
_API.handler.fileblob @path, (d) ->
|
||||||
@ -152,7 +158,7 @@ class RemoteFileHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
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
|
||||||
|
|
||||||
self.OS.API.VFS.register "^(home|shared|desktop|os|Untitled)$", RemoteFileHandler
|
self.OS.API.VFS.register "^(home|desktop|os|Untitled)$", RemoteFileHandler
|
||||||
|
|
||||||
# Application Handler
|
# Application Handler
|
||||||
class ApplicationHandler extends self.OS.API.VFS.BaseFileHandler
|
class ApplicationHandler extends self.OS.API.VFS.BaseFileHandler
|
||||||
@ -185,7 +191,8 @@ class ApplicationHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
when "remove"
|
when "remove"
|
||||||
#uninstall
|
#uninstall
|
||||||
return
|
return
|
||||||
|
when "publish"
|
||||||
|
return
|
||||||
when "download"
|
when "download"
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -233,7 +240,8 @@ class BlobFileHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
when "remove"
|
when "remove"
|
||||||
#uninstall
|
#uninstall
|
||||||
return
|
return
|
||||||
|
when "publish"
|
||||||
|
return
|
||||||
when "download"
|
when "download"
|
||||||
blob = new Blob [@cache], { type: "octet/stream" }
|
blob = new Blob [@cache], { type: "octet/stream" }
|
||||||
_API.saveblob me.basename, blob
|
_API.saveblob me.basename, blob
|
||||||
@ -243,4 +251,45 @@ class BlobFileHandler extends self.OS.API.VFS.BaseFileHandler
|
|||||||
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
|
||||||
|
|
||||||
self.OS.API.VFS.register "^blob$", BlobFileHandler
|
self.OS.API.VFS.register "^blob$", BlobFileHandler
|
||||||
|
|
||||||
|
class SharedFileHandler extends self.OS.API.VFS.BaseFileHandler
|
||||||
|
constructor: (path) ->
|
||||||
|
super path
|
||||||
|
@ready = true if @isRoot()
|
||||||
|
meta: (f) ->
|
||||||
|
_API.handler.fileinfo @path, f
|
||||||
|
|
||||||
|
action: (n, p, f) ->
|
||||||
|
me = @
|
||||||
|
switch n
|
||||||
|
when "read"
|
||||||
|
return _API.get "#{_API.handler.shared}/all", f, ((e, s)->) if @isRoot()
|
||||||
|
#read the file
|
||||||
|
_API.handler.readfile @path, f, if p then p else "text"
|
||||||
|
when "mk"
|
||||||
|
return
|
||||||
|
|
||||||
|
when "write"
|
||||||
|
_API.handler.write @path, p, f
|
||||||
|
|
||||||
|
when "remove"
|
||||||
|
_API.handler.delete @path, f
|
||||||
|
|
||||||
|
when "upload"
|
||||||
|
return
|
||||||
|
|
||||||
|
when "publish"
|
||||||
|
return f { result: @basename }
|
||||||
|
|
||||||
|
when "download"
|
||||||
|
return if @info.type is "dir"
|
||||||
|
_API.handler.fileblob @path, (d) ->
|
||||||
|
blob = new Blob [d], { type: "octet/stream" }
|
||||||
|
_API.saveblob me.basename, blob
|
||||||
|
when "move"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
|
||||||
|
|
||||||
|
self.OS.API.VFS.register "^shared$", SharedFileHandler
|
@ -131,8 +131,10 @@ class Blogger extends this.OS.GUI.BaseApplication
|
|||||||
className: "fa fa-file-image-o",
|
className: "fa fa-file-image-o",
|
||||||
action: (e) ->
|
action: (e) ->
|
||||||
me.openDialog "FileDiaLog", (d, n) ->
|
me.openDialog "FileDiaLog", (d, n) ->
|
||||||
doc = me.editor.codemirror.getDoc()
|
"#{d}/#{n}".asFileHandler().publish (r) ->
|
||||||
doc.replaceSelection "![](#{me._api.handler.get}/#{d}/#{n})"
|
return me.error "Cannot export file for embeding to text" if r.error
|
||||||
|
doc = me.editor.codemirror.getDoc()
|
||||||
|
doc.replaceSelection "![](#{me._api.handler.shared}/#{r.result})"
|
||||||
, "Select image file", { mimes: ["image/.*"] }
|
, "Select image file", { mimes: ["image/.*"] }
|
||||||
},
|
},
|
||||||
"|",
|
"|",
|
||||||
|
@ -21,6 +21,9 @@ afx-list-view[data-id = "notifylist"] li{
|
|||||||
border:1px solid #a6a6a6;
|
border:1px solid #a6a6a6;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
-ms-word-break: break-all;
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
afx-overlay[data-id = "feedzone"]{
|
afx-overlay[data-id = "feedzone"]{
|
||||||
@ -42,4 +45,7 @@ afx-list-view[data-id = "notifeed"] li{
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
z-index: 99999;
|
z-index: 99999;
|
||||||
|
-ms-word-break: break-all;
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
}
|
}
|
@ -80,7 +80,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
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}"
|
||||||
console.log "error"
|
|
||||||
me.currdir = dir
|
me.currdir = dir
|
||||||
if not dir.isRoot()
|
if not dir.isRoot()
|
||||||
p = dir.parent().asFileHandler()
|
p = dir.parent().asFileHandler()
|
||||||
@ -103,6 +103,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "Open with", dataid: "#{@name}-open", child:@apps },
|
{ text: "Open with", dataid: "#{@name}-open", child:@apps },
|
||||||
{ text: "Upload", dataid: "#{@name}-upload" },
|
{ text: "Upload", dataid: "#{@name}-upload" },
|
||||||
{ text: "Download", dataid: "#{@name}-download" },
|
{ text: "Download", dataid: "#{@name}-download" },
|
||||||
|
{ text: "Share file", dataid: "#{@name}-share" },
|
||||||
{ text: "Properties", dataid: "#{@name}-info" }
|
{ text: "Properties", dataid: "#{@name}-info" }
|
||||||
], onmenuselect: (e) -> me.actionFile e
|
], onmenuselect: (e) -> me.actionFile e
|
||||||
}
|
}
|
||||||
@ -251,6 +252,13 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@currdir.upload (r) ->
|
@currdir.upload (r) ->
|
||||||
me.error "Faile to upload to: #{d}: #{r.error}" if r.error
|
me.error "Faile to upload to: #{d}: #{r.error}" if r.error
|
||||||
|
|
||||||
|
when "#{@name}-share"
|
||||||
|
me = @
|
||||||
|
return unless file and file.type is "file"
|
||||||
|
file.path.asFileHandler().publish (r) ->
|
||||||
|
return me.error "Cannot share file: #{r.error}" if r.error
|
||||||
|
return me.notify "Shared url: #{r.result}"
|
||||||
|
|
||||||
when "#{@name}-download"
|
when "#{@name}-download"
|
||||||
return unless file
|
return unless file
|
||||||
file.path.asFileHandler().download ()->
|
file.path.asFileHandler().download ()->
|
||||||
|
Loading…
Reference in New Issue
Block a user