mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 17:58:22 +01:00
core services renamed to syslog
This commit is contained in:
parent
33eab1d30a
commit
9008396ac9
2
Makefile
2
Makefile
@ -49,7 +49,7 @@ coffees= src/core/core.coffee \
|
|||||||
src/core/tags/SystemPanelTag.coffee \
|
src/core/tags/SystemPanelTag.coffee \
|
||||||
src/antos.coffee
|
src/antos.coffee
|
||||||
|
|
||||||
packages = CoreServices Files Setting CodePad MarketPlace
|
packages = Syslog Files Setting CodePad MarketPlace
|
||||||
|
|
||||||
main: initd build_coffees build_themes libs build_packages languages
|
main: initd build_coffees build_themes libs build_packages languages
|
||||||
- cp src/index.html $(BUILDDIR)/
|
- cp src/index.html $(BUILDDIR)/
|
||||||
|
@ -36,7 +36,7 @@ class SubWindow extends this.OS.GUI.BaseModel
|
|||||||
|
|
||||||
show: () ->
|
show: () ->
|
||||||
@trigger 'focus'
|
@trigger 'focus'
|
||||||
($ @scheme).css "z-index", window._zindex + 2
|
($ @scheme).css "z-index", Ant.OS.GUI.zindex + 2
|
||||||
hide: () ->
|
hide: () ->
|
||||||
@trigger 'hide'
|
@trigger 'hide'
|
||||||
|
|
||||||
@ -56,10 +56,14 @@ this.OS.GUI.BaseDialog = BaseDialog
|
|||||||
class BasicDialog extends BaseDialog
|
class BasicDialog extends BaseDialog
|
||||||
constructor: ( name, target) ->
|
constructor: ( name, target) ->
|
||||||
super name
|
super name
|
||||||
if typeof target is "string"
|
if target
|
||||||
Ant.OS.GUI.htmlToScheme target, @, @host
|
if typeof target is "string"
|
||||||
else # a file handle
|
Ant.OS.GUI.htmlToScheme target, @, @host
|
||||||
@render target.path
|
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: () ->
|
init: () ->
|
||||||
@scheme.set "apptitle", @data.title if @data and @data.title
|
@scheme.set "apptitle", @data.title if @data and @data.title
|
||||||
@ -70,20 +74,28 @@ this.OS.GUI.BasicDialog = BasicDialog
|
|||||||
|
|
||||||
class PromptDialog extends BasicDialog
|
class PromptDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "PromptDialog", PromptDialog.scheme
|
super "PromptDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
|
$input = $(@find "txtInput")
|
||||||
@find("lbl").set "text", @data.label if @data and @data.label
|
@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) =>
|
(@find "btnOk").set "onbtclick", (e) =>
|
||||||
@handle($(@find "txtInput").val()) if @handle
|
@handle($input.val()) if @handle
|
||||||
@quit()
|
@quit()
|
||||||
|
|
||||||
(@find "btnCancel").set "onbtclick", (e) =>
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
@quit()
|
@quit()
|
||||||
|
|
||||||
|
$input.keyup (e) =>
|
||||||
|
return unless e.which is 13
|
||||||
|
@handle($input.val()) if @handle
|
||||||
|
@quit()
|
||||||
|
|
||||||
|
$input.focus()
|
||||||
|
|
||||||
|
|
||||||
PromptDialog.scheme = """
|
PromptDialog.scheme = """
|
||||||
<afx-app-window width='200' height='150' apptitle = "Prompt">
|
<afx-app-window width='200' height='150' apptitle = "Prompt">
|
||||||
@ -110,7 +122,7 @@ this.OS.register "PromptDialog", PromptDialog
|
|||||||
|
|
||||||
class CalendarDialog extends BasicDialog
|
class CalendarDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "CalendarDialog", CalendarDialog.scheme
|
super "CalendarDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
@ -149,7 +161,7 @@ this.OS.register "CalendarDialog", CalendarDialog
|
|||||||
|
|
||||||
class ColorPickerDialog extends BasicDialog
|
class ColorPickerDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "ColorPickerDialog", ColorPickerDialog.scheme
|
super "ColorPickerDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
@ -188,7 +200,7 @@ this.OS.register "ColorPickerDialog", ColorPickerDialog
|
|||||||
|
|
||||||
class InfoDialog extends BasicDialog
|
class InfoDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "InfoDialog", InfoDialog.scheme
|
super "InfoDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
@ -226,7 +238,7 @@ this.OS.register "InfoDialog", InfoDialog
|
|||||||
|
|
||||||
class YesNoDialog extends BasicDialog
|
class YesNoDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "YesNoDialog", YesNoDialog.scheme
|
super "YesNoDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
@ -262,7 +274,7 @@ this.OS.register "YesNoDialog", YesNoDialog
|
|||||||
|
|
||||||
class SelectionDialog extends BasicDialog
|
class SelectionDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "SelectionDialog", SelectionDialog.scheme
|
super "SelectionDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
@ -302,8 +314,7 @@ this.OS.register "SelectionDialog", SelectionDialog
|
|||||||
|
|
||||||
class AboutDialog extends BasicDialog
|
class AboutDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "AboutDialog", AboutDialog.scheme
|
super "AboutDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
mt = @meta()
|
mt = @meta()
|
||||||
@scheme.set "apptitle", __("About: {0}", mt.name)
|
@scheme.set "apptitle", __("About: {0}", mt.name)
|
||||||
@ -348,7 +359,7 @@ this.OS.register "AboutDialog", AboutDialog
|
|||||||
|
|
||||||
class FileDialog extends BasicDialog
|
class FileDialog extends BasicDialog
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super "FileDialog", FileDialog.scheme
|
super "FileDialog"
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
|
@ -113,7 +113,7 @@ class BaseModel
|
|||||||
@publish "warning", m
|
@publish "warning", m
|
||||||
|
|
||||||
error: (m, e) ->
|
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) ->
|
fail: (m) ->
|
||||||
@publish "fail", m
|
@publish "fail", m
|
||||||
|
@ -391,6 +391,17 @@ Ant.OS.API =
|
|||||||
err = e
|
err = e
|
||||||
return "" if not err
|
return "" if not err
|
||||||
return 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
|
# utilities functioncs
|
||||||
switcher: () ->
|
switcher: () ->
|
||||||
o = {}
|
o = {}
|
||||||
|
@ -41,32 +41,32 @@ Ant.OS or=
|
|||||||
pidalloc: 0
|
pidalloc: 0
|
||||||
processes: {}
|
processes: {}
|
||||||
createProcess: (app, cls, args) ->
|
createProcess: (app, cls, args) ->
|
||||||
f = () ->
|
new Promise (resolve, reject) ->
|
||||||
#if it is single ton
|
f = () ->
|
||||||
# and a process is existing
|
#if it is single ton
|
||||||
# just return it
|
# and a process is existing
|
||||||
if cls.singleton and Ant.OS.PM.processes[app] and Ant.OS.PM.processes[app].length == 1
|
# just return it
|
||||||
Ant.OS.PM.processes[app][0].show()
|
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
|
else
|
||||||
Ant.OS.PM.processes[app] = [] if not Ant.OS.PM.processes[app]
|
resolve f()
|
||||||
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()
|
|
||||||
appByPid: (pid) ->
|
appByPid: (pid) ->
|
||||||
app = undefined
|
app = undefined
|
||||||
find = (l) ->
|
find = (l) ->
|
||||||
|
@ -53,11 +53,19 @@ Ant.OS.GUI =
|
|||||||
.attr "href", path
|
.attr "href", path
|
||||||
|
|
||||||
pushServices: (srvs) ->
|
pushServices: (srvs) ->
|
||||||
return unless srvs.length > 0
|
new Promise (resolve, reject) ->
|
||||||
Ant.OS.announcer.observable.one "srvroutineready", () ->
|
return resolve() unless srvs.length > 0
|
||||||
srvs.splice 0, 1
|
srv = srvs.splice(0, 1)[0]
|
||||||
Ant.OS.GUI.pushServices srvs
|
Ant.OS.GUI.pushService srv
|
||||||
Ant.OS.GUI.pushService srvs[0]
|
.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) ->
|
openDialog: (d, data) ->
|
||||||
new Promise (resolve, reject) ->
|
new Promise (resolve, reject) ->
|
||||||
@ -76,16 +84,23 @@ Ant.OS.GUI =
|
|||||||
Ant.OS.GUI.dialog.init()
|
Ant.OS.GUI.dialog.init()
|
||||||
|
|
||||||
pushService: (ph) ->
|
pushService: (ph) ->
|
||||||
arr = ph.split "/"
|
new Promise (resolve, reject) ->
|
||||||
srv = arr[1]
|
arr = ph.split "/"
|
||||||
app = arr[0]
|
srv = arr[1]
|
||||||
return Ant.OS.PM.createProcess srv, Ant.OS.APP[srv] if Ant.OS.APP[srv]
|
app = arr[0]
|
||||||
Ant.OS.GUI.loadApp app
|
if Ant.OS.APP[srv]
|
||||||
.then (a) ->
|
Ant.OS.PM.createProcess srv, Ant.OS.APP[srv]
|
||||||
return Ant.OS.PM.createProcess srv, Ant.OS.APP[srv] if Ant.OS.APP[srv]
|
.then (d) -> resolve d
|
||||||
.catch (e) ->
|
.catch (e) -> reject e
|
||||||
Ant.OS.announcer.trigger "srvroutineready", srv
|
else
|
||||||
Ant.OS.announcer.osfail __("Cannot read service script: {0}", srv), e
|
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) ->
|
appsByMime: (mime) ->
|
||||||
metas = ( v for k, v of Ant.OS.setting.system.packages when v and v.app )
|
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]
|
if not Ant.OS.APP[app]
|
||||||
# first load it
|
# first load it
|
||||||
Ant.OS.GUI.loadApp(app).then (a) ->
|
Ant.OS.GUI.loadApp(app).then (a) ->
|
||||||
|
console.log "apploaded"
|
||||||
Ant.OS.PM.createProcess a, Ant.OS.APP[a], args
|
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
|
else
|
||||||
# now launch it
|
# now launch it
|
||||||
if Ant.OS.APP[app]
|
if Ant.OS.APP[app]
|
||||||
Ant.OS.PM.createProcess app, Ant.OS.APP[app], args
|
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: (app, meta) ->
|
||||||
# dock an application to a dock
|
# dock an application to a dock
|
||||||
# create a data object
|
# create a data object
|
||||||
@ -473,6 +494,7 @@ Ant.OS.GUI.schemes.ws = """
|
|||||||
</div>
|
</div>
|
||||||
<afx-menu id="contextmenu" data-id="contextmenu" context="true" style="display:none;"></afx-menu>
|
<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>
|
<afx-label id="systooltip" data-id="systooltip" style="display:none;position:absolute;"></afx-label>
|
||||||
|
<textarea id="clipboard"></textarea>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Ant.OS.GUI.schemes.login = """
|
Ant.OS.GUI.schemes.login = """
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
Ant.OS.setting.system = conf.system if conf.system
|
Ant.OS.setting.system = conf.system if conf.system
|
||||||
Ant.OS.setting.system.startup = {
|
Ant.OS.setting.system.startup = {
|
||||||
services: [
|
services: [
|
||||||
"CoreServices/PushNotification",
|
"Syslog/PushNotification",
|
||||||
"CoreServices/Calendar"
|
"Syslog/Calendar"
|
||||||
],
|
],
|
||||||
apps: []
|
apps: []
|
||||||
} if not Ant.OS.setting.system.startup
|
} if not Ant.OS.setting.system.startup
|
||||||
|
@ -32,6 +32,7 @@ class SystemPanelTag extends Ant.OS.GUI.BaseTag
|
|||||||
@toggle false
|
@toggle false
|
||||||
# launch the app or open the file
|
# launch the app or open the file
|
||||||
Ant.OS.GUI.openWith data
|
Ant.OS.GUI.openWith data
|
||||||
|
@refs.applist.unselect()
|
||||||
|
|
||||||
search: (e) ->
|
search: (e) ->
|
||||||
switch e.which
|
switch e.which
|
||||||
|
@ -100,7 +100,7 @@ class WindowTag extends Ant.OS.GUI.BaseTag
|
|||||||
$(@refs["grip"]).hide()
|
$(@refs["grip"]).hide()
|
||||||
|
|
||||||
__apptitle__: (value) ->
|
__apptitle__: (value) ->
|
||||||
$(@refs["dragger"]).text value.__() if value
|
@refs["txtTitle"].set "text", value if value
|
||||||
|
|
||||||
enable_dragging: () ->
|
enable_dragging: () ->
|
||||||
$(@refs["dragger"])
|
$(@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-close", ref: "closebt" },
|
||||||
{ el: "li", class: "afx-window-minimize", ref: "minbt" },
|
{ el: "li", class: "afx-window-minimize", ref: "minbt" },
|
||||||
{ el: "li", class: "afx-window-maximize", ref: "maxbt" },
|
{ 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" },
|
{ el: "div", class: "afx-clear" },
|
||||||
|
@ -51,6 +51,10 @@ class BaseFileHandle
|
|||||||
@basename = @genealogy[@genealogy.length - 1] unless @isRoot()
|
@basename = @genealogy[@genealogy.length - 1] unless @isRoot()
|
||||||
@ext = @basename.split( "." ).pop() unless @basename.lastIndexOf(".") is 0 or @basename.indexOf( "." ) is -1
|
@ext = @basename.split( "." ).pop() unless @basename.lastIndexOf(".") is 0 or @basename.indexOf( "." ) is -1
|
||||||
|
|
||||||
|
filename: () ->
|
||||||
|
return "Untitled" unless @basename
|
||||||
|
@basename
|
||||||
|
|
||||||
setCache: (v) ->
|
setCache: (v) ->
|
||||||
@cache = v
|
@cache = v
|
||||||
@
|
@
|
||||||
|
@ -14,8 +14,8 @@ class CodePad.BaseExtension
|
|||||||
notify: (m) ->
|
notify: (m) ->
|
||||||
@app.notify m
|
@app.notify m
|
||||||
|
|
||||||
error: (m) ->
|
error: (m, e) ->
|
||||||
@app.error m
|
@app.error m, e
|
||||||
|
|
||||||
dependencies: () ->
|
dependencies: () ->
|
||||||
[]
|
[]
|
||||||
@ -87,6 +87,7 @@ class CodePad.BaseExtension
|
|||||||
path = (list.splice 0, 1)[0].asFileHandle()
|
path = (list.splice 0, 1)[0].asFileHandle()
|
||||||
path.parent().mk path.basename
|
path.parent().mk path.basename
|
||||||
.then (d) =>
|
.then (d) =>
|
||||||
|
@app.trigger "filechange", { file: path.parent(), type: "dir" }
|
||||||
@mkdirAll list
|
@mkdirAll list
|
||||||
.then () -> resolve()
|
.then () -> resolve()
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
@ -101,9 +102,11 @@ class CodePad.BaseExtension
|
|||||||
.read()
|
.read()
|
||||||
.then (data) =>
|
.then (data) =>
|
||||||
file = item[1].asFileHandle()
|
file = item[1].asFileHandle()
|
||||||
|
file
|
||||||
.setCache(data.format name, "#{path}/#{name}")
|
.setCache(data.format name, "#{path}/#{name}")
|
||||||
.write "text/plain"
|
.write "text/plain"
|
||||||
.then () =>
|
.then () =>
|
||||||
|
@app.trigger "filechange", { file: file, type: "file" }
|
||||||
@mkfileAll list, path, name
|
@mkfileAll list, path, name
|
||||||
.then () -> resolve()
|
.then () -> resolve()
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
@ -47,9 +47,6 @@ class App.extensions.AntOSDK extends App.BaseExtension
|
|||||||
mktpl: (path, name, flag) ->
|
mktpl: (path, name, flag) ->
|
||||||
rpath = "#{path}/#{name}"
|
rpath = "#{path}/#{name}"
|
||||||
dirs = [
|
dirs = [
|
||||||
"#{rpath}/build",
|
|
||||||
"#{rpath}/build/release",
|
|
||||||
"#{rpath}/build/debug",
|
|
||||||
"#{rpath}/javascripts",
|
"#{rpath}/javascripts",
|
||||||
"#{rpath}/css",
|
"#{rpath}/css",
|
||||||
"#{rpath}/coffees",
|
"#{rpath}/coffees",
|
||||||
@ -102,33 +99,40 @@ class App.extensions.AntOSDK extends App.BaseExtension
|
|||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
build: (meta) ->
|
build: (meta) ->
|
||||||
|
dirs = [
|
||||||
|
"#{meta.root}/build",
|
||||||
|
"#{meta.root}/build/debug",
|
||||||
|
"#{meta.root}/build/release"
|
||||||
|
]
|
||||||
new Promise (resolve, reject) =>
|
new Promise (resolve, reject) =>
|
||||||
@compile(meta).then (src) =>
|
@mkdirAll(dirs).then =>
|
||||||
@cat ("#{meta.root}/#{v}" for v in meta.javascripts), src
|
@compile(meta).then (src) =>
|
||||||
.then (jsrc) ->
|
@cat ("#{meta.root}/#{v}" for v in meta.javascripts), src
|
||||||
new Promise (r, e) ->
|
.then (jsrc) ->
|
||||||
"#{meta.root}/build/debug/main.js"
|
new Promise (r, e) ->
|
||||||
.asFileHandle()
|
"#{meta.root}/build/debug/main.js"
|
||||||
.setCache jsrc
|
.asFileHandle()
|
||||||
.write("text/plain")
|
.setCache jsrc
|
||||||
.then (d) ->
|
.write("text/plain")
|
||||||
r()
|
.then (d) ->
|
||||||
.catch (ex) -> e ex
|
r()
|
||||||
.then () =>
|
.catch (ex) -> e ex
|
||||||
new Promise (r, e) =>
|
.then () =>
|
||||||
@cat ("#{meta.root}/#{v}" for v in meta.css), ""
|
new Promise (r, e) =>
|
||||||
.then (txt) ->
|
@cat ("#{meta.root}/#{v}" for v in meta.css), ""
|
||||||
return r() if txt is ""
|
.then (txt) ->
|
||||||
"#{meta.root}/build/debug/main.css"
|
return r() if txt is ""
|
||||||
.asFileHandle()
|
"#{meta.root}/build/debug/main.css"
|
||||||
.setCache txt
|
.asFileHandle()
|
||||||
.write("text/plain")
|
.setCache txt
|
||||||
.then (d) ->
|
.write("text/plain")
|
||||||
r()
|
.then (d) ->
|
||||||
.catch (ex) -> e ex
|
r()
|
||||||
.then () =>
|
.catch (ex) -> e ex
|
||||||
@copy ("#{meta.root}/#{v}" for v in meta.copies), "#{meta.root}/build/debug"
|
.then () =>
|
||||||
.then () -> resolve()
|
@copy ("#{meta.root}/#{v}" for v in meta.copies), "#{meta.root}/build/debug"
|
||||||
|
.then () -> resolve()
|
||||||
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
dir.read().then (d) ->
|
dir.read().then (d) ->
|
||||||
return reject d.error if d.error
|
return reject d.error if d.error
|
||||||
resolve d.result
|
resolve d.result
|
||||||
|
.catch (e) -> reject e
|
||||||
@setup()
|
@setup()
|
||||||
|
|
||||||
setup: () ->
|
setup: () ->
|
||||||
@ -38,6 +39,8 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
enableSnippets: true,
|
enableSnippets: true,
|
||||||
enableLiveAutocompletion: true,
|
enableLiveAutocompletion: true,
|
||||||
highlightActiveLine: true,
|
highlightActiveLine: true,
|
||||||
|
highlightSelectedWord: true,
|
||||||
|
behavioursEnabled: true,
|
||||||
wrap: true,
|
wrap: true,
|
||||||
fontSize: "11pt"
|
fontSize: "11pt"
|
||||||
}
|
}
|
||||||
@ -72,11 +75,13 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
@editor.focus()
|
@editor.focus()
|
||||||
return false
|
return false
|
||||||
@fileview.set "onfileopen", (e) =>
|
@fileview.set "onfileopen", (e) =>
|
||||||
|
return unless e.data and e.data.path
|
||||||
return if e.data.type is "dir"
|
return if e.data.type is "dir"
|
||||||
@openFile e.data.path.asFileHandle()
|
@openFile e.data.path.asFileHandle()
|
||||||
|
|
||||||
@fileview.set "onfileselect", (e) =>
|
@fileview.set "onfileselect", (e) =>
|
||||||
return unless e.data or e.data.type is "dir"
|
return unless e.data and e.data.path
|
||||||
|
return if e.data.type is "dir"
|
||||||
i = @findTabByFile e.data.path.asFileHandle()
|
i = @findTabByFile e.data.path.asFileHandle()
|
||||||
return @tabbar.set "selected", i if i isnt -1
|
return @tabbar.set "selected", i if i isnt -1
|
||||||
|
|
||||||
@ -118,6 +123,12 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
e.data.from.get("parent").update src.parent().path
|
e.data.from.get("parent").update src.parent().path
|
||||||
.catch (e) => @error __("Unable to move file/folder"), e
|
.catch (e) => @error __("Unable to move file/folder"), e
|
||||||
|
|
||||||
|
@on "filechange", (data) =>
|
||||||
|
path = data.file.path
|
||||||
|
path = data.file.parent().path if data.type is "file"
|
||||||
|
@fileview.update path
|
||||||
|
|
||||||
|
|
||||||
@loadExtensionMetaData()
|
@loadExtensionMetaData()
|
||||||
@initCommandPalete()
|
@initCommandPalete()
|
||||||
@initSideBar()
|
@initSideBar()
|
||||||
@ -178,16 +189,17 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
m = @modes.getModeForPath(file.path)
|
m = @modes.getModeForPath(file.path)
|
||||||
file.langmode = { caption: m.caption, mode: m.mode }
|
file.langmode = { caption: m.caption, mode: m.mode }
|
||||||
else
|
else
|
||||||
file.langmode = { caption: "Text", mode: "ace/mode/text" }
|
file.langmode = { caption: "Text", mode: "ace/mode/text" }
|
||||||
@editormux = true
|
@editormux = true
|
||||||
|
@editor.getSession().setUndoManager new ace.UndoManager()
|
||||||
@editor.setValue file.cache, -1
|
@editor.setValue file.cache, -1
|
||||||
@editor.session.setMode file.langmode.mode
|
@editor.getSession().setMode file.langmode.mode
|
||||||
@editor.session.setUndoManager file.um
|
|
||||||
if file.cursor
|
if file.cursor
|
||||||
@editor.renderer.scrollCursorIntoView {
|
@editor.renderer.scrollCursorIntoView {
|
||||||
row: file.cursor.row, column: file.cursor.column
|
row: file.cursor.row, column: file.cursor.column
|
||||||
}, 0.5
|
}, 0.5
|
||||||
@editor.selection.moveTo file.cursor.row, file.cursor.column
|
@editor.selection.moveTo file.cursor.row, file.cursor.column
|
||||||
|
@editor.getSession().setUndoManager file.um
|
||||||
@updateStatus()
|
@updateStatus()
|
||||||
@editor.focus()
|
@editor.focus()
|
||||||
|
|
||||||
@ -423,7 +435,7 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
@.openDialog("YesNoDialog", {
|
@.openDialog("YesNoDialog", {
|
||||||
title: "__(Quit)",
|
title: "__(Quit)",
|
||||||
text: __("Ignore all {0} unsaved files ?", dirties.length)
|
text: __("Ignore all unsaved files: {0} ?", (v.filename() for v in dirties).join ", " )
|
||||||
}).then (d) =>
|
}).then (d) =>
|
||||||
if d
|
if d
|
||||||
v.dirty = false for v in dirties
|
v.dirty = false for v in dirties
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
coffee_files = Calendar.coffee PushNotification.coffee
|
|
||||||
|
|
||||||
jsfiles =
|
|
||||||
|
|
||||||
cssfiles = main.css
|
|
||||||
|
|
||||||
copyfiles = package.json
|
|
||||||
|
|
||||||
|
|
||||||
PKG_NAME=CoreServices
|
|
||||||
include ../pkg.mk
|
|
@ -36,15 +36,22 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
|
|
||||||
@view.contextmenuHandle = (e, m) =>
|
@view.contextmenuHandle = (e, m) =>
|
||||||
file = @view.get "selectedFile"
|
file = @view.get "selectedFile"
|
||||||
|
return unless file
|
||||||
apps = []
|
apps = []
|
||||||
if file and file.mime
|
file.mime = "dir" if file.type is "dir"
|
||||||
file.mime = "dir" if file.type is "dir"
|
|
||||||
|
|
||||||
for v in @_gui.appsByMime file.mime
|
for v in @_gui.appsByMime file.mime
|
||||||
v.args = [ file ]
|
v.args = [ file ]
|
||||||
apps.push v
|
apps.push v
|
||||||
m.set "items", [
|
m.set "items", [
|
||||||
{ text: "__(Open with)", dataid: "#{@name}-open", child: apps },
|
{
|
||||||
|
text: "__(Open with)",
|
||||||
|
child: apps,
|
||||||
|
onchildselect: (e) =>
|
||||||
|
return unless e
|
||||||
|
it = e.data.item.get("data")
|
||||||
|
@_gui.launch it.app, [file]
|
||||||
|
},
|
||||||
@mnFile(),
|
@mnFile(),
|
||||||
@mnEdit()
|
@mnEdit()
|
||||||
]
|
]
|
||||||
@ -83,33 +90,50 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
resolve d.result
|
resolve d.result
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
|
@vfs_event_flag = true
|
||||||
@view.set "ondragndrop", (e) =>
|
@view.set "ondragndrop", (e) =>
|
||||||
return unless e
|
return unless e
|
||||||
src = e.data.from.get("data")
|
src = e.data.from.get("data")
|
||||||
des = e.data.to.get("data")
|
des = e.data.to.get("data")
|
||||||
return if des.type is "file"
|
return if des.type is "file"
|
||||||
file = src.path.asFileHandle()
|
file = src.path.asFileHandle()
|
||||||
|
# disable the vfs event on
|
||||||
|
# we update it manually
|
||||||
|
@vfs_event_flag = false
|
||||||
file.move "#{des.path}/#{file.basename}"
|
file.move "#{des.path}/#{file.basename}"
|
||||||
.then () =>
|
.then () =>
|
||||||
@view.set "path", @view.get("path")
|
if @view.get("view") is "icon"
|
||||||
@view.update file.parent().path
|
@view.set "path", @view.get("path")
|
||||||
@view.update des.path
|
else
|
||||||
.catch (e) => @error __("Unable to move: {0} -> {1}", src.path, des.path), e
|
@view.update file.parent().path
|
||||||
|
@view.update des.path
|
||||||
|
#reenable the vfs event
|
||||||
|
@vfs_event_flag = true
|
||||||
|
.catch (e) =>
|
||||||
|
# reenable the vfs event
|
||||||
|
@vfs_event_flag = true
|
||||||
|
@error __("Unable to move: {0} -> {1}", src.path, des.path), e
|
||||||
|
|
||||||
|
# application setting
|
||||||
@setting.sidebar = true if @setting.sidebar is undefined
|
@setting.sidebar = true if @setting.sidebar is undefined
|
||||||
@setting.nav = true if @setting.nav is undefined
|
@setting.nav = true if @setting.nav is undefined
|
||||||
@setting.showhidden = false if @setting.showhidden is undefined
|
@setting.showhidden = false if @setting.showhidden is undefined
|
||||||
@applyAllSetting()
|
@applyAllSetting()
|
||||||
|
|
||||||
|
# VFS mount point and event
|
||||||
mntpoints = @systemsetting.VFS.mountpoints
|
mntpoints = @systemsetting.VFS.mountpoints
|
||||||
el.selected = false for el, i in mntpoints
|
el.selected = false for el, i in mntpoints
|
||||||
@favo.set "data", mntpoints
|
@favo.set "data", mntpoints
|
||||||
#@favo.set "selected", -1
|
#@favo.set "selected", -1
|
||||||
@view.set "view", @setting.view if @setting.view
|
@view.set "view", @setting.view if @setting.view
|
||||||
@subscribe "VFS", (d) =>
|
@subscribe "VFS", (d) =>
|
||||||
|
return unless @vfs_event_flag
|
||||||
return if ["read", "publish", "download"].includes d.data.m
|
return if ["read", "publish", "download"].includes d.data.m
|
||||||
if d.data.file.hash() is @currdir.hash() or d.data.file.parent().hash() is @currdir.hash()
|
if (d.data.file.hash() is @currdir.hash() or
|
||||||
|
d.data.file.parent().hash() is @currdir.hash())
|
||||||
@view.set "path", @currdir
|
@view.set "path", @currdir
|
||||||
|
|
||||||
|
# bind keyboard shortcut
|
||||||
@bindKey "CTRL-F", () => @actionFile "#{@name}-mkf"
|
@bindKey "CTRL-F", () => @actionFile "#{@name}-mkf"
|
||||||
@bindKey "CTRL-D", () => @actionFile "#{@name}-mkdir"
|
@bindKey "CTRL-D", () => @actionFile "#{@name}-mkdir"
|
||||||
@bindKey "CTRL-U", () => @actionFile "#{@name}-upload"
|
@bindKey "CTRL-U", () => @actionFile "#{@name}-upload"
|
||||||
|
@ -50,7 +50,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
|||||||
el = @applist.get "selectedItem"
|
el = @applist.get "selectedItem"
|
||||||
return unless el
|
return unless el
|
||||||
app = el.get("data")
|
app = el.get("data")
|
||||||
@_gui.launch app.className if app.className
|
@_gui.launch app.pkgname if app.pkgname
|
||||||
|
|
||||||
@btinstall.set "onbtclick", (e) =>
|
@btinstall.set "onbtclick", (e) =>
|
||||||
if @btinstall.get "dirty"
|
if @btinstall.get "dirty"
|
||||||
@ -108,7 +108,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
|||||||
list = []
|
list = []
|
||||||
for k, v of pkgcache
|
for k, v of pkgcache
|
||||||
list.push {
|
list.push {
|
||||||
className: if v.app then v.app else v.className,
|
pkgname: if v.pkgname then v.pkgname else v.app,
|
||||||
name: v.name,
|
name: v.name,
|
||||||
text: v.name,
|
text: v.name,
|
||||||
icon: v.icon,
|
icon: v.icon,
|
||||||
@ -140,14 +140,16 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
|||||||
d.description.asFileHandle().read().then (text) =>
|
d.description.asFileHandle().read().then (text) =>
|
||||||
converter = new showdown.Converter()
|
converter = new showdown.Converter()
|
||||||
($ @appdesc).html(converter.makeHtml text)
|
($ @appdesc).html(converter.makeHtml text)
|
||||||
.catch (e) => @notify __("Unable to read package description")
|
.catch (e) =>
|
||||||
|
@notify __("Unable to read package description")
|
||||||
|
($ @appdesc).empty()
|
||||||
else
|
else
|
||||||
($ @appdesc).empty()
|
($ @appdesc).empty()
|
||||||
pkgcache = @systemsetting.system.packages
|
pkgcache = @systemsetting.system.packages
|
||||||
@btinstall.set "text", "__(Install)"
|
@btinstall.set "text", "__(Install)"
|
||||||
@btinstall.set "dirty", false
|
@btinstall.set "dirty", false
|
||||||
if pkgcache[d.className]
|
if pkgcache[d.pkgname]
|
||||||
vs = pkgcache[d.className].version
|
vs = pkgcache[d.pkgname].version
|
||||||
ovs = d.version
|
ovs = d.version
|
||||||
($ @btinstall).hide()
|
($ @btinstall).hide()
|
||||||
if vs and ovs
|
if vs and ovs
|
||||||
@ -223,7 +225,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
|||||||
.then (n) =>
|
.then (n) =>
|
||||||
@repo.unselect()
|
@repo.unselect()
|
||||||
@repo.set "selected", 0
|
@repo.set "selected", 0
|
||||||
apps = (v.className for v in @applist.get("data"))
|
apps = (v.pkgname for v in @applist.get("data"))
|
||||||
idx = apps.indexOf n
|
idx = apps.indexOf n
|
||||||
if idx >= 0
|
if idx >= 0
|
||||||
@applist.set "selected", idx
|
@applist.set "selected", idx
|
||||||
@ -249,7 +251,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
|||||||
@mkdirs(dir).then () =>
|
@mkdirs(dir).then () =>
|
||||||
@installFile(v.app, zip, files).then () =>
|
@installFile(v.app, zip, files).then () =>
|
||||||
app_meta = {
|
app_meta = {
|
||||||
className: v.app,
|
pkgname: v.app,
|
||||||
name: v.name,
|
name: v.name,
|
||||||
text: v.name,
|
text: v.name,
|
||||||
icon: v.icon,
|
icon: v.icon,
|
||||||
@ -281,8 +283,8 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
|||||||
return unless el
|
return unless el
|
||||||
sel = el.get "data"
|
sel = el.get "data"
|
||||||
return unless sel
|
return unless sel
|
||||||
name = sel.className
|
name = sel.pkgname
|
||||||
app = @systemsetting.system.packages[sel.className]
|
app = @systemsetting.system.packages[sel.pkgname]
|
||||||
return unless app
|
return unless app
|
||||||
@openDialog("YesNoDialog", {
|
@openDialog("YesNoDialog", {
|
||||||
title: __("Uninstall") ,
|
title: __("Uninstall") ,
|
||||||
|
11
src/packages/Syslog/Makefile
Normal file
11
src/packages/Syslog/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
coffee_files = Calendar.coffee PushNotification.coffee Syslog.coffee
|
||||||
|
|
||||||
|
jsfiles =
|
||||||
|
|
||||||
|
cssfiles = main.css
|
||||||
|
|
||||||
|
copyfiles = package.json scheme.html
|
||||||
|
|
||||||
|
|
||||||
|
PKG_NAME=Syslog
|
||||||
|
include ../pkg.mk
|
@ -15,74 +15,6 @@
|
|||||||
|
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
#along with this program. If not, see https://www.gnu.org/licenses/.
|
#along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
Ant = this
|
|
||||||
class LogDialog extends this.OS.GUI.BasicDialog
|
|
||||||
constructor: () ->
|
|
||||||
super "LogDialog", LogDialog.scheme
|
|
||||||
|
|
||||||
init: () ->
|
|
||||||
@loglist = @find "loglist"
|
|
||||||
@logdetail = @find "logdetail"
|
|
||||||
@loglist.set "data", @data.logs if @data and @data.logs
|
|
||||||
$(@find("txturi")).val Ant.OS.setting.system.error_report
|
|
||||||
@loglist.set "onlistselect", (e) =>
|
|
||||||
data = e.data.item.get("data") if e and e.data
|
|
||||||
return unless data
|
|
||||||
stacktrace = "None"
|
|
||||||
stacktrace = data.error.stack if data.error
|
|
||||||
$(@logdetail).text LogDialog.template.format(
|
|
||||||
data.text,
|
|
||||||
data.type,
|
|
||||||
data.time,
|
|
||||||
data.name,
|
|
||||||
data.id,
|
|
||||||
stacktrace
|
|
||||||
)
|
|
||||||
@find("btnreport").set "onbtclick", (e) =>
|
|
||||||
uri = $(@find("txturi")).val()
|
|
||||||
return if uri is ""
|
|
||||||
el = @loglist.get "selectedItem"
|
|
||||||
return unless el
|
|
||||||
data = el.get("data")
|
|
||||||
return unless data
|
|
||||||
Ant.OS.API.post uri, data
|
|
||||||
.then (d) =>
|
|
||||||
@notify __("Error reported")
|
|
||||||
.catch (e) =>
|
|
||||||
@notify __("Unable to report error: {0}", e.toString())
|
|
||||||
|
|
||||||
LogDialog.template = """
|
|
||||||
{0}
|
|
||||||
Log type: {1}
|
|
||||||
Log time: {2}
|
|
||||||
Process: {3} ({4})
|
|
||||||
detail:
|
|
||||||
|
|
||||||
{5}
|
|
||||||
"""
|
|
||||||
LogDialog.scheme = """
|
|
||||||
<afx-app-window data-id="LogDialog" width='500' height='350' apptitle = "__(System error log)" >
|
|
||||||
<afx-hbox>
|
|
||||||
<afx-list-view data-id = "loglist" data-width="200"> </afx-list-view>
|
|
||||||
<afx-resizer data-width = "2" />
|
|
||||||
<afx-vbox>
|
|
||||||
<div data-height="10" />
|
|
||||||
<div data-id = "container">
|
|
||||||
<pre><code data-id="logdetail"></code></pre>
|
|
||||||
</div>
|
|
||||||
<div data-height="10" />
|
|
||||||
<afx-hbox style="text-align:right;" data-height = "27">
|
|
||||||
<div data-width="5" />
|
|
||||||
<input type = "text" data-id = "txturi" />
|
|
||||||
<afx-button data-width ="80" text = "__(Report)"
|
|
||||||
iconclass = "fa fa-bug" data-id = "btnreport" />
|
|
||||||
<div data-width="10" />
|
|
||||||
</afx-hbox>
|
|
||||||
<div data-height="10" />
|
|
||||||
</afx-vbox>
|
|
||||||
</afx-hbox>
|
|
||||||
</afx-app-window>
|
|
||||||
"""
|
|
||||||
|
|
||||||
class PushNotification extends this.OS.GUI.BaseService
|
class PushNotification extends this.OS.GUI.BaseService
|
||||||
constructor: (args) ->
|
constructor: (args) ->
|
||||||
@ -91,6 +23,7 @@ class PushNotification extends this.OS.GUI.BaseService
|
|||||||
@cb = undefined
|
@cb = undefined
|
||||||
@pending = []
|
@pending = []
|
||||||
@logs = []
|
@logs = []
|
||||||
|
@logmon = undefined
|
||||||
init: ->
|
init: ->
|
||||||
@view = false
|
@view = false
|
||||||
@_gui.htmlToScheme PushNotification.scheme, @, @host
|
@_gui.htmlToScheme PushNotification.scheme, @, @host
|
||||||
@ -139,23 +72,26 @@ class PushNotification extends this.OS.GUI.BaseService
|
|||||||
.hide()
|
.hide()
|
||||||
|
|
||||||
showLogReport: () ->
|
showLogReport: () ->
|
||||||
@openDialog(new LogDialog(), {
|
@_gui.launch "Syslog"
|
||||||
logs: @logs
|
|
||||||
})
|
|
||||||
|
|
||||||
addLog: (s, o) ->
|
addLog: (s, o) ->
|
||||||
logtime = new Date()
|
logtime = new Date()
|
||||||
@logs.push {
|
log = {
|
||||||
type: s,
|
type: s,
|
||||||
name: o.name,
|
name: o.name,
|
||||||
text: "#{logtime}: #{o.data.m}",
|
text: "#{o.data.m}",
|
||||||
id: o.id,
|
id: o.id,
|
||||||
icon: o.data.icon,
|
icon: o.data.icon,
|
||||||
iconclass: o.data.iconclass,
|
iconclass: o.data.iconclass,
|
||||||
error: o.data.e,
|
error: o.data.e,
|
||||||
time: logtime
|
time: logtime,
|
||||||
|
closable: true,
|
||||||
|
tag: "afx-bug-list-item"
|
||||||
}
|
}
|
||||||
@dialog.loglist.set "data", @dialog.data.logs if @dialog
|
if @logmon
|
||||||
|
@logmon.addLog log
|
||||||
|
else
|
||||||
|
@logs.push log
|
||||||
|
|
||||||
pushout: (s, o) ->
|
pushout: (s, o) ->
|
||||||
d = {
|
d = {
|
105
src/packages/Syslog/Syslog.coffee
Normal file
105
src/packages/Syslog/Syslog.coffee
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
Ant = this
|
||||||
|
|
||||||
|
class BugListItemTag extends Ant.OS.GUI.tag["afx-list-item-proto"]
|
||||||
|
constructor: (r, o) ->
|
||||||
|
super r, o
|
||||||
|
|
||||||
|
__data__: (v) ->
|
||||||
|
return unless v
|
||||||
|
@refs.error.set "text", v.text
|
||||||
|
@refs.time.set "text", v.time
|
||||||
|
@refs.error.set "icon", v.icon if v.icon
|
||||||
|
if not v.icon
|
||||||
|
@refs.error.set "iconclass", if v.iconclass then v.iconclass else "fa fa-bug"
|
||||||
|
@set "closable", v.closable
|
||||||
|
|
||||||
|
__selected: (v) ->
|
||||||
|
@get("data").selected = v
|
||||||
|
|
||||||
|
|
||||||
|
itemlayout: () ->
|
||||||
|
{ el: "div", children: [
|
||||||
|
{ el: "afx-label", ref: "error", class: "afx-bug-list-item-error" },
|
||||||
|
{ el: "afx-label", ref: "time", class: "afx-bug-list-item-time" }
|
||||||
|
|
||||||
|
] }
|
||||||
|
|
||||||
|
|
||||||
|
Ant.OS.GUI.define "afx-bug-list-item", BugListItemTag
|
||||||
|
|
||||||
|
class Syslog extends this.OS.GUI.BaseApplication
|
||||||
|
constructor: (args) ->
|
||||||
|
super "Syslog", args
|
||||||
|
|
||||||
|
main: () ->
|
||||||
|
@loglist = @find "loglist"
|
||||||
|
@logdetail = @find "logdetail"
|
||||||
|
|
||||||
|
@_gui.pushService "Syslog/PushNotification"
|
||||||
|
.then (srv) =>
|
||||||
|
@srv = srv
|
||||||
|
@loglist.set "data", @srv.logs if @srv and @srv.logs
|
||||||
|
@srv.logmon = @
|
||||||
|
.catch (e) =>
|
||||||
|
@error __("Unable to load push notification service"), e
|
||||||
|
@quit()
|
||||||
|
|
||||||
|
$(@find("txturi")).val Ant.OS.setting.system.error_report
|
||||||
|
@loglist.set "onlistselect", (e) =>
|
||||||
|
data = e.data.item.get("data") if e and e.data
|
||||||
|
return unless data
|
||||||
|
stacktrace = "None"
|
||||||
|
stacktrace = data.error.stack if data.error
|
||||||
|
$(@logdetail).text Syslog.template.format(
|
||||||
|
data.text,
|
||||||
|
data.type,
|
||||||
|
data.time,
|
||||||
|
data.name,
|
||||||
|
data.id,
|
||||||
|
stacktrace
|
||||||
|
)
|
||||||
|
@loglist.set "onitemclose", (e) =>
|
||||||
|
el = e.data.item if e and e.data
|
||||||
|
return true unless el
|
||||||
|
data = el.get "data"
|
||||||
|
console.log data
|
||||||
|
return true unless data.selected
|
||||||
|
$(@logdetail).text("")
|
||||||
|
return true
|
||||||
|
|
||||||
|
@find("btnreport").set "onbtclick", (e) =>
|
||||||
|
uri = $(@find("txturi")).val()
|
||||||
|
return if uri is ""
|
||||||
|
el = @loglist.get "selectedItem"
|
||||||
|
return unless el
|
||||||
|
data = el.get("data")
|
||||||
|
return unless data
|
||||||
|
Ant.OS.API.post uri, data
|
||||||
|
.then (d) =>
|
||||||
|
@notify __("Error reported")
|
||||||
|
.catch (e) =>
|
||||||
|
@notify __("Unable to report error: {0}", e.toString())
|
||||||
|
|
||||||
|
@find("btclean").set "onbtclick", (e) =>
|
||||||
|
return unless @srv
|
||||||
|
@srv.logs = []
|
||||||
|
@loglist.set "data", @srv.logs
|
||||||
|
$(@logdetail).text("")
|
||||||
|
|
||||||
|
addLog: (log) ->
|
||||||
|
@loglist.push log
|
||||||
|
|
||||||
|
cleanup: () ->
|
||||||
|
@srv.logmon = undefined if @srv
|
||||||
|
|
||||||
|
Syslog.template = """
|
||||||
|
{0}
|
||||||
|
Log type: {1}
|
||||||
|
Log time: {2}
|
||||||
|
Process: {3} ({4})
|
||||||
|
detail:
|
||||||
|
|
||||||
|
{5}
|
||||||
|
"""
|
||||||
|
Syslog.singleton = true
|
||||||
|
this.OS.register "Syslog", Syslog
|
@ -49,13 +49,38 @@ afx-list-view[data-id = "notifeed"] li{
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
afx-app-window[data-id ='LogDialog'] div[data-id ='container']{
|
afx-app-window[data-id ='Syslog'] div[data-id ='container']{
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
afx-app-window[data-id ='LogDialog'] pre {
|
afx-app-window[data-id ='Syslog'] .afx-bug-list-item-error {
|
||||||
padding: 10px;
|
display: block;
|
||||||
|
|
||||||
}
|
}
|
||||||
afx-app-window[data-id ='LogDialog'] input{
|
|
||||||
|
afx-app-window[data-id ='Syslog'] .afx-bug-list-item-error i::before {
|
||||||
|
color: chocolate;
|
||||||
|
}
|
||||||
|
afx-app-window[data-id ='Syslog'] .afx-bug-list-item-time{
|
||||||
|
display: block;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
afx-app-window[data-id ='Syslog'] .afx-bug-list-item-time i.label-text{
|
||||||
|
font-size: 10px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id ='Syslog'] afx-bug-list-item li.selected {
|
||||||
|
background-color: #116cd6;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
afx-app-window[data-id ='Syslog'] pre {
|
||||||
|
padding: 10px;
|
||||||
|
margin:0;
|
||||||
|
user-select: text;
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
afx-app-window[data-id ='Syslog'] input{
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"app":null,
|
"app":"Syslog",
|
||||||
"className": "CoreServices",
|
"pkgname": "Syslog",
|
||||||
"services": [ "Calendar", "PushNotification" ],
|
"services": [ "Calendar", "PushNotification" ],
|
||||||
"name": "Core services",
|
"name": "System log",
|
||||||
"description":"This is the core services",
|
"description":"Core services and system log",
|
||||||
"info":{
|
"info":{
|
||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "xsang.le@gmail.com",
|
"email": "xsang.le@gmail.com",
|
||||||
@ -12,5 +12,6 @@
|
|||||||
},
|
},
|
||||||
"version":"0.0.1-a",
|
"version":"0.0.1-a",
|
||||||
"category":"System",
|
"category":"System",
|
||||||
"mimes":["*"]
|
"iconclass": "fa fa-bug",
|
||||||
|
"mimes":[]
|
||||||
}
|
}
|
21
src/packages/Syslog/scheme.html
Normal file
21
src/packages/Syslog/scheme.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<afx-app-window data-id="Syslog" width='500' height='350' apptitle = "__(System error log)" >
|
||||||
|
<afx-hbox>
|
||||||
|
<afx-list-view data-id = "loglist" data-width="200"> </afx-list-view>
|
||||||
|
<afx-resizer data-width = "2" />
|
||||||
|
<afx-vbox>
|
||||||
|
<div data-id = "container">
|
||||||
|
<pre><code data-id="logdetail"></code></pre>
|
||||||
|
</div>
|
||||||
|
<div data-height="10" />
|
||||||
|
<afx-hbox style="text-align:right;" data-height = "27">
|
||||||
|
<afx-button data-width ="20"
|
||||||
|
tooltip = "ct:__(Clear all logs)" iconclass = "fa fa-trash-o" data-id = "btclean" />
|
||||||
|
<input type = "text" data-id = "txturi" />
|
||||||
|
<afx-button data-width ="80" text = "__(Report)"
|
||||||
|
iconclass = "fa fa-bug" data-id = "btnreport" />
|
||||||
|
<div data-width="10" />
|
||||||
|
</afx-hbox>
|
||||||
|
<div data-height="10" />
|
||||||
|
</afx-vbox>
|
||||||
|
</afx-hbox>
|
||||||
|
</afx-app-window>
|
@ -11,7 +11,6 @@ afx-file-view afx-list-view > div.list-container > ul li{
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding:3px;
|
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
@ -27,9 +26,8 @@ afx-file-view afx-list-view i.dir:before{
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
afx-file-view afx-list-view i{
|
afx-file-view afx-list-view i{
|
||||||
width: 32px;
|
width: 100%;
|
||||||
height: 32px;
|
margin-left: 3px;
|
||||||
margin-left: 19px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +40,11 @@ afx-file-view afx-list-view i.file:before{
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
afx-file-view afx-list-view > div.list-container > ul > afx-list-item > li.selected, afx-file-view afx-list-view div.list-container > ul li.selected i:before {
|
afx-file-view afx-list-view > div.list-container > ul > afx-list-item > li.selected
|
||||||
|
{
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
afx-file-view afx-list-view div.list-container > ul li.selected i.label-text {
|
||||||
background-color: #116cd6;
|
background-color: #116cd6;
|
||||||
color:white;
|
color:white;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
@ -67,3 +67,11 @@ input {
|
|||||||
font-family: "Ubuntu";
|
font-family: "Ubuntu";
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
color: white;
|
||||||
|
background-color: #464646;
|
||||||
|
outline: none;
|
||||||
|
border: 1px solid #262626;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
@ -10,7 +10,6 @@ afx-file-view afx-list-view > div.list-container > ul li{
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding:3px;
|
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
@ -26,9 +25,8 @@ afx-file-view afx-list-view i.dir:before{
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
afx-file-view afx-list-view i{
|
afx-file-view afx-list-view i{
|
||||||
width: 32px;
|
width: 100%;
|
||||||
height: 32px;
|
margin-left: 3px;
|
||||||
margin-left: 19px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -40,8 +38,11 @@ afx-file-view afx-list-view i.file:before{
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
afx-file-view afx-list-view > div.list-container > ul > afx-list-item > li.selected
|
||||||
afx-file-view afx-list-view > div.list-container > ul > afx-list-item > li.selected, afx-file-view afx-list-view div.list-container > ul li.selected i:before {
|
{
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
afx-file-view afx-list-view div.list-container > ul li.selected i.label-text {
|
||||||
background-color: #116cd6;
|
background-color: #116cd6;
|
||||||
color:white;
|
color:white;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
@ -67,3 +67,10 @@ input {
|
|||||||
font-family: "Ubuntu";
|
font-family: "Ubuntu";
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
textarea {
|
||||||
|
color: #414339;
|
||||||
|
background-color: #f6F6F6;
|
||||||
|
outline: none;
|
||||||
|
border: 1px solid #a6a6a6;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
@ -122,3 +122,11 @@ body
|
|||||||
color:chocolate;
|
color:chocolate;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#clipboard {
|
||||||
|
position: absolute;
|
||||||
|
left: -9999px;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user