adapt apps

This commit is contained in:
lxsang 2020-05-12 21:08:39 +02:00
parent c53fd8bd88
commit 04e5a4d50c
29 changed files with 416 additions and 479 deletions

View File

@ -52,7 +52,7 @@ coffees= src/core/core.coffee \
packages = CoreServices ActivityMonitor Setting ShowCase DummyApp # Files MarkOn MarketPlace Preview NotePad wTerm packages = CoreServices ActivityMonitor Files Setting ShowCase MarkOn# Files MarketPlace Preview NotePad wTerm
main: initd build_coffees build_themes schemes libs build_packages languages main: initd build_coffees build_themes schemes libs build_packages languages
- cp src/index.html $(BUILDDIR)/ - cp src/index.html $(BUILDDIR)/

View File

@ -72,12 +72,12 @@ Ant.OS.announcer =
Ant.OS.announcer.listeners[a.pid].push { e: e, f: f } Ant.OS.announcer.listeners[a.pid].push { e: e, f: f }
Ant.OS.announcer.observable.on e, f Ant.OS.announcer.observable.on e, f
trigger: (e, d) -> Ant.OS.announcer.observable.trigger e, d trigger: (e, d) -> Ant.OS.announcer.observable.trigger e, d
osfail: (m, e, s) -> osfail: (m, e) ->
Ant.OS.announcer.ostrigger "fail", { m: m, e: e, s: s } Ant.OS.announcer.ostrigger "fail", { m: m, e: e }
oserror: (m, e, s) -> oserror: (m, e) ->
Ant.OS.announcer.ostrigger "error", { m: m, e: e, s: s } Ant.OS.announcer.ostrigger "error", { m: m, e: e }
osinfo: (m) -> osinfo: (m) ->
Ant.OS.announcer.ostrigger "info", { m: m, e: null, s: null } Ant.OS.announcer.ostrigger "info", { m: m, e: null }
ostrigger: (e, d) -> ostrigger: (e, d) ->
Ant.OS.announcer.trigger e, { id: 0, data: d, name: "OS" } Ant.OS.announcer.trigger e, { id: 0, data: d, name: "OS" }
unregister: (app) -> unregister: (app) ->

View File

@ -233,7 +233,7 @@ class YesNoDialog extends BasicDialog
init: () -> init: () ->
super.init() super.init()
me = @ me = @
@find("lbl").set "text", @data.label if @data and @data.label @find("lbl").set "*", @data if @data
(@find "btnYes").set "onbtclick", (e) -> (@find "btnYes").set "onbtclick", (e) ->
me.handle(true) if me.handle me.handle(true) if me.handle
me.quit() me.quit()

View File

@ -289,42 +289,47 @@ Ant.OS.API =
libready: (l) -> libready: (l) ->
return Ant.OS.API.shared[l] || false return Ant.OS.API.shared[l] || false
require: (l,f) -> requires: (l) ->
if not Ant.OS.API.shared[l] new Promise (resolve, reject) ->
if l.match /^(https?:\/\/[^\s]+)/g if not Ant.OS.API.shared[l]
Ant.OS.API.script l, () -> link = l
Ant.OS.API.shared[l] = true if not l.match /^(https?:\/\/[^\s]+)/g
Ant.OS.announcer.trigger "sharedlibraryloaded", l path = "os://scripts/"
f() if f cssFile = "#{path}#{l}.css".asFileHandle()
, (e, s) -> cssFile.onready()
Ant.OS.announcer.oserror __("Cannot load 3rd library at: {0}", l), e, r .then () ->
$('<link>', {
rel: 'stylesheet',
type: 'text/css',
'href': "#{cssFile.getlink()}"
})
.appendTo 'head'
.catch (e) ->
js = "#{path}#{l}.js"
link = js.asFileHandle().getlink()
Ant.OS.API.script link
.then () ->
Ant.OS.API.shared[l] = true
console.log "loaded:", l
Ant.OS.announcer.trigger "sharedlibraryloaded", l
resolve(l)
.catch (e) ->
reject e
else else
path = "os://scripts/" console.log l, "Library exist, no need to load"
js = "#{path}#{l}.js" Ant.OS.announcer.trigger "sharedlibraryloaded", l
js.asFileHandle().onready (d) -> resolve()
Ant.OS.API.shared[l] = true
el = $ '<script>', { src: "#{Ant.OS.API.handle.get}/#{js}" }
.appendTo 'head'
#load css file
css = "#{path}#{l}.css"
css.asFileHandle().onready (d) ->
el = $ '<link>', { rel: 'stylesheet', type: 'text/css', 'href': "#{Ant.OS.API.handle.get}/#{css}" }
.appendTo 'head'
, () ->
console.log "loaded", l
Ant.OS.announcer.trigger "sharedlibraryloaded", l
f() if f
else
console.log l, "Library exist, no need to load"
f() if f
Ant.OS.announcer.trigger "sharedlibraryloaded", l
requires:(libs, f) -> require: (libs) ->
return f() unless libs.length > 0 new Promise (resolve, reject) ->
Ant.OS.announcer.observable.one "sharedlibraryloaded", (l) -> return resolve() unless libs.length > 0
libs.splice 0, 1 Ant.OS.announcer.observable.one "sharedlibraryloaded", (l) ->
Ant.OS.API.requires libs, f libs.splice 0, 1
Ant.OS.API.require libs[0], null Ant.OS.API.require libs
.catch (e) -> reject e
.then (r) -> resolve(r)
Ant.OS.API.requires libs[0]
.catch (e) -> reject e
packages: packages:
fetch: () -> fetch: () ->

View File

@ -56,7 +56,12 @@ Ant.OS or=
Ant.OS.announcer.trigger "srvroutineready", app Ant.OS.announcer.trigger "srvroutineready", app
if cls.dependencies if cls.dependencies
libs = (v for v in cls.dependencies) libs = (v for v in cls.dependencies)
Ant.OS.API.requires libs, f Ant.OS.API.require libs
.then () ->
console.log "launch the app"
f()
.catch (e) ->
Ant.OS.announcer.oserror __("Unable to load libraries"), e
else else
f() f()
appByPid: (pid) -> appByPid: (pid) ->

View File

@ -311,10 +311,10 @@ Ant.OS.GUI =
return unless el.length > 0 return unless el.length > 0
Ant.OS.GUI.showTooltip el, ($(el).attr "tooltip"), e Ant.OS.GUI.showTooltip el, ($(el).attr "tooltip"), e
fp = Ant.OS.setting.desktop.path.asFileHandle()
# desktop default file manager # desktop default file manager
desktop = $ Ant.OS.GUI.workspace desktop = $ Ant.OS.GUI.workspace
desktop[0].fetch = () -> desktop[0].fetch = () ->
fp = Ant.OS.setting.desktop.path.asFileHandle()
fn = () -> fn = () ->
fp.read().then (d) -> fp.read().then (d) ->
return Ant.OS.announcer.osfail d.error, (Ant.OS.API.throwe "OS.VFS"), d.error if d.error return Ant.OS.announcer.osfail d.error, (Ant.OS.API.throwe "OS.VFS"), d.error if d.error
@ -385,6 +385,7 @@ Ant.OS.GUI =
desktop[0].fetch() desktop[0].fetch()
Ant.OS.announcer.observable.on "VFS", (d) -> Ant.OS.announcer.observable.on "VFS", (d) ->
return if ["read", "publish", "download"].includes d.data.m
desktop[0].fetch() if d.data.file.hash() is fp.hash() or d.data.file.parent().hash() is fp.hash() desktop[0].fetch() if d.data.file.hash() is fp.hash() or d.data.file.parent().hash() is fp.hash()
Ant.OS.announcer.ostrigger "desktoploaded" Ant.OS.announcer.ostrigger "desktoploaded"
# mount it # mount it

