mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 01:38:21 +01:00
adapt apps
This commit is contained in:
parent
c53fd8bd88
commit
04e5a4d50c
2
Makefile
2
Makefile
@ -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
|
||||
- cp src/index.html $(BUILDDIR)/
|
||||
|
@ -72,12 +72,12 @@ Ant.OS.announcer =
|
||||
Ant.OS.announcer.listeners[a.pid].push { e: e, f: f }
|
||||
Ant.OS.announcer.observable.on e, f
|
||||
trigger: (e, d) -> Ant.OS.announcer.observable.trigger e, d
|
||||
osfail: (m, e, s) ->
|
||||
Ant.OS.announcer.ostrigger "fail", { m: m, e: e, s: s }
|
||||
oserror: (m, e, s) ->
|
||||
Ant.OS.announcer.ostrigger "error", { m: m, e: e, s: s }
|
||||
osfail: (m, e) ->
|
||||
Ant.OS.announcer.ostrigger "fail", { m: m, e: e }
|
||||
oserror: (m, e) ->
|
||||
Ant.OS.announcer.ostrigger "error", { m: m, e: e }
|
||||
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) ->
|
||||
Ant.OS.announcer.trigger e, { id: 0, data: d, name: "OS" }
|
||||
unregister: (app) ->
|
||||
|
@ -233,7 +233,7 @@ class YesNoDialog extends BasicDialog
|
||||
init: () ->
|
||||
super.init()
|
||||
me = @
|
||||
@find("lbl").set "text", @data.label if @data and @data.label
|
||||
@find("lbl").set "*", @data if @data
|
||||
(@find "btnYes").set "onbtclick", (e) ->
|
||||
me.handle(true) if me.handle
|
||||
me.quit()
|
||||
|
@ -289,42 +289,47 @@ Ant.OS.API =
|
||||
libready: (l) ->
|
||||
return Ant.OS.API.shared[l] || false
|
||||
|
||||
require: (l,f) ->
|
||||
requires: (l) ->
|
||||
new Promise (resolve, reject) ->
|
||||
if not Ant.OS.API.shared[l]
|
||||
if l.match /^(https?:\/\/[^\s]+)/g
|
||||
Ant.OS.API.script l, () ->
|
||||
Ant.OS.API.shared[l] = true
|
||||
Ant.OS.announcer.trigger "sharedlibraryloaded", l
|
||||
f() if f
|
||||
, (e, s) ->
|
||||
Ant.OS.announcer.oserror __("Cannot load 3rd library at: {0}", l), e, r
|
||||
else
|
||||
link = l
|
||||
if not l.match /^(https?:\/\/[^\s]+)/g
|
||||
path = "os://scripts/"
|
||||
cssFile = "#{path}#{l}.css".asFileHandle()
|
||||
cssFile.onready()
|
||||
.then () ->
|
||||
$('<link>', {
|
||||
rel: 'stylesheet',
|
||||
type: 'text/css',
|
||||
'href': "#{cssFile.getlink()}"
|
||||
})
|
||||
.appendTo 'head'
|
||||
.catch (e) ->
|
||||
js = "#{path}#{l}.js"
|
||||
js.asFileHandle().onready (d) ->
|
||||
link = js.asFileHandle().getlink()
|
||||
Ant.OS.API.script link
|
||||
.then () ->
|
||||
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
|
||||
console.log "loaded:", l
|
||||
Ant.OS.announcer.trigger "sharedlibraryloaded", l
|
||||
f() if f
|
||||
resolve(l)
|
||||
.catch (e) ->
|
||||
reject e
|
||||
else
|
||||
console.log l, "Library exist, no need to load"
|
||||
f() if f
|
||||
Ant.OS.announcer.trigger "sharedlibraryloaded", l
|
||||
resolve()
|
||||
|
||||
requires:(libs, f) ->
|
||||
return f() unless libs.length > 0
|
||||
require: (libs) ->
|
||||
new Promise (resolve, reject) ->
|
||||
return resolve() unless libs.length > 0
|
||||
Ant.OS.announcer.observable.one "sharedlibraryloaded", (l) ->
|
||||
libs.splice 0, 1
|
||||
Ant.OS.API.requires libs, f
|
||||
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:
|
||||
fetch: () ->
|
||||
|
@ -56,7 +56,12 @@ Ant.OS or=
|
||||
Ant.OS.announcer.trigger "srvroutineready", app
|
||||
if 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
|
||||
f()
|
||||
appByPid: (pid) ->
|
||||
|
@ -311,10 +311,10 @@ Ant.OS.GUI =
|
||||
return unless el.length > 0
|
||||
Ant.OS.GUI.showTooltip el, ($(el).attr "tooltip"), e
|
||||
|
||||
fp = Ant.OS.setting.desktop.path.asFileHandle()
|
||||
# desktop default file manager
|
||||
desktop = $ Ant.OS.GUI.workspace
|
||||
desktop[0].fetch = () ->
|
||||
fp = Ant.OS.setting.desktop.path.asFileHandle()
|
||||
fn = () ->
|
||||
fp.read().then (d) ->
|
||||
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()
|
||||
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()
|
||||
Ant.OS.announcer.ostrigger "desktoploaded"
|
||||
# mount it
|
||||
|
@ -26,6 +26,9 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
||||
return $(@refs.status).show() if v
|
||||
$(@refs.status).hide()
|
||||
|
||||
__showhidden__: (v) ->
|
||||
@switchView()
|
||||
|
||||
__path__: (v) ->
|
||||
return unless v
|
||||
me = @
|
||||
@ -36,7 +39,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
||||
me.refs.status.set("text", " ") if me.get "status"
|
||||
.catch (e) ->
|
||||
# this should be handled by the OS
|
||||
console.error e
|
||||
Ant.OS.announcer.oserror e
|
||||
|
||||
__data__: (v) ->
|
||||
return unless v
|
||||
|
@ -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
|
||||
constructor: (r, o) ->
|
||||
super r, o
|
||||
@ -10,12 +16,15 @@ class GridCellPrototype extends Ant.OS.GUI.BaseTag
|
||||
__data__: (v) ->
|
||||
return unless v.selected
|
||||
@set "selected", v.selected
|
||||
delete v.selected
|
||||
|
||||
__selected__: (v) ->
|
||||
@get("data").selected = v
|
||||
return unless v
|
||||
@cellseleck {}, false
|
||||
|
||||
update: () ->
|
||||
@set "data", @get("data")
|
||||
|
||||
mount: () ->
|
||||
me = @
|
||||
$(@root).css "display", "block"
|
||||
@ -34,7 +43,7 @@ class GridCellPrototype extends Ant.OS.GUI.BaseTag
|
||||
__class__: (v) ->
|
||||
$(@root).removeClass().addClass @get("class")
|
||||
|
||||
class SimpleGridCell extends GridCellPrototype
|
||||
class SimpleGridCellTag extends GridCellPrototype
|
||||
constructor: (r, o) ->
|
||||
super r, o
|
||||
@setopt "header", false
|
||||
@ -64,6 +73,10 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
||||
@setopt "onrowselect", (e) ->
|
||||
@setopt "oncelldbclick", (e) ->
|
||||
@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) ->
|
||||
return $(@refs.header).hide() if not v or v.length is 0
|
||||
@ -79,17 +92,43 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
||||
me = @
|
||||
$(@refs.grid).empty()
|
||||
for row in rows
|
||||
div = $("<div>")
|
||||
.addClass("afx-grid-row")
|
||||
@push row, false
|
||||
|
||||
remove: (row) ->
|
||||
return unless row
|
||||
rowdata = row.get "data"
|
||||
data = @get "rows"
|
||||
@set "selectedRow", undefined if @get("selectedRow") is row
|
||||
@set "selectedCell", undefined if $(@get("selectedCell")).parent()[0] is row
|
||||
list = @get("selectedRows")
|
||||
list.splice(list.indexOf(row), 1) if list.includes(row)
|
||||
if data.includes rowdata
|
||||
data.splice data.indexOf(rowdata), 1
|
||||
$(row).remove()
|
||||
|
||||
|
||||
push: (row, flag) ->
|
||||
me = @
|
||||
rowel = $("<afx-grid-row>")
|
||||
.css "display", "contents"
|
||||
.appendTo @refs.grid
|
||||
rowel[0].uify undefined
|
||||
rowel[0].set "data", row
|
||||
row.domel = rowel[0]
|
||||
|
||||
for cell in row
|
||||
el = $("<#{@get("cellitem")}>").appendTo div
|
||||
el[0].uify undefined
|
||||
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: () ->
|
||||
@get "multiselect"
|
||||
@ -114,23 +153,23 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
||||
selectedRow = @get "selectedRow"
|
||||
selectedRows = @get "selectedRows"
|
||||
evt = { id: @aid(), data: {} }
|
||||
div = $(e.data.item).parent()[0]
|
||||
row = $(e.data.item).parent()[0]
|
||||
if @multiselect()
|
||||
if selectedRows.includes div
|
||||
selectedRows.splice selectedRows.indexOf(div) , 1
|
||||
$(div).removeClass()
|
||||
if selectedRows.includes row
|
||||
selectedRows.splice selectedRows.indexOf(row) , 1
|
||||
$(row).removeClass()
|
||||
else
|
||||
selectedRows.push div
|
||||
$(div).removeClass().addClass("afx-grid-row-selected")
|
||||
selectedRows.push row
|
||||
$(row).removeClass().addClass("afx-grid-row-selected")
|
||||
evt.data.items = @get "selectedRows"
|
||||
else
|
||||
return if selectedRow is div
|
||||
return if selectedRow is row
|
||||
$(selectedRow).removeClass()
|
||||
@set "selectedRow", div
|
||||
@set "selectedRows", [div]
|
||||
evt.data.item = div
|
||||
evt.data.items = [ div ]
|
||||
$(div).removeClass().addClass("afx-grid-row-selected")
|
||||
@set "selectedRow", row
|
||||
@set "selectedRows", [row]
|
||||
evt.data.item = row
|
||||
evt.data.items = [ row ]
|
||||
$(row).removeClass().addClass("afx-grid-row-selected")
|
||||
@get("onrowselect") 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-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
|
@ -49,7 +49,6 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
|
||||
|
||||
mount: () ->
|
||||
me = @
|
||||
@refs.switch.set "enable", false
|
||||
$(@refs.entry).click (e) -> me.select e
|
||||
|
||||
submenuoff: () ->
|
||||
@ -99,6 +98,7 @@ class SimpleMenuEntryTag extends MenuEntryTag
|
||||
$(@refs.switch).hide()
|
||||
|
||||
__checked__: (v) ->
|
||||
@get("data").checked = v
|
||||
return unless @get("radio") or @get("switch")
|
||||
@refs.switch.set "swon", v
|
||||
|
||||
@ -124,7 +124,7 @@ class SimpleMenuEntryTag extends MenuEntryTag
|
||||
$(@refs.shortcut).hide()
|
||||
return unless v
|
||||
$(@refs.shortcut).show()
|
||||
$(@refs.shortcut).val v
|
||||
$(@refs.shortcut).text v
|
||||
|
||||
reset_radio: () ->
|
||||
return unless @has_children()
|
||||
@ -132,15 +132,19 @@ class SimpleMenuEntryTag extends MenuEntryTag
|
||||
return unless v.domel.get "radio"
|
||||
v.domel.set "checked", false
|
||||
|
||||
mount: () ->
|
||||
super.mount()
|
||||
me = @
|
||||
@refs.switch.set "enable", false
|
||||
|
||||
select: (e) ->
|
||||
super.select(e)
|
||||
if @get "switch"
|
||||
@set "checked", !@get "checked"
|
||||
else if @get "radio"
|
||||
p = @get "parent"
|
||||
p.reset_radio() if p
|
||||
@set "checked", !@get "checked"
|
||||
super.select(e)
|
||||
|
||||
itemlayout: () ->
|
||||
[
|
||||
|
@ -156,7 +156,12 @@ class SystemPanelTag extends Ant.OS.GUI.BaseTag
|
||||
|
||||
$(@refs.applist).click (e) ->
|
||||
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.GUI.define "afx-sys-panel", SystemPanelTag
|
@ -11,6 +11,7 @@ class Ant.OS.GUI.BaseTag
|
||||
@root.get = (k) -> me.get k
|
||||
@root.aid = () -> me.aid()
|
||||
@root.calibrate = () -> me.calibrate()
|
||||
@root.update = () -> me.update()
|
||||
@mounted = false
|
||||
@root.sync = () -> me.sync()
|
||||
@refs = {}
|
||||
@ -60,6 +61,7 @@ class Ant.OS.GUI.BaseTag
|
||||
@get "data-id"
|
||||
|
||||
calibrate: () ->
|
||||
update: () ->
|
||||
|
||||
get: (opt) ->
|
||||
return @opts if opt is "*"
|
||||
|
@ -50,8 +50,9 @@ class BaseFileHandle
|
||||
@genealogy = re.split("/")
|
||||
@basename = @genealogy[@genealogy.length - 1] unless @isRoot()
|
||||
@ext = @basename.split( "." ).pop() unless @basename.lastIndexOf(".") is 0 or @basename.indexOf( "." ) is -1
|
||||
asFileHandle: () ->
|
||||
@
|
||||
|
||||
asFileHandle: () -> @
|
||||
|
||||
isRoot: () -> (not @genealogy) or (@genealogy.size is 0)
|
||||
|
||||
child: (name) ->
|
||||
@ -92,6 +93,7 @@ class BaseFileHandle
|
||||
parent: () ->
|
||||
return @ if @isRoot()
|
||||
return (@protocol + "://" + (@genealogy.slice 0 , @genealogy.length - 1).join "/")
|
||||
.asFileHandle()
|
||||
|
||||
onready: () ->
|
||||
# read meta data
|
||||
@ -112,15 +114,19 @@ class BaseFileHandle
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
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
|
||||
|
||||
write: (d, t) ->
|
||||
write: (t) ->
|
||||
me = @
|
||||
new Promise (resolve, reject) ->
|
||||
me._wr(d, t)
|
||||
.then (r) -> resolve r
|
||||
me._wr(t)
|
||||
.then (r) ->
|
||||
Ant.OS.announcer.ostrigger "VFS", { m: "write", file: me }
|
||||
resolve r
|
||||
.catch (e) -> reject e
|
||||
|
||||
mk: (d) ->
|
||||
@ -129,7 +135,9 @@ class BaseFileHandle
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
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
|
||||
|
||||
@ -139,7 +147,9 @@ class BaseFileHandle
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
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
|
||||
|
||||
@ -149,7 +159,9 @@ class BaseFileHandle
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
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
|
||||
|
||||
@ -159,7 +171,9 @@ class BaseFileHandle
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
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
|
||||
|
||||
@ -169,7 +183,9 @@ class BaseFileHandle
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
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
|
||||
|
||||
@ -178,8 +194,10 @@ class BaseFileHandle
|
||||
new Promise (resolve, reject) ->
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
me._mv()
|
||||
.then (d) -> resolve d
|
||||
me._mv(d)
|
||||
.then (data) ->
|
||||
Ant.OS.announcer.ostrigger "VFS", { m: "move", file: me }
|
||||
resolve data
|
||||
.catch (e) -> reject e
|
||||
.catch (e) -> reject e
|
||||
|
||||
@ -189,7 +207,9 @@ class BaseFileHandle
|
||||
me.onready()
|
||||
.then (r) ->
|
||||
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
|
||||
|
||||
@ -232,22 +252,23 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
||||
return Ant.OS.API.handle.fileblob @path if t is "binary"
|
||||
Ant.OS.API.handle.readfile @path, if t then t else "text"
|
||||
|
||||
_wr: (d, t) ->
|
||||
_wr: (t) ->
|
||||
# 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 = @
|
||||
new Promise (resolve, reject) ->
|
||||
me.b64(t)
|
||||
.then (r) ->
|
||||
Ant.OS.API.handle.write me.path, d
|
||||
resolve r
|
||||
Ant.OS.API.handle.write me.path, r
|
||||
.then (result) -> resolve result
|
||||
.catch (e) -> reject e
|
||||
.catch (e) -> reject e
|
||||
|
||||
_mk: (d) ->
|
||||
me = @
|
||||
if @info.type is "file"
|
||||
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}"
|
||||
|
||||
_rm: () ->
|
||||
@ -259,17 +280,17 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
||||
|
||||
_up: () ->
|
||||
me = @
|
||||
if @info.type isnt "file"
|
||||
if @info.type isnt "dir"
|
||||
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
|
||||
|
||||
_down: () ->
|
||||
me = @
|
||||
new Promise (resolve, reject) ->
|
||||
if me.info.type is "dir"
|
||||
return reject { error: __("{0} is not a file", me.path) }
|
||||
Ant.OS.API.handle.fileblob(@path)
|
||||
return Ant.OS.API.throwe __("{0} is not a file", me.path)
|
||||
Ant.OS.API.handle.fileblob(me.path)
|
||||
.then (d) ->
|
||||
blob = new Blob [d], { type: "octet/stream" }
|
||||
Ant.OS.API.saveblob me.basename, blob
|
||||
@ -293,7 +314,7 @@ class ApplicationHandle extends Ant.OS.API.VFS.BaseFileHandle
|
||||
me = @
|
||||
new Promise (resolve, reject) ->
|
||||
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 ) }
|
||||
|
||||
|
||||
@ -341,7 +362,7 @@ class URLFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
||||
_rd: (t) ->
|
||||
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
|
||||
@ -368,12 +389,13 @@ class SharedFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
||||
me = @
|
||||
new Promise (resolve, reject) ->
|
||||
if me.info.type is "dir"
|
||||
return reject { error: __("{0} is not a file", me.path) }
|
||||
Ant.OS.API.handle.fileblob me.path, (d) ->
|
||||
blob = new Blob [d], { type: "octet/stream" }
|
||||
return reject Ant.OS.API.throwe __("{0} is not a file", me.path)
|
||||
Ant.OS.API.handle.fileblob me.path
|
||||
.then (data) ->
|
||||
blob = new Blob [data], { type: "octet/stream" }
|
||||
Ant.OS.API.saveblob me.basename, blob
|
||||
resolve()
|
||||
|
||||
.catch (e) -> reject e
|
||||
_pub: () ->
|
||||
me = @
|
||||
return new Promise (resolve, reject) -> resolve { result: me.basename }
|
||||
|
@ -26,9 +26,10 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
|
||||
@grid = @find "mygrid"
|
||||
@on "btclick", (e) ->
|
||||
return unless e.id == "btkill"
|
||||
item = me.grid.get "selected"
|
||||
item = me.grid.get "selectedRow"
|
||||
return unless item
|
||||
app = _PM.appByPid item[0].value
|
||||
data = item.get("data")[0]
|
||||
app = _PM.appByPid data.text
|
||||
app.quit(true) if app
|
||||
|
||||
header = [
|
||||
@ -44,13 +45,14 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
width: 75,
|
||||
width: 80,
|
||||
text: "__(Alive (ms))"
|
||||
}
|
||||
]
|
||||
@gdata =
|
||||
@gdata = {
|
||||
processes: {}
|
||||
alive: []
|
||||
}
|
||||
@grid.set "header", header
|
||||
@monitor()
|
||||
|
||||
@ -62,7 +64,8 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
|
||||
$.each _PM.processes, (i, d) ->
|
||||
$.each d , (j, a) ->
|
||||
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
|
||||
me.gdata.processes[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: now - a.birth
|
||||
}
|
||||
]
|
||||
me.grid.push me.gdata.processes[a.pid]
|
||||
me.gdata.alive.push a.pid
|
||||
@refreshGrid()
|
||||
|
||||
$.each @gdata.processes, (i, e) ->
|
||||
if ($.inArray (Number i), me.gdata.alive) < 0
|
||||
me.grid.remove me.gdata.processes[i].domel
|
||||
me.gdata.processes[i] = undefined
|
||||
delete me.gdata.processes[i]
|
||||
|
||||
@timer = setTimeout (() -> me.monitor()), 500
|
||||
|
||||
refreshGrid: () ->
|
||||
activeList = []
|
||||
me = @
|
||||
$.each @gdata.processes, (i, e) ->
|
||||
if ($.inArray (Number i), me.gdata.alive) >= 0
|
||||
activeList.push e
|
||||
else
|
||||
me.gdata.processes[i] = undefined
|
||||
@grid.set "rows", activeList
|
||||
cleanup: (e) ->
|
||||
clearTimeout @timer if @timer
|
||||
|
||||
|
@ -2,7 +2,13 @@ afx-app-window[data-id="am-window"] afx-button{
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="am-window"] afx-grid-view{
|
||||
padding-left:10px;
|
||||
padding-right: 10px;
|
||||
afx-app-window[data-id="am-window"] afx-grid-view afx-grid-row afx-grid-cell{
|
||||
padding:5px;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
@ -1,6 +1,11 @@
|
||||
<afx-app-window data-id = "am-window" apptitle="" width="400" height="300">
|
||||
<afx-hbox>
|
||||
<div data-width="7"></div>
|
||||
<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>
|
@ -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 |
@ -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
|
@ -1,7 +0,0 @@
|
||||
/*.dummyapp-icon {
|
||||
background-image: url("icon.png");
|
||||
background-color: blueviolet;
|
||||
display: block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}*/
|
@ -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"]
|
||||
}
|
@ -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>
|
@ -26,7 +26,10 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@view = @find "fileview"
|
||||
@navinput = @find "navinput"
|
||||
@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"
|
||||
@clipboard = undefined
|
||||
@viewType = @_api.switcher "icon", "list", "tree"
|
||||
@ -35,37 +38,44 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
|
||||
@view.contextmenuHandle = (e, m) ->
|
||||
m.set "items", [ me.mnFile(), me.mnEdit() ]
|
||||
m.set "onmenuselect", (evt) ->
|
||||
me._gui.launch evt.item.data.app, evt.item.data.args if evt.item.data.app
|
||||
# Fix m.set "onmenuselect", (evt) ->
|
||||
# me._gui.launch evt.item.data.app, evt.item.data.args if evt.item.data.app
|
||||
m.show e
|
||||
#@on "fileselect", (d) -> console.log d
|
||||
|
||||
@view.set "onfileopen", (e) ->
|
||||
return unless e
|
||||
return if e.type is "dir"
|
||||
me._gui.openWith e
|
||||
return unless e.data
|
||||
return if e.data.type is "dir"
|
||||
me._gui.openWith e.data
|
||||
|
||||
@favo.set "onlistselect", (e) ->
|
||||
me.chdir e.data.path
|
||||
me.view.set "path", e.data.item.get("data").path
|
||||
|
||||
($ @find "btback").click () ->
|
||||
return if me.currdir.isRoot()
|
||||
p = me.currdir.parent()
|
||||
me.favo.set "selected", -1
|
||||
me.chdir p
|
||||
me.view.set "path", p.path
|
||||
|
||||
($ @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", (e, f) ->
|
||||
return unless e.child
|
||||
return if e.child.filename is "[..]"
|
||||
e.child.path.asFileHandler().read (d) ->
|
||||
return me.error __("Resource not found {0}", e.child.path) if d.error
|
||||
f d.result
|
||||
@view.set "fetch", (path) ->
|
||||
new Promise (resolve, reject) ->
|
||||
dir = path
|
||||
dir = path.asFileHandle() if typeof path is "string"
|
||||
dir.read().then (d) ->
|
||||
return reject d.error if d.error
|
||||
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) ->
|
||||
file = me.view.get "selectedFile"
|
||||
file = e.data
|
||||
return unless file and file.mime
|
||||
file.mime = "dir" if file.type is "dir"
|
||||
me.apps.length = 0
|
||||
@ -79,13 +89,13 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
|
||||
mntpoints = @systemsetting.VFS.mountpoints
|
||||
el.selected = false for el, i in mntpoints
|
||||
|
||||
@favo.set "items", mntpoints
|
||||
@favo.set "data", mntpoints
|
||||
#@favo.set "selected", -1
|
||||
@view.set "view", @setting.view if @setting.view
|
||||
|
||||
@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-D", () -> me.actionFile "#{me.name}-mkdir"
|
||||
@bindKey "CTRL-U", () -> me.actionFile "#{me.name}-upload"
|
||||
@ -101,10 +111,11 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
(@find "btgrid").set "onbtclick", (e) ->
|
||||
me.view.set 'view', "icon"
|
||||
me.viewType.icon = true
|
||||
|
||||
(@find "btlist").set "onbtclick", (e) ->
|
||||
me.view.set 'view', "list"
|
||||
me.viewType.list = true
|
||||
@chdir null
|
||||
@view.set "path", @currdir
|
||||
|
||||
applySetting: (k) ->
|
||||
# view setting
|
||||
@ -112,28 +123,6 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
when "showhidden" then @view.set "showhidden", @setting.showhidden
|
||||
when "nav" then @toggleNav @setting.nav
|
||||
when "sidebar" then @toggleSidebar @setting.sidebar
|
||||
#@view.set "view", @setting.view if @setting.view
|
||||
|
||||
|
||||
chdir: (p) ->
|
||||
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
|
||||
@ -148,7 +137,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
{ text: "__(Download)", dataid: "#{@name}-download" },
|
||||
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
|
||||
{ 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
|
||||
mnEdit: () ->
|
||||
@ -161,7 +150,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
|
||||
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
|
||||
{ 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: () ->
|
||||
me = @
|
||||
@ -176,14 +165,15 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
{ text: "__(Navigation bar)", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" },
|
||||
{ text: "__(Hidden files)", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" },
|
||||
{ text: "__(Type)", child: [
|
||||
{ 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: "__(Tree view)", radio:true, checked: (() -> me.viewType.tree), dataid: "#{@name}-tree", type: 'tree' }
|
||||
], onmenuselect: (e) ->
|
||||
me.view.set 'view', e.item.data.type
|
||||
me.viewType[e.item.data.type] = true
|
||||
{ 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: "__(Tree view)", radio:true, checked: me.viewType.tree, dataid: "#{@name}-tree", type: 'tree' }
|
||||
], onchildselect: (e) ->
|
||||
type = e.data.item.get("data").type
|
||||
me.view.set 'view', type
|
||||
me.viewType[type] = true
|
||||
},
|
||||
], onmenuselect: (e) -> me.actionView e
|
||||
], onchildselect: (e) -> me.actionView e
|
||||
},
|
||||
]
|
||||
menu
|
||||
@ -197,19 +187,20 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@trigger "resize"
|
||||
|
||||
actionView: (e) ->
|
||||
switch e.item.data.dataid
|
||||
data = e.data.item.get("data")
|
||||
switch data.dataid
|
||||
when "#{@name}-hidden"
|
||||
#@.view.set "showhidden", e.item.data.checked
|
||||
@registry "showhidden", e.item.data.checked
|
||||
@registry "showhidden", data.checked
|
||||
#@.setting.showhidden = e.item.data.checked
|
||||
when "#{@name}-refresh"
|
||||
@.chdir null
|
||||
when "#{@name}-side"
|
||||
@registry "sidebar", e.item.data.checked
|
||||
@registry "sidebar", data.checked
|
||||
#@setting.sidebar = e.item.data.checked
|
||||
#@toggleSidebar e.item.data.checked
|
||||
when "#{@name}-nav"
|
||||
@registry "nav", e.item.data.checked
|
||||
@registry "nav", data.checked
|
||||
#@setting.nav = e.item.data.checked
|
||||
#@toggleNav e.item.data.checked
|
||||
|
||||
@ -219,98 +210,130 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
switch e
|
||||
when "#{@name}-mv"
|
||||
return unless file
|
||||
@openDialog "PromptDialog",
|
||||
(d) ->
|
||||
@openDialog("PromptDialog", {
|
||||
title: "__(Rename)",
|
||||
label: "__(File name)",
|
||||
value: file.filename
|
||||
})
|
||||
.then (d) ->
|
||||
return if d is file.filename
|
||||
file.path.asFileHandler()
|
||||
.move "#{me.currdir.path}/#{d}", (r) ->
|
||||
file.path.asFileHandle().move "#{me.currdir.path}/#{d}"
|
||||
.then (r) ->
|
||||
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"
|
||||
return unless file
|
||||
@openDialog "YesNoDialog",
|
||||
(d) ->
|
||||
@openDialog("YesNoDialog", {
|
||||
title: "__(Delete)",
|
||||
iconclass: "fa fa-question-circle",
|
||||
text: __("Do you really want to delete: {0}?", file.filename)
|
||||
})
|
||||
.then (d) ->
|
||||
return unless d
|
||||
file.path.asFileHandler()
|
||||
.remove (r) ->
|
||||
file.path.asFileHandle().remove()
|
||||
.then (r) ->
|
||||
me.error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
|
||||
,"__(Delete)" ,
|
||||
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?", file.filename) }
|
||||
.catch (e) ->
|
||||
me.error __("Fail to delete: {0}", e.stack)
|
||||
|
||||
when "#{@name}-cut"
|
||||
return unless file
|
||||
@clipboard =
|
||||
cut: true
|
||||
file: file.path.asFileHandler()
|
||||
file: file.path.asFileHandle()
|
||||
@notify __("File {0} cut", file.filename)
|
||||
|
||||
when "#{@name}-copy"
|
||||
return unless file or file.type is "dir"
|
||||
@clipboard =
|
||||
cut: false
|
||||
file: file.path.asFileHandler()
|
||||
file: file.path.asFileHandle()
|
||||
@notify __("File {0} copied", file.filename)
|
||||
|
||||
when "#{@name}-paste"
|
||||
me = @
|
||||
return unless @clipboard
|
||||
if @clipboard.cut
|
||||
@clipboard.file # duplicate file check
|
||||
.move "#{me.currdir.path}/#{@clipboard.file.basename}", (r) ->
|
||||
@clipboard.file.move "#{me.currdir.path}/#{@clipboard.file.basename}"
|
||||
.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
|
||||
@clipboard.file.read (d) ->
|
||||
@clipboard.file.read("binary")
|
||||
.then (d) ->
|
||||
blob = new Blob [d], { type: me.clipboard.file.info.mime }
|
||||
fp = "#{me.currdir.path}/#{me.clipboard.file.basename}".asFileHandler()
|
||||
fp = "#{me.currdir.path}/#{me.clipboard.file.basename}".asFileHandle()
|
||||
fp.cache = blob
|
||||
fp.write me.clipboard.file.info.mime, (r) ->
|
||||
fp.write(me.clipboard.file.info.mime)
|
||||
.then (r) ->
|
||||
me.clipboard = undefined
|
||||
me.error __("Fail to paste: {0}", r.error) if r.error
|
||||
, "binary"
|
||||
.catch (e) ->
|
||||
me.error __("Fail to paste: {0}", e.stack)
|
||||
else
|
||||
@_api.handler.setting()
|
||||
@_api.handle.setting()
|
||||
|
||||
actionFile: (e) ->
|
||||
me = @
|
||||
file = @view.get "selectedFile"
|
||||
switch e
|
||||
|
||||
when "#{@name}-mkdir"
|
||||
@openDialog "PromptDialog",
|
||||
(d) ->
|
||||
me.currdir.mk d, (r) ->
|
||||
@openDialog("PromptDialog", {
|
||||
title: "__(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
|
||||
, "__(New folder)", { label: "__(Folder name)" }
|
||||
.catch (e) ->
|
||||
me.error __("Fail to create: {0}", e.stack)
|
||||
|
||||
when "#{@name}-mkf"
|
||||
@openDialog "PromptDialog",
|
||||
(d) ->
|
||||
fp = "#{me.currdir.path}/#{d}".asFileHandler()
|
||||
fp.write "text/plain", (r) ->
|
||||
@openDialog("PromptDialog", {
|
||||
title: "__(New file)",
|
||||
label: "__(File name)"
|
||||
})
|
||||
.then (d) ->
|
||||
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
|
||||
, "__(New file)", { label: "__(File name)" }
|
||||
.catch (e) ->
|
||||
me.error __("Fail to create: {0}", e.stack)
|
||||
|
||||
when "#{@name}-info"
|
||||
return unless file
|
||||
@openDialog "InfoDialog", null, file.filename, file
|
||||
@openDialog "InfoDialog", file
|
||||
|
||||
when "#{@name}-upload"
|
||||
me = @
|
||||
@currdir.upload (r) ->
|
||||
@currdir.upload()
|
||||
.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"
|
||||
me = @
|
||||
return unless file and file.type is "file"
|
||||
file.path.asFileHandler().publish (r) ->
|
||||
file.path.asFileHandle().publish()
|
||||
.then (r) ->
|
||||
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"
|
||||
return unless file
|
||||
file.path.asFileHandler().download ()->
|
||||
return unless file.type is "file"
|
||||
file.path.asFileHandle().download()
|
||||
.catch (e) ->
|
||||
me.error __("Fail to download: {0}", e.stack)
|
||||
else
|
||||
console.log e
|
||||
|
||||
|
@ -11,6 +11,12 @@ afx-app-window[data-id ='files-app-window'] afx-resizer{
|
||||
background-color: transparent;
|
||||
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{
|
||||
background-color: transparent;
|
||||
}
|
||||
|
@ -25,7 +25,10 @@ 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()
|
||||
if @args and @args.length > 0
|
||||
@currfile = @args[0].asFileHandle()
|
||||
else
|
||||
@currfile = "Untitled".asFileHandle()
|
||||
@editormux = false
|
||||
@editor = new SimpleMDE
|
||||
element: markarea
|
||||
@ -82,21 +85,25 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
||||
return if file.path is "Untitled"
|
||||
me = @
|
||||
file.dirty = false
|
||||
file.read (d) ->
|
||||
file.read()
|
||||
.then (d) ->
|
||||
me.currfile = file
|
||||
me.editormux = true
|
||||
me.editor.value d
|
||||
me.scheme.set "apptitle", "#{me.currfile.basename}"
|
||||
me.editormux = false
|
||||
.catch (e) -> me.error e.stack
|
||||
|
||||
|
||||
save: (file) ->
|
||||
me = @
|
||||
file.write "text/plain", (d) ->
|
||||
return me.error __("Error saving file {0}", file.basename) if d.error
|
||||
file.write("text/plain")
|
||||
.then (d) ->
|
||||
return me.error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
|
||||
file.dirty = false
|
||||
file.text = file.basename
|
||||
me.scheme.set "apptitle", "#{me.currfile.basename}"
|
||||
.catch (e) -> me.error e.stack
|
||||
|
||||
menu: () ->
|
||||
me = @
|
||||
@ -108,22 +115,34 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
||||
{ text: "__(Save)", dataid: "#{@name}-Save", shortcut: "C-S" },
|
||||
{ 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
|
||||
|
||||
actionFile: (e) ->
|
||||
me = @
|
||||
saveas = () ->
|
||||
me.openDialog "FileDiaLog", (d, n) ->
|
||||
me.currfile.setPath "#{d}/#{n}"
|
||||
me.openDialog("FileDialog", {
|
||||
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
|
||||
, __("Save as"), { file: me.currfile }
|
||||
.catch (e) ->
|
||||
me.error e.stack
|
||||
|
||||
switch e
|
||||
when "#{@name}-Open"
|
||||
@openDialog "FileDiaLog", ( d, f ) ->
|
||||
me.open "#{d}/#{f}".asFileHandler()
|
||||
, __("Open file")
|
||||
@openDialog("FileDialog", {
|
||||
title: __("Open file")
|
||||
})
|
||||
.then (f) ->
|
||||
me.open f.file.path.asFileHandle()
|
||||
|
||||
when "#{@name}-Save"
|
||||
@currfile.cache = @editor.value()
|
||||
return @save @currfile if @currfile.basename
|
||||
@ -132,7 +151,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
||||
@currfile.cache = @editor.value()
|
||||
saveas()
|
||||
when "#{@name}-New"
|
||||
@currfile = "Untitled".asFileHandler()
|
||||
@currfile = "Untitled".asFileHandle()
|
||||
@currfile.cache = ""
|
||||
@editor.value("")
|
||||
|
||||
|
@ -194,7 +194,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
when "yesno"
|
||||
me.openDialog("YesNoDialog", {
|
||||
title: "Question ?",
|
||||
label: "Do you realy want to delete file ?"
|
||||
text: "Do you realy want to delete file ?"
|
||||
})
|
||||
.then (d) ->
|
||||
console.log d
|
||||
|
@ -47,12 +47,12 @@ afx-calendar-view afx-grid-view afx-grid-row.selected{
|
||||
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;
|
||||
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;
|
||||
color:white;
|
||||
|
@ -80,13 +80,16 @@ afx-file-view afx-grid-view i{
|
||||
display: inline-block;
|
||||
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;
|
||||
}
|
||||
afx-file-view afx-grid-view .grid_row_header{
|
||||
background-color: #dfdfdf;
|
||||
afx-file-view afx-grid-view afx-grid-row afx-grid-cell
|
||||
{
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
afx-file-view afx-grid-view .grid_row_header afx-grid-cell{
|
||||
background-color: #dfdfdf;
|
||||
border-top: 1px solid #a6a6a6;
|
||||
border-right: 1px solid #a6a6a6;
|
||||
}
|
||||
|
@ -1,35 +1,30 @@
|
||||
afx-grid-view afx-grid-row div{
|
||||
padding:3px;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
afx-grid-view afx-grid-row afx-grid-cell{
|
||||
user-select:none;
|
||||
-webkit-user-select:none;
|
||||
cursor:default;
|
||||
}
|
||||
|
||||
|
||||
afx-grid-view div.afx-grid-row:nth-child(even) .afx-grid-cell
|
||||
afx-grid-view afx-grid-row:nth-child(even) afx-grid-cell
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
afx-grid-view div.grid_row_header{
|
||||
afx-grid-view .grid_row_header afx-grid-cell{
|
||||
border-right: 2px solid #e5e5e5;
|
||||
user-select:none;
|
||||
-webkit-user-select:none;
|
||||
cursor:default;
|
||||
font-weight: bold;
|
||||
border: 1px solid #e5e5e5;
|
||||
border-right:0;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ afx-sys-panel .afx-panel-os-menu {
|
||||
padding:0;
|
||||
margin: 0;
|
||||
float:left;
|
||||
margin-right: 10px;
|
||||
}
|
||||
afx-sys-panel .afx-panel-os-menu li
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user