core services renamed to syslog

This commit is contained in:
Xuan Sang LE
2020-05-20 23:11:58 +02:00
parent 33eab1d30a
commit 9008396ac9
28 changed files with 436 additions and 226 deletions

View File

@ -36,7 +36,7 @@ class SubWindow extends this.OS.GUI.BaseModel
show: () ->
@trigger 'focus'
($ @scheme).css "z-index", window._zindex + 2
($ @scheme).css "z-index", Ant.OS.GUI.zindex + 2
hide: () ->
@trigger 'hide'
@ -56,10 +56,14 @@ this.OS.GUI.BaseDialog = BaseDialog
class BasicDialog extends BaseDialog
constructor: ( name, target) ->
super name
if typeof target is "string"
Ant.OS.GUI.htmlToScheme target, @, @host
else # a file handle
@render target.path
if target
if typeof target is "string"
Ant.OS.GUI.htmlToScheme target, @, @host
else # a file handle
@render target.path
else if Ant.OS.GUI.subwindows[name] and Ant.OS.GUI.subwindows[name].scheme
scheme = Ant.OS.GUI.subwindows[name].scheme
Ant.OS.GUI.htmlToScheme scheme, @, @host
init: () ->
@scheme.set "apptitle", @data.title if @data and @data.title
@ -70,20 +74,28 @@ this.OS.GUI.BasicDialog = BasicDialog
class PromptDialog extends BasicDialog
constructor: () ->
super "PromptDialog", PromptDialog.scheme
super "PromptDialog"
init: () ->
super.init()
$input = $(@find "txtInput")
@find("lbl").set "text", @data.label if @data and @data.label
$(@find "txtInput").val @data.value if @data and @data.value
$input.val @data.value if @data and @data.value
(@find "btnOk").set "onbtclick", (e) =>
@handle($(@find "txtInput").val()) if @handle
@handle($input.val()) if @handle
@quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
$input.keyup (e) =>
return unless e.which is 13
@handle($input.val()) if @handle
@quit()
$input.focus()
PromptDialog.scheme = """
<afx-app-window width='200' height='150' apptitle = "Prompt">
@ -110,7 +122,7 @@ this.OS.register "PromptDialog", PromptDialog
class CalendarDialog extends BasicDialog
constructor: () ->
super "CalendarDialog", CalendarDialog.scheme
super "CalendarDialog"
init: () ->
super.init()
@ -149,7 +161,7 @@ this.OS.register "CalendarDialog", CalendarDialog
class ColorPickerDialog extends BasicDialog
constructor: () ->
super "ColorPickerDialog", ColorPickerDialog.scheme
super "ColorPickerDialog"
init: () ->
super.init()
@ -188,7 +200,7 @@ this.OS.register "ColorPickerDialog", ColorPickerDialog
class InfoDialog extends BasicDialog
constructor: () ->
super "InfoDialog", InfoDialog.scheme
super "InfoDialog"
init: () ->
super.init()
@ -226,7 +238,7 @@ this.OS.register "InfoDialog", InfoDialog
class YesNoDialog extends BasicDialog
constructor: () ->
super "YesNoDialog", YesNoDialog.scheme
super "YesNoDialog"
init: () ->
super.init()
@ -262,7 +274,7 @@ this.OS.register "YesNoDialog", YesNoDialog
class SelectionDialog extends BasicDialog
constructor: () ->
super "SelectionDialog", SelectionDialog.scheme
super "SelectionDialog"
init: () ->
super.init()
@ -302,8 +314,7 @@ this.OS.register "SelectionDialog", SelectionDialog
class AboutDialog extends BasicDialog
constructor: () ->
super "AboutDialog", AboutDialog.scheme
super "AboutDialog"
init: () ->
mt = @meta()
@scheme.set "apptitle", __("About: {0}", mt.name)
@ -348,7 +359,7 @@ this.OS.register "AboutDialog", AboutDialog
class FileDialog extends BasicDialog
constructor: () ->
super "FileDialog", FileDialog.scheme
super "FileDialog"
init: () ->
super.init()

View File

@ -113,7 +113,7 @@ class BaseModel
@publish "warning", m
error: (m, e) ->
@publish "error", m, if e then e else (@_api.throwe @name)
@publish "error", m, if e then e else (@_api.throwe m)
fail: (m) ->
@publish "fail", m

View File

@ -391,6 +391,17 @@ Ant.OS.API =
err = e
return "" if not err
return err
setClipboard: (v) ->
$el = $("#clipboard")
$el.val v
$el[0].select()
$el[0].setSelectionRange(0, 99999)
document.execCommand("copy")
getClipboard: () ->
$("#clipboard").val()
# utilities functioncs
switcher: () ->
o = {}

View File

@ -41,32 +41,32 @@ Ant.OS or=
pidalloc: 0
processes: {}
createProcess: (app, cls, args) ->
f = () ->
#if it is single ton
# and a process is existing
# just return it
if cls.singleton and Ant.OS.PM.processes[app] and Ant.OS.PM.processes[app].length == 1
Ant.OS.PM.processes[app][0].show()
new Promise (resolve, reject) ->
f = () ->
#if it is single ton
# and a process is existing
# just return it
if cls.singleton and Ant.OS.PM.processes[app] and Ant.OS.PM.processes[app].length == 1
obj = Ant.OS.PM.processes[app][0]
obj.show()
else
Ant.OS.PM.processes[app] = [] if not Ant.OS.PM.processes[app]
obj = new cls(args)
obj.birth = (new Date).getTime()
Ant.OS.PM.pidalloc++
obj.pid = Ant.OS.PM.pidalloc
Ant.OS.PM.processes[app].push obj
if cls.type is 1 then Ant.OS.GUI.dock obj, cls.meta else Ant.OS.GUI.attachservice obj
obj
if cls.dependencies
libs = (v for v in cls.dependencies)
Ant.OS.API.require libs
.then () ->
resolve f()
.catch (e) ->
reject e
else
Ant.OS.PM.processes[app] = [] if not Ant.OS.PM.processes[app]
obj = new cls(args)
obj.birth = (new Date).getTime()
Ant.OS.PM.pidalloc++
obj.pid = Ant.OS.PM.pidalloc
Ant.OS.PM.processes[app].push obj
if cls.type is 1 then Ant.OS.GUI.dock obj, cls.meta else Ant.OS.GUI.attachservice obj
if cls.type is 2
Ant.OS.announcer.trigger "srvroutineready", app
if cls.dependencies
libs = (v for v in cls.dependencies)
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()
resolve f()
appByPid: (pid) ->
app = undefined
find = (l) ->

View File

@ -53,11 +53,19 @@ Ant.OS.GUI =
.attr "href", path
pushServices: (srvs) ->
return unless srvs.length > 0
Ant.OS.announcer.observable.one "srvroutineready", () ->
srvs.splice 0, 1
Ant.OS.GUI.pushServices srvs
Ant.OS.GUI.pushService srvs[0]
new Promise (resolve, reject) ->
return resolve() unless srvs.length > 0
srv = srvs.splice(0, 1)[0]
Ant.OS.GUI.pushService srv
.then (d) ->
Ant.OS.GUI.pushServices srvs
.then () -> resolve()
.catch (e) -> reject e
.catch (e) ->
Ant.OS.announcer.osfail __("Unable to load: {0}", srv), e
Ant.OS.GUI.pushServices srvs
.then () -> resolve()
.catch (e) -> reject e
openDialog: (d, data) ->
new Promise (resolve, reject) ->
@ -76,16 +84,23 @@ Ant.OS.GUI =
Ant.OS.GUI.dialog.init()
pushService: (ph) ->
arr = ph.split "/"
srv = arr[1]
app = arr[0]
return Ant.OS.PM.createProcess srv, Ant.OS.APP[srv] if Ant.OS.APP[srv]
Ant.OS.GUI.loadApp app
.then (a) ->
return Ant.OS.PM.createProcess srv, Ant.OS.APP[srv] if Ant.OS.APP[srv]
.catch (e) ->
Ant.OS.announcer.trigger "srvroutineready", srv
Ant.OS.announcer.osfail __("Cannot read service script: {0}", srv), e
new Promise (resolve, reject) ->
arr = ph.split "/"
srv = arr[1]
app = arr[0]
if Ant.OS.APP[srv]
Ant.OS.PM.createProcess srv, Ant.OS.APP[srv]
.then (d) -> resolve d
.catch (e) -> reject e
else
Ant.OS.GUI.loadApp app
.then (a) ->
if not Ant.OS.APP[srv]
return reject Ant.OS.API.throwe __("Service not found: {0}", ph)
Ant.OS.PM.createProcess srv, Ant.OS.APP[srv]
.then (d) -> resolve d
.catch (e) -> reject e
.catch (e) -> reject e
appsByMime: (mime) ->
metas = ( v for k, v of Ant.OS.setting.system.packages when v and v.app )
@ -165,12 +180,18 @@ Ant.OS.GUI =
if not Ant.OS.APP[app]
# first load it
Ant.OS.GUI.loadApp(app).then (a) ->
console.log "apploaded"
Ant.OS.PM.createProcess a, Ant.OS.APP[a], args
.catch (e) ->
console.log e
Ant.OS.announcer.osfail __("Unable to launch: {0}", app), e
else
# now launch it
if Ant.OS.APP[app]
Ant.OS.PM.createProcess app, Ant.OS.APP[app], args
.catch (e)->
console.log e
Ant.OS.announcer.osfail __("Unable to launch: {0}", app), e
dock: (app, meta) ->
# dock an application to a dock
# create a data object
@ -473,6 +494,7 @@ Ant.OS.GUI.schemes.ws = """
</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>
<textarea id="clipboard"></textarea>
"""
Ant.OS.GUI.schemes.login = """