View File

@ -26,6 +26,9 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
return $(@refs.status).show() if v return $(@refs.status).show() if v
$(@refs.status).hide() $(@refs.status).hide()
__showhidden__: (v) ->
@switchView()
__path__: (v) -> __path__: (v) ->
return unless v return unless v
me = @ me = @
@ -36,7 +39,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
me.refs.status.set("text", " ") if me.get "status" me.refs.status.set("text", " ") if me.get "status"
.catch (e) -> .catch (e) ->
# this should be handled by the OS # this should be handled by the OS
console.error e Ant.OS.announcer.oserror e
__data__: (v) -> __data__: (v) ->
return unless v return unless v

View File

@ -1,3 +1,9 @@
class GridRowTag extends Ant.OS.GUI.BaseTag
constructor: (r, o) ->
super r, o
@setopt "data", []
@refs.yield = @root
class GridCellPrototype extends Ant.OS.GUI.BaseTag class GridCellPrototype extends Ant.OS.GUI.BaseTag
constructor: (r, o) -> constructor: (r, o) ->
super r, o super r, o
@ -10,12 +16,15 @@ class GridCellPrototype extends Ant.OS.GUI.BaseTag
__data__: (v) -> __data__: (v) ->
return unless v.selected return unless v.selected
@set "selected", v.selected @set "selected", v.selected
delete v.selected
__selected__: (v) -> __selected__: (v) ->
@get("data").selected = v
return unless v return unless v
@cellseleck {}, false @cellseleck {}, false
update: () ->
@set "data", @get("data")
mount: () -> mount: () ->
me = @ me = @
$(@root).css "display", "block" $(@root).css "display", "block"
@ -34,7 +43,7 @@ class GridCellPrototype extends Ant.OS.GUI.BaseTag
__class__: (v) -> __class__: (v) ->
$(@root).removeClass().addClass @get("class") $(@root).removeClass().addClass @get("class")
class SimpleGridCell extends GridCellPrototype class SimpleGridCellTag extends GridCellPrototype
constructor: (r, o) -> constructor: (r, o) ->
super r, o super r, o
@setopt "header", false @setopt "header", false
@ -64,6 +73,10 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
@setopt "onrowselect", (e) -> @setopt "onrowselect", (e) ->
@setopt "oncelldbclick", (e) -> @setopt "oncelldbclick", (e) ->
@setopt "multiselect", false @setopt "multiselect", false
me = @
@root.push = (r) -> me.push r, false
@root.unshift = (r) -> me.unshift r
@root.remove = (r) -> me.remove r
__header__: (v) -> __header__: (v) ->
return $(@refs.header).hide() if not v or v.length is 0 return $(@refs.header).hide() if not v or v.length is 0
@ -79,17 +92,43 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
me = @ me = @
$(@refs.grid).empty() $(@refs.grid).empty()
for row in rows for row in rows
div = $("<div>") @push row, false
.addClass("afx-grid-row")
.css "display", "contents" remove: (row) ->
.appendTo @refs.grid return unless row
for cell in row rowdata = row.get "data"
el = $("<#{@get("cellitem")}>").appendTo div data = @get "rows"
el[0].uify undefined @set "selectedRow", undefined if @get("selectedRow") is row
cell.domel = el[0] @set "selectedCell", undefined if $(@get("selectedCell")).parent()[0] is row
el[0].set "oncellselect", (e) -> me.cellselect e, false list = @get("selectedRows")
el[0].set "oncelldbclick", (e) -> me.cellselect e, true list.splice(list.indexOf(row), 1) if list.includes(row)
el[0].set "data", cell if data.includes rowdata
data.splice data.indexOf(rowdata), 1
$(row).remove()
push: (row, flag) ->
me = @
rowel = $("<afx-grid-row>")
.css "display", "contents"
rowel[0].uify undefined
rowel[0].set "data", row
row.domel = rowel[0]
for cell in row
el = $("<#{@get("cellitem")}>").appendTo rowel
cell.domel = el[0]
el[0].uify undefined
el[0].set "oncellselect", (e) -> me.cellselect e, false
el[0].set "oncelldbclick", (e) -> me.cellselect e, true
el[0].set "data", cell
if flag
$(@refs.grid).prepend rowel[0]
else
rowel.appendTo @refs.grid
unshift: (row) ->
@push row, true
multiselect: () -> multiselect: () ->
@get "multiselect" @get "multiselect"
@ -114,23 +153,23 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
selectedRow = @get "selectedRow" selectedRow = @get "selectedRow"
selectedRows = @get "selectedRows" selectedRows = @get "selectedRows"
evt = { id: @aid(), data: {} } evt = { id: @aid(), data: {} }
div = $(e.data.item).parent()[0] row = $(e.data.item).parent()[0]
if @multiselect() if @multiselect()
if selectedRows.includes div if selectedRows.includes row
selectedRows.splice selectedRows.indexOf(div) , 1 selectedRows.splice selectedRows.indexOf(row) , 1
$(div).removeClass() $(row).removeClass()
else else
selectedRows.push div selectedRows.push row
$(div).removeClass().addClass("afx-grid-row-selected") $(row).removeClass().addClass("afx-grid-row-selected")
evt.data.items = @get "selectedRows" evt.data.items = @get "selectedRows"
else else
return if selectedRow is div return if selectedRow is row
$(selectedRow).removeClass() $(selectedRow).removeClass()
@set "selectedRow", div @set "selectedRow", row
@set "selectedRows", [div] @set "selectedRows", [row]
evt.data.item = div evt.data.item = row
evt.data.items = [ div ] evt.data.items = [ row ]
$(div).removeClass().addClass("afx-grid-row-selected") $(row).removeClass().addClass("afx-grid-row-selected")
@get("onrowselect") evt @get("onrowselect") evt
@observable.trigger "rowselect", evt @observable.trigger "rowselect", evt
@ -190,5 +229,6 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
] } ] }
] ]
Ant.OS.GUI.define "afx-grid-view", GridViewTag Ant.OS.GUI.define "afx-grid-view", GridViewTag
Ant.OS.GUI.define "afx-grid-cell", SimpleGridCell Ant.OS.GUI.define "afx-grid-cell", SimpleGridCellTag
Ant.OS.GUI.define "afx-grid-row", GridRowTag
Ant.OS.GUI.define "afx-grid-cell-proto", GridCellPrototype Ant.OS.GUI.define "afx-grid-cell-proto", GridCellPrototype

View File

