mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-19 15:29:51 +02:00
adapt more apps
This commit is contained in:
@ -52,10 +52,10 @@ class Announcer
|
||||
for evt in names
|
||||
continue unless me.observable[evt]
|
||||
me.observable[evt].one.forEach (f) ->
|
||||
f data
|
||||
f d
|
||||
me.observable[evt].one = new Set()
|
||||
me.observable[evt].many.forEach (f) ->
|
||||
f data
|
||||
f d
|
||||
|
||||
if evtName is "*"
|
||||
trig k, data for k, v of me.observable when k isnt "*"
|
||||
|
@ -274,7 +274,7 @@ class SelectionDialog extends BasicDialog
|
||||
(@find "btnOk").set "onbtclick", (e) ->
|
||||
data = (me.find "list").get "selectedItem"
|
||||
return me.notify __("Please select an item") unless data
|
||||
me.handle(data) if me.handle
|
||||
me.handle(data.get("data")) if me.handle
|
||||
me.quit()
|
||||
|
||||
(@find "btnCancel").set "onbtclick", (e) ->
|
||||
@ -357,6 +357,7 @@ class FileDialog extends BasicDialog
|
||||
me = @
|
||||
fileview.set "fetch", (path) ->
|
||||
new Promise (resolve, reject) ->
|
||||
return resolve() unless path
|
||||
path.asFileHandle().read()
|
||||
.then (d) ->
|
||||
return reject d if d.error
|
||||
|
@ -36,12 +36,12 @@ Ant.OS.GUI =
|
||||
app.main()
|
||||
app.show()
|
||||
loadScheme: (path, app, parent) ->
|
||||
path.asFileHandle().read().then (x) ->
|
||||
return null unless x
|
||||
Ant.OS.GUI.htmlToScheme x, app, parent
|
||||
#, (e, s) ->
|
||||
# Ant.OS.announcer.osfail "Cannot load scheme file: #{path} for #{app.name} (#{app.pid})", e, s
|
||||
|
||||
path.asFileHandle().read()
|
||||
.then (x) ->
|
||||
return null unless x
|
||||
Ant.OS.GUI.htmlToScheme x, app, parent
|
||||
.catch (e) ->
|
||||
Ant.OS.announcer.oserror __("Cannot load scheme: {0}", path), e
|
||||
clearTheme: () ->
|
||||
$ "head link#ostheme"
|
||||
.attr "href", ""
|
||||
@ -83,9 +83,9 @@ Ant.OS.GUI =
|
||||
Ant.OS.GUI.loadApp app
|
||||
.then (a) ->
|
||||
return Ant.OS.PM.createProcess srv, Ant.OS.APP[srv] if Ant.OS.APP[srv]
|
||||
.catch (e, s) ->
|
||||
.catch (e) ->
|
||||
Ant.OS.announcer.trigger "srvroutineready", srv
|
||||
Ant.OS.announcer.osfail __("Cannot read service script: {0}", srv), e, s
|
||||
Ant.OS.announcer.osfail __("Cannot read service script: {0}", srv), e
|
||||
|
||||
appsByMime: (mime) ->
|
||||
metas = ( v for k, v of Ant.OS.setting.system.packages when v and v.app )
|
||||
@ -101,7 +101,7 @@ Ant.OS.GUI =
|
||||
return false
|
||||
return false
|
||||
catch e
|
||||
Ant.OS.announcer.osfail __("Error find app by mimes {0}", mime), e, mime
|
||||
Ant.OS.announcer.osfail __("Error find app by mimes {0}", mime), e
|
||||
|
||||
( f m, i if m ) for m, i in mimes
|
||||
return apps
|
||||
@ -315,8 +315,9 @@ Ant.OS.GUI =
|
||||
# desktop default file manager
|
||||
desktop = $ Ant.OS.GUI.workspace
|
||||
desktop[0].fetch = () ->
|
||||
file = Ant.OS.setting.desktop.path.asFileHandle()
|
||||
fn = () ->
|
||||
fp.read().then (d) ->
|
||||
file.read().then (d) ->
|
||||
return Ant.OS.announcer.osfail d.error, (Ant.OS.API.throwe "OS.VFS"), d.error if d.error
|
||||
items = []
|
||||
$.each d.result, (i, v) ->
|
||||
@ -328,12 +329,12 @@ Ant.OS.GUI =
|
||||
desktop[0].set "data", items
|
||||
desktop[0].refresh()
|
||||
|
||||
fp.onready()
|
||||
file.onready()
|
||||
.then () -> fn()
|
||||
.catch ( e ) -> # try to create the path
|
||||
console.log "#{fp.path} not found"
|
||||
name = fp.basename
|
||||
fp.parent().asFileHandle().mk(name).then (r) ->
|
||||
console.log "#{file.path} not found"
|
||||
name = file.basename
|
||||
file.parent().asFileHandle().mk(name).then (r) ->
|
||||
ex = Ant.OS.API.throwe "OS.VFS"
|
||||
if r.error then Ant.OS.announcer.osfail d.error, ex, d.error else fn()
|
||||
|
||||
@ -398,25 +399,20 @@ Ant.OS.GUI =
|
||||
return new Ant.OS.GUI.BasicDialog conf.name, conf.layout
|
||||
|
||||
login: () ->
|
||||
Ant.OS.API.resource "schemes/login.html"
|
||||
.then (x) ->
|
||||
return null unless x
|
||||
scheme = $.parseHTML x
|
||||
($ "#wrapper").append scheme
|
||||
($ "#btlogin").click () ->
|
||||
data =
|
||||
username: ($ "#txtuser").val(),
|
||||
password: ($ "#txtpass").val()
|
||||
Ant.OS.API.handle.login data
|
||||
.then (d) ->
|
||||
return ($ "#login_error").html d.error if d.error
|
||||
Ant.OS.GUI.startAntOS d.result
|
||||
.catch (e) ->
|
||||
($ "#login_error").html "Login: server error"
|
||||
($ "#txtpass").keyup (e) ->
|
||||
($ "#btlogin").click() if e.which is 13
|
||||
.catch (e) ->
|
||||
alert __("System fail: Cannot init login screen")
|
||||
scheme = $.parseHTML Ant.OS.GUI.schemes.login
|
||||
($ "#wrapper").append scheme
|
||||
($ "#btlogin").click () ->
|
||||
data =
|
||||
username: ($ "#txtuser").val(),
|
||||
password: ($ "#txtpass").val()
|
||||
Ant.OS.API.handle.login data
|
||||
.then (d) ->
|
||||
return ($ "#login_error").html d.error if d.error
|
||||
Ant.OS.GUI.startAntOS d.result
|
||||
.catch (e) ->
|
||||
($ "#login_error").html "Login: server error"
|
||||
($ "#txtpass").keyup (e) ->
|
||||
($ "#btlogin").click() if e.which is 13
|
||||
|
||||
startAntOS: (conf) ->
|
||||
# clean up things
|
||||
@ -469,4 +465,11 @@ Ant.OS.GUI.schemes.ws = """
|
||||
"""
|
||||
|
||||
Ant.OS.GUI.schemes.login = """
|
||||
<div id = "login_form">
|
||||
<p>Welcome to AntOS, please identify</p>
|
||||
<input id = "txtuser" type = "text" value = "demo" />
|
||||
<input id = "txtpass" type = "password" value = "demo" />
|
||||
<button id = "btlogin">Login</button>
|
||||
<div id = "login_error"></div>
|
||||
</div>
|
||||
"""
|
@ -1,8 +0,0 @@
|
||||
|
||||
<afx-sys-panel id = "syspanel"></afx-sys-panel>
|
||||
<div id = "workspace">
|
||||
<afx-apps-dock id="sysdock"></afx-apps-dock>
|
||||
<afx-float-list id = "desktop" dir="vertical" ></afx-float-list>
|
||||
</div>
|
||||
<afx-menu id="contextmenu" data-id="contextmenu" context="true" style="display:none;"></afx-menu>
|
||||
<afx-label id="systooltip" data-id="systooltip" style="display:none;position:absolute;"></afx-label>
|
@ -1,78 +0,0 @@
|
||||
<!--
|
||||
Since nothing is loaded, the login form is a standalone element,
|
||||
it deserves it own unique style
|
||||
For now, it can not be themed !!!
|
||||
-->
|
||||
<style>
|
||||
body, html{
|
||||
background-color: rgba(215,215,215,0.7);
|
||||
}
|
||||
#login_form{
|
||||
width:300px;
|
||||
height: 200px;
|
||||
display: block;
|
||||
border:1px solid #a6a6a6;
|
||||
border-radius: 6px;
|
||||
box-shadow: 1px 1px 1px #9f9F9F;
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
top:0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
font-family:Verdana, Geneva, Tahoma, sans-serif;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
color: #414339;
|
||||
}
|
||||
|
||||
#login_form p{
|
||||
display: inline-block;
|
||||
background-color:#dfdfdf;
|
||||
border-bottom: 1px solid #a6a6a6;
|
||||
padding:10px;
|
||||
width: calc(100% - 20px);
|
||||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
font-weight: bold;
|
||||
margin:0;
|
||||
|
||||
}
|
||||
#login_form input {
|
||||
width: 250px;
|
||||
outline: none;
|
||||
margin-top:10px;
|
||||
border-radius: 6px;
|
||||
box-sizing: border-box;
|
||||
font-size: 13px;
|
||||
padding: 5px;
|
||||
border: 1px solid #a6a6a6;
|
||||
background-color: white;
|
||||
color: #414339;
|
||||
}
|
||||
#login_form button{
|
||||
margin-top:10px;
|
||||
width: 250px;
|
||||
height: 30px;
|
||||
background-color: #2786F3;
|
||||
color: white;
|
||||
border: 1px solid #dedede;
|
||||
border-radius: 6px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
font-size: 13px;
|
||||
padding:5px;
|
||||
}
|
||||
#login_error{
|
||||
padding:3px;
|
||||
color:red;
|
||||
font-weight: normal;
|
||||
}
|
||||
</style>
|
||||
<div id = "login_form">
|
||||
<p>Welcome to AntOS, please identify</p>
|
||||
<input id = "txtuser" type = "text" value = "demo" />
|
||||
<input id = "txtpass" type = "password" value = "demo" />
|
||||
<button id = "btlogin">Login</button>
|
||||
<span id = "login_error"></span>
|
||||
</div>
|
@ -20,7 +20,7 @@
|
||||
Ant.OS.setting.applications = conf.applications if conf.applications
|
||||
Ant.OS.setting.appearance = conf.appearance if conf.appearance
|
||||
Ant.OS.setting.appearance.wp = {
|
||||
url: "os://resources/themes/system/wp/wp2.jpg",
|
||||
url: "os://resources/themes/system/wp/wp3.jpg",
|
||||
size: "cover",
|
||||
repeat: "repeat"
|
||||
} unless Ant.OS.setting.appearance.wp
|
||||
|
@ -27,6 +27,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
||||
$(@refs.status).hide()
|
||||
|
||||
__showhidden__: (v) ->
|
||||
return unless @get "data"
|
||||
@switchView()
|
||||
|
||||
__path__: (v) ->
|
||||
@ -35,6 +36,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
||||
return unless @get "fetch"
|
||||
@get("fetch")(v)
|
||||
.then (data) ->
|
||||
return unless data
|
||||
me.set "data", data
|
||||
me.refs.status.set("text", " ") if me.get "status"
|
||||
.catch (e) ->
|
||||
@ -172,6 +174,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
||||
@refs.treeview.set "fetch", (v) ->
|
||||
new Promise (resolve, reject) ->
|
||||
return resolve undefined unless me.get("fetch")
|
||||
return resolve undefined unless v.get("data").path
|
||||
me.get("fetch")(v.get("data").path)
|
||||
.then (d) -> resolve me.getTreeData(d.sort me.sortByType)
|
||||
.catch (e) -> reject e
|
||||
|
@ -21,7 +21,7 @@ class GridCellPrototype extends Ant.OS.GUI.BaseTag
|
||||
@get("data").selected = v
|
||||
return unless v
|
||||
@cellseleck {}, false
|
||||
|
||||
|
||||
update: () ->
|
||||
@set "data", @get("data")
|
||||
|
||||
|
@ -11,6 +11,9 @@ class LabelTag extends Ant.OS.GUI.BaseTag
|
||||
|
||||
mount: () ->
|
||||
|
||||
update: () ->
|
||||
@set "text", @get("text")
|
||||
|
||||
__class__: (v) ->
|
||||
$(@root).removeClass()
|
||||
$(@root).addClass v if v
|
||||
|
@ -155,7 +155,15 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
|
||||
__buttons__: (v) ->
|
||||
return if @get "dropdown"
|
||||
|
||||
return unless v.length > 0
|
||||
for item in v
|
||||
$(@refs.btlist).show()
|
||||
bt = $("<afx-button>").appendTo @refs.btlist
|
||||
bt[0].uify @observable
|
||||
bt[0].set "*", item
|
||||
item.domel = bt[0]
|
||||
|
||||
|
||||
__data__: (data) ->
|
||||
$( @refs.mlist).empty()
|
||||
for item in data
|
||||
@ -203,6 +211,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
|
||||
mount: () ->
|
||||
me = @
|
||||
$(@refs.btlist).hide()
|
||||
@observable.on "resize", (e) -> me.calibrate()
|
||||
@calibrate()
|
||||
|
||||
|
@ -5,10 +5,12 @@ class TabContainerTag extends Ant.OS.GUI.BaseTag
|
||||
@setopt "selectedTab", undefined
|
||||
@setopt "tabbarwidth", undefined
|
||||
@setopt "tabbarheight", undefined
|
||||
@setopt "ontabselect", () ->
|
||||
me = @
|
||||
@refs.bar.set "ontabselect", (e) ->
|
||||
data = e.data.item.get "data"
|
||||
me.set "selectedTab", data
|
||||
me.get("ontabselect") { data: data, id: me.aid() }
|
||||
|
||||
__selectedTab: (v) ->
|
||||
return unless v
|
||||
|
@ -28,8 +28,11 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
|
||||
.removeClass()
|
||||
if(v)
|
||||
if @get("fetch")
|
||||
@get("fetch")(@root).then (d) ->
|
||||
me.set "nodes", d
|
||||
@get("fetch")(@root)
|
||||
.then (d) ->
|
||||
return unless d
|
||||
me.set "nodes", d
|
||||
.catch (e) -> Ant.OS.announcer.oserror e
|
||||
$(@refs.childnodes).show()
|
||||
else
|
||||
$(@refs.childnodes).hide()
|
||||
|
@ -11,9 +11,9 @@ 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()
|
||||
@mounted = false
|
||||
@root.setup = () -> me.setup()
|
||||
@refs = {}
|
||||
@setopt "data-id", (Math.floor(Math.random() * 100000) + 1).toString()
|
||||
@setopt "tooltip", undefined
|
||||
@ -61,13 +61,19 @@ class Ant.OS.GUI.BaseTag
|
||||
@get "data-id"
|
||||
|
||||
calibrate: () ->
|
||||
update: () ->
|
||||
|
||||
update: () ->
|
||||
|
||||
get: (opt) ->
|
||||
return @opts if opt is "*"
|
||||
@opts[opt]
|
||||
|
||||
sync: () ->
|
||||
@update()
|
||||
$(@root).children().each () -> @update()
|
||||
@root
|
||||
|
||||
setup: () ->
|
||||
return if @mounted
|
||||
@mounted = true
|
||||
@mount()
|
||||
@ -107,10 +113,15 @@ Element.prototype.mkui = (observable) ->
|
||||
|
||||
|
||||
Element.prototype.mount = () ->
|
||||
return @sync() if @sync
|
||||
return @setup() if @setup
|
||||
$(@).children().each () -> @mount()
|
||||
@
|
||||
|
||||
Element.prototype.update = () ->
|
||||
return @sync() if @sync
|
||||
$(@).children().each () -> @update()
|
||||
@
|
||||
|
||||
Element.prototype.uify = (observable) ->
|
||||
@mkui(observable)
|
||||
@mount()
|
||||
|
Reference in New Issue
Block a user