From 9008396ac99d9fc5768275d0907a32dc659bd387 Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Wed, 20 May 2020 23:11:58 +0200 Subject: [PATCH] core services renamed to syslog --- Makefile | 2 +- src/core/BaseDialog.coffee | 43 ++++--- src/core/BaseModel.coffee | 2 +- src/core/api.coffee | 11 ++ src/core/core.coffee | 50 ++++----- src/core/gui.coffee | 54 ++++++--- src/core/settings.coffee | 4 +- src/core/tags/SystemPanelTag.coffee | 1 + src/core/tags/WindowTag.coffee | 6 +- src/core/vfs.coffee | 4 + .../CodePad/coffees/BaseExtension.coffee | 7 +- .../CodePad/coffees/extensions/AntOSDK.coffee | 62 ++++++----- src/packages/CodePad/coffees/main.coffee | 22 +++- src/packages/CoreServices/Makefile | 11 -- src/packages/Files/main.coffee | 46 ++++++-- src/packages/MarketPlace/main.coffee | 20 ++-- .../{CoreServices => Syslog}/Calendar.coffee | 0 src/packages/Syslog/Makefile | 11 ++ .../PushNotification.coffee | 88 ++------------- src/packages/Syslog/Syslog.coffee | 105 ++++++++++++++++++ .../{CoreServices => Syslog}/main.css | 33 +++++- .../{CoreServices => Syslog}/package.json | 11 +- src/packages/Syslog/scheme.html | 21 ++++ src/themes/antos_dark/afx-file-view.css | 12 +- src/themes/antos_dark/antos.css | 8 ++ src/themes/antos_light/afx-file-view.css | 13 ++- src/themes/antos_light/antos.css | 7 ++ src/themes/system/antos.css | 8 ++ 28 files changed, 436 insertions(+), 226 deletions(-) delete mode 100644 src/packages/CoreServices/Makefile rename src/packages/{CoreServices => Syslog}/Calendar.coffee (100%) create mode 100644 src/packages/Syslog/Makefile rename src/packages/{CoreServices => Syslog}/PushNotification.coffee (63%) create mode 100644 src/packages/Syslog/Syslog.coffee rename src/packages/{CoreServices => Syslog}/main.css (61%) rename src/packages/{CoreServices => Syslog}/package.json (62%) create mode 100644 src/packages/Syslog/scheme.html diff --git a/Makefile b/Makefile index c36eca3..590bd3d 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ coffees= src/core/core.coffee \ src/core/tags/SystemPanelTag.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 - cp src/index.html $(BUILDDIR)/ diff --git a/src/core/BaseDialog.coffee b/src/core/BaseDialog.coffee index e30ac20..bd742d8 100644 --- a/src/core/BaseDialog.coffee +++ b/src/core/BaseDialog.coffee @@ -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 = """ @@ -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() diff --git a/src/core/BaseModel.coffee b/src/core/BaseModel.coffee index c7bb899..9bce597 100644 --- a/src/core/BaseModel.coffee +++ b/src/core/BaseModel.coffee @@ -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 diff --git a/src/core/api.coffee b/src/core/api.coffee index 0c73baa..c712eb7 100644 --- a/src/core/api.coffee +++ b/src/core/api.coffee @@ -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 = {} diff --git a/src/core/core.coffee b/src/core/core.coffee index bd3be92..14efa15 100644 --- a/src/core/core.coffee +++ b/src/core/core.coffee @@ -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) -> diff --git a/src/core/gui.coffee b/src/core/gui.coffee index ce5b063..52ced63 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -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 = """ + """ Ant.OS.GUI.schemes.login = """ diff --git a/src/core/settings.coffee b/src/core/settings.coffee index ac9bb55..4c7d4b1 100644 --- a/src/core/settings.coffee +++ b/src/core/settings.coffee @@ -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 diff --git a/src/core/tags/SystemPanelTag.coffee b/src/core/tags/SystemPanelTag.coffee index c64621a..c60237a 100644 --- a/src/core/tags/SystemPanelTag.coffee +++ b/src/core/tags/SystemPanelTag.coffee @@ -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 diff --git a/src/core/tags/WindowTag.coffee b/src/core/tags/WindowTag.coffee index e2f0195..5d68c3e 100644 --- a/src/core/tags/WindowTag.coffee +++ b/src/core/tags/WindowTag.coffee @@ -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" }, diff --git a/src/core/vfs.coffee b/src/core/vfs.coffee index 12c88ed..66fb74e 100644 --- a/src/core/vfs.coffee +++ b/src/core/vfs.coffee @@ -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 @ diff --git a/src/packages/CodePad/coffees/BaseExtension.coffee b/src/packages/CodePad/coffees/BaseExtension.coffee index 45e8270..111cec5 100644 --- a/src/packages/CodePad/coffees/BaseExtension.coffee +++ b/src/packages/CodePad/coffees/BaseExtension.coffee @@ -14,8 +14,8 @@ class CodePad.BaseExtension notify: (m) -> @app.notify m - error: (m) -> - @app.error m + error: (m, e) -> + @app.error m, e dependencies: () -> [] @@ -87,6 +87,7 @@ class CodePad.BaseExtension path = (list.splice 0, 1)[0].asFileHandle() path.parent().mk path.basename .then (d) => + @app.trigger "filechange", { file: path.parent(), type: "dir" } @mkdirAll list .then () -> resolve() .catch (e) -> reject e @@ -101,9 +102,11 @@ class CodePad.BaseExtension .read() .then (data) => file = item[1].asFileHandle() + file .setCache(data.format name, "#{path}/#{name}") .write "text/plain" .then () => + @app.trigger "filechange", { file: file, type: "file" } @mkfileAll list, path, name .then () -> resolve() .catch (e) -> reject e diff --git a/src/packages/CodePad/coffees/extensions/AntOSDK.coffee b/src/packages/CodePad/coffees/extensions/AntOSDK.coffee index b4163ad..2a253f2 100644 --- a/src/packages/CodePad/coffees/extensions/AntOSDK.coffee +++ b/src/packages/CodePad/coffees/extensions/AntOSDK.coffee @@ -47,9 +47,6 @@ class App.extensions.AntOSDK extends App.BaseExtension mktpl: (path, name, flag) -> rpath = "#{path}/#{name}" dirs = [ - "#{rpath}/build", - "#{rpath}/build/release", - "#{rpath}/build/debug", "#{rpath}/javascripts", "#{rpath}/css", "#{rpath}/coffees", @@ -102,33 +99,40 @@ class App.extensions.AntOSDK extends App.BaseExtension .catch (e) -> reject e build: (meta) -> + dirs = [ + "#{meta.root}/build", + "#{meta.root}/build/debug", + "#{meta.root}/build/release" + ] new Promise (resolve, reject) => - @compile(meta).then (src) => - @cat ("#{meta.root}/#{v}" for v in meta.javascripts), src - .then (jsrc) -> - new Promise (r, e) -> - "#{meta.root}/build/debug/main.js" - .asFileHandle() - .setCache jsrc - .write("text/plain") - .then (d) -> - r() - .catch (ex) -> e ex - .then () => - new Promise (r, e) => - @cat ("#{meta.root}/#{v}" for v in meta.css), "" - .then (txt) -> - return r() if txt is "" - "#{meta.root}/build/debug/main.css" - .asFileHandle() - .setCache txt - .write("text/plain") - .then (d) -> - r() - .catch (ex) -> e ex - .then () => - @copy ("#{meta.root}/#{v}" for v in meta.copies), "#{meta.root}/build/debug" - .then () -> resolve() + @mkdirAll(dirs).then => + @compile(meta).then (src) => + @cat ("#{meta.root}/#{v}" for v in meta.javascripts), src + .then (jsrc) -> + new Promise (r, e) -> + "#{meta.root}/build/debug/main.js" + .asFileHandle() + .setCache jsrc + .write("text/plain") + .then (d) -> + r() + .catch (ex) -> e ex + .then () => + new Promise (r, e) => + @cat ("#{meta.root}/#{v}" for v in meta.css), "" + .then (txt) -> + return r() if txt is "" + "#{meta.root}/build/debug/main.css" + .asFileHandle() + .setCache txt + .write("text/plain") + .then (d) -> + r() + .catch (ex) -> e ex + .then () => + @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 diff --git a/src/packages/CodePad/coffees/main.coffee b/src/packages/CodePad/coffees/main.coffee index bafda64..37a0fdc 100644 --- a/src/packages/CodePad/coffees/main.coffee +++ b/src/packages/CodePad/coffees/main.coffee @@ -27,6 +27,7 @@ class CodePad extends this.OS.GUI.BaseApplication dir.read().then (d) -> return reject d.error if d.error resolve d.result + .catch (e) -> reject e @setup() setup: () -> @@ -38,6 +39,8 @@ class CodePad extends this.OS.GUI.BaseApplication enableSnippets: true, enableLiveAutocompletion: true, highlightActiveLine: true, + highlightSelectedWord: true, + behavioursEnabled: true, wrap: true, fontSize: "11pt" } @@ -72,11 +75,13 @@ class CodePad extends this.OS.GUI.BaseApplication @editor.focus() return false @fileview.set "onfileopen", (e) => + return unless e.data and e.data.path return if e.data.type is "dir" @openFile e.data.path.asFileHandle() @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() 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 .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() @initCommandPalete() @initSideBar() @@ -178,16 +189,17 @@ class CodePad extends this.OS.GUI.BaseApplication m = @modes.getModeForPath(file.path) file.langmode = { caption: m.caption, mode: m.mode } else - file.langmode = { caption: "Text", mode: "ace/mode/text" } + file.langmode = { caption: "Text", mode: "ace/mode/text" } @editormux = true + @editor.getSession().setUndoManager new ace.UndoManager() @editor.setValue file.cache, -1 - @editor.session.setMode file.langmode.mode - @editor.session.setUndoManager file.um + @editor.getSession().setMode file.langmode.mode if file.cursor @editor.renderer.scrollCursorIntoView { row: file.cursor.row, column: file.cursor.column }, 0.5 @editor.selection.moveTo file.cursor.row, file.cursor.column + @editor.getSession().setUndoManager file.um @updateStatus() @editor.focus() @@ -423,7 +435,7 @@ class CodePad extends this.OS.GUI.BaseApplication evt.preventDefault() @.openDialog("YesNoDialog", { 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) => if d v.dirty = false for v in dirties diff --git a/src/packages/CoreServices/Makefile b/src/packages/CoreServices/Makefile deleted file mode 100644 index 22f2a64..0000000 --- a/src/packages/CoreServices/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -coffee_files = Calendar.coffee PushNotification.coffee - -jsfiles = - -cssfiles = main.css - -copyfiles = package.json - - -PKG_NAME=CoreServices -include ../pkg.mk \ No newline at end of file diff --git a/src/packages/Files/main.coffee b/src/packages/Files/main.coffee index 128c483..d9ff926 100644 --- a/src/packages/Files/main.coffee +++ b/src/packages/Files/main.coffee @@ -36,15 +36,22 @@ class Files extends this.OS.GUI.BaseApplication @view.contextmenuHandle = (e, m) => file = @view.get "selectedFile" + return unless file 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 - v.args = [ file ] - apps.push v + for v in @_gui.appsByMime file.mime + v.args = [ file ] + apps.push v 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(), @mnEdit() ] @@ -83,33 +90,50 @@ class Files extends this.OS.GUI.BaseApplication resolve d.result .catch (e) -> reject e + @vfs_event_flag = true @view.set "ondragndrop", (e) => return unless e src = e.data.from.get("data") des = e.data.to.get("data") return if des.type is "file" file = src.path.asFileHandle() + # disable the vfs event on + # we update it manually + @vfs_event_flag = false file.move "#{des.path}/#{file.basename}" .then () => - @view.set "path", @view.get("path") - @view.update file.parent().path - @view.update des.path - .catch (e) => @error __("Unable to move: {0} -> {1}", src.path, des.path), e + if @view.get("view") is "icon" + @view.set "path", @view.get("path") + else + @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.nav = true if @setting.nav is undefined @setting.showhidden = false if @setting.showhidden is undefined @applyAllSetting() + # VFS mount point and event mntpoints = @systemsetting.VFS.mountpoints el.selected = false for el, i in mntpoints @favo.set "data", mntpoints #@favo.set "selected", -1 @view.set "view", @setting.view if @setting.view @subscribe "VFS", (d) => + return unless @vfs_event_flag 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 + + # bind keyboard shortcut @bindKey "CTRL-F", () => @actionFile "#{@name}-mkf" @bindKey "CTRL-D", () => @actionFile "#{@name}-mkdir" @bindKey "CTRL-U", () => @actionFile "#{@name}-upload" diff --git a/src/packages/MarketPlace/main.coffee b/src/packages/MarketPlace/main.coffee index 3558adf..e11b773 100644 --- a/src/packages/MarketPlace/main.coffee +++ b/src/packages/MarketPlace/main.coffee @@ -50,7 +50,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication el = @applist.get "selectedItem" return unless el app = el.get("data") - @_gui.launch app.className if app.className + @_gui.launch app.pkgname if app.pkgname @btinstall.set "onbtclick", (e) => if @btinstall.get "dirty" @@ -108,7 +108,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication list = [] for k, v of pkgcache 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, text: v.name, icon: v.icon, @@ -140,14 +140,16 @@ class MarketPlace extends this.OS.GUI.BaseApplication d.description.asFileHandle().read().then (text) => converter = new showdown.Converter() ($ @appdesc).html(converter.makeHtml text) - .catch (e) => @notify __("Unable to read package description") + .catch (e) => + @notify __("Unable to read package description") + ($ @appdesc).empty() else ($ @appdesc).empty() pkgcache = @systemsetting.system.packages @btinstall.set "text", "__(Install)" @btinstall.set "dirty", false - if pkgcache[d.className] - vs = pkgcache[d.className].version + if pkgcache[d.pkgname] + vs = pkgcache[d.pkgname].version ovs = d.version ($ @btinstall).hide() if vs and ovs @@ -223,7 +225,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication .then (n) => @repo.unselect() @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 if idx >= 0 @applist.set "selected", idx @@ -249,7 +251,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication @mkdirs(dir).then () => @installFile(v.app, zip, files).then () => app_meta = { - className: v.app, + pkgname: v.app, name: v.name, text: v.name, icon: v.icon, @@ -281,8 +283,8 @@ class MarketPlace extends this.OS.GUI.BaseApplication return unless el sel = el.get "data" return unless sel - name = sel.className - app = @systemsetting.system.packages[sel.className] + name = sel.pkgname + app = @systemsetting.system.packages[sel.pkgname] return unless app @openDialog("YesNoDialog", { title: __("Uninstall") , diff --git a/src/packages/CoreServices/Calendar.coffee b/src/packages/Syslog/Calendar.coffee similarity index 100% rename from src/packages/CoreServices/Calendar.coffee rename to src/packages/Syslog/Calendar.coffee diff --git a/src/packages/Syslog/Makefile b/src/packages/Syslog/Makefile new file mode 100644 index 0000000..81d7457 --- /dev/null +++ b/src/packages/Syslog/Makefile @@ -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 \ No newline at end of file diff --git a/src/packages/CoreServices/PushNotification.coffee b/src/packages/Syslog/PushNotification.coffee similarity index 63% rename from src/packages/CoreServices/PushNotification.coffee rename to src/packages/Syslog/PushNotification.coffee index 44c22b0..9cef2de 100644 --- a/src/packages/CoreServices/PushNotification.coffee +++ b/src/packages/Syslog/PushNotification.coffee @@ -5,7 +5,7 @@ # 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 +# 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, @@ -15,74 +15,6 @@ # You should have received a copy of the GNU General Public License #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 = """ - - - - - -
-
-
-
-
- -
- - -
- -
- - - -""" class PushNotification extends this.OS.GUI.BaseService constructor: (args) -> @@ -91,6 +23,7 @@ class PushNotification extends this.OS.GUI.BaseService @cb = undefined @pending = [] @logs = [] + @logmon = undefined init: -> @view = false @_gui.htmlToScheme PushNotification.scheme, @, @host @@ -139,23 +72,26 @@ class PushNotification extends this.OS.GUI.BaseService .hide() showLogReport: () -> - @openDialog(new LogDialog(), { - logs: @logs - }) + @_gui.launch "Syslog" addLog: (s, o) -> logtime = new Date() - @logs.push { + log = { type: s, name: o.name, - text: "#{logtime}: #{o.data.m}", + text: "#{o.data.m}", id: o.id, icon: o.data.icon, iconclass: o.data.iconclass, 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) -> d = { diff --git a/src/packages/Syslog/Syslog.coffee b/src/packages/Syslog/Syslog.coffee new file mode 100644 index 0000000..7ac9035 --- /dev/null +++ b/src/packages/Syslog/Syslog.coffee @@ -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 \ No newline at end of file diff --git a/src/packages/CoreServices/main.css b/src/packages/Syslog/main.css similarity index 61% rename from src/packages/CoreServices/main.css rename to src/packages/Syslog/main.css index 73aa2a9..65ab4ca 100644 --- a/src/packages/CoreServices/main.css +++ b/src/packages/Syslog/main.css @@ -49,13 +49,38 @@ afx-list-view[data-id = "notifeed"] li{ 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; } -afx-app-window[data-id ='LogDialog'] pre { - padding: 10px; +afx-app-window[data-id ='Syslog'] .afx-bug-list-item-error { + 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%; } \ No newline at end of file diff --git a/src/packages/CoreServices/package.json b/src/packages/Syslog/package.json similarity index 62% rename from src/packages/CoreServices/package.json rename to src/packages/Syslog/package.json index 078e818..513f93b 100644 --- a/src/packages/CoreServices/package.json +++ b/src/packages/Syslog/package.json @@ -1,9 +1,9 @@ { - "app":null, - "className": "CoreServices", + "app":"Syslog", + "pkgname": "Syslog", "services": [ "Calendar", "PushNotification" ], - "name": "Core services", - "description":"This is the core services", + "name": "System log", + "description":"Core services and system log", "info":{ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com", @@ -12,5 +12,6 @@ }, "version":"0.0.1-a", "category":"System", - "mimes":["*"] + "iconclass": "fa fa-bug", + "mimes":[] } \ No newline at end of file diff --git a/src/packages/Syslog/scheme.html b/src/packages/Syslog/scheme.html new file mode 100644 index 0000000..0162f38 --- /dev/null +++ b/src/packages/Syslog/scheme.html @@ -0,0 +1,21 @@ + + + + + +
+
+
+
+ + + + +
+ +
+ + + \ No newline at end of file diff --git a/src/themes/antos_dark/afx-file-view.css b/src/themes/antos_dark/afx-file-view.css index 00ced86..d2b7ba3 100644 --- a/src/themes/antos_dark/afx-file-view.css +++ b/src/themes/antos_dark/afx-file-view.css @@ -11,7 +11,6 @@ afx-file-view afx-list-view > div.list-container > ul li{ height: 60px; background-color: transparent; text-align: center; - padding:3px; margin-right: 5px; margin-bottom: 5px; } @@ -27,9 +26,8 @@ afx-file-view afx-list-view i.dir:before{ font-style: normal; } afx-file-view afx-list-view i{ - width: 32px; - height: 32px; - margin-left: 19px; + width: 100%; + margin-left: 3px; } @@ -42,7 +40,11 @@ afx-file-view afx-list-view i.file:before{ 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; color:white; border-radius: 6px; diff --git a/src/themes/antos_dark/antos.css b/src/themes/antos_dark/antos.css index 6eca082..8512130 100644 --- a/src/themes/antos_dark/antos.css +++ b/src/themes/antos_dark/antos.css @@ -66,4 +66,12 @@ input { box-sizing: border-box; font-family: "Ubuntu"; font-size: 13px; +} + +textarea { + color: white; + background-color: #464646; + outline: none; + border: 1px solid #262626; + box-sizing: border-box; } \ No newline at end of file diff --git a/src/themes/antos_light/afx-file-view.css b/src/themes/antos_light/afx-file-view.css index 87122c4..51706a6 100644 --- a/src/themes/antos_light/afx-file-view.css +++ b/src/themes/antos_light/afx-file-view.css @@ -10,7 +10,6 @@ afx-file-view afx-list-view > div.list-container > ul li{ height: 60px; background-color: transparent; text-align: center; - padding:3px; margin-right: 5px; margin-bottom: 5px; } @@ -26,9 +25,8 @@ afx-file-view afx-list-view i.dir:before{ font-style: normal; } afx-file-view afx-list-view i{ - width: 32px; - height: 32px; - margin-left: 19px; + width: 100%; + margin-left: 3px; } @@ -40,8 +38,11 @@ afx-file-view afx-list-view i.file:before{ font-style: 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; color:white; border-radius: 6px; diff --git a/src/themes/antos_light/antos.css b/src/themes/antos_light/antos.css index 2c55038..3e9f397 100644 --- a/src/themes/antos_light/antos.css +++ b/src/themes/antos_light/antos.css @@ -66,4 +66,11 @@ input { box-sizing: border-box; font-family: "Ubuntu"; font-size: 13px; +} +textarea { + color: #414339; + background-color: #f6F6F6; + outline: none; + border: 1px solid #a6a6a6; + box-sizing: border-box; } \ No newline at end of file diff --git a/src/themes/system/antos.css b/src/themes/system/antos.css index fb69477..7bf1571 100644 --- a/src/themes/system/antos.css +++ b/src/themes/system/antos.css @@ -121,4 +121,12 @@ body padding:3px; color:chocolate; font-weight: normal; +} + +#clipboard { + position: absolute; + left: -9999px; + width: 1px; + height: 1px; + box-sizing: border-box; } \ No newline at end of file