@ -49,7 +49,6 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
mount: () -> mount: () ->
me = @ me = @
@refs.switch.set "enable", false
$(@refs.entry).click (e) -> me.select e $(@refs.entry).click (e) -> me.select e
submenuoff: () -> submenuoff: () ->
@ -99,6 +98,7 @@ class SimpleMenuEntryTag extends MenuEntryTag
$(@refs.switch).hide() $(@refs.switch).hide()
__checked__: (v) -> __checked__: (v) ->
@get("data").checked = v
return unless @get("radio") or @get("switch") return unless @get("radio") or @get("switch")
@refs.switch.set "swon", v @refs.switch.set "swon", v
@ -124,7 +124,7 @@ class SimpleMenuEntryTag extends MenuEntryTag
$(@refs.shortcut).hide() $(@refs.shortcut).hide()
return unless v return unless v
$(@refs.shortcut).show() $(@refs.shortcut).show()
$(@refs.shortcut).val v $(@refs.shortcut).text v
reset_radio: () -> reset_radio: () ->
return unless @has_children() return unless @has_children()
@ -132,15 +132,19 @@ class SimpleMenuEntryTag extends MenuEntryTag
return unless v.domel.get "radio" return unless v.domel.get "radio"
v.domel.set "checked", false v.domel.set "checked", false
mount: () ->
super.mount()
me = @
@refs.switch.set "enable", false
select: (e) -> select: (e) ->
super.select(e)
if @get "switch" if @get "switch"
@set "checked", !@get "checked" @set "checked", !@get "checked"
else if @get "radio" else if @get "radio"
p = @get "parent" p = @get "parent"
p.reset_radio() if p p.reset_radio() if p
@set "checked", !@get "checked" @set "checked", !@get "checked"
super.select(e)
itemlayout: () -> itemlayout: () ->
[ [

View File

@ -156,7 +156,12 @@ class SystemPanelTag extends Ant.OS.GUI.BaseTag
$(@refs.applist).click (e) -> $(@refs.applist).click (e) ->
me.open() me.open()
Ant.OS.GUI.bindKey "CTRL- ", (e) ->
if me.view is false
me.toggle true
else
me.toggle false
me.view = not me.view
Ant.OS.announcer.trigger("syspanelloaded") Ant.OS.announcer.trigger("syspanelloaded")
Ant.OS.GUI.define "afx-sys-panel", SystemPanelTag Ant.OS.GUI.define "afx-sys-panel", SystemPanelTag

View File

@ -11,6 +11,7 @@ class Ant.OS.GUI.BaseTag
@root.get = (k) -> me.get k @root.get = (k) -> me.get k
@root.aid = () -> me.aid() @root.aid = () -> me.aid()
@root.calibrate = () -> me.calibrate() @root.calibrate = () -> me.calibrate()
@root.update = () -> me.update()
@mounted = false @mounted = false
@root.sync = () -> me.sync() @root.sync = () -> me.sync()
@refs = {} @refs = {}
@ -60,6 +61,7 @@ class Ant.OS.GUI.BaseTag
@get "data-id" @get "data-id"
calibrate: () -> calibrate: () ->
update: () ->
get: (opt) -> get: (opt) ->
return @opts if opt is "*" return @opts if opt is "*"

View File

@ -50,8 +50,9 @@ class BaseFileHandle
@genealogy = re.split("/") @genealogy = re.split("/")
@basename = @genealogy[@genealogy.length - 1] unless @isRoot() @basename = @genealogy[@genealogy.length - 1] unless @isRoot()
@ext = @basename.split( "." ).pop() unless @basename.lastIndexOf(".") is 0 or @basename.indexOf( "." ) is -1 @ext = @basename.split( "." ).pop() unless @basename.lastIndexOf(".") is 0 or @basename.indexOf( "." ) is -1
asFileHandle: () ->
@ asFileHandle: () -> @
isRoot: () -> (not @genealogy) or (@genealogy.size is 0) isRoot: () -> (not @genealogy) or (@genealogy.size is 0)
child: (name) -> child: (name) ->
@ -92,6 +93,7 @@ class BaseFileHandle
parent: () -> parent: () ->
return @ if @isRoot() return @ if @isRoot()
return (@protocol + "://" + (@genealogy.slice 0 , @genealogy.length - 1).join "/") return (@protocol + "://" + (@genealogy.slice 0 , @genealogy.length - 1).join "/")
.asFileHandle()
onready: () -> onready: () ->
# read meta data # read meta data
@ -112,15 +114,19 @@ class BaseFileHandle
me.onready() me.onready()
.then (r) -> .then (r) ->
me._rd(t) me._rd(t)
.then (d) -> resolve d .then (d) ->
# Ant.OS.announcer.ostrigger "VFS", { m: "read", file: me }
resolve d
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
write: (d, t) -> write: (t) ->
me = @ me = @
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
me._wr(d, t) me._wr(t)
.then (r) -> resolve r .then (r) ->
Ant.OS.announcer.ostrigger "VFS", { m: "write", file: me }
resolve r
.catch (e) -> reject e .catch (e) -> reject e
mk: (d) -> mk: (d) ->
@ -129,7 +135,9 @@ class BaseFileHandle
me.onready() me.onready()
.then (r) -> .then (r) ->
me._mk(d) me._mk(d)
.then (d) -> resolve d .then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "mk", file: me }
resolve d
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -139,7 +147,9 @@ class BaseFileHandle
me.onready() me.onready()
.then (r) -> .then (r) ->
me._rm() me._rm()
.then (d) -> resolve d .then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "remove", file: me }
resolve d
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -149,7 +159,9 @@ class BaseFileHandle
me.onready() me.onready()
.then (r) -> .then (r) ->
me._up() me._up()
.then (d) -> resolve d .then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "upload", file: me }
resolve d
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -159,7 +171,9 @@ class BaseFileHandle
me.onready() me.onready()
.then (r) -> .then (r) ->
me._pub() me._pub()
.then (d) -> resolve d .then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "publish", file: me }
resolve d
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -169,7 +183,9 @@ class BaseFileHandle
me.onready() me.onready()
.then (r) -> .then (r) ->
me._down() me._down()
.then (d) -> resolve d .then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "download", file: me }
resolve d
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -178,8 +194,10 @@ class BaseFileHandle
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
me.onready() me.onready()
.then (r) -> .then (r) ->
me._mv() me._mv(d)
.then (d) -> resolve d .then (data) ->
Ant.OS.announcer.ostrigger "VFS", { m: "move", file: me }
resolve data
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -189,7 +207,9 @@ class BaseFileHandle
me.onready() me.onready()
.then (r) -> .then (r) ->
me._exec() me._exec()
.then (d) -> resolve d .then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "execute", file: me }
resolve d
.catch (e) -> reject e .catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
@ -232,22 +252,23 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
return Ant.OS.API.handle.fileblob @path if t is "binary" return Ant.OS.API.handle.fileblob @path if t is "binary"
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: (t) ->
# t is base64 or undefined # t is base64 or undefined
return Ant.OS.API.handle.write me.path, me.cache if p is "base64" return Ant.OS.API.handle.write me.path, me.cache if t is "base64"
me = @ me = @
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
me.b64(t) me.b64(t)
.then (r) -> .then (r) ->
Ant.OS.API.handle.write me.path, d Ant.OS.API.handle.write me.path, r
resolve r .then (result) -> resolve result
.catch (e) -> reject e
.catch (e) -> reject e .catch (e) -> reject e
_mk: (d) -> _mk: (d) ->
me = @ me = @
if @info.type is "file" if @info.type is "file"
return new Promise (resolve, reject) -> return new Promise (resolve, reject) ->
reject { error: __("{0} is not a directory", me.path) } reject Ant.OS.API.throwe __("{0} is not a directory", me.path)
Ant.OS.API.handle.mkdir "#{@path}/#{d}" Ant.OS.API.handle.mkdir "#{@path}/#{d}"
_rm: () -> _rm: () ->
@ -259,17 +280,17 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
_up: () -> _up: () ->
me = @ me = @
if @info.type isnt "file" if @info.type isnt "dir"
return new Promise (resolve, reject) -> return new Promise (resolve, reject) ->
reject { error: __("{0} is not a file", me.path) } reject Ant.OS.API.throwe __("{0} is not a file", me.path)
Ant.OS.API.handle.upload @path Ant.OS.API.handle.upload @path
_down: () -> _down: () ->
me = @ me = @
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
if me.info.type is "dir" if me.info.type is "dir"
return reject { error: __("{0} is not a file", me.path) } return Ant.OS.API.throwe __("{0} is not a file", me.path)
Ant.OS.API.handle.fileblob(@path) Ant.OS.API.handle.fileblob(me.path)
.then (d) -> .then (d) ->
blob = new Blob [d], { type: "octet/stream" } blob = new Blob [d], { type: "octet/stream" }
Ant.OS.API.saveblob me.basename, blob Ant.OS.API.saveblob me.basename, blob
@ -293,7 +314,7 @@ class ApplicationHandle extends Ant.OS.API.VFS.BaseFileHandle
me = @ me = @
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
return resolve { result: me.info } if me.info return resolve { result: me.info } if me.info
return reject { error: __("Application meta data isnt found") } unless me.isRoot() return reject Ant.OS.API.throwe(__("Application meta data isnt found")) unless me.isRoot()
resolve { result: ( v for k, v of Ant.OS.setting.system.packages ) } resolve { result: ( v for k, v of Ant.OS.setting.system.packages ) }
@ -341,7 +362,7 @@ class URLFileHandle extends Ant.OS.API.VFS.BaseFileHandle
_rd: (t) -> _rd: (t) ->
Ant.OS.API.get @path, if t then t else "text" Ant.OS.API.get @path, if t then t else "text"
Ant.OS.API.VFS.register "^(http|https)$", URLFileHandle Ant.OS.API.VFS.register "^(http|https|ftp)$", URLFileHandle
class SharedFileHandle extends Ant.OS.API.VFS.BaseFileHandle class SharedFileHandle extends Ant.OS.API.VFS.BaseFileHandle
@ -368,12 +389,13 @@ class SharedFileHandle extends Ant.OS.API.VFS.BaseFileHandle
me = @ me = @
new Promise (resolve, reject) -> new Promise (resolve, reject) ->
if me.info.type is "dir" if me.info.type is "dir"
return reject { error: __("{0} is not a file", me.path) } return reject Ant.OS.API.throwe __("{0} is not a file", me.path)
Ant.OS.API.handle.fileblob me.path, (d) -> Ant.OS.API.handle.fileblob me.path
blob = new Blob [d], { type: "octet/stream" } .then (data) ->
Ant.OS.API.saveblob me.basename, blob blob = new Blob [data], { type: "octet/stream" }
resolve() Ant.OS.API.saveblob me.basename, blob
resolve()
.catch (e) -> reject e
_pub: () -> _pub: () ->
me = @ me = @
return new Promise (resolve, reject) -> resolve { result: me.basename } return new Promise (resolve, reject) -> resolve { result: me.basename }

