diff --git a/OnlyOffice/README.md b/OnlyOffice/README.md index 760f61b..6436036 100644 --- a/OnlyOffice/README.md +++ b/OnlyOffice/README.md @@ -10,4 +10,5 @@ way to work with multiple documents at the same time. ![https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true) ## Change log +- v 0.1.1a: generate document key based on username, file path and modified time - v 0.1.1a: generate document key based on username and file path diff --git a/OnlyOffice/build/debug/README.md b/OnlyOffice/build/debug/README.md index 25788f9..6436036 100644 --- a/OnlyOffice/build/debug/README.md +++ b/OnlyOffice/build/debug/README.md @@ -5,8 +5,10 @@ It needs to connect to a working OnlyOffice document server. The application allows to open/edit commons document, presentation, and spreedsheet. Integrate OnlyOffice to an virtual window environment like AntOs allows an inconvenient -way to work with multiple document at the same time +way to work with multiple documents at the same time. +![https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true) ## Change log -- v 0.1.1a: generate document key based on username and file path \ No newline at end of file +- v 0.1.1a: generate document key based on username, file path and modified time +- v 0.1.1a: generate document key based on username and file path diff --git a/OnlyOffice/build/debug/main.js b/OnlyOffice/build/debug/main.js index ee246ce..c7cad48 100644 --- a/OnlyOffice/build/debug/main.js +++ b/OnlyOffice/build/debug/main.js @@ -1 +1 @@ -(function(){var e;(e=class extends this.OS.application.BaseApplication{constructor(e){super("OnlyOffice",e),this.eid="id"+Math.random().toString(36).replace(".","")}main(){if(this.currfile=void 0,this.args&&this.args.length>0&&(this.currfile=this.args[0].path.asFileHandle()),this.placeholder=this.find("editor-area"),this.placeholder.id=this.eid,this.find("btn-open-file").onbtclick=e=>this.openFile(),this.find("btn-new-doc").onbtclick=e=>this.create("word"),this.find("btn-new-cell").onbtclick=e=>this.create("sheet"),this.find("btn-new-slide").onbtclick=e=>this.create("slide"),this.currfile)return this.open()}create(e){var t;return t=void 0,"word"===e&&(t="docx"),"sheet"===e&&(t="xlsx"),"slide"===e&&(t="pptx"),t?this.openDialog("FileDialog",{title:__("Save file as"),type:"dir",file:("home://Untitled."+t).asFileHandle()}).then(e=>{var i,s;return i=`${e.file.path}/${e.name}`.asFileHandle(),(s=`${this.path()}/templates/model.${t}`.asFileHandle()).read("binary").then(e=>{var t;return t=new Blob([e],{type:s.info.mime}),i.cache=t,i.write(s.info.mime).then(e=>(i.cache=void 0,this.currfile=i,this.open())).catch(e=>this.error(e.toString(),e))}).catch(e=>this.error(e.toString(),e))}):this.error(__("Unkown file type"))}openFile(){return this.openDialog("FileDialog",{title:__("Open file"),type:"file",mimes:this.meta().mimes}).then((e,t)=>(this.currfile=e.file.path.asFileHandle(),this.open()))}editorReady(){return console.log($('iframe[name="frameEditor"]',this.scheme).contents())}open(){if(this.currfile)return this.exec("token",{file:this.currfile.path}).then(e=>e.error?this.error(e.error):(this.access_token=e.result,this.currfile.onready().then(e=>{var t;return t=(t=`${this.systemsetting.user.username}:${this.currfile.path}`).hash().toString(),this.scheme.apptitle=this.currfile.path,$(this.placeholder).empty(),this.editor&&this.editor.destroyEditor(),this.editor=new DocsAPI.DocEditor(this.eid,{events:{onAppReady:e=>this.editorReady(e),onRequestCreateNew:()=>this.newDocument(),onRequestSaveAs:e=>this.saveAs(e)},document:{fileType:this.currfile.ext,key:t,title:this.currfile.filename,url:this.currfile.getlink()+"?"+this.access_token},documentType:this.getDocType(this.currfile.ext),editorConfig:{user:{id:this.systemsetting.user.id.toString(),name:this.systemsetting.user.username},customization:{compactHeader:!1},callbackUrl:this.uapi("save")}})}))).catch(e=>this.error(e.toString(),e))}getDocType(e){return"doc,docx,epub,odt".split(",").includes(e)?"word":"csv,ods,xls,xlsx".split(",").includes(e)?"cell":"odp,ppt,pptx".split(",").includes(e)?"slide":"none"}saveAs(e){if(e.data.url)return e.data.url.asFileHandle(),this.openDialog("FileDialog",{title:__("Save file as"),type:"dir",file:("home://"+e.data.title).asFileHandle()}).then(t=>{var i;return i=`${t.file.path}/${t.name}`,this.exec("duplicate",{remote:e.data.url,as:i}).then(e=>e.error?this.error(e.error):(this.currfile=i.asFileHandle(),this.open())).catch(e=>this.error(e.toString(),e))})}newDocument(){return this.openDialog("SelectionDialog",{title:__("Create new"),data:[{text:__("Open a file"),iconclass:"fa fa-folder-open",type:"open"},{text:__("Document"),iconclass:"fa fa-file-word-o",type:"word"},{text:__("Spreadsheet"),iconclass:"fa fa-file-excel-o",type:"sheet"},{text:__("Presentation"),iconclass:"fa fa-file-powerpoint-o",type:"slide"}]}).then(e=>{switch(e.type){case"open":return this.openFile();default:return this.create(e.type)}})}uapi(e){return`${this._api.REST}/system/apigateway?ws=0&path=${this.path()}/api.lua&action=${e}&file=${this.currfile.path}&${this.access_token}`}exec(e,t){var i;return i={path:this.path()+"/api.lua",parameters:{action:e,args:t}},this.call(i)}cleanup(){return this.editor&&this.editor.destroyEditor(),this.editor=void 0}}).dependencies=["https://office.iohub.dev/web-apps/apps/api/documents/api.js"],this.OS.register("OnlyOffice",e),this.extensionParams={url:"https://office.iohub.dev/web-apps/"}}).call(this); \ No newline at end of file +(function(){var e;(e=class extends this.OS.application.BaseApplication{constructor(e){super("OnlyOffice",e),this.eid="id"+Math.random().toString(36).replace(".","")}main(){if(this.currfile=void 0,this.args&&this.args.length>0&&(this.currfile=this.args[0].path.asFileHandle()),this.placeholder=this.find("editor-area"),this.placeholder.id=this.eid,this.find("btn-open-file").onbtclick=e=>this.openFile(),this.find("btn-new-doc").onbtclick=e=>this.create("word"),this.find("btn-new-cell").onbtclick=e=>this.create("sheet"),this.find("btn-new-slide").onbtclick=e=>this.create("slide"),this.currfile)return this.open()}create(e){var t;return t=void 0,"word"===e&&(t="docx"),"sheet"===e&&(t="xlsx"),"slide"===e&&(t="pptx"),t?this.openDialog("FileDialog",{title:__("Save file as"),type:"dir",file:("home://Untitled."+t).asFileHandle()}).then(e=>{var i,s;return i=`${e.file.path}/${e.name}`.asFileHandle(),(s=`${this.path()}/templates/model.${t}`.asFileHandle()).read("binary").then(e=>{var t;return t=new Blob([e],{type:s.info.mime}),i.cache=t,i.write(s.info.mime).then(e=>(i.cache=void 0,this.currfile=i,this.open())).catch(e=>this.error(e.toString(),e))}).catch(e=>this.error(e.toString(),e))}):this.error(__("Unkown file type"))}openFile(){return this.openDialog("FileDialog",{title:__("Open file"),type:"file",mimes:this.meta().mimes}).then((e,t)=>(this.currfile=e.file.path.asFileHandle(),this.open()))}editorReady(){return console.log($('iframe[name="frameEditor"]',this.scheme).contents())}open(){if(this.currfile)return this.exec("token",{file:this.currfile.path}).then(e=>e.error?this.error(e.error):(this.access_token=e.result,this.currfile.onready().then(e=>{var t;return t=(t=`${this.systemsetting.user.username}:${this.currfile.path}:${e.mtime}`).hash().toString(),this.scheme.apptitle=this.currfile.path,$(this.placeholder).empty(),this.editor&&this.editor.destroyEditor(),this.editor=new DocsAPI.DocEditor(this.eid,{events:{onAppReady:e=>this.editorReady(e),onRequestCreateNew:()=>this.newDocument(),onRequestSaveAs:e=>this.saveAs(e)},document:{fileType:this.currfile.ext,key:t,title:this.currfile.filename,url:this.currfile.getlink()+"?"+this.access_token},documentType:this.getDocType(this.currfile.ext),editorConfig:{user:{id:this.systemsetting.user.id.toString(),name:this.systemsetting.user.username},customization:{compactHeader:!1},callbackUrl:this.uapi("save")}})}))).catch(e=>this.error(e.toString(),e))}getDocType(e){return"doc,docx,epub,odt".split(",").includes(e)?"word":"csv,ods,xls,xlsx".split(",").includes(e)?"cell":"odp,ppt,pptx".split(",").includes(e)?"slide":"none"}saveAs(e){if(e.data.url)return e.data.url.asFileHandle(),this.openDialog("FileDialog",{title:__("Save file as"),type:"dir",file:("home://"+e.data.title).asFileHandle()}).then(t=>{var i;return i=`${t.file.path}/${t.name}`,this.exec("duplicate",{remote:e.data.url,as:i}).then(e=>e.error?this.error(e.error):"none"!==this.getDocType(i.asFileHandle().ext)?(this.currfile=i.asFileHandle(),this.open()):void 0).catch(e=>this.error(e.toString(),e))})}newDocument(){return this.openDialog("SelectionDialog",{title:__("Create new"),data:[{text:__("Open a file"),iconclass:"fa fa-folder-open",type:"open"},{text:__("Document"),iconclass:"fa fa-file-word-o",type:"word"},{text:__("Spreadsheet"),iconclass:"fa fa-file-excel-o",type:"sheet"},{text:__("Presentation"),iconclass:"fa fa-file-powerpoint-o",type:"slide"}]}).then(e=>{switch(e.type){case"open":return this.openFile();default:return this.create(e.type)}})}uapi(e){return`${this._api.REST}/system/apigateway?ws=0&path=${this.path()}/api.lua&action=${e}&file=${this.currfile.path}&${this.access_token}`}exec(e,t){var i;return i={path:this.path()+"/api.lua",parameters:{action:e,args:t}},this.call(i)}cleanup(){return this.editor&&this.editor.destroyEditor(),this.editor=void 0}}).dependencies=["https://office.iohub.dev/web-apps/apps/api/documents/api.js"],this.OS.register("OnlyOffice",e),this.extensionParams={url:"https://office.iohub.dev/web-apps/"}}).call(this); \ No newline at end of file diff --git a/OnlyOffice/build/debug/package.json b/OnlyOffice/build/debug/package.json index 204cbd5..8281437 100644 --- a/OnlyOffice/build/debug/package.json +++ b/OnlyOffice/build/debug/package.json @@ -7,7 +7,7 @@ "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version":"0.1.1-a", + "version":"0.1.2-a", "category":"Other", "icon":"icon.png", "mimes":[ diff --git a/OnlyOffice/build/release/OnlyOffice.zip b/OnlyOffice/build/release/OnlyOffice.zip index 7ba76a6..b714bf4 100644 Binary files a/OnlyOffice/build/release/OnlyOffice.zip and b/OnlyOffice/build/release/OnlyOffice.zip differ diff --git a/OnlyOffice/coffees/main.coffee b/OnlyOffice/coffees/main.coffee index ef367b0..888ca41 100644 --- a/OnlyOffice/coffees/main.coffee +++ b/OnlyOffice/coffees/main.coffee @@ -79,8 +79,7 @@ class OnlyOffice extends this.OS.application.BaseApplication @access_token = d.result @currfile.onready() .then (meta) => - key = "#{@systemsetting.user.username}:#{@currfile.path}" - # :#{meta.mtime} + key = "#{@systemsetting.user.username}:#{@currfile.path}:#{meta.mtime}" key = key.hash().toString() @scheme.apptitle = @currfile.path $(@placeholder).empty() @@ -136,6 +135,7 @@ class OnlyOffice extends this.OS.application.BaseApplication as: file }).then (r) => return @error r.error if r.error + return if @getDocType(file.asFileHandle().ext) is "none" @currfile = file.asFileHandle() @open() .catch (e) => diff --git a/OnlyOffice/package.json b/OnlyOffice/package.json index 204cbd5..8281437 100644 --- a/OnlyOffice/package.json +++ b/OnlyOffice/package.json @@ -7,7 +7,7 @@ "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version":"0.1.1-a", + "version":"0.1.2-a", "category":"Other", "icon":"icon.png", "mimes":[ diff --git a/packages.json b/packages.json index c4144e2..5d22ba0 100644 --- a/packages.json +++ b/packages.json @@ -129,36 +129,6 @@ "dependencies": [], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Katex/build/release/Katex.zip" }, - { - "pkgname": "libjpeg", - "name": "libjpeg", - "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libjpeg/README.md", - "category": "Library", - "author": "", - "version": "0.1.1-a", - "dependencies": [], - "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libjpeg/build/release/libjpeg.zip" - }, - { - "pkgname": "libpdfjs", - "name": "PDF JS library", - "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libpdfjs/README.md", - "category": "Library", - "author": "Xuan Sang LE", - "version": "2.6.347-r", - "dependencies": [], - "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libpdfjs/build/release/libpdfjs.zip" - }, - { - "pkgname": "libwvnc", - "name": "libwvnc", - "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libwvnc/README.md", - "category": "Library", - "author": "", - "version": "0.1.2-a", - "dependencies": ["libjpeg@0.1.1-a"], - "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libwvnc/build/release/libwvnc.zip" - }, { "pkgname": "LuaPlayground", "name": "LuaPlayground", @@ -185,7 +155,7 @@ "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OnlyOffice/README.md", "category": "Other", "author": "Xuan Sang LE", - "version": "0.1.1-a", + "version": "0.1.2-a", "dependencies": [], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OnlyOffice/build/release/OnlyOffice.zip" }, @@ -279,6 +249,36 @@ "dependencies": [], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/VizApp/build/release/VizApp.zip" }, + { + "pkgname": "libjpeg", + "name": "libjpeg", + "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libjpeg/README.md", + "category": "Library", + "author": "", + "version": "0.1.1-a", + "dependencies": [], + "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libjpeg/build/release/libjpeg.zip" + }, + { + "pkgname": "libpdfjs", + "name": "PDF JS library", + "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libpdfjs/README.md", + "category": "Library", + "author": "Xuan Sang LE", + "version": "2.6.347-r", + "dependencies": [], + "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libpdfjs/build/release/libpdfjs.zip" + }, + { + "pkgname": "libwvnc", + "name": "libwvnc", + "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libwvnc/README.md", + "category": "Library", + "author": "", + "version": "0.1.2-a", + "dependencies": ["libjpeg@0.1.1-a"], + "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libwvnc/build/release/libwvnc.zip" + }, { "pkgname": "vTerm", "name": "Virtual Terminal",