diff --git a/data/assets/index.html b/data/assets/index.html index cd66ec2..08704f8 100644 --- a/data/assets/index.html +++ b/data/assets/index.html @@ -42,6 +42,7 @@ installUrl: '/__local__/install', uploadResumeSizeUrl: '__local__/uploadResumeSize', installUrlUrl: '/__local__/install_url', + downloadUrlUrl: '/__local__/download_url', multipleDownloadFileName: 'ezremote-client.zip', isExtractableFilePattern: /\.(7z|rar|zip)$/i, pickCallback: function (item) { @@ -63,4 +64,4 @@ - \ No newline at end of file + diff --git a/data/assets/res/angular-filemanager.min.js b/data/assets/res/angular-filemanager.min.js index 6e9a5e4..7ccb1e8 100644 --- a/data/assets/res/angular-filemanager.min.js +++ b/data/assets/res/angular-filemanager.min.js @@ -1 +1 @@ -!function(e,n){"use strict";n.module("FileManagerApp",["pascalprecht.translate","ngFileUpload"]),n.element(e.document).on("shown.bs.modal",".modal",function(){e.setTimeout(function(){n.element("[autofocus]",this).focus()}.bind(this),100)}),n.element(e.document).on("click",function(){n.element("#context-menu").hide()}),n.element(e.document).on("contextmenu",'.main-navigation .table-files tr.item-list:has("td"), .item-list',function(i){var a=n.element("#context-menu");i.pageX>=e.innerWidth-a.width()&&(i.pageX-=a.width()),i.pageY>=e.innerHeight-a.height()&&(i.pageY-=a.height()),a.hide().css({left:i.pageX,top:i.pageY}).appendTo("body").show(),i.preventDefault()}),Array.prototype.find||(Array.prototype.find=function(e){if(null==this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n,i=Object(this),a=i.length>>>0,r=arguments[1],t=0;to){for(n.temps=[];s>=o;)d=t[s],!n.isSelected(d)&&n.temps.push(d),s--;return}}!i||r||!i.ctrlKey&&!i.metaKey?n.temps=[e]:n.isSelected(e)?n.temps.splice(a,1):n.temps.push(e)}},n.singleSelection=function(){return 1===n.temps.length&&n.temps[0]},n.totalSelecteds=function(){return{total:n.temps.length}},n.selectionHas=function(e){return n.temps.find(function(n){return n&&n.model.type===e})},n.prepareNewFolder=function(){var e=new o(null,n.fileNavigator.currentPath);return n.temps=[e],e},n.prepareInstallUrl=function(){var e=new o(null,null);return n.temps=[e],e},n.smartClick=function(e){var i=n.config.allowedActions.pickFiles;if(e.isFolder())return n.fileNavigator.folderClick(e);if("function"==typeof n.config.pickCallback&&i){if(!0===n.config.pickCallback(e.model))return}return e.isImage()?n.config.previewImagesInModal?n.openImagePreview(e):n.apiMiddleware.download(e,!0):e.isEditable()?n.openEditItem(e):void 0},n.openImagePreview=function(){var e=n.singleSelection();n.apiMiddleware.apiHandler.inprocess=!0,n.modal("imagepreview",null,!0).find("#imagepreview-target").attr("src",n.getUrl(e)).unbind("load error").on("load error",function(){n.apiMiddleware.apiHandler.inprocess=!1,n.$apply()})},n.openEditItem=function(){var e=n.singleSelection();n.apiMiddleware.getContent(e).then(function(n){e.tempModel.content=e.model.content=n.result}),n.modal("edit")},n.modal=function(i,a,r){var t=e.element("#"+i);return t.modal(a?"hide":"show"),n.apiMiddleware.apiHandler.error="",n.apiMiddleware.apiHandler.asyncSuccess=!1,!r||t},n.modalWithPathSelector=function(e){return i.selectedModalPath=n.fileNavigator.currentPath,n.modal(e)},n.isInThisPath=function(e){return-1!==(n.fileNavigator.currentPath.join("/")+"/").indexOf(e+"/")},n.edit=function(){n.apiMiddleware.edit(n.singleSelection()).then(function(){n.modal("edit",!0)})},n.changePermissions=function(){n.apiMiddleware.changePermissions(n.temps,n.temp).then(function(){n.fileNavigator.refresh(),n.modal("changepermissions",!0)})},n.download=function(){var e=n.singleSelection();return e?n.apiMiddleware.download(e):n.apiMiddleware.downloadMultiple(n.temps)},n.copy=function(){var e=n.singleSelection();if(e){var a=e.tempModel.name.trim();if(n.fileNavigator.fileNameExists(a)&&c(e))return n.apiMiddleware.apiHandler.error=r.instant("error_invalid_filename"),!1;if(!a)return n.apiMiddleware.apiHandler.error=r.instant("error_invalid_filename"),!1}n.apiMiddleware.copy(n.temps,i.selectedModalPath).then(function(){n.fileNavigator.refresh(),n.modal("copy",!0)})},n.compress=function(){var e=n.temp.tempModel.name.trim();return n.fileNavigator.fileNameExists(e)&&c(n.temp)?(n.apiMiddleware.apiHandler.error=r.instant("error_invalid_filename"),!1):e?void n.apiMiddleware.compress(n.temps,e,i.selectedModalPath).then(function(){if(n.fileNavigator.refresh(),!n.config.compressAsync)return n.modal("compress",!0);n.apiMiddleware.apiHandler.asyncSuccess=!0},function(){n.apiMiddleware.apiHandler.asyncSuccess=!1}):(n.apiMiddleware.apiHandler.error=r.instant("error_invalid_filename"),!1)},n.extract=function(){var e=n.temp,a=n.temp.tempModel.name.trim();return n.fileNavigator.fileNameExists(a)&&c(n.temp)?(n.apiMiddleware.apiHandler.error=r.instant("error_invalid_filename"),!1):a?void n.apiMiddleware.extract(e,a,i.selectedModalPath).then(function(){if(n.fileNavigator.refresh(),!n.config.extractAsync)return n.modal("extract",!0);n.apiMiddleware.apiHandler.asyncSuccess=!0},function(){n.apiMiddleware.apiHandler.asyncSuccess=!1}):(n.apiMiddleware.apiHandler.error=r.instant("error_invalid_filename"),!1)},n.remove=function(){n.apiMiddleware.remove(n.temps).then(function(){n.fileNavigator.refresh(),n.modal("remove",!0)})},n.isInstallable=function(){for(var e=0;e1024);var o=n.useBinarySizePrefixes?a[r]:i[r];return Math.max(t,.1).toFixed(1)+" "+o}}])}(),function(e){"use strict";angular.module("FileManagerApp").service("apiHandler",["$http","$q","$window","$translate","$httpParamSerializer","Upload",function(e,n,i,a,r,t){e.defaults.headers.common["X-Requested-With"]="XMLHttpRequest";var o=function(){this.inprocess=!1,this.asyncSuccess=!1,this.error=""};return o.prototype.deferredHandler=function(e,n,i,a){return e&&"object"==typeof e||(this.error="Error %s - Bridge response error, please check the API docs or this ajax response.".replace("%s",i)),404==i&&(this.error="Error 404 - Backend bridge is not working, please check the ajax response."),e.result&&e.result.error&&(this.error=e.result.error),!this.error&&e.error&&(this.error=e.error.message),!this.error&&a&&(this.error=a),this.error?n.reject(e):n.resolve(e)},o.prototype.list=function(i,a,r,t){var o=this,l=r||o.deferredHandler,s=n.defer(),d={action:"list",path:a,fileExtensions:t&&t.length?t:void 0};return o.inprocess=!0,o.error="",e.post(i,d).then(function(e){l(e.data,s,e.status)},function(e){l(e.data,s,e.status,"Unknown error listing, check the response")}).finally(function(){o.inprocess=!1}),s.promise},o.prototype.copy=function(i,r,t,o){var l=this,s=n.defer(),d={action:"copy",items:r,newPath:t};return o&&1===r.length&&(d.singleFilename=o),l.inprocess=!0,l.error="",e.post(i,d).then(function(e){l.deferredHandler(e.data,s,e.status)},function(e){l.deferredHandler(e.data,s,e.status,a.instant("error_copying"))}).finally(function(){l.inprocess=!1}),s.promise},o.prototype.move=function(i,r,t){var o=this,l=n.defer(),s={action:"move",items:r,newPath:t};return o.inprocess=!0,o.error="",e.post(i,s).then(function(e){o.deferredHandler(e.data,l,e.status)},function(e){o.deferredHandler(e.data,l,e.status,a.instant("error_moving"))}).finally(function(){o.inprocess=!1}),l.promise},o.prototype.remove=function(i,r){var t=this,o=n.defer(),l={action:"remove",items:r};return t.inprocess=!0,t.error="",e.post(i,l).then(function(e){t.deferredHandler(e.data,o,e.status)},function(e){t.deferredHandler(e.data,o,e.status,a.instant("error_deleting"))}).finally(function(){t.inprocess=!1}),o.promise},o.prototype.install=function(i,r){var t=this,o=n.defer(),l={action:"install",items:r};return t.inprocess=!0,t.error="",e.post(i,l).then(function(e){t.deferredHandler(e.data,o,e.status)},function(e){t.deferredHandler(e.data,o,e.status,a.instant("error_installing"))}).finally(function(){t.inprocess=!1}),o.promise},o.prototype.upload=function(e,i,a,r,o){var l=this,s=n.defer();l.inprocess=!0,l.progress=0,l.error="",l.total_size=0,l.total_loaded=0,l.status=[];for(d=0;d=l.total_size&&l.deferredHandler(e.data,s,e.status)},function(e){l.deferredHandler(e.data,s,e.status,"Unknown error uploading files")},function(e){l.status[e.config._file.name].loaded=e.loaded;for(var n=0,i=0;i=l.total_size&&(l.inprocess=!1,l.progress=0,l.status=[])})}return s.promise},o.prototype.getContent=function(i,r){var t=this,o=n.defer(),l={action:"getContent",item:r};return t.inprocess=!0,t.error="",e.post(i,l).then(function(e){t.deferredHandler(e.data,o,e.status)},function(e){t.deferredHandler(e.data,o,e.status,a.instant("error_getting_content"))}).finally(function(){t.inprocess=!1}),o.promise},o.prototype.edit=function(i,r,t){var o=this,l=n.defer(),s={action:"edit",item:r,content:t};return o.inprocess=!0,o.error="",e.post(i,s).then(function(e){o.deferredHandler(e.data,l,e.status)},function(e){o.deferredHandler(e.data,l,e.status,a.instant("error_modifying"))}).finally(function(){o.inprocess=!1}),l.promise},o.prototype.rename=function(i,r,t){var o=this,l=n.defer(),s={action:"rename",item:r,newItemPath:t};return o.inprocess=!0,o.error="",e.post(i,s).then(function(e){o.deferredHandler(e.data,l,e.status)},function(e){o.deferredHandler(e.data,l,e.status,a.instant("error_renaming"))}).finally(function(){o.inprocess=!1}),l.promise},o.prototype.getUrl=function(e,n){return n&&[e,r({action:"download",path:n})].join("?")},o.prototype.download=function(r,t,o,l,s){var d=this,c=this.getUrl(r,t);if(!l||s||!i.saveAs)return!i.saveAs&&i.console.log("Your browser dont support ajax download, downloading by default"),!!i.open(c,"_blank","");var p=n.defer();return d.inprocess=!0,e.get(c).then(function(e){var n=new i.Blob([e.data]);p.resolve(e.data),i.saveAs(n,o)},function(e){d.deferredHandler(e.data,p,e.status,a.instant("error_downloading"))}).finally(function(){d.inprocess=!1}),p.promise},o.prototype.downloadMultiple=function(t,o,l,s,d){var c=this,p=n.defer(),u=[t,r({action:"downloadMultiple",items:o,toFilename:l})].join("?");return s&&!d&&i.saveAs?(c.inprocess=!0,e.get(t).then(function(e){var n=new i.Blob([e.data]);p.resolve(e.data),i.saveAs(n,l)},function(e){c.deferredHandler(e.data,p,e.status,a.instant("error_downloading"))}).finally(function(){c.inprocess=!1}),p.promise):(!i.saveAs&&i.console.log("Your browser dont support ajax download, downloading by default"),!!i.open(u,"_blank",""))},o.prototype.compress=function(i,r,t,o){var l=this,s=n.defer(),d={action:"compress",items:r,destination:o,compressedFilename:t};return l.inprocess=!0,l.error="",e.post(i,d).then(function(e){l.deferredHandler(e.data,s,e.status)},function(e){l.deferredHandler(e.data,s,e.status,a.instant("error_compressing"))}).finally(function(){l.inprocess=!1}),s.promise},o.prototype.extract=function(i,r,t,o){var l=this,s=n.defer(),d={action:"extract",item:r,destination:o,folderName:t};return l.inprocess=!0,l.error="",e.post(i,d).then(function(e){l.deferredHandler(e.data,s,e.status)},function(e){l.deferredHandler(e.data,s,e.status,a.instant("error_extracting"))}).finally(function(){l.inprocess=!1}),s.promise},o.prototype.changePermissions=function(i,r,t,o,l){var s=this,d=n.defer(),c={action:"changePermissions",items:r,perms:t,permsCode:o,recursive:!!l};return s.inprocess=!0,s.error="",e.post(i,c).then(function(e){s.deferredHandler(e.data,d,e.status)},function(e){s.deferredHandler(e.data,d,e.status,a.instant("error_changing_perms"))}).finally(function(){s.inprocess=!1}),d.promise},o.prototype.createFolder=function(i,r){var t=this,o=n.defer(),l={action:"createFolder",newPath:r};return t.inprocess=!0,t.error="",e.post(i,l).then(function(e){t.deferredHandler(e.data,o,e.status)},function(e){t.deferredHandler(e.data,o,e.status,a.instant("error_creating_folder"))}).finally(function(){t.inprocess=!1}),o.promise},o.prototype.installUrl=function(i,r,t,o,l){var s=this,d=n.defer(),c={action:"installUrl",url:r,use_alldebrid:t,use_realdebrid:o,use_disk_cache:l};return s.inprocess=!0,s.error="",e.post(i,c).then(function(e){s.deferredHandler(e.data,d,e.status)},function(e){s.deferredHandler(e.data,d,e.status,a.instant("error_installing_url"))}).finally(function(){s.inprocess=!1}),d.promise},o}])}(),function(e){"use strict";angular.module("FileManagerApp").service("apiMiddleware",["$window","fileManagerConfig","apiHandler",function(e,n,i){var a=function(){this.apiHandler=new i};return a.prototype.getPath=function(e){return"/"+e.join("/")},a.prototype.getFileList=function(e){return(e||[]).map(function(e){return e&&e.model.fullPath()})},a.prototype.getFilePath=function(e){return e&&e.model.fullPath()},a.prototype.list=function(e,i){return this.apiHandler.list(n.listUrl,this.getPath(e),i)},a.prototype.copy=function(e,i){var a=this.getFileList(e),r=1===a.length?e[0].tempModel.name:void 0;return this.apiHandler.copy(n.copyUrl,a,this.getPath(i),r)},a.prototype.move=function(e,i){var a=this.getFileList(e);return this.apiHandler.move(n.moveUrl,a,this.getPath(i))},a.prototype.remove=function(e){var i=this.getFileList(e);return this.apiHandler.remove(n.removeUrl,i)},a.prototype.install=function(e){var i=this.getFileList(e);return this.apiHandler.install(n.installUrl,i)},a.prototype.upload=function(i,a){if(!e.FormData)throw new Error("Unsupported browser version");var r=this.getPath(a);return this.apiHandler.upload(n.uploadUrl,n.uploadResumeSizeUrl,n.resumeChunkSize,r,i)},a.prototype.getContent=function(e){var i=this.getFilePath(e);return this.apiHandler.getContent(n.getContentUrl,i)},a.prototype.edit=function(e){var i=this.getFilePath(e);return this.apiHandler.edit(n.editUrl,i,e.tempModel.content)},a.prototype.rename=function(e){var i=this.getFilePath(e),a=e.tempModel.fullPath();return this.apiHandler.rename(n.renameUrl,i,a)},a.prototype.getUrl=function(e){var i=this.getFilePath(e);return this.apiHandler.getUrl(n.downloadFileUrl,i)},a.prototype.download=function(e,i){var a=this.getFilePath(e),r=e.model.name;if(!e.isFolder())return this.apiHandler.download(n.downloadFileUrl,a,r,n.downloadFilesByAjax,i)},a.prototype.downloadMultiple=function(e,i){var a=this.getFileList(e),r=(new Date).getTime().toString().substr(8,13)+"-"+n.multipleDownloadFileName;return this.apiHandler.downloadMultiple(n.downloadMultipleUrl,a,r,n.downloadFilesByAjax,i)},a.prototype.compress=function(e,i,a){var r=this.getFileList(e);return this.apiHandler.compress(n.compressUrl,r,i,this.getPath(a))},a.prototype.extract=function(e,i,a){var r=this.getFilePath(e);return this.apiHandler.extract(n.extractUrl,r,i,this.getPath(a))},a.prototype.changePermissions=function(e,i){var a=this.getFileList(e),r=i.tempModel.perms.toCode(),t=i.tempModel.perms.toOctal(),o=!!i.tempModel.recursive;return this.apiHandler.changePermissions(n.permissionsUrl,a,r,t,o)},a.prototype.createFolder=function(e){var i=e.tempModel.fullPath();return this.apiHandler.createFolder(n.createFolderUrl,i)},a.prototype.installUrl=function(e){var i=e.tempModel.name,a=e.tempModel.use_alldebrid,r=e.tempModel.use_realdebrid,t=e.tempModel.use_disk_cache;return this.apiHandler.installUrl(n.installUrlUrl,i,a,r,t)},a}])}(),function(e){"use strict";angular.module("FileManagerApp").service("fileNavigator",["apiMiddleware","fileManagerConfig","item",function(e,n,i){var a=function(){this.apiMiddleware=new e,this.requesting=!1,this.fileList=[],this.currentPath=this.getBasePath(),this.history=[],this.error="",this.onRefresh=function(){}};return a.prototype.getBasePath=function(){var e=(n.basePath||"").replace(/^\//,"");return e.trim()?e.split("/"):[]},a.prototype.deferredHandler=function(e,n,i,a){return e&&"object"==typeof e||(this.error="Error %s - Bridge response error, please check the API docs or this ajax response.".replace("%s",i)),404==i&&(this.error="Error 404 - Backend bridge is not working, please check the ajax response."),200==i&&(this.error=null),!this.error&&e.result&&e.result.error&&(this.error=e.result.error),!this.error&&e.error&&(this.error=e.error.message),!this.error&&a&&(this.error=a),this.error?n.reject(e):n.resolve(e)},a.prototype.list=function(){return this.apiMiddleware.list(this.currentPath,this.deferredHandler.bind(this))},a.prototype.refresh=function(){var e=this;e.currentPath.length||(e.currentPath=this.getBasePath());var n=e.currentPath.join("/");return e.requesting=!0,e.fileList=[],e.list().then(function(a){e.fileList=(a.result||[]).map(function(n){return new i(n,e.currentPath)}),e.buildTree(n),e.onRefresh()}).finally(function(){e.requesting=!1})},a.prototype.buildTree=function(e){function n(e,i,a){var r=a?a+"/"+i.model.name:i.model.name;if(e.name&&e.name.trim()&&0!==a.trim().indexOf(e.name)&&(e.nodes=[]),e.name!==a)e.nodes.forEach(function(e){n(e,i,a)});else{for(var t in e.nodes)if(e.nodes[t].name===r)return;e.nodes.push({item:i,name:r,nodes:[]})}e.nodes=e.nodes.sort(function(e,n){return e.name.toLowerCase()\n
  • \n \n {{"filemanager" | translate}}\n \n
  • \n
  • \n \n {{dir | strLimit : 8}}\n \n \n {{dir | strLimit : 12}}\n \n
  • \n'),e.put("src/templates/item-context-menu.html",''),e.put("src/templates/main-icons.html",'
    \n \n\n
    \n
    \n
    \n\n
    \n {{"no_files_in_folder" | translate}}...\n
    \n \n
    \n {{ fileNavigator.error }}\n
    \n
    '),e.put("src/templates/main-table-modal.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n {{"name" | translate}}\n \n \n
    \n
    \n
    \n {{"no_folders_in_folder" | translate}}...\n \n \n
    \n {{ fileNavigator.error }}\n
    \n \n \n {{item.model.name | strLimit : 32}}\n \n \n \n
    '),e.put("src/templates/main-table.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n \n {{"name" | translate}}\n \n \n
    \n
    \n
    \n {{"no_files_in_folder" | translate}}...\n
    \n {{ fileNavigator.error }}\n
    \n \n \n \n {{item.model.name | strLimit : 64}}\n \n
    \n'),e.put("src/templates/main.html",'
    \n
    \n\n
    \n
    \n\n \n\n
    \n \n
    \n
    \n
    \n\n
    \n
    \n
    \n'),e.put("src/templates/modals.html",'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n