View File

@ -26,9 +26,10 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
@grid = @find "mygrid" @grid = @find "mygrid"
@on "btclick", (e) -> @on "btclick", (e) ->
return unless e.id == "btkill" return unless e.id == "btkill"
item = me.grid.get "selected" item = me.grid.get "selectedRow"
return unless item return unless item
app = _PM.appByPid item[0].value data = item.get("data")[0]
app = _PM.appByPid data.text
app.quit(true) if app app.quit(true) if app
header = [ header = [
@ -44,13 +45,14 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
width: 80 width: 80
}, },
{ {
width: 75, width: 80,
text: "__(Alive (ms))" text: "__(Alive (ms))"
} }
] ]
@gdata = @gdata = {
processes: {} processes: {}
alive: [] alive: []
}
@grid.set "header", header @grid.set "header", header
@monitor() @monitor()
@ -62,7 +64,8 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
$.each _PM.processes, (i, d) -> $.each _PM.processes, (i, d) ->
$.each d , (j, a) -> $.each d , (j, a) ->
if me.gdata.processes[a.pid] #update it if me.gdata.processes[a.pid] #update it
me.gdata.processes[a.pid][3].value = now - a.birth me.gdata.processes[a.pid][3].text = now - a.birth
me.gdata.processes[a.pid][3].domel.update()
else #add it else #add it
me.gdata.processes[a.pid] = [ me.gdata.processes[a.pid] = [
{ text: a.pid }, { text: a.pid },
@ -73,24 +76,22 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
}, },
{ {
text: if _APP[a.name].type == 1 then "__(Application)" else "__(Service)" text: if _APP[a.name].type == 1 then "__(Application)" else "__(Service)"
} },
{ {
text: now - a.birth text: now - a.birth
} }
] ]
me.gdata.alive.push a.pid me.grid.push me.gdata.processes[a.pid]
@refreshGrid() me.gdata.alive.push a.pid
@timer = setTimeout (() -> me.monitor()), 500
refreshGrid: () ->
activeList = []
me = @
$.each @gdata.processes, (i, e) -> $.each @gdata.processes, (i, e) ->
if ($.inArray (Number i), me.gdata.alive) >= 0 if ($.inArray (Number i), me.gdata.alive) < 0
activeList.push e me.grid.remove me.gdata.processes[i].domel
else
me.gdata.processes[i] = undefined me.gdata.processes[i] = undefined
@grid.set "rows", activeList delete me.gdata.processes[i]
@timer = setTimeout (() -> me.monitor()), 500
cleanup: (e) -> cleanup: (e) ->
clearTimeout @timer if @timer clearTimeout @timer if @timer

View File

@ -2,7 +2,13 @@ afx-app-window[data-id="am-window"] afx-button{
margin: 3px; margin: 3px;
} }
afx-app-window[data-id="am-window"] afx-grid-view{ afx-app-window[data-id="am-window"] afx-grid-view afx-grid-row afx-grid-cell{
padding-left:10px; padding:5px;
padding-right: 10px; }
afx-app-window[data-id="am-window"] afx-grid-view .grid_row_header afx-grid-cell{
background-color: #dfdfdf;
border: 1px solid #a6a6a6;
padding: 5px;
} }

View File

@ -1,6 +1,11 @@
<afx-app-window data-id = "am-window" apptitle="" width="400" height="300"> <afx-app-window data-id = "am-window" apptitle="" width="400" height="300">
<afx-vbox> <afx-hbox>
<afx-grid-view data-id = "mygrid"></afx-grid-view> <div data-width="7"></div>
<afx-button data-height="30" data-id = "btkill" text = "__(Kill process)" iconclass="fa fa-times"></afx-button> <afx-vbox>
</afx-vbox> <div data-height="7"></div>
<afx-grid-view data-id = "mygrid"></afx-grid-view>
<afx-button data-height="30" data-id = "btkill" text = "__(Kill process)" iconclass="fa fa-times"></afx-button>
</afx-vbox>
<div data-width="7"></div>
</afx-hbox>
</afx-app-window> </afx-app-window>

View File

