mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-26 18:59:45 +02:00
adapt apps
This commit is contained in:
@ -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.gdata.alive.push a.pid
|
||||
@refreshGrid()
|
||||
@timer = setTimeout (() -> me.monitor()), 500
|
||||
|
||||
refreshGrid: () ->
|
||||
activeList = []
|
||||
me = @
|
||||
me.grid.push me.gdata.processes[a.pid]
|
||||
me.gdata.alive.push a.pid
|
||||
|
||||
$.each @gdata.processes, (i, e) ->
|
||||
if ($.inArray (Number i), me.gdata.alive) >= 0
|
||||
activeList.push e
|
||||
else
|
||||
if ($.inArray (Number i), me.gdata.alive) < 0
|
||||
me.grid.remove me.gdata.processes[i].domel
|
||||
me.gdata.processes[i] = undefined
|
||||
@grid.set "rows", activeList
|
||||
delete me.gdata.processes[i]
|
||||
|
||||
@timer = setTimeout (() -> me.monitor()), 500
|
||||
|
||||
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-vbox>
|
||||
<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>
|
||||
<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,30 +123,8 @@ 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:() ->
|
||||
mnFile: () ->
|
||||
#console.log file
|
||||
me = @
|
||||
arr = {
|
||||
@ -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) ->
|
||||
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) ->
|
||||
@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
|
||||
, "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
|
||||
@_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) ->
|
||||
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
|
||||
, "__(New folder)", { label: "__(Folder name)" }
|
||||
@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
|
||||
.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) ->
|
||||
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
|
||||
, "__(New file)", { label: "__(File name)" }
|
||||
@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
|
||||
.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) ->
|
||||
me.error __("Fail to upload to {0}: {1}", me.currdir.path, r.error) if r.error
|
||||
@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) ->
|
||||
return me.error __("Cannot share file: {0}", r.error) if r.error
|
||||
return me.notify __("Shared url: {0}", r.result)
|
||||
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) ->
|
||||
me.currfile = file
|
||||
me.editormux = true
|
||||
me.editor.value d
|
||||
me.scheme.set "apptitle", "#{me.currfile.basename}"
|
||||
me.editormux = false
|
||||
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.dirty = false
|
||||
file.text = file.basename
|
||||
me.scheme.set "apptitle", "#{me.currfile.basename}"
|
||||
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
|
||||
|
Reference in New Issue
Block a user