From 704e0aa2da3f45572d935e86108fbef750773536 Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Tue, 2 Mar 2021 17:03:00 +0100 Subject: [PATCH] update onlyoffice wrapper --- OnlyOffice/README.md | 1 + OnlyOffice/build/debug/README.md | 6 ++- OnlyOffice/build/debug/main.js | 2 +- OnlyOffice/build/debug/package.json | 2 +- OnlyOffice/build/release/OnlyOffice.zip | Bin 60587 -> 60912 bytes OnlyOffice/coffees/main.coffee | 4 +- OnlyOffice/package.json | 2 +- packages.json | 62 ++++++++++++------------ 8 files changed, 41 insertions(+), 38 deletions(-) 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 7ba76a6f12766df23a17b75d9e758411035cc8c3..b714bf4925c16bc99c7b81ed79245f80fe975779 100644 GIT binary patch delta 787 zcmZ2|lljAKX5IjAW)?065HM*-+Q@6b&1~9`wAq1s89RqrLsHPwD@`Vw-wBB@G8%1W z7Fo>12NIl+Hh1Q6CI*J%Oq;ieFcLwmSmJB=_Tjq>gQAxC+4N=C+3yp7pG+FCKePF>nG*pC+X)V7MG+J>HFv9RQji- zWhSTU7bh2`rsfrAiOERo5~Y}t@B`MXN1!Q!4 zFcmY~02vc@%gQm^0+npI`Gglp2XRLpt6Ry>z_4=j!dti4xU5vFQ}uE|p|-i|VJ(Zk zQeJ*us*<9uZAnIEv0i#=iA#QRNM%8)My6h3u^Z5N9zd7nq-tpDrB;+^+E4!eREOQF zEI%_v!C?+ACvFWKNEGWdx7Q$MX$TksLHP^5 z?Kje4U;tqemu4mnWvXrT#W1_ln@7oIy;J!`fg9|c_Yad I^BN=y02N#ND*ylh delta 467 zcmexxn|bw3X5IjAW)?065LmpxYa_1#H#3ml?7+Q@odd`SQh0mYWAi&95k^MC&CDW; znfO40+27`;9A;!-ILx?ti&#FRkV0aKLP5D+gAx<<=8kppu{oXN_)W@G~%EY+ic% z7Te~oM>Q;yO`q#b=6ay9dBXD>%pmtp&VFqSrWd|8f;)Ti?bk+V&Ydj%M$-o5gC~z3 z);KdWFn};O*!M7^O@e`;I5{IVH&rjABsV9(n~_O`0TMtUhc~>DX8I&OdF~qt1(4(N z7kt}qq{F}f!Xhvuz_gUi - 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",