@ -1,11 +0,0 @@
coffee_files = main.coffee
jsfiles =
cssfiles = main.css
copyfiles = scheme.html package.json icon.png
PKG_NAME=DummyApp
include ../pkg.mk

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,154 +0,0 @@
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
# AnTOS Web desktop is is licensed under the GNU General Public
# License v3.0, see the LICENCE file for more information
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
_GUI = this.OS.GUI
class DummyApp extends this.OS.GUI.BaseApplication
constructor: (args) ->
super "DummyApp", args
main: () ->
self = @
@on "btclick", (e)->
#_GUI.pushService "Budgy"
self.openDialog "ColorPickerDialog", (d) -> console.log d
self.addMenu()
self.systemsetting.system.menu["test"] =
text: 'Adding system menu'
self._gui.refreshSystemMenu()
"self._gui.buildSystemMenu()"
@on "resize", (w,h)->
console.log "#{self.name}: resize"
#@on "listselect", (i)->
# console.log self.name, i
@on "treeselect", (i) ->
console.log self.name,i
@on "focus", ()->
console.log self.name, "is focused"
@on "dayselect", (e) -> console.log "cellselected", e
@on "gridselect", (e) -> console.log "GRID selected", e
tree = @find "mytree"
@scheme.set "apptitle", "Terminal"
tdata = {
name: 'My Tree',
nodes: [
{ name: 'hello', iconclass:'fa fa-car'},
{ name: 'wat' },
{
name: 'child folder',
nodes: [
{
name: 'child folder',
nodes: [
{ name: 'hello' },
{ name: 'wat' }
]
},
{ name: 'hello' },
{ name: 'wat' },
{
name: 'child folder',
nodes: [
{ name: 'hello' },
{ name: 'wat' }
]
}
]
}
]
}
(@find "sw").set "onchange", (e) ->
console.log e, ((self.find "sw").get "swon")
tree.set "data",tdata
(@find "spinner").set "onchange", (e) -> console.log e
list = @find "mylist"
ldata = [
{text:"some thing with avery long text"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing", complex:true, detail:[{text:"Inner content", class:""}]},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"},
{text:"some thing"}
]
list.set "items",ldata
list.set "onlistselect", (e)->
console.log e
tabs = @find "mytabs"
tabdatas = [
{text:"file1.txt"},
{text:"file2.cpp"}
]
tabs.set "items", tabdatas
(@find "slider").set "max", 200
(@find "slider").set "onchange", (d) ->
console.log d
@scheme.set "apptitle", "AntOS feature showcase"
@scheme.contextmenuHandler = (e, m) ->
mdata = [
{ text: " Child 1" },
{ text: "child2", child: [
{text: "sub child", child:[{text:"sub sub child"}] },
{text: "sub child 1" }
], onmenuselect: (e) -> console.log e
}
]
m.set "items", mdata
m.show(e)
@menu_ = [
{
text: "__(View)",
child: [
{ text: "__(Refresh)", dataid: "#{@name}-refresh" },
{ text: "__(Sidebar)", dataid: "#{@name}-side" },
{ text: "__(Navigation bar)", dataid: "#{@name}-nav" },
{ text: "__(Hidden files)", dataid: "#{@name}-hidden" },
{ text: "__(Type)", child: [
{ text: "__(Icon view)", dataid: "#{@name}-icon", type: 'icon' },
{ text: "__(List view)", dataid: "#{@name}-list", type: 'list' },
{ text: "__(Tree view)", dataid: "#{@name}-tree", type: 'tree' }
], onmenuselect: (e) ->
console.log e
},
], onmenuselect: (e) ->console.log e
},
]
menu: () ->
@menu_
addMenu: () ->
@menu_[0].child.push {text:'One more menu'}
DummyApp.singleton = false
this.OS.register "DummyApp",DummyApp

View File

@ -1,7 +0,0 @@
/*.dummyapp-icon {
background-image: url("icon.png");
background-color: blueviolet;
display: block;
width: 32px;
height: 32px;
}*/

View File

@ -1,15 +0,0 @@
{
"app":"DummyApp",
"name":"DummyApp",
"description":"App for test",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com",
"credit": "dedicated to some one here",
"licences": "GPLv3"
},
"version":"0.0.3-a",
"category":"System",
"icon": "icon.png",
"mimes":["none"]
}

View File

@ -1,22 +0,0 @@
<afx-app-window apptitle="Preview" width="650" height="500">
<afx-hbox>
<afx-switch enable= true data-width="50"></afx-switch>
<afx-vbox>
<afx-tab-bar data-height = "50" data-id="mytabs" closable = true></afx-tab-bar>
<afx-tree-view data-id="mytree"> </afx-tree-view>
<afx-slider data-id="slider" data-height="20" value="30"></afx-slider>
<div data-height="10"></div>
</afx-vbox>
<afx-resizer data-width = "5" ></afx-resizer>
<afx-vbox>
<afx-nspinner value = "10" data-height="50" data-id="spinner"></afx-nspinner>
<afx-nspinner value = "10" data-height="30" data-id="spinner"></afx-nspinner>
<afx-button data-height="30" toggle = "true" text="__(Read more)" iconclass="fa fa-camera-retro fa-lg" id="button"></afx-button>
<afx-switch data-id="sw" enable= true data-height="30"></afx-switch>
<afx-calendar-view></afx-calendar-view>
<afx-resizer data-height = "5" ></afx-resizer>
<afx-color-picker></afx-color-picker>
<afx-list-view data-id = "mylist" dropdown = "true" width="200" data-height = "40"></afx-list-view>
</afx-vbox>
</afx-hbox>
</afx-app-window>

View File