View File

@ -43,8 +43,8 @@
Ant.OS.setting.system = conf.system if conf.system
Ant.OS.setting.system.startup = {
services: [
"CoreServices/PushNotification",
"CoreServices/Calendar"
"Syslog/PushNotification",
"Syslog/Calendar"
],
apps: []
} if not Ant.OS.setting.system.startup

View File

@ -32,6 +32,7 @@ class SystemPanelTag extends Ant.OS.GUI.BaseTag
@toggle false
# launch the app or open the file
Ant.OS.GUI.openWith data
@refs.applist.unselect()
search: (e) ->
switch e.which

View File

@ -100,7 +100,7 @@ class WindowTag extends Ant.OS.GUI.BaseTag
$(@refs["grip"]).hide()
__apptitle__: (value) ->
$(@refs["dragger"]).text value.__() if value
@refs["txtTitle"].set "text", value if value
enable_dragging: () ->
$(@refs["dragger"])
@ -190,7 +190,9 @@ class WindowTag extends Ant.OS.GUI.BaseTag
{ el: "li", class: "afx-window-close", ref: "closebt" },
{ el: "li", class: "afx-window-minimize", ref: "minbt" },
{ el: "li", class: "afx-window-maximize", ref: "maxbt" },
{ el: "li", class: "afx-window-title", ref: "dragger" }
{ el: "li", class: "afx-window-title", ref: "dragger", children: [{
el: "afx-label", ref: "txtTitle"
}] }
]
},
{ el: "div", class: "afx-clear" },

View File

@ -51,6 +51,10 @@ class BaseFileHandle
@basename = @genealogy[@genealogy.length - 1] unless @isRoot()
@ext = @basename.split( "." ).pop() unless @basename.lastIndexOf(".") is 0 or @basename.indexOf( "." ) is -1
filename: () ->
return "Untitled" unless @basename
@basename
setCache: (v) ->
@cache = v
@