mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-27 03:09:45 +02:00
add file sync mechanism between apps
This commit is contained in:
@ -32,6 +32,7 @@ class PushNotification extends this.OS.GUI.BaseService
|
||||
@subscribe "fail", (o) -> me.pushout 'FAIL', o
|
||||
@subscribe "error", (o) -> me.pushout 'ERROR', o
|
||||
@subscribe "info", (o) -> me.pushout 'INFO', o
|
||||
@subscribe "VFS", (o) -> me.pushout 'INFO', o
|
||||
|
||||
@subscribe "loading", (o) ->
|
||||
me.pending.push o.id
|
||||
|
@ -19,7 +19,6 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@view.set "onfileopen", (e) ->
|
||||
return unless e
|
||||
return if e.type is "dir"
|
||||
#console.log e
|
||||
me._gui.openWith e
|
||||
|
||||
@favo.set "onlistselect", (e) ->
|
||||
@ -52,6 +51,8 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@favo.set "items", mntpoints
|
||||
#@favo.set "selected", -1
|
||||
@applySetting()
|
||||
@subscribe "VFS", (d) ->
|
||||
me.chdir null if d.data.file.hash() is me.currdir.hash() or d.data.file.parent().hash() is me.currdir.hash()
|
||||
@chdir null
|
||||
|
||||
applySetting: (k) ->
|
||||
@ -86,7 +87,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
child: [
|
||||
{ text: "New file", dataid: "#{@name}-mkf" },
|
||||
{ text: "New folder", dataid: "#{@name}-mkdir" },
|
||||
{ text: "Open with", dataid: "#{@name}-open" },
|
||||
{ text: "Open", dataid: "#{@name}-open" },
|
||||
{ text: "Upload", dataid: "#{@name}-upload" },
|
||||
{ text: "Download", dataid: "#{@name}-download" },
|
||||
{ text: "Properties", dataid: "#{@name}-info" }
|
||||
@ -165,7 +166,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
return if d is file.filename
|
||||
file.path.asFileHandler()
|
||||
.move "#{me.currdir.path}/#{d}", (r) ->
|
||||
if r.result then me.chdir null else me.error "Fail to rename to #{d}: #{r.error}"
|
||||
me.error "Fail to rename to #{d}: #{r.error}" if r.error
|
||||
, "Rename", file.filename
|
||||
|
||||
when "#{@name}-rm"
|
||||
@ -175,7 +176,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
return unless d
|
||||
file.path.asFileHandler()
|
||||
.remove (r) ->
|
||||
if r.result then me.chdir null else me.error "Fail to delete #{file.filename}: #{r.error}"
|
||||
me.error "Fail to delete #{file.filename}: #{r.error}" if r.error
|
||||
, "Delete" ,
|
||||
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{file.filename} ?" }
|
||||
|
||||
@ -200,7 +201,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@clipboard.file # duplicate file check
|
||||
.move "#{me.currdir.path}/#{@clipboard.file.basename}", (r) ->
|
||||
me.clipboard = undefined
|
||||
if r.result then me.chdir null else me.error "Fail to paste: #{r.error}"
|
||||
me.error "Fail to paste: #{r.error}" if r.error
|
||||
else
|
||||
@notify "Copy not yet implemented"
|
||||
@clipboard = undefined
|
||||
@ -216,7 +217,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@openDialog "PromptDialog",
|
||||
(d) ->
|
||||
me.currdir.mk d, (r) ->
|
||||
if r.result then me.chdir null else me.error "Fail to create #{d}: #{r.error}"
|
||||
me.error "Fail to create #{d}: #{r.error}" if r.error
|
||||
, "New folder"
|
||||
|
||||
when "#{@name}-mkf"
|
||||
@ -224,7 +225,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
(d) ->
|
||||
fp = "#{me.currdir.path}/#{d}".asFileHandler()
|
||||
fp.write "", (r) ->
|
||||
if r.result then me.chdir null else me.error "Fail to create #{d}: #{r.error}"
|
||||
me.error "Fail to create #{d}: #{r.error}" if r.error
|
||||
, "New file"
|
||||
|
||||
when "#{@name}-info"
|
||||
@ -234,11 +235,14 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
when "#{@name}-upload"
|
||||
me = @
|
||||
@currdir.upload (r) ->
|
||||
if r.result then me.chdir null else me.error "Faile to upload to: #{d}: #{r.error}"
|
||||
me.error "Faile to upload to: #{d}: #{r.error}" if r.error
|
||||
|
||||
when "#{@name}-download"
|
||||
return unless file
|
||||
file.path.asFileHandler().download ()->
|
||||
when "#{@name}-open"
|
||||
return unless file
|
||||
@_gui.openWith file
|
||||
else
|
||||
console.log e
|
||||
|
||||
|
@ -7,6 +7,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
||||
markarea = @find "markarea"
|
||||
@container = @find "mycontainer"
|
||||
@previewOn = false
|
||||
@currfile = if @args and @args.length > 0 then @args[0].asFileHandler() else "Untitled".asFileHandler()
|
||||
@editor = new SimpleMDE
|
||||
element: markarea
|
||||
autofocus: true
|
||||
@ -35,11 +36,13 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
||||
#}
|
||||
}
|
||||
]
|
||||
|
||||
@editor.codemirror.on "change", () ->
|
||||
console.log "thing changed"
|
||||
@on "vboxchange", (e) -> me.resizeContent()
|
||||
@resizeContent()
|
||||
|
||||
@open @currfile
|
||||
|
||||
resizeContent: () ->
|
||||
children = ($ @container).children()
|
||||
titlebar = (($ @scheme).find ".afx-window-top")[0]
|
||||
@ -47,5 +50,51 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
||||
statusbar = children[4]
|
||||
cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 40
|
||||
($ children[2]).css("height", cheight + "px")
|
||||
#($ children[2]).css("height", )
|
||||
|
||||
open: (file) ->
|
||||
#find table
|
||||
me = @
|
||||
file.read (d) ->
|
||||
me.editor.value d
|
||||
|
||||
|
||||
save: (file) ->
|
||||
me = @
|
||||
file.write (file.getb64 "text/plain"), (d) ->
|
||||
return me.error "Error saving file #{file.basename}" if d.error
|
||||
file.dirty = false
|
||||
file.text = file.basename
|
||||
|
||||
menu: () ->
|
||||
me = @
|
||||
menu = [{
|
||||
text: "File",
|
||||
child: [
|
||||
{ text: "Open", dataid: "#{@name}-Open" },
|
||||
{ text: "Save", dataid: "#{@name}-Save" },
|
||||
{ text: "Save as", dataid: "#{@name}-Saveas" }
|
||||
],
|
||||
onmenuselect: (e) -> me.actionFile e
|
||||
}]
|
||||
menu
|
||||
|
||||
actionFile: (e) ->
|
||||
me = @
|
||||
saveas = () ->
|
||||
me.openDialog "FileDiaLog", (d, n) ->
|
||||
me.currfile.setPath "#{d}/#{n}"
|
||||
me.save me.currfile
|
||||
, "Save as", { file: me.currfile }
|
||||
switch e.item.data.dataid
|
||||
when "#{@name}-Open"
|
||||
@openDialog "FileDiaLog", ( d, f ) ->
|
||||
me.open "#{d}/#{f}".asFileHandler()
|
||||
, "Open file"
|
||||
when "#{@name}-Save"
|
||||
@currfile.cache = @editor.value()
|
||||
return @save @currfile if @currfile.basename
|
||||
saveas()
|
||||
when "#{@name}-Saveas"
|
||||
@currfile.cache = @editor.value()
|
||||
saveas()
|
||||
this.OS.register "MarkOn", MarkOn
|
@ -9,5 +9,5 @@
|
||||
"version":"0.1a",
|
||||
"category":"System",
|
||||
"iconclass":"fa fa-pencil-square-o",
|
||||
"mimes":[".*"]
|
||||
"mimes":["text/.*"]
|
||||
}
|
Reference in New Issue
Block a user