@ -26,7 +26,10 @@ class Files extends this.OS.GUI.BaseApplication
@view = @find "fileview" @view = @find "fileview"
@navinput = @find "navinput" @navinput = @find "navinput"
@navbar = @find "nav-bar" @navbar = @find "nav-bar"
@currdir = if @args and @args.length > 0 then @args[0].asFileHandler() else "home://".asFileHandler() if @args and @args.length > 0
@currdir = @args[0].asFileHandle()
else
@currdir = "home://".asFileHandle()
@favo = @find "favouri" @favo = @find "favouri"
@clipboard = undefined @clipboard = undefined
@viewType = @_api.switcher "icon", "list", "tree" @viewType = @_api.switcher "icon", "list", "tree"
@ -35,37 +38,44 @@ class Files extends this.OS.GUI.BaseApplication
@view.contextmenuHandle = (e, m) -> @view.contextmenuHandle = (e, m) ->
m.set "items", [ me.mnFile(), me.mnEdit() ] m.set "items", [ me.mnFile(), me.mnEdit() ]
m.set "onmenuselect", (evt) -> # Fix m.set "onmenuselect", (evt) ->
me._gui.launch evt.item.data.app, evt.item.data.args if evt.item.data.app # me._gui.launch evt.item.data.app, evt.item.data.args if evt.item.data.app
m.show e m.show e
#@on "fileselect", (d) -> console.log d
@view.set "onfileopen", (e) -> @view.set "onfileopen", (e) ->
return unless e return unless e.data
return if e.type is "dir" return if e.data.type is "dir"
me._gui.openWith e me._gui.openWith e.data
@favo.set "onlistselect", (e) -> @favo.set "onlistselect", (e) ->
me.chdir e.data.path me.view.set "path", e.data.item.get("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 me.view.set "path", p.path
($ @navinput).keyup (e) -> ($ @navinput).keyup (e) ->
me.chdir ($ me.navinput).val() if e.keyCode is 13 #enter me.view.set "path", ($ me.navinput).val() if e.keyCode is 13 #enter
@view.set "chdir", (p) -> me.chdir p @view.set "fetch", (path) ->
@view.set "fetch", (e, f) -> new Promise (resolve, reject) ->
return unless e.child dir = path
return if e.child.filename is "[..]" dir = path.asFileHandle() if typeof path is "string"
e.child.path.asFileHandler().read (d) -> dir.read().then (d) ->
return me.error __("Resource not found {0}", e.child.path) if d.error return reject d.error if d.error
f d.result if not dir.isRoot()
p = dir.parent()
p.filename = "[..]"
p.type = "dir"
d.result.unshift p
me.currdir = dir
($ me.navinput).val dir.path
resolve d.result
@view.set "onfileselect", (e) -> @view.set "onfileselect", (e) ->
file = me.view.get "selectedFile" file = e.data
return unless file and file.mime return unless file and file.mime
file.mime = "dir" if file.type is "dir" file.mime = "dir" if file.type is "dir"
me.apps.length = 0 me.apps.length = 0
@ -79,13 +89,13 @@ class Files extends this.OS.GUI.BaseApplication
mntpoints = @systemsetting.VFS.mountpoints mntpoints = @systemsetting.VFS.mountpoints
el.selected = false for el, i in mntpoints el.selected = false for el, i in mntpoints
@favo.set "data", mntpoints
@favo.set "items", mntpoints
#@favo.set "selected", -1 #@favo.set "selected", -1
@view.set "view", @setting.view if @setting.view @view.set "view", @setting.view if @setting.view
@subscribe "VFS", (d) -> @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() return if ["read", "publish", "download"].includes d.data.m
if d.data.file.hash() is me.currdir.hash() or d.data.file.parent().hash() is me.currdir.hash()
me.view.set "path", me.currdir
@bindKey "CTRL-F", () -> me.actionFile "#{me.name}-mkf" @bindKey "CTRL-F", () -> me.actionFile "#{me.name}-mkf"
@bindKey "CTRL-D", () -> me.actionFile "#{me.name}-mkdir" @bindKey "CTRL-D", () -> me.actionFile "#{me.name}-mkdir"
@bindKey "CTRL-U", () -> me.actionFile "#{me.name}-upload" @bindKey "CTRL-U", () -> me.actionFile "#{me.name}-upload"
@ -101,10 +111,11 @@ class Files extends this.OS.GUI.BaseApplication
(@find "btgrid").set "onbtclick", (e) -> (@find "btgrid").set "onbtclick", (e) ->
me.view.set 'view', "icon" me.view.set 'view', "icon"
me.viewType.icon = true me.viewType.icon = true
(@find "btlist").set "onbtclick", (e) -> (@find "btlist").set "onbtclick", (e) ->
me.view.set 'view', "list" me.view.set 'view', "list"
me.viewType.list = true me.viewType.list = true
@chdir null @view.set "path", @currdir
applySetting: (k) -> applySetting: (k) ->
# view setting # view setting
@ -112,30 +123,8 @@ class Files extends this.OS.GUI.BaseApplication
when "showhidden" then @view.set "showhidden", @setting.showhidden when "showhidden" then @view.set "showhidden", @setting.showhidden
when "nav" then @toggleNav @setting.nav when "nav" then @toggleNav @setting.nav
when "sidebar" then @toggleSidebar @setting.sidebar when "sidebar" then @toggleSidebar @setting.sidebar
#@view.set "view", @setting.view if @setting.view
chdir: (p) -> mnFile: () ->
me = @
#console.log "ch"
dir = if p then p.asFileHandler() else me.currdir
dir.read (d) ->
if(d.error)
return me.error __("Resource not found {0}", p)
me.currdir = dir
if not dir.isRoot()
p = dir.parent().asFileHandler()
p.filename = "[..]"
p.type = "dir"
#p.size = 0
d.result.unshift p
($ me.navinput).val dir.path
me.view.set "path", dir.path
#console.log d.result
me.view.set "data", d.result
mnFile:() ->
#console.log file #console.log file
me = @ me = @
arr = { arr = {
@ -148,7 +137,7 @@ class Files extends this.OS.GUI.BaseApplication
{ text: "__(Download)", dataid: "#{@name}-download" }, { text: "__(Download)", dataid: "#{@name}-download" },
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' }, { text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
{ text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' } { text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' }
], onmenuselect: (e) -> me.actionFile e.item.data.dataid ], onchildselect: (e) -> me.actionFile e.data.item.get("data").dataid
} }
return arr return arr
mnEdit: () -> mnEdit: () ->
@ -161,7 +150,7 @@ class Files extends this.OS.GUI.BaseApplication
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' }, { text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' }, { text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' } { text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
], onmenuselect: (e) -> me.actionEdit e.item.data.dataid ], onchildselect: (e) -> me.actionEdit e.data.item.get("data").dataid
} }
menu: () -> menu: () ->
me = @ me = @
@ -176,14 +165,15 @@ class Files extends this.OS.GUI.BaseApplication
{ text: "__(Navigation bar)", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" }, { text: "__(Navigation bar)", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" },
{ text: "__(Hidden files)", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" }, { text: "__(Hidden files)", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" },
{ text: "__(Type)", child: [ { text: "__(Type)", child: [
{ text: "__(Icon view)", radio: true, checked: (() -> me.viewType.icon), dataid: "#{@name}-icon", type: 'icon' }, { text: "__(Icon view)", radio: true, checked: me.viewType.icon, dataid: "#{@name}-icon", type: 'icon' },
{ text: "__(List view)", radio:true, checked: (() -> me.viewType.list), dataid: "#{@name}-list", type: 'list' }, { text: "__(List view)", radio:true, checked: me.viewType.list, dataid: "#{@name}-list", type: 'list' },
{ text: "__(Tree view)", radio:true, checked: (() -> me.viewType.tree), dataid: "#{@name}-tree", type: 'tree' } { text: "__(Tree view)", radio:true, checked: me.viewType.tree, dataid: "#{@name}-tree", type: 'tree' }
], onmenuselect: (e) -> ], onchildselect: (e) ->
me.view.set 'view', e.item.data.type type = e.data.item.get("data").type
me.viewType[e.item.data.type] = true me.view.set 'view', type
me.viewType[type] = true
}, },
], onmenuselect: (e) -> me.actionView e ], onchildselect: (e) -> me.actionView e
}, },
] ]
menu menu
@ -197,19 +187,20 @@ class Files extends this.OS.GUI.BaseApplication
@trigger "resize" @trigger "resize"
actionView: (e) -> actionView: (e) ->
switch e.item.data.dataid data = e.data.item.get("data")
switch data.dataid
when "#{@name}-hidden" when "#{@name}-hidden"
#@.view.set "showhidden", e.item.data.checked #@.view.set "showhidden", e.item.data.checked
@registry "showhidden", e.item.data.checked @registry "showhidden", data.checked
#@.setting.showhidden = e.item.data.checked #@.setting.showhidden = e.item.data.checked
when "#{@name}-refresh" when "#{@name}-refresh"
@.chdir null @.chdir null
when "#{@name}-side" when "#{@name}-side"
@registry "sidebar", e.item.data.checked @registry "sidebar", data.checked
#@setting.sidebar = e.item.data.checked #@setting.sidebar = e.item.data.checked
#@toggleSidebar e.item.data.checked #@toggleSidebar e.item.data.checked
when "#{@name}-nav" when "#{@name}-nav"
@registry "nav", e.item.data.checked @registry "nav", data.checked
#@setting.nav = e.item.data.checked #@setting.nav = e.item.data.checked
#@toggleNav e.item.data.checked #@toggleNav e.item.data.checked
@ -219,98 +210,130 @@ class Files extends this.OS.GUI.BaseApplication
switch e switch e
when "#{@name}-mv" when "#{@name}-mv"
return unless file return unless file
@openDialog "PromptDialog", @openDialog("PromptDialog", {
(d) -> title: "__(Rename)",
label: "__(File name)",
value: file.filename
})
.then (d) ->
return if d is file.filename return if d is file.filename
file.path.asFileHandler() file.path.asFileHandle().move "#{me.currdir.path}/#{d}"
.move "#{me.currdir.path}/#{d}", (r) -> .then (r) ->
me.error __("Fail to rename to {0}: {1}", d, r.error) if r.error me.error __("Fail to rename to {0}: {1}", d, r.error) if r.error
, "__(Rename)", { label: "__(File name)", value: file.filename } .catch (e) ->
console.log e
me.error __("Fail to rename: {0}", e.stack)
when "#{@name}-rm" when "#{@name}-rm"
return unless file return unless file
@openDialog "YesNoDialog", @openDialog("YesNoDialog", {
(d) -> title: "__(Delete)",
iconclass: "fa fa-question-circle",
text: __("Do you really want to delete: {0}?", file.filename)
})
.then (d) ->
return unless d return unless d
file.path.asFileHandler() file.path.asFileHandle().remove()
.remove (r) -> .then (r) ->
me.error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error me.error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
,"__(Delete)" , .catch (e) ->
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?", file.filename) } me.error __("Fail to delete: {0}", e.stack)
when "#{@name}-cut" when "#{@name}-cut"
return unless file return unless file
@clipboard = @clipboard =
cut: true cut: true
file: file.path.asFileHandler() file: file.path.asFileHandle()
@notify __("File {0} cut", file.filename) @notify __("File {0} cut", file.filename)
when "#{@name}-copy" when "#{@name}-copy"
return unless file or file.type is "dir" return unless file or file.type is "dir"
@clipboard = @clipboard =
cut: false cut: false
file: file.path.asFileHandler() file: file.path.asFileHandle()
@notify __("File {0} copied", file.filename) @notify __("File {0} copied", file.filename)
when "#{@name}-paste" when "#{@name}-paste"
me = @ me = @
return unless @clipboard return unless @clipboard
if @clipboard.cut if @clipboard.cut
@clipboard.file # duplicate file check @clipboard.file.move "#{me.currdir.path}/#{@clipboard.file.basename}"
.move "#{me.currdir.path}/#{@clipboard.file.basename}", (r) -> .then (r) ->
me.clipboard = undefined
me.error __("Fail to paste: {0}", r.error) if r.error
else
@clipboard.file.read (d) ->
blob = new Blob [d], { type: me.clipboard.file.info.mime }
fp = "#{me.currdir.path}/#{me.clipboard.file.basename}".asFileHandler()
fp.cache = blob
fp.write me.clipboard.file.info.mime, (r) ->
me.clipboard = undefined me.clipboard = undefined
me.error __("Fail to paste: {0}", r.error) if r.error me.error __("Fail to paste: {0}", r.error) if r.error
, "binary" .catch (e) ->
me.error __("Fail to paste: {0}", e.stack)
else
@clipboard.file.read("binary")
.then (d) ->
blob = new Blob [d], { type: me.clipboard.file.info.mime }
fp = "#{me.currdir.path}/#{me.clipboard.file.basename}".asFileHandle()
fp.cache = blob
fp.write(me.clipboard.file.info.mime)
.then (r) ->
me.clipboard = undefined
me.error __("Fail to paste: {0}", r.error) if r.error
.catch (e) ->
me.error __("Fail to paste: {0}", e.stack)
else else
@_api.handler.setting() @_api.handle.setting()
actionFile: (e) -> actionFile: (e) ->
me = @ me = @
file = @view.get "selectedFile" file = @view.get "selectedFile"
switch e switch e
when "#{@name}-mkdir" when "#{@name}-mkdir"
@openDialog "PromptDialog", @openDialog("PromptDialog", {
(d) -> title: "__(New folder)",
me.currdir.mk d, (r) -> label: "__(Folder name)"
me.error __("Fail to create {0}: {1}", d, r.error) if r.error })
, "__(New folder)", { label: "__(Folder name)" } .then (d) ->
me.currdir.mk(d)
.then (r) ->
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) ->
me.error __("Fail to create: {0}", e.stack)
when "#{@name}-mkf" when "#{@name}-mkf"
@openDialog "PromptDialog", @openDialog("PromptDialog", {
(d) -> title: "__(New file)",
fp = "#{me.currdir.path}/#{d}".asFileHandler() label: "__(File name)"
fp.write "text/plain", (r) -> })
me.error __("Fail to create {0}: {1}", d, r.error) if r.error .then (d) ->
, "__(New file)", { label: "__(File name)" } fp = "#{me.currdir.path}/#{d}".asFileHandle()
fp.write("text/plain")
.then (r) ->
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) ->
me.error __("Fail to create: {0}", e.stack)
when "#{@name}-info" when "#{@name}-info"
return unless file return unless file
@openDialog "InfoDialog", null, file.filename, file @openDialog "InfoDialog", file
when "#{@name}-upload" when "#{@name}-upload"
me = @ me = @
@currdir.upload (r) -> @currdir.upload()
me.error __("Fail to upload to {0}: {1}", me.currdir.path, r.error) if r.error .then (r) ->
me.error __("Fail to upload to {0}: {1}", me.currdir.path, r.error) if r.error
.catch (e) ->
me.error __("Fail to upload: {0}", e.stack)
when "#{@name}-share" when "#{@name}-share"
me = @ me = @
return unless file and file.type is "file" return unless file and file.type is "file"
file.path.asFileHandler().publish (r) -> file.path.asFileHandle().publish()
return me.error __("Cannot share file: {0}", r.error) if r.error .then (r) ->
return me.notify __("Shared url: {0}", r.result) return me.error __("Cannot share file: {0}", r.error) if r.error
return me.notify __("Shared url: {0}", r.result)
.catch (e) ->
me.error __("Fail to publish: {0}", e.stack)
when "#{@name}-download" when "#{@name}-download"
return unless file return unless file.type is "file"
file.path.asFileHandler().download ()-> file.path.asFileHandle().download()
.catch (e) ->
me.error __("Fail to download: {0}", e.stack)
else else
console.log e console.log e

