1
2
3
|
/*! For license information please see files_external-main.js.LICENSE.txt */
(()=>{"use strict";var e,t={37935:(e,t,n)=>{var r=n(31352),i=n(79954),o=n(79753),s=n(3255),a=n(26937),l=n(20144),u=n(17499);const c=(0,u.IY)().setApp("files").detectUser().build();var d;!function(e){e.DEFAULT="default",e.HIDDEN="hidden"}(d||(d={}));class f{constructor(e){var t,n,r;t=this,r=void 0,(n=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(n="_action"))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,this.validateAction(e),this._action=e}get id(){return this._action.id}get displayName(){return this._action.displayName}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(e){if(!e.id||"string"!=typeof e.id)throw new Error("Invalid id");if(!e.displayName||"function"!=typeof e.displayName)throw new Error("Invalid displayName function");if(!e.iconSvgInline||"function"!=typeof e.iconSvgInline)throw new Error("Invalid iconSvgInline function");if(!e.exec||"function"!=typeof e.exec)throw new Error("Invalid exec function");if("enabled"in e&&"function"!=typeof e.enabled)throw new Error("Invalid enabled function");if("execBatch"in e&&"function"!=typeof e.execBatch)throw new Error("Invalid execBatch function");if("order"in e&&"number"!=typeof e.order)throw new Error("Invalid order");if(e.default&&!Object.values(d).includes(e.default))throw new Error("Invalid default");if("inline"in e&&"function"!=typeof e.inline)throw new Error("Invalid inline function");if("renderInline"in e&&"function"!=typeof e.renderInline)throw new Error("Invalid renderInline function")}}const h=function(e){void 0===window._nc_fileactions&&(window._nc_fileactions=[],c.debug("FileActions initialized")),window._nc_fileactions.find((t=>t.id===e.id))?c.error("FileAction ".concat(e.id," already registered"),{action:e}):window._nc_fileactions.push(e)};var p;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.ERROR=1]="ERROR",e[e.INDETERMINATE=2]="INDETERMINATE",e[e.INCOMPLETE_CONF=3]="INCOMPLETE_CONF",e[e.UNAUTHORIZED=4]="UNAUTHORIZED",e[e.TIMEOUT=5]="TIMEOUT",e[e.NETWORK_ERROR=6]="NETWORK_ERROR"}(p||(p={}));const g=function(e){return!(!e.status||e.status===p.SUCCESS)&&(e.userProvided||"password::global::user"===e.authMechanism)};var w,m,v,A=n(77958),b=n(62520);null===(w=(0,A.ts)())?(0,u.IY)().setApp("files").build():(0,u.IY)().setApp("files").setUid(w.uid).build(),function(e){e.Folder="folder",e.File="file"}(m||(m={})),function(e){e[e.NONE=0]="NONE",e[e.CREATE=4]="CREATE",e[e.READ=1]="READ",e[e.UPDATE=2]="UPDATE",e[e.DELETE=8]="DELETE",e[e.SHARE=16]="SHARE",e[e.ALL=31]="ALL"}(v||(v={}));const E=function(e,t){return null!==e.match(t)},_=(e,t)=>{if("id"in e&&("number"!=typeof e.id||e.id<0))throw new Error("Invalid id type of value");if(!e.source)throw new Error("Missing mandatory source");try{new URL(e.source)}catch(e){throw new Error("Invalid source format, source must be a valid URL")}if(!e.source.startsWith("http"))throw new Error("Invalid source format, only http(s) is supported");if("mtime"in e&&!(e.mtime instanceof Date))throw new Error("Invalid mtime type");if("crtime"in e&&!(e.crtime instanceof Date))throw new Error("Invalid crtime type");if(!e.mime||"string"!=typeof e.mime||!e.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))throw new Error("Missing or invalid mandatory mime");if("size"in e&&"number"!=typeof e.size)throw new Error("Invalid size type");if("permissions"in e&&!("number"==typeof e.permissions&&e.permissions>=v.NONE&&e.permissions<=v.ALL))throw new Error("Invalid permissions");if("owner"in e&&null!==e.owner&&"string"!=typeof e.owner)throw new Error("Invalid owner type");if("attributes"in e&&"object"!=typeof e.attributes)throw new Error("Invalid attributes format");if("root"in e&&"string"!=typeof e.root)throw new Error("Invalid root format");if(e.root&&!e.root.startsWith("/"))throw new Error("Root must start with a leading slash");if(e.root&&!e.source.includes(e.root))throw new Error("Root must be part of the source");if(e.root&&E(e.source,t)){const n=e.source.match(t)[0];if(!e.source.includes((0,b.join)(n,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class y{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(e,t){_(e,t||this._knownDavService),this._data=e;const n={set:(e,t,n)=>(this._data.mtime=new Date,Reflect.set(e,t,n)),deleteProperty:(e,t)=>(this._data.mtime=new Date,Reflect.deleteProperty(e,t))};this._attributes=new Proxy(e.attributes||{},n),delete this._data.attributes,t&&(this._knownDavService=t)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return(0,b.basename)(this.source)}get extension(){return(0,b.extname)(this.source)}get dirname(){if(this.root){const e=this.source.indexOf(this.root);return(0,b.dirname)(this.source.slice(e+this.root.length)||"/")}const e=new URL(this.source);return(0,b.dirname)(e.pathname)}get mime(){return this._data.mime}get mtime(){return this._data.mtime}get crtime(){return this._data.crtime}get size(){return this._data.size}get attributes(){return this._attributes}get permissions(){return null!==this.owner||this.isDavRessource?void 0!==this._data.permissions?this._data.permissions:v.NONE:v.READ}get owner(){return this.isDavRessource?this._data.owner:null}get isDavRessource(){return E(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&(0,b.dirname)(this.source).split(this._knownDavService).pop()||null}get path(){if(this.root){const e=this.source.indexOf(this.root);return this.source.slice(e+this.root.length)||"/"}return(this.dirname+"/"+this.basename).replace(/\/\//g,"/")}get fileid(){return this._data?.id||this.attributes?.fileid}move(e){_({...this._data,source:e},this._knownDavService),this._data.source=e,this._data.mtime=new Date}rename(e){if(e.includes("/"))throw new Error("Invalid basename");this.move((0,b.dirname)(this.source)+"/"+e)}}class x extends y{constructor(e){super({...e,mime:"httpd/unix-directory"})}get type(){return m.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}const C=function(e){if(e.type===m.File)return!1;const t=e.attributes;return!(!t.scope||!t.backend||"personal"!==t.scope&&"system"!==t.scope)};h(new f({id:"credentials-external-storage",displayName:()=>(0,r.Iu)("files","Enter missing credentials"),iconSvgInline:()=>'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-login" viewBox="0 0 24 24"><path d="M10,17V14H3V10H10V7L15,12L10,17M10,2H19A2,2 0 0,1 21,4V20A2,2 0 0,1 19,22H10A2,2 0 0,1 8,20V18H10V20H19V4H10V6H8V4A2,2 0 0,1 10,2Z" /></svg>',enabled:e=>{var t;if(1!==e.length)return!1;const n=e[0];if(!C(n))return!1;const r=(null===(t=n.attributes)||void 0===t?void 0:t.config)||{};return!!g(r)},async exec(e){const t=await a.Z.get((0,o.generateOcsUrl)("/apps/files_external/api/v1/auth"),{validateStatus:()=>!0}),n=(null==t?void 0:t.data)||{};if(n.ocs.data.user&&n.ocs.data.password){const t=(await a.Z.put((0,o.generateUrl)("apps/files_external/userglobalstorages/{id}",e.attributes),{backendOptions:n.ocs.data})).data;if(t.status!==p.SUCCESS)return(0,s.x2)((0,r.Iu)("files_external","Unable to update this external storage config. {statusMessage}",{statusMessage:(null==t?void 0:t.statusMessage)||""})),null;(0,s.s$)((0,r.Iu)("files_external","New configuration successfully saved")),l.default.set(e.attributes,"config",t)}return null},order:-1e3,default:d.DEFAULT,inline:()=>!0}));var I,S=n(93379),O=n.n(S),R=n(7795),N=n.n(R),T=n(90569),D=n.n(T),U=n(3565),H=n.n(U),k=n(19216),M=n.n(k),L=n(44589),P=n.n(L),j=n(17150),B={};B.styleTagTransform=P(),B.setAttributes=H(),B.insert=D().bind(null,"head"),B.domAPI=N(),B.insertStyleElement=M(),O()(j.Z,B),j.Z&&j.Z.locals&&j.Z.locals;const V="/files/".concat(null===(I=(0,A.ts)())||void 0===I?void 0:I.uid),F=e=>{var t;const n=(e.path+"/"+e.name).replace(/^\//gm,"");return new x({id:e.id,source:(0,o.generateRemoteUrl)("dav"+V+"/"+n),root:V,owner:(null===(t=(0,A.ts)())||void 0===t?void 0:t.uid)||null,permissions:e.config.status!==p.SUCCESS?v.NONE:(null==e?void 0:e.permissions)||v.READ,attributes:{displayName:n,...e}})};h(new f({id:"check-external-storage",displayName:()=>"",iconSvgInline:()=>"",enabled:e=>e.every((e=>!0===C(e))),exec:async()=>null,async renderInline(e){let t=null;try{const i=await function(e){const t=arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?"userstorages":"userglobalstorages";return a.Z.get((0,o.generateUrl)("apps/files_external/".concat(t,"/").concat(e,"?testOnly=false")))}(e.attributes.id,"system"===e.attributes.scope);var n;if(t=i.data,l.default.set(e.attributes,"config",t),t.status!==p.SUCCESS)throw new Error((null===(n=t)||void 0===n?void 0:n.statusMessage)||(0,r.Iu)("files_external","There was an error with this external storage."));return null}catch(n){if(n.response&&!t)return(0,s.K2)((0,r.Iu)("files_external","We were unable to check the external storage {basename}",{basename:e.basename})),null;const i=g(t),o=document.createElement("span");o.classList.add("files-list__row-status--".concat(i?"warning":"error"));const a=document.createElement("span");return a.className="files-list__row-status",i||(a.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-alert-circle" viewBox="0 0 24 24"><path d="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /></svg>',a.title=n.message),a.prepend(o),a}},order:10})),h(new f({id:"open-in-files-external-storage",displayName:e=>{var t,n;return((null==e||null===(t=e[0])||void 0===t||null===(n=t.attributes)||void 0===n?void 0:n.config)||{status:p.INDETERMINATE}).status!==p.SUCCESS?(0,r.Iu)("files_external","Examine this faulty external storage configuration"):(0,r.Iu)("files","Open in files")},iconSvgInline:()=>"",enabled:(e,t)=>"extstoragemounts"===t.id,async exec(e){const t=e.attributes.config;return(null==t?void 0:t.status)!==p.SUCCESS?(window.OC.dialogs.confirm((0,r.Iu)("files_external","There was an error with this external storage. Do you want to review this mount point config in the settings page?"),(0,r.Iu)("files_external","External mount error"),(t=>{if(!0===t){const t="personal"===e.attributes.scope?"user":"admin";window.location.href=(0,o.generateUrl)("/settings/".concat(t,"/externalstorages"))}})),null):(window.OCP.Files.Router.goToRoute(null,{view:"files"},{dir:e.path}),null)},order:-1e3,default:d.HIDDEN}));const Z=(0,i.j)("files_external","allowUserMounting",!1);window.OCP.Files.Navigation.register({id:"extstoragemounts",name:(0,r.Iu)("files_external","External storage"),caption:(0,r.Iu)("files_external","List of external storage."),emptyCaption:Z?(0,r.Iu)("files_external","There is no external storage configured. You can configure them in your Personal settings."):(0,r.Iu)("files_external","There is no external storage configured and you don't have the permission to configure them."),emptyTitle:(0,r.Iu)("files_external","No external storage"),icon:'<svg xmlns="http://www.w3.org/2000/svg" id="mdi-folder-network" viewBox="0 0 24 24"><path d="M3,15V5A2,2 0 0,1 5,3H11L13,5H19A2,2 0 0,1 21,7V15A2,2 0 0,1 19,17H13V19H14A1,1 0 0,1 15,20H22V22H15A1,1 0 0,1 14,23H10A1,1 0 0,1 9,22H2V20H9A1,1 0 0,1 10,19H11V17H5A2,2 0 0,1 3,15Z" /></svg>',order:30,columns:[{id:"storage-type",title:(0,r.Iu)("files_external","Storage type"),render(e){var t;const n=(null===(t=e.attributes)||void 0===t?void 0:t.backend)||(0,r.Iu)("files_external","Unknown"),i=document.createElement("span");return i.textContent=n,i}},{id:"scope",title:(0,r.Iu)("files_external","Scope"),render(e){var t;const n=document.createElement("span");let i=(0,r.Iu)("files_external","Personal");return"system"===(null===(t=e.attributes)||void 0===t?void 0:t.scope)&&(i=(0,r.Iu)("files_external","System")),n.textContent=i,n}}],getContents:async()=>{var e;const t=(await a.Z.get((0,o.generateOcsUrl)("apps/files_external/api/v1/mounts"))).data.ocs.data.map(F);return{folder:new x({id:0,source:(0,o.generateRemoteUrl)("dav"+V),root:V,owner:(null===(e=(0,A.ts)())||void 0===e?void 0:e.uid)||null,permissions:v.READ}),contents:t}}})},17150:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(87537),i=n.n(r),o=n(23645),s=n.n(o)()(i());s.push([e.id,".files-list__row-status{display:flex;width:44px;justify-content:center;align-items:center;height:100%}.files-list__row-status svg{width:24px;height:24px}.files-list__row-status svg path{fill:currentColor}.files-list__row-status--error,.files-list__row-status--warning{position:absolute;display:block;top:0;left:0;right:0;bottom:0;opacity:.1;z-index:-1}.files-list__row-status--error{background:var(--color-error)}.files-list__row-status--warning{background:var(--color-warning)}","",{version:3,sources:["webpack://./apps/files_external/src/css/fileEntryStatus.scss"],names:[],mappings:"AAAA,wBACC,YAAA,CACA,UAAA,CACA,sBAAA,CACA,kBAAA,CACA,WAAA,CAEA,4BACC,UAAA,CACA,WAAA,CAEA,iCACC,iBAAA,CAIF,gEAEC,iBAAA,CACA,aAAA,CACA,KAAA,CACA,MAAA,CACA,OAAA,CACA,QAAA,CACA,UAAA,CACA,UAAA,CAGD,+BACC,6BAAA,CAGD,iCACC,+BAAA",sourcesContent:[".files-list__row-status {\n\tdisplay: flex;\n\twidth: 44px;\n\tjustify-content: center;\n\talign-items: center;\n\theight: 100%;\n\n\tsvg {\n\t\twidth: 24px;\n\t\theight: 24px;\n\n\t\tpath {\n\t\t\tfill: currentColor;\n\t\t}\n\t}\n\n\t&--error,\n\t&--warning {\n\t\tposition: absolute;\n\t\tdisplay: block;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tright: 0;\n\t\tbottom: 0;\n\t\topacity: .1;\n\t\tz-index: -1;\n\t}\n\n\t&--error {\n\t\tbackground: var(--color-error);\n\t}\n\n\t&--warning {\n\t\tbackground: var(--color-warning);\n\t}\n}\n"],sourceRoot:""}]);const a=s}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var o=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}r.m=t,e=[],r.O=(t,n,i,o)=>{if(!n){var s=1/0;for(c=0;c<e.length;c++){n=e[c][0],i=e[c][1],o=e[c][2];for(var a=!0,l=0;l<n.length;l++)(!1&o||s>=o)&&Object.keys(r.O).every((e=>r.O[e](n[l])))?n.splice(l--,1):(a=!1,o<s&&(s=o));if(a){e.splice(c--,1);var u=i();void 0!==u&&(t=u)}}return t}o=o||0;for(var c=e.length;c>0&&e[c-1][2]>o;c--)e[c]=e[c-1];e[c]=[n,i,o]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r.j=4692,(()=>{r.b=document.baseURI||self.location.href;var e={4692:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var i,o,s=n[0],a=n[1],l=n[2],u=0;if(s.some((t=>0!==e[t]))){for(i in a)r.o(a,i)&&(r.m[i]=a[i]);if(l)var c=l(r)}for(t&&t(n);u<s.length;u++)o=s[u],r.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return r.O(c)},n=self.webpackChunknextcloud=self.webpackChunknextcloud||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),r.nc=void 0;var i=r.O(void 0,[7874],(()=>r(37935)));i=r.O(i)})();
//# sourceMappingURL=files_external-main.js.map?v=6f4dd0110e1f480e48ac
|