add draggable treeview

This commit is contained in:
Xuan Sang LE 2020-05-19 20:00:56 +02:00
parent ff6f480f08
commit 53df50f196
22 changed files with 215 additions and 93 deletions

View File

@ -117,7 +117,7 @@ Ant.OS.GUI =
return Ant.OS.announcer.osinfo __("Application {0} is not executable", it.text) if it.type is "app" return Ant.OS.announcer.osinfo __("Application {0} is not executable", it.text) if it.type is "app"
apps = Ant.OS.GUI.appsByMime ( if it.type is "dir" then "dir" else it.mime ) apps = Ant.OS.GUI.appsByMime ( if it.type is "dir" then "dir" else it.mime )
return Ant.OS.announcer.osinfo __("No application available to open {0}", it.filename) if apps.length is 0 return Ant.OS.announcer.osinfo __("No application available to open {0}", it.filename) if apps.length is 0
return Ant.OS.GUI.launch apps[0].app, [it.path] if apps.length is 1 return Ant.OS.GUI.launch apps[0].app, [it] if apps.length is 1
list = ( { text: e.app, icon: e.icon, iconclass: e.iconclass } for e in apps ) list = ( { text: e.app, icon: e.icon, iconclass: e.iconclass } for e in apps )
Ant.OS.GUI.openDialog("SelectionDialog", { Ant.OS.GUI.openDialog("SelectionDialog", {
title: __("Open with"), title: __("Open with"),
@ -360,7 +360,11 @@ Ant.OS.GUI =
# desktop[0].set "selected", -1 # desktop[0].set "selected", -1
desktop.on "click", (e) -> desktop.on "click", (e) ->
return unless e.target.tagName.toUpperCase() is "UL" el = $(e.target).parent()
return unless el.length > 0
el = el.parent()
return unless el.length > 0
return unless el[0] is desktop[0]
desktop[0].unselect() desktop[0].unselect()
($ "#sysdock").get(0).set "selectedApp", null ($ "#sysdock").get(0).set "selectedApp", null
@ -418,6 +422,8 @@ Ant.OS.GUI =
($ "#login_error").html "Login: server error" ($ "#login_error").html "Login: server error"
($ "#txtpass").keyup (e) -> ($ "#txtpass").keyup (e) ->
($ "#btlogin").click() if e.which is 13 ($ "#btlogin").click() if e.which is 13
($ "#txtuser").keyup (e) ->
($ "#btlogin").click() if e.which is 13
startAntOS: (conf) -> startAntOS: (conf) ->
# clean up things # clean up things
@ -471,7 +477,7 @@ Ant.OS.GUI.schemes.ws = """
Ant.OS.GUI.schemes.login = """ Ant.OS.GUI.schemes.login = """
<div id = "login_form"> <div id = "login_form">
<p>Welcome to AntOS, please identify</p> <p>Welcome to AntOS, please login</p>
<input id = "txtuser" type = "text" value = "demo" /> <input id = "txtuser" type = "text" value = "demo" />
<input id = "txtpass" type = "password" value = "demo" /> <input id = "txtpass" type = "password" value = "demo" />
<button id = "btlogin">Login</button> <button id = "btlogin">Login</button>

View File

@ -3,6 +3,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
super r, o super r, o
@setopt "onfileselect", ()-> @setopt "onfileselect", ()->
@setopt "onfileopen", () -> @setopt "onfileopen", () ->
@setopt "ondragndrop", () ->
@setopt "selectedFile", undefined @setopt "selectedFile", undefined
@setopt "data", [] @setopt "data", []
@setopt "status", true @setopt "status", true
@ -41,12 +42,15 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
@refs.status.set("text", " ") if @get "status" @refs.status.set("text", " ") if @get "status"
.catch (e) -> .catch (e) ->
# this should be handled by the OS # this should be handled by the OS
Ant.OS.announcer.oserror e Ant.OS.announcer.oserror e.toString(), e
__data__: (v) -> __data__: (v) ->
return unless v return unless v
@refreshData() @refreshData()
__ondragndrop__: (v) ->
@refs.treeview.set "ondragndrop", v
sortByType: (a, b) -> sortByType: (a, b) ->
if a.type < b.type if a.type < b.type
-1 -1
@ -182,6 +186,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
.then (d) => resolve @getTreeData(d.sort @sortByType) .then (d) => resolve @getTreeData(d.sort @sortByType)
.catch (e) -> reject e .catch (e) -> reject e
@refs.gridview.set "header", @header @refs.gridview.set "header", @header
@refs.treeview.set "dragndrop", true
# even handles # even handles
@refs.listview.set "onlistselect", (e) => @refs.listview.set "onlistselect", (e) =>
@fileselect e.data.item.get("data") @fileselect e.data.item.get("data")

View File

@ -112,7 +112,9 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
row.domel = rowel[0] row.domel = rowel[0]
for cell in row for cell in row
el = $("<#{@get("cellitem")}>").appendTo rowel tag = @get "cellitem"
tag = cell.tag if cell.tag
el = $("<#{tag}>").appendTo rowel
cell.domel = el[0] cell.domel = el[0]
el[0].uify undefined el[0].uify undefined
el[0].set "oncellselect", (e) => @cellselect e, false el[0].set "oncellselect", (e) => @cellselect e, false

View File

@ -103,7 +103,9 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
@get("data").includes v @get("data").includes v
push: (item, flag) -> push: (item, flag) ->
el = $("<#{@get "itemtag"}>") tag = @get "itemtag"
tag = item.tag if item.tag
el = $("<#{tag}>")
if flag if flag
@get("data").unshift item if not @has_data item @get("data").unshift item if not @has_data item
$(@refs.mlist).prepend el[0] $(@refs.mlist).prepend el[0]

View File

@ -208,7 +208,9 @@ class MenuTag extends Ant.OS.GUI.BaseTag
$(item).remove() $(item).remove()
push: (item, flag) -> push: (item, flag) ->
el = $("<#{@get("contentag")}>") tag = @get "contentag"
tag = item.tag if item.tag
el = $("<#{tag}>")
if flag if flag
$(@refs.container).prepend el[0] $(@refs.container).prepend el[0]
@get("items").unshift item @get("items").unshift item

View File

@ -13,12 +13,14 @@ class ResizerTag extends Ant.OS.GUI.BaseTag
if tagname is "AFX-HBOX" if tagname is "AFX-HBOX"
@dir = "hz" @dir = "hz"
$(@root).css "cursor", "col-resize" $(@root).css "cursor", "col-resize"
$(@root).addClass "horizontal"
if @resizable_el if @resizable_el
att = $(@resizable_el).attr "min-width" att = $(@resizable_el).attr "min-width"
@minsize = parseInt(att) if att @minsize = parseInt(att) if att
else if tagname is "AFX-VBOX" else if tagname is "AFX-VBOX"
@dir = "ve" @dir = "ve"
$(@root).css "cursor", "row-resize" $(@root).css "cursor", "row-resize"
$(@root).addClass "vertical"
if @resizable_el if @resizable_el
att = $(@resizable_el).attr "min-height" att = $(@resizable_el).attr "min-height"
@minsize = parseInt(att) if att @minsize = parseInt(att) if att

View File

@ -3,7 +3,7 @@ class SystemPanelTag extends Ant.OS.GUI.BaseTag
super r, o super r, o
@setopt "osmenu", { @setopt "osmenu", {
text: __("Start"), text: __("Start"),
iconclass: "fa fa-eercast" iconclass: "fa fa-circle"
} }
@setopt "appmenu", [] @setopt "appmenu", []
@setopt "systray", [] @setopt "systray", []

View File

@ -9,6 +9,7 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
@setopt "fetch", undefined @setopt "fetch", undefined
@setopt "open", true @setopt "open", true
@setopt "itemindex", 0 @setopt "itemindex", 0
@setopt "parent", undefined
@setopt "selected", false @setopt "selected", false
@setopt "treepath", @aid() @setopt "treepath", @aid()
@ -37,7 +38,10 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
.then (d) => .then (d) =>
return unless d return unless d
@.set "nodes", d @.set "nodes", d
.catch (e) -> Ant.OS.announcer.oserror e .catch (e) ->
Ant.OS.announcer.oserror e.toString(), e
else
@.set "nodes", @__("nodes")
$(@refs.childnodes).show() $(@refs.childnodes).show()
else else
$(@refs.childnodes).hide() $(@refs.childnodes).hide()
@ -71,9 +75,10 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
for v in nodes for v in nodes
el = $("<afx-tree-view>").appendTo @refs.childnodes el = $("<afx-tree-view>").appendTo @refs.childnodes
el[0].uify undefined el[0].uify undefined
el[0].set "treeroot", @get("treeroot") el[0].set "treeroot", root
el[0].set "indent", (@get("indent") + 1) el[0].set "indent", (@get("indent") + 1)
root.indexcounter++ root.indexcounter++
el[0].set "parent", @get("parent")
el[0].set "itemindex", root.indexcounter el[0].set "itemindex", root.indexcounter
el[0].set "treepath", "#{@get("treepath")}/#{el[0].aid()}" el[0].set "treepath", "#{@get("treepath")}/#{el[0].aid()}"
el[0].set "fetch", @get("fetch") el[0].set "fetch", @get("fetch")
@ -154,9 +159,12 @@ class TreeViewTag extends Ant.OS.GUI.BaseTag
@setopt "itemindex", 0 @setopt "itemindex", 0
@setopt "ontreeselect", () -> @setopt "ontreeselect", () ->
@setopt "ontreedbclick", () -> @setopt "ontreedbclick", () ->
@setopt "ondragndrop", () ->
@setopt "selectedItem", undefined @setopt "selectedItem", undefined
@setopt "fetch", undefined @setopt "fetch", undefined
@setopt "dragndrop", false
@setopt "treepath", @aid() @setopt "treepath", @aid()
@root.is_left = () => @is_left()
@indexcounter = 0 @indexcounter = 0
__selectedItem: (v) -> __selectedItem: (v) ->
@ -164,6 +172,7 @@ class TreeViewTag extends Ant.OS.GUI.BaseTag
@get("selectedItem").set "selected", false if @get("selectedItem") @get("selectedItem").set "selected", false if @get("selectedItem")
v.set "selected", true v.set "selected", true
itemclick: (e, flag) -> itemclick: (e, flag) ->
return unless e and e.item return unless e and e.item
return if e.item is @get("selectedItem") and not flag return if e.item is @get("selectedItem") and not flag
@ -179,11 +188,18 @@ class TreeViewTag extends Ant.OS.GUI.BaseTag
is_root: () -> is_root: () ->
return @get("treeroot") is undefined return @get("treeroot") is undefined
is_left: () ->
data = @get "data"
return true unless data
return if data.nodes then false else true
__data__: (v) -> __data__: (v) ->
return unless v return unless v
$(@root).empty() $(@root).empty()
@set "treepath", v.path if v.path @set "treepath", v.path if v.path
el = $("<#{@get "itemtag"}>").appendTo @root tag = @get "itemtag"
tag = v.tag if v.tag
el = $("<#{tag}>").appendTo @root
el[0].uify undefined el[0].uify undefined
el[0].set "treeroot", if @is_root() then @ else @get "treeroot" el[0].set "treeroot", if @is_root() then @ else @get "treeroot"
el[0].set "indent", @get("indent") el[0].set "indent", @get("indent")
@ -191,7 +207,52 @@ class TreeViewTag extends Ant.OS.GUI.BaseTag
el[0].set "treepath", @get("treepath") el[0].set "treepath", @get("treepath")
el[0].set "open", @get("open") el[0].set "open", @get("open")
el[0].set "fetch", @get("fetch") el[0].set "fetch", @get("fetch")
el[0].set "parent", @root
el[0].set "data", v el[0].set "data", v
if @is_root()
$(@root).off "mousedown", @treemousedown
$(@root).on "mousedown", @treemousedown if @get("dragndrop")
mount: () ->
@dnd = {}
@treemousedown = (e) =>
el = $(e.target).closest("afx-tree-view")
return if el.length is 0
el = el[0]
return if el is @root
e.source = el
@dnd.from = el
@dnd.to = undefined
$(window).on "mouseup", @treemouseup
$(window).on "mousemove", @treemousemove
@treemouseup = (e) =>
$(window).off "mouseup", @treemouseup
$(window).off "mousemove", @treemousemove
($ "#systooltip").hide()
el = $(e.target).closest("afx-tree-view")
return if el.length is 0
el = el[0]
el = el.get("parent") if el.is_left()
return if el is @dnd.from or el is @dnd.from.get("parent")
@dnd.to = el
@__("ondragndrop") { id: @aid(), data: @dnd }
@dnd = {}
@treemousemove = (e) =>
return unless e
return unless @dnd.from
data = @dnd.from.get("data")
$label = $("#systooltip")
top = e.clientY + 5
left = e.clientX + 5
$label.show()
$label[0].set "text", data.name
$label[0].set "icon", data.icon if data.icon
$label[0].set "iconclass", data.iconclass if data.iconclass
$label
.css "top", top + "px"
.css "left", left + "px"
Ant.OS.GUI.define "afx-tree-view", TreeViewTag Ant.OS.GUI.define "afx-tree-view", TreeViewTag
Ant.OS.GUI.define "afx-tree-view-item-proto", TreeViewItemPrototype Ant.OS.GUI.define "afx-tree-view-item-proto", TreeViewItemPrototype

View File

@ -104,7 +104,7 @@ class BaseFileHandle
return resolve(@info) if @ready return resolve(@info) if @ready
@meta() @meta()
.then (d) => .then (d) =>
return reject d if d.errors return reject Ant.OS.API.throwe d.error if d.errors
@info = d.result @info = d.result
@ready = true @ready = true
resolve(d.result) resolve(d.result)
@ -190,7 +190,7 @@ class BaseFileHandle
.then (r) => .then (r) =>
@_mv(d) @_mv(d)
.then (data) => .then (data) =>
Ant.OS.announcer.ostrigger "VFS", { m: "move", file: @ } Ant.OS.announcer.ostrigger "VFS", { m: "move", file: d.asFileHandle() }
resolve data resolve data
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -210,7 +210,7 @@ class BaseFileHandle
unsupported: (t) -> unsupported: (t) ->
new Promise (resolve, reject) => new Promise (resolve, reject) =>
reject { error: __("Action {0} is unsupported on: {1}", t, @path) } reject Ant.OS.API.throwe __("Action {0} is unsupported on: {1}", t, @path)
# actions must be implemented by subclasses # actions must be implemented by subclasses
_rd: (t) -> @unsupported "read" _rd: (t) -> @unsupported "read"
@ -232,7 +232,13 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
super path super path
meta: () -> meta: () ->
Ant.OS.API.handle.fileinfo @path new Promise (resolve, reject) =>
Ant.OS.API.handle.fileinfo @path
.then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
getlink: () -> getlink: () ->
Ant.OS.API.handle.get + "/" + @path Ant.OS.API.handle.get + "/" + @path
@ -250,38 +256,62 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
_wr: (t) -> _wr: (t) ->
# t is base64 or undefined # t is base64 or undefined
return Ant.OS.API.handle.write @path, @cache if t is "base64"
new Promise (resolve, reject) => new Promise (resolve, reject) =>
@b64(t) if t is "base64"
.then (r) => Ant.OS.API.handle.write(@path, @cache).then (d) ->
Ant.OS.API.handle.write @path, r return reject Ant.OS.API.throwe d.error if d.error
.then (result) -> resolve d
resolve result
.catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
else
@b64(t)
.then (r) =>
Ant.OS.API.handle.write @path, r
.then (result) ->
return reject Ant.OS.API.throwe result.error if result.error
resolve result
.catch (e) -> reject e
.catch (e) -> reject e
_mk: (d) -> _mk: (d) ->
if not @info new Promise (resolve, reject) =>
return new Promise (resolve, reject) => if not @info
reject Ant.OS.API.throwe __( return reject Ant.OS.API.throwe __(
"file meta-data not found: {0}", @path) "file meta-data not found: {0}", @path)
if @info.type is "file" if @info.type is "file"
return new Promise (resolve, reject) => return reject Ant.OS.API.throwe __("{0} is not a directory", @path)
reject Ant.OS.API.throwe __("{0} is not a directory", @path) Ant.OS.API.handle.mkdir "#{@path}/#{d}"
Ant.OS.API.handle.mkdir "#{@path}/#{d}" .then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
_rm: () -> _rm: () ->
Ant.OS.API.handle.delete @path new Promise (resolve, reject) =>
Ant.OS.API.handle.delete @path
.then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
_mv: (d) -> _mv: (d) ->
Ant.OS.API.handle.move @path, d new Promise (resolve, reject) =>
Ant.OS.API.handle.move @path, d
.then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
_up: () -> _up: () ->
if @info.type isnt "dir" new Promise (resolve, reject) =>
return new Promise (resolve, reject) => if @info.type isnt "dir"
reject Ant.OS.API.throwe __("{0} is not a file", @path) return reject Ant.OS.API.throwe __("{0} is not a file", @path)
Ant.OS.API.handle.upload @path Ant.OS.API.handle.upload @path
.then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
_down: () -> _down: () ->
new Promise (resolve, reject) => new Promise (resolve, reject) =>
@ -296,7 +326,12 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
reject e reject e
_pub: () -> _pub: () ->
Ant.OS.API.handle.sharefile @path, true new Promise (resolve, reject) =>
Ant.OS.API.handle.sharefile @path, true
.then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
Ant.OS.API.VFS.register "^(home|desktop|os|Untitled)$", RemoteFileHandle Ant.OS.API.VFS.register "^(home|desktop|os|Untitled)$", RemoteFileHandle
@ -374,10 +409,20 @@ class SharedFileHandle extends Ant.OS.API.VFS.BaseFileHandle
Ant.OS.API.handle.readfile @path, if t then t else "text" Ant.OS.API.handle.readfile @path, if t then t else "text"
_wr: (d, t) -> _wr: (d, t) ->
Ant.OS.API.handle.write @path, d new Promise (resolve, reject) =>
Ant.OS.API.handle.write @path, d
.then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
_rm: () -> _rm: () ->
Ant.OS.API.handle.sharefile @basename, false new Promise (resolve, reject) =>
Ant.OS.API.handle.sharefile @basename, false
.then (d) ->
return reject Ant.OS.API.throwe d.error if d.error
resolve d
.catch (e) -> reject e
_down: () -> _down: () ->
new Promise (resolve, reject) => new Promise (resolve, reject) =>

View File

@ -77,7 +77,6 @@ class CodePad.BaseExtension
dest.asFileHandle() dest.asFileHandle()
.setCache('data:application/zip;base64,' + data) .setCache('data:application/zip;base64,' + data)
.write("base64").then (r) => .write("base64").then (r) =>
return reject r.error if r.error
@notify __("Package is generated in release folder") @notify __("Package is generated in release folder")
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e

View File

@ -112,7 +112,6 @@ class App.extensions.AntOSDK extends App.BaseExtension
.setCache jsrc .setCache jsrc
.write("text/plain") .write("text/plain")
.then (d) -> .then (d) ->
return e d.error if d.error
r() r()
.catch (ex) -> e ex .catch (ex) -> e ex
.then () => .then () =>
@ -125,7 +124,6 @@ class App.extensions.AntOSDK extends App.BaseExtension
.setCache txt .setCache txt
.write("text/plain") .write("text/plain")
.then (d) -> .then (d) ->
return e d.error if d.error
r() r()
.catch (ex) -> e ex .catch (ex) -> e ex
.then () => .then () =>

View File

@ -107,7 +107,6 @@ class App.extensions.ExtensionMaker extends App.BaseExtension
.setCache jsrc .setCache jsrc
.write("text/plain") .write("text/plain")
.then (d) -> .then (d) ->
return e d.error if d.error
r() r()
.catch (ex) -> e ex .catch (ex) -> e ex
.then () -> .then () ->
@ -117,7 +116,6 @@ class App.extensions.ExtensionMaker extends App.BaseExtension
.setCache meta.meta .setCache meta.meta
.write("object") .write("object")
.then (data) -> .then (data) ->
return e data.error if data.error
r data r data
.catch (ex) -> e ex .catch (ex) -> e ex
.then () => .then () =>

View File

@ -109,11 +109,19 @@ class CodePad extends this.OS.GUI.BaseApplication
@bindKey "CTRL-S", () => @menuAction "save" @bindKey "CTRL-S", () => @menuAction "save"
@bindKey "ALT-W", () => @menuAction "saveas" @bindKey "ALT-W", () => @menuAction "saveas"
@fileview.set "ondragndrop", (e) =>
src = e.data.from.get("data").path.asFileHandle()
des = e.data.to.get("data").path
src.move "#{des}/#{src.basename}"
.then (d) ->
e.data.to.update des
e.data.from.get("parent").update src.parent().path
.catch (e) => @error __("Unable to move file/folder"), e
@loadExtensionMetaData() @loadExtensionMetaData()
@initCommandPalete() @initCommandPalete()
@initSideBar() @initSideBar()
@openFile @currfile @openFile @currfile
openFile: (file) -> openFile: (file) ->
#find tab #find tab
@ -303,10 +311,9 @@ class CodePad extends this.OS.GUI.BaseApplication
fp = "#{dir.path}/#{d}".asFileHandle() fp = "#{dir.path}/#{d}".asFileHandle()
fp.write("text/plain") fp.write("text/plain")
.then (r) => .then (r) =>
return @error __("Fail to create {0}: {1}", d, r.error) if r.error
@fileview.update dir.path @fileview.update dir.path
.catch (e) => .catch (e) =>
@error __("Fail to create: {0}", e.stack), e @error __("Fail to create: {0}", e.stack), e
when "newdir" when "newdir"
return unless dir return unless dir
@ -317,10 +324,9 @@ class CodePad extends this.OS.GUI.BaseApplication
.then (d) => .then (d) =>
dir.mk(d) dir.mk(d)
.then (r) => .then (r) =>
return @error __("Fail to create {0}: {1}", d, r.error) if r.error
@fileview.update dir.path @fileview.update dir.path
.catch (e) => .catch (e) =>
@error __("Fail to create: {0}", dir.path), e @error __("Fail to create: {0}", dir.path), e
when "rename" when "rename"
return unless file return unless file
@ -335,10 +341,9 @@ class CodePad extends this.OS.GUI.BaseApplication
dir = file.parent() dir = file.parent()
file.move "#{dir.path}/#{d}" file.move "#{dir.path}/#{d}"
.then (r) => .then (r) =>
return @error __("Fail to rename to {0}: {1}", d, r.error) if r.error
@fileview.update dir.path @fileview.update dir.path
.catch (e) => .catch (e) =>
@error __("Fail to rename: {0}", file.path), e @error __("Fail to rename: {0}", file.path), e
when "delete" when "delete"
return unless file return unless file
@ -353,10 +358,9 @@ class CodePad extends this.OS.GUI.BaseApplication
dir = file.parent() dir = file.parent()
file.remove() file.remove()
.then (r) => .then (r) =>
return @error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
@fileview.update dir.path @fileview.update dir.path
.catch (e) => .catch (e) =>
@error __("Fail to delete: {0}", file.path), e @error __("Fail to delete: {0}", file.path), e
else else
@ -364,7 +368,6 @@ class CodePad extends this.OS.GUI.BaseApplication
save: (file) -> save: (file) ->
file.write("text/plain") file.write("text/plain")
.then (d) => .then (d) =>
return @error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
file.dirty = false file.dirty = false
file.text = file.basename file.text = file.basename
@tabbar.update() @tabbar.update()

View File

@ -155,6 +155,7 @@ class PushNotification extends this.OS.GUI.BaseService
error: o.data.e, error: o.data.e,
time: logtime time: logtime
} }
@dialog.loglist.set "data", @dialog.data.logs if @dialog
pushout: (s, o) -> pushout: (s, o) ->
d = { d = {

View File

@ -81,6 +81,7 @@ class Files extends this.OS.GUI.BaseApplication
@currdir = dir @currdir = dir
($ @navinput).val dir.path ($ @navinput).val dir.path
resolve d.result resolve d.result
.catch (e) -> reject e
@setting.sidebar = true if @setting.sidebar is undefined @setting.sidebar = true if @setting.sidebar is undefined
@setting.nav = true if @setting.nav is undefined @setting.nav = true if @setting.nav is undefined
@ -214,8 +215,6 @@ class Files extends this.OS.GUI.BaseApplication
.then (d) => .then (d) =>
return if d is file.filename return if d is file.filename
file.path.asFileHandle().move "#{@currdir.path}/#{d}" file.path.asFileHandle().move "#{@currdir.path}/#{d}"
.then (r) =>
@error __("Fail to rename to {0}: {1}", d, r.error) if r.error
.catch (e) => .catch (e) =>
@error __("Fail to rename: {0}", file.path), e @error __("Fail to rename: {0}", file.path), e
@ -229,8 +228,6 @@ class Files extends this.OS.GUI.BaseApplication
.then (d) => .then (d) =>
return unless d return unless d
file.path.asFileHandle().remove() file.path.asFileHandle().remove()
.then (r) =>
@error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
.catch (e) => .catch (e) =>
@error __("Fail to delete: {0}", file.path), e @error __("Fail to delete: {0}", file.path), e
@ -254,7 +251,6 @@ class Files extends this.OS.GUI.BaseApplication
@clipboard.file.move "#{@currdir.path}/#{@clipboard.file.basename}" @clipboard.file.move "#{@currdir.path}/#{@clipboard.file.basename}"
.then (r) => .then (r) =>
@clipboard = undefined @clipboard = undefined
@error __("Fail to paste: {0}", r.error) if r.error
.catch (e) => .catch (e) =>
@error __("Fail to paste: {0}", @clipboard.file.path), e @error __("Fail to paste: {0}", @clipboard.file.path), e
else else
@ -266,7 +262,6 @@ class Files extends this.OS.GUI.BaseApplication
fp.write(@clipboard.file.info.mime) fp.write(@clipboard.file.info.mime)
.then (r) => .then (r) =>
@clipboard = undefined @clipboard = undefined
@error __("Fail to paste: {0}", r.error) if r.error
.catch (e) => .catch (e) =>
@error __("Fail to paste: {0}", @clipboard.file.path), e @error __("Fail to paste: {0}", @clipboard.file.path), e
.catch (e) => .catch (e) =>
@ -284,8 +279,6 @@ class Files extends this.OS.GUI.BaseApplication
}) })
.then (d) => .then (d) =>
@currdir.mk(d) @currdir.mk(d)
.then (r) =>
@error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) => .catch (e) =>
@error __("Fail to create: {0}", d), e @error __("Fail to create: {0}", d), e
@ -297,8 +290,6 @@ class Files extends this.OS.GUI.BaseApplication
.then (d) => .then (d) =>
fp = "#{@currdir.path}/#{d}".asFileHandle() fp = "#{@currdir.path}/#{d}".asFileHandle()
fp.write("text/plain") fp.write("text/plain")
.then (r) =>
@error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) => .catch (e) =>
@error __("Fail to create: {0}", fp.path) @error __("Fail to create: {0}", fp.path)
@ -308,8 +299,6 @@ class Files extends this.OS.GUI.BaseApplication
when "#{@name}-upload" when "#{@name}-upload"
@currdir.upload() @currdir.upload()
.then (r) =>
@error __("Fail to upload to {0}: {1}", @currdir.path, r.error) if r.error
.catch (e) => .catch (e) =>
@error __("Fail to upload: {0}", e.toString()), e @error __("Fail to upload: {0}", e.toString()), e
@ -317,8 +306,7 @@ class Files extends this.OS.GUI.BaseApplication
return unless file and file.type is "file" return unless file and file.type is "file"
file.path.asFileHandle().publish() file.path.asFileHandle().publish()
.then (r) => .then (r) =>
return @error __("Cannot share file: {0}", r.error) if r.error @notify __("Shared url: {0}", r.result)
return @notify __("Shared url: {0}", r.result)
.catch (e) => .catch (e) =>
@error __("Fail to publish: {0}", file.path), e @error __("Fail to publish: {0}", file.path), e

View File

@ -1,6 +1,6 @@
afx-grid-view afx-grid-row:nth-child(even) afx-grid-cell afx-grid-view afx-grid-row:nth-child(even) afx-grid-cell
{ {
background-color: #464646; background-color: #3b3b3b;
} }
afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell

View File

@ -6,7 +6,7 @@ afx-list-view > div.list-container > ul li{
background-color: #363636; background-color: #363636;
} }
afx-list-view > div.list-container > ul afx-list-item:nth-child(even) li{ afx-list-view > div.list-container > ul afx-list-item:nth-child(even) li{
background-color:#464646; background-color:#3b3b3b;
} }
afx-list-view i.closable{ afx-list-view i.closable{
width: 16px; width: 16px;

View File

@ -1,4 +1,8 @@
afx-resizer { afx-resizer.vertical {
background-color: transparent;
border-top: 1px solid #262626;
}
afx-resizer.horizontal {
background-color: transparent; background-color: transparent;
border-left: 1px solid #262626; border-left: 1px solid #262626;
} }

View File

@ -21,7 +21,7 @@ afx-tree-view div.afx_tree_item_selected:hover{
afx-tree-view .afx_folder_item{ afx-tree-view .afx_folder_item{
font-weight: bold; font-weight: bold;
} }
/*
afx-tree-view .afx_tree_item_odd{ afx-tree-view .afx_tree_item_odd{
background-color: #464646; background-color: #464646;
} }*/

View File

@ -1,4 +1,8 @@
afx-resizer { afx-resizer.vertical {
background-color: transparent; background-color: transparent;
border-left: 1px solid #868686; border-top: 1px solid #868686;
}
afx-resizer.horizontal {
background-color: transparent;
border-left: 1px solid #868686;
} }

View File

@ -21,7 +21,8 @@ afx-tree-view div.afx_tree_item_selected:hover{
afx-tree-view .afx_folder_item{ afx-tree-view .afx_folder_item{
font-weight: bold; font-weight: bold;
} }
/*
afx-tree-view .afx_tree_item_odd{ afx-tree-view .afx_tree_item_odd{
background-color: #f5F5F5; background-color: #f5F5F5;
} }
*/

View File

@ -62,11 +62,11 @@ body
#login_form{ #login_form{
width:300px; width:300px;
height: 200px; height: 180px;
display: block; display: block;
border:1px solid #a6a6a6; border:1px solid #262626;
border-radius: 6px; border-radius: 6px;
box-shadow: 1px 1px 1px #9f9F9F; box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.65);
position: absolute; position: absolute;
margin: auto; margin: auto;
top:0; top:0;
@ -76,14 +76,14 @@ body
font-family:Verdana, Geneva, Tahoma, sans-serif; font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size: 13px; font-size: 13px;
text-align: center; text-align: center;
background-color: white; background-color: #363636;
color: #414339; color: white;
} }
#login_form p{ #login_form p{
display: inline-block; display: inline-block;
background-color:#dfdfdf; /* background-color:#dfdfdf; */
border-bottom: 1px solid #a6a6a6; border-bottom: 1px solid #262626;
padding:10px; padding:10px;
width: calc(100% - 20px); width: calc(100% - 20px);
border-top-left-radius: 6px; border-top-left-radius: 6px;
@ -100,24 +100,25 @@ body
box-sizing: border-box; box-sizing: border-box;
font-size: 13px; font-size: 13px;
padding: 5px; padding: 5px;
border: 1px solid #a6a6a6; color: white;
background-color: white; border: 1px solid #262626;
color: #414339; background-color: #464646;
} }
#login_form button{ #login_form button{
margin-top:10px; margin-top:10px;
width: 250px; width: 250px;
height: 30px; height: 30px;
background-color: #2786F3; background-color: #464646;
border: 1px solid #262626;
color: white; color: white;
border: 1px solid #dedede;
border-radius: 6px; border-radius: 6px;
font-family: Verdana, Geneva, Tahoma, sans-serif; font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 13px; font-size: 13px;
padding:5px; padding:5px;
outline: none;
} }
#login_error{ #login_error{
padding:3px; padding:3px;
color:red; color:chocolate;
font-weight: normal; font-weight: normal;
} }