View File

@ -11,6 +11,12 @@ afx-app-window[data-id ='files-app-window'] afx-resizer{
background-color: transparent; background-color: transparent;
border-left: 1px solid #cbcbcb; border-left: 1px solid #cbcbcb;
} }
afx-app-window[data-id ='files-app-window'] afx-file-view afx-list-view i:before{
font-size: 32px;
font-weight: normal;
font-style: normal;
text-align: center;
}
afx-app-window[data-id ='files-app-window'] afx-list-view[data-id='favouri'] li{ afx-app-window[data-id ='files-app-window'] afx-list-view[data-id='favouri'] li{
background-color: transparent; background-color: transparent;
} }

View File

@ -25,7 +25,10 @@ class MarkOn extends this.OS.GUI.BaseApplication
markarea = @find "markarea" markarea = @find "markarea"
@container = @find "mycontainer" @container = @find "mycontainer"
@previewOn = false @previewOn = false
@currfile = if @args and @args.length > 0 then @args[0].asFileHandler() else "Untitled".asFileHandler() if @args and @args.length > 0
@currfile = @args[0].asFileHandle()
else
@currfile = "Untitled".asFileHandle()
@editormux = false @editormux = false
@editor = new SimpleMDE @editor = new SimpleMDE
element: markarea element: markarea
@ -82,21 +85,25 @@ class MarkOn extends this.OS.GUI.BaseApplication
return if file.path is "Untitled" return if file.path is "Untitled"
me = @ me = @
file.dirty = false file.dirty = false
file.read (d) -> file.read()
me.currfile = file .then (d) ->
me.editormux = true me.currfile = file
me.editor.value d me.editormux = true
me.scheme.set "apptitle", "#{me.currfile.basename}" me.editor.value d
me.editormux = false me.scheme.set "apptitle", "#{me.currfile.basename}"
me.editormux = false
.catch (e) -> me.error e.stack
save: (file) -> save: (file) ->
me = @ me = @
file.write "text/plain", (d) -> file.write("text/plain")
return me.error __("Error saving file {0}", file.basename) if d.error .then (d) ->
file.dirty = false return me.error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
file.text = file.basename file.dirty = false
me.scheme.set "apptitle", "#{me.currfile.basename}" file.text = file.basename
me.scheme.set "apptitle", "#{me.currfile.basename}"
.catch (e) -> me.error e.stack
menu: () -> menu: () ->
me = @ me = @
@ -108,22 +115,34 @@ class MarkOn extends this.OS.GUI.BaseApplication
{ text: "__(Save)", dataid: "#{@name}-Save", shortcut: "C-S" }, { text: "__(Save)", dataid: "#{@name}-Save", shortcut: "C-S" },
{ text: "__(Save as)", dataid: "#{@name}-Saveas", shortcut: "A-W" } { text: "__(Save as)", dataid: "#{@name}-Saveas", shortcut: "A-W" }
], ],
onmenuselect: (e) -> me.actionFile e.item.data.dataid onchildselect: (e) -> me.actionFile e.data.item.get("data").dataid
}] }]
menu menu
actionFile: (e) -> actionFile: (e) ->
me = @ me = @
saveas = () -> saveas = () ->
me.openDialog "FileDiaLog", (d, n) -> me.openDialog("FileDialog", {
me.currfile.setPath "#{d}/#{n}" title: __("Save as"),
file: me.currfile
})
.then (f) ->
d = f.file.path.asFileHandle()
d = d.parent() if f.file.type is "file"
me.currfile.setPath "#{d.path}/#{f.name}"
console.log me.currfile
me.save me.currfile me.save me.currfile
, __("Save as"), { file: me.currfile } .catch (e) ->
me.error e.stack
switch e switch e
when "#{@name}-Open" when "#{@name}-Open"
@openDialog "FileDiaLog", ( d, f ) -> @openDialog("FileDialog", {
me.open "#{d}/#{f}".asFileHandler() title: __("Open file")
, __("Open file") })
.then (f) ->
me.open f.file.path.asFileHandle()
when "#{@name}-Save" when "#{@name}-Save"
@currfile.cache = @editor.value() @currfile.cache = @editor.value()
return @save @currfile if @currfile.basename return @save @currfile if @currfile.basename
@ -132,7 +151,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
@currfile.cache = @editor.value() @currfile.cache = @editor.value()
saveas() saveas()
when "#{@name}-New" when "#{@name}-New"
@currfile = "Untitled".asFileHandler() @currfile = "Untitled".asFileHandle()
@currfile.cache = "" @currfile.cache = ""
@editor.value("") @editor.value("")

View File

@ -194,7 +194,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
when "yesno" when "yesno"
me.openDialog("YesNoDialog", { me.openDialog("YesNoDialog", {
title: "Question ?", title: "Question ?",
label: "Do you realy want to delete file ?" text: "Do you realy want to delete file ?"
}) })
.then (d) -> .then (d) ->
console.log d console.log d

View File

@ -47,12 +47,12 @@ afx-calendar-view afx-grid-view afx-grid-row.selected{
color:#414339; color:#414339;
}*/ }*/
afx-calendar-view afx-grid-view div.afx-grid-row-selected .afx-grid-cell afx-calendar-view afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell
{ {
background-color: transparent; background-color: transparent;
color:black; color:black;
} }
afx-calendar-view afx-grid-view div.afx-grid-row-selected .afx-grid-cell-selected afx-calendar-view afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell.afx-grid-cell-selected
{ {
background-color: #116cd6; background-color: #116cd6;
color:white; color:white;

View File

@ -80,13 +80,16 @@ afx-file-view afx-grid-view i{
display: inline-block; display: inline-block;
margin-right: 5px; margin-right: 5px;
} }
afx-file-view afx-grid-view afx-grid-row.selected i:before{ afx-file-view afx-grid-view afx-grid-row.afx-grid-row-selected i:before{
color:white; color:white;
} }
afx-file-view afx-grid-view .grid_row_header{ afx-file-view afx-grid-view afx-grid-row afx-grid-cell
background-color: #dfdfdf; {
padding: 3px;
} }
afx-file-view afx-grid-view .grid_row_header afx-grid-cell{ afx-file-view afx-grid-view .grid_row_header afx-grid-cell{
background-color: #dfdfdf;
border-top: 1px solid #a6a6a6; border-top: 1px solid #a6a6a6;
border-right: 1px solid #a6a6a6; border-right: 1px solid #a6a6a6;
} }

View File

@ -1,35 +1,30 @@
afx-grid-view afx-grid-row div{ afx-grid-view afx-grid-row afx-grid-cell{
padding:3px;
padding-left: 5px;
padding-right: 5px;
user-select:none; user-select:none;
-webkit-user-select:none; -webkit-user-select:none;
cursor:default; cursor:default;
} }
afx-grid-view afx-grid-row:nth-child(even) afx-grid-cell
afx-grid-view div.afx-grid-row:nth-child(even) .afx-grid-cell
{ {
background-color: #f5F5F5; background-color: #f5F5F5;
} }
afx-grid-view div.afx-grid-row-selected .afx-grid-cell afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell
{ {
background-color: #116cd6; background-color: #116cd6;
color:white; color:white;
} }
afx-grid-view div.afx-grid-row-selected .afx-grid-cell-selected afx-grid-view afx-grid-row.afx-grid-row-selected afx-grid-cell.afx-grid-cell-selected
{ {
font-weight: bold; font-weight: bold;
} }
afx-grid-view div.grid_row_header{ afx-grid-view .grid_row_header afx-grid-cell{
border-right: 2px solid #e5e5e5; border-right: 2px solid #e5e5e5;
user-select:none; user-select:none;
-webkit-user-select:none; -webkit-user-select:none;
cursor:default; cursor:default;
font-weight: bold; font-weight: bold;
border: 1px solid #e5e5e5; border-right:0;
border-right:0;
} }

View File

@ -17,6 +17,7 @@ afx-sys-panel .afx-panel-os-menu {
padding:0; padding:0;
margin: 0; margin: 0;
float:left; float:left;
margin-right: 10px;
} }
afx-sys-panel .afx-panel-os-menu li afx-sys-panel .afx-panel-os-menu li
{ {