server/dist/files_sharing-files_sharing.js

3 lines
17 KiB
JavaScript

/*! For license information please see files_sharing-files_sharing.js.LICENSE.txt */
(()=>{var e,i={24839:(e,i,s)=>{var n=s(64492),a=s(19755);OCA.Sharing||(OCA.Sharing={}),OCA.Sharing.App={_inFileList:null,_outFileList:null,_overviewFileList:null,_pendingFileList:null,initSharingIn(e){return this._inFileList||(this._inFileList=new OCA.Sharing.FileList(e,{id:"shares.self",sharedWithUser:!0,fileActions:this._createFileActions(),config:OCA.Files.App.getFilesConfig(),shown:!0}),this._extendFileList(this._inFileList),this._inFileList.appName=t("files_sharing","Shared with you"),this._inFileList.$el.find("#emptycontent").html('<div class="icon-shared"></div><h2>'+t("files_sharing","Nothing shared with you yet")+"</h2><p>"+t("files_sharing","Files and folders others share with you will show up here")+"</p>")),this._inFileList},initSharingOut(e){return this._outFileList||(this._outFileList=new OCA.Sharing.FileList(e,{id:"shares.others",sharedWithUser:!1,fileActions:this._createFileActions(),config:OCA.Files.App.getFilesConfig(),shown:!0}),this._extendFileList(this._outFileList),this._outFileList.appName=t("files_sharing","Shared with others"),this._outFileList.$el.find("#emptycontent").html('<div class="icon-shared"></div><h2>'+t("files_sharing","Nothing shared yet")+"</h2><p>"+t("files_sharing","Files and folders you share will show up here")+"</p>")),this._outFileList},initSharingLinks(e){return this._linkFileList||(this._linkFileList=new OCA.Sharing.FileList(e,{id:"shares.link",linksOnly:!0,fileActions:this._createFileActions(),config:OCA.Files.App.getFilesConfig(),shown:!0}),this._extendFileList(this._linkFileList),this._linkFileList.appName=t("files_sharing","Shared by link"),this._linkFileList.$el.find("#emptycontent").html('<div class="icon-public"></div><h2>'+t("files_sharing","No shared links")+"</h2><p>"+t("files_sharing","Files and folders you share by link will show up here")+"</p>")),this._linkFileList},initSharingDeleted(e){return this._deletedFileList||(this._deletedFileList=new OCA.Sharing.FileList(e,{id:"shares.deleted",defaultFileActionsDisabled:!0,showDeleted:!0,sharedWithUser:!0,fileActions:this._restoreShareAction(),config:OCA.Files.App.getFilesConfig(),shown:!0}),this._extendFileList(this._deletedFileList),this._deletedFileList.appName=t("files_sharing","Deleted shares"),this._deletedFileList.$el.find("#emptycontent").html('<div class="icon-share"></div><h2>'+t("files_sharing","No deleted shares")+"</h2><p>"+t("files_sharing","Shares you deleted will show up here")+"</p>")),this._deletedFileList},initSharingPening(e){return this._pendingFileList||(this._pendingFileList=new OCA.Sharing.FileList(e,{id:"shares.pending",showPending:!0,detailsViewEnabled:!1,defaultFileActionsDisabled:!0,sharedWithUser:!0,fileActions:this._acceptShareAction(),config:OCA.Files.App.getFilesConfig(),shown:!0}),this._extendFileList(this._pendingFileList),this._pendingFileList.appName=t("files_sharing","Pending shares"),this._pendingFileList.$el.find("#emptycontent").html('<div class="icon-share"></div><h2>'+t("files_sharing","No pending shares")+"</h2><p>"+t("files_sharing","Shares you have received but not confirmed will show up here")+"</p>")),this._pendingFileList},initShareingOverview(e){return this._overviewFileList||(this._overviewFileList=new OCA.Sharing.FileList(e,{id:"shares.overview",config:OCA.Files.App.getFilesConfig(),isOverview:!0,shown:!0}),this._extendFileList(this._overviewFileList),this._overviewFileList.appName=t("files_sharing","Shares"),this._overviewFileList.$el.find("#emptycontent").html('<div class="icon-share"></div><h2>'+t("files_sharing","No shares")+"</h2><p>"+t("files_sharing","Shares will show up here")+"</p>")),this._overviewFileList},removeSharingIn(){this._inFileList&&this._inFileList.$fileList.empty()},removeSharingOut(){this._outFileList&&this._outFileList.$fileList.empty()},removeSharingLinks(){this._linkFileList&&this._linkFileList.$fileList.empty()},removeSharingDeleted(){this._deletedFileList&&this._deletedFileList.$fileList.empty()},removeSharingPending(){this._pendingFileList&&this._pendingFileList.$fileList.empty()},removeSharingOverview(){this._overviewFileList&&this._overviewFileList.$fileList.empty()},destroy(){OCA.Files.fileActions.off("setDefault.app-sharing",this._onActionsUpdated),OCA.Files.fileActions.off("registerAction.app-sharing",this._onActionsUpdated),this.removeSharingIn(),this.removeSharingOut(),this.removeSharingLinks(),this._inFileList=null,this._outFileList=null,this._linkFileList=null,this._overviewFileList=null,delete this._globalActionsInitialized},_createFileActions(){const e=new OCA.Files.FileActions;return e.registerDefaultActions(),e.merge(OCA.Files.fileActions),this._globalActionsInitialized||(this._onActionsUpdated=n.bind(this._onActionsUpdated,this),OCA.Files.fileActions.on("setDefault.app-sharing",this._onActionsUpdated),OCA.Files.fileActions.on("registerAction.app-sharing",this._onActionsUpdated),this._globalActionsInitialized=!0),e.register("dir","Open",OC.PERMISSION_READ,"",(function(e,i){OCA.Files.App.setActiveView("files",{silent:!0}),OCA.Files.App.fileList.changeDirectory(OC.joinPaths(i.$file.attr("data-path"),e),!0,!0)})),e.setDefault("dir","Open"),e},_restoreShareAction(){const e=new OCA.Files.FileActions;return e.registerAction({name:"Restore",displayName:t("files_sharing","Restore"),altText:t("files_sharing","Restore share"),mime:"all",permissions:OC.PERMISSION_ALL,iconClass:"icon-history",type:OCA.Files.FileActions.TYPE_INLINE,actionHandler(e,i){const s=i.$file.data("shareId");a.post(OC.linkToOCS("apps/files_sharing/api/v1/deletedshares",2)+s).success((function(e){i.fileList.remove(i.fileInfoModel.attributes.name)})).fail((function(){OC.Notification.showTemporary(t("files_sharing","Something happened. Unable to restore the share."))}))}}),e},_acceptShareAction(){const e=new OCA.Files.FileActions;return e.registerAction({name:"Accept share",displayName:t("files_sharing","Accept share"),mime:"all",permissions:OC.PERMISSION_ALL,iconClass:"icon-checkmark",type:OCA.Files.FileActions.TYPE_INLINE,actionHandler(e,i){const s=i.$file.data("shareId");let n="shares/pending";i.$file.attr("data-remote-id"),a.post(OC.linkToOCS("apps/files_sharing/api/v1/shares/pending",2)+s).success((function(e){i.fileList.remove(i.fileInfoModel.attributes.name)})).fail((function(){OC.Notification.showTemporary(t("files_sharing","Something happened. Unable to accept the share."))}))}}),e.registerAction({name:"Reject share",displayName:t("files_sharing","Reject share"),mime:"all",permissions:OC.PERMISSION_ALL,iconClass:"icon-close",type:OCA.Files.FileActions.TYPE_INLINE,shouldRender:e=>!e.$file.attr("data-remote-id")||parseInt(e.$file.attr("data-share-type"),10)!==OC.Share.SHARE_TYPE_REMOTE_GROUP,actionHandler(e,i){const s=i.$file.data("shareId");let n="shares";i.$file.attr("data-remote-id"),a.ajax({url:OC.linkToOCS("apps/files_sharing/api/v1/shares",2)+s,type:"DELETE"}).success((function(e){i.fileList.remove(i.fileInfoModel.attributes.name)})).fail((function(){OC.Notification.showTemporary(t("files_sharing","Something happened. Unable to reject the share."))}))}}),e},_onActionsUpdated(e){n.each([this._inFileList,this._outFileList,this._linkFileList],(function(i){i&&(e.action?i.fileActions.registerAction(e.action):e.defaultAction&&i.fileActions.setDefault(e.defaultAction.mime,e.defaultAction.name))}))},_extendFileList(e){e.fileSummary.$el.find(".filesize").remove()}},window.addEventListener("DOMContentLoaded",(function(){a("#app-content-sharingin").on("show",(function(e){OCA.Sharing.App.initSharingIn(a(e.target))})),a("#app-content-sharingin").on("hide",(function(){OCA.Sharing.App.removeSharingIn()})),a("#app-content-sharingout").on("show",(function(e){OCA.Sharing.App.initSharingOut(a(e.target))})),a("#app-content-sharingout").on("hide",(function(){OCA.Sharing.App.removeSharingOut()})),a("#app-content-sharinglinks").on("show",(function(e){OCA.Sharing.App.initSharingLinks(a(e.target))})),a("#app-content-sharinglinks").on("hide",(function(){OCA.Sharing.App.removeSharingLinks()})),a("#app-content-deletedshares").on("show",(function(e){OCA.Sharing.App.initSharingDeleted(a(e.target))})),a("#app-content-deletedshares").on("hide",(function(){OCA.Sharing.App.removeSharingDeleted()})),a("#app-content-pendingshares").on("show",(function(e){OCA.Sharing.App.initSharingPening(a(e.target))})),a("#app-content-pendingshares").on("hide",(function(){OCA.Sharing.App.removeSharingPending()})),a("#app-content-shareoverview").on("show",(function(e){OCA.Sharing.App.initShareingOverview(a(e.target))})),a("#app-content-shareoverview").on("hide",(function(){OCA.Sharing.App.removeSharingOverview()}))}))},46658:(e,i,s)=>{var n,a=s(64492),r=s(19755);(n=function(e,i){this.initialize(e,i)}).prototype=a.extend({},OCA.Files.FileList.prototype,{appName:"Shares",_sharedWithUser:!1,_linksOnly:!1,_showDeleted:!1,_showPending:!1,_clientSideSort:!0,_allowSelection:!1,_isOverview:!1,initialize:function(e,i){OCA.Files.FileList.prototype.initialize.apply(this,arguments),this.initialized||(i&&i.sharedWithUser&&(this._sharedWithUser=!0),i&&i.linksOnly&&(this._linksOnly=!0),i&&i.showDeleted&&(this._showDeleted=!0),i&&i.showPending&&(this._showPending=!0),i&&i.isOverview&&(this._isOverview=!0))},_renderRow:function(){return OCA.Files.FileList.prototype._renderRow.apply(this,arguments)},_createRow:function(e){var i=OCA.Files.FileList.prototype._createRow.apply(this,arguments);if(i.find(".filesize").remove(),i.find("td.date").before(i.children("td:first")),i.find("td.filename input:checkbox").remove(),i.attr("data-share-id",a.pluck(e.shares,"id").join(",")),this._sharedWithUser){i.attr("data-share-owner",e.shareOwner),i.attr("data-mounttype","shared-root");var s=parseInt(i.attr("data-permissions"))|OC.PERMISSION_DELETE;i.attr("data-permissions",s)}if((this._showDeleted||this._showPending)&&(s=e.permissions,i.attr("data-share-permissions",s)),e.remoteId&&i.attr("data-remote-id",e.remoteId),e.shareType&&i.attr("data-share-type",e.shareType),this._linksOnly){var n=0;e.shares&&null!==e.shares[0].expiration&&(n=moment(e.shares[0].expiration).valueOf()),i.attr("data-expiration",n);var h,o,l=Math.round((n-(new Date).getTime())/1e3/60/60/24*5);l>=160&&(l=160),n>0?(h=OC.Util.formatDate(n),o=OC.Util.relativeModifiedDate(n)):(h=t("files_sharing","No expiration date set"),o="",l=160),td=r("<td></td>").attr({class:"date"}),td.append(r("<span></span>").attr({class:"modified",title:h,style:"color:rgb("+l+","+l+","+l+")"}).text(o).tooltip({placement:"top"})),i.append(td)}return i},setSharedWithUser:function(e){this._sharedWithUser=!!e},updateEmptyContent:function(){var e=this.getCurrentDirectory();"/"===e?(this.$el.find("#emptycontent").toggleClass("hidden",!this.isEmpty),this.$el.find("#filestable thead th").toggleClass("hidden",this.isEmpty),this._linksOnly||this.$el.find("th.column-expiration").addClass("hidden")):OCA.Files.FileList.prototype.updateEmptyContent.apply(this,arguments)},getDirectoryPermissions:function(){return OC.PERMISSION_READ|OC.PERMISSION_DELETE},updateStorageStatistics:function(){},updateRow:function(e,i,t){return e},reload:function(){this.showMask(),this._reloadCall&&this._reloadCall.abort(),this._setCurrentDir("/",!1);var e=[],i={url:OC.linkToOCS("apps/files_sharing/api/v1",2)+"deletedshares",data:{format:"json",include_tags:!0},type:"GET",beforeSend:function(e){e.setRequestHeader("OCS-APIREQUEST","true")}},t={url:OC.linkToOCS("apps/files_sharing/api/v1/shares",2)+"pending",data:{format:"json"},type:"GET",beforeSend:function(e){e.setRequestHeader("OCS-APIREQUEST","true")}},s={url:OC.linkToOCS("apps/files_sharing/api/v1/remote_shares",2)+"pending",data:{format:"json"},type:"GET",beforeSend:function(e){e.setRequestHeader("OCS-APIREQUEST","true")}},n={url:OC.linkToOCS("apps/files_sharing/api/v1")+"shares",data:{format:"json",shared_with_me:!1!==this._sharedWithUser,include_tags:!0},type:"GET",beforeSend:function(e){e.setRequestHeader("OCS-APIREQUEST","true")}},a={url:OC.linkToOCS("apps/files_sharing/api/v1")+"remote_shares",data:{format:"json",include_tags:!0},type:"GET",beforeSend:function(e){e.setRequestHeader("OCS-APIREQUEST","true")}};this._showDeleted?e.push(r.ajax(i)):this._showPending?(e.push(r.ajax(t)),e.push(r.ajax(s))):(e.push(r.ajax(n)),(!1!==this._sharedWithUser||this._isOverview)&&e.push(r.ajax(a)),this._isOverview&&(n.data.shared_with_me=!n.data.shared_with_me,e.push(r.ajax(n)))),this._reloadCall=r.when.apply(r,e);var h=this.reloadCallback.bind(this);return this._reloadCall.then(h,h)},reloadCallback:function(e,i,s){delete this._reloadCall,this.hideMask(),this.$el.find("#headerSharedWith").text(t("files_sharing",this._sharedWithUser?"Shared by":"Shared with"));var n=[];return e[0]&&e[0].ocs&&(e=e[0]),i&&i[0]&&i[0].ocs&&(i=i[0]),s&&s[0]&&s[0].ocs&&(s=s[0]),e.ocs&&e.ocs.data&&(n=n.concat(this._makeFilesFromShares(e.ocs.data,this._sharedWithUser))),i&&i.ocs&&i.ocs.data&&(n=n.concat(this._makeFilesFromRemoteShares(i.ocs.data))),s&&s.ocs&&s.ocs.data&&(n=this._showPending?n.concat(this._makeFilesFromRemoteShares(s.ocs.data)):n.concat(this._makeFilesFromShares(s.ocs.data,!this._sharedWithUser))),this.setFiles(n),!0},_makeFilesFromRemoteShares:function(e){var i=e;return a.chain(i).map((function(e){var i={shareOwner:e.owner+"@"+e.remote.replace(/.*?:\/\//g,""),name:OC.basename(e.mountpoint),mtime:1e3*e.mtime,mimetype:e.mimetype,type:e.type,shareType:1===parseInt(e.share_type,10)?OC.Share.SHARE_TYPE_REMOTE_GROUP:OC.Share.SHARE_TYPE_REMOTE,id:e.file_id,path:OC.dirname(e.mountpoint),permissions:e.permissions,tags:e.tags||[]};return e.remote_id&&("1"!==e.accepted&&(i.name=OC.basename(e.name),i.path="/"),i.remoteId=e.remote_id,i.shareOwnerId=e.owner),i.mimetype||(i.mimetype="dir-shared"),i.shares=[{id:e.id,type:OC.Share.SHARE_TYPE_REMOTE}],i})).value()},_makeFilesFromShares:function(e,i){var t=e;return this._linksOnly&&(t=a.filter(e,(function(e){return e.share_type===OC.Share.SHARE_TYPE_LINK}))),t=a.chain(t).map((function(e){var t={id:e.file_source,icon:OC.MimeType.getIconUrl(e.mimetype),mimetype:e.mimetype,hasPreview:e.has_preview,tags:e.tags||[]};return"folder"===e.item_type?(t.type="dir",t.mimetype="httpd/unix-directory"):t.type="file",t.share={id:e.id,type:e.share_type,target:e.share_with,stime:1e3*e.stime,expiration:e.expiration},i?(t.shareOwner=e.displayname_owner,t.shareOwnerId=e.uid_owner,t.name=OC.basename(e.file_target),t.path=OC.dirname(e.file_target),t.permissions=e.permissions,t.path&&(t.extraData=e.file_target)):(e.share_type!==OC.Share.SHARE_TYPE_LINK&&(t.share.targetDisplayName=e.share_with_displayname,t.share.targetShareWithId=e.share_with),t.name=OC.basename(e.path),t.path=OC.dirname(e.path),t.permissions=OC.PERMISSION_ALL,t.path&&(t.extraData=e.path)),t})).reduce((function(e,i){var t=e[i.id],s=i.share.targetDisplayName,n=i.share.targetShareWithId;return t?(i.share.stime>t.mtime&&(t.mtime=i.share.stime),t.shares.push(i.share)):((t=e[i.id]=i).shares=[i.share],t.recipients={},t.recipientData={},t.shareTypes={},t.recipientsCount=0,t.mtime=i.share.stime),s&&(t.recipientsCount<4&&(t.recipients[s]=!0,t.recipientData[t.recipientsCount]={shareWith:n,shareWithDisplayName:s}),t.recipientsCount++),t.shareTypes[i.share.type]=!0,delete i.share,e}),{}).values().each((function(e){e.mountType="shared",delete e.recipientsCount,i?delete e.shareTypes:e.shareTypes=a.keys(e.shareTypes)})).value(),t.sort(this._sortComparator)}}),OCA.Sharing.FileList=n},35270:(e,i,t)=>{"use strict";t(24839),t(46658),t.nc=btoa(OC.requestToken),t.p=OC.linkTo("files_sharing","js/dist/")}},s={};function n(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={id:e,loaded:!1,exports:{}};return i[e].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}n.m=i,n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},e=[],n.O=(i,t,s,a)=>{if(!t){var r=1/0;for(d=0;d<e.length;d++){t=e[d][0],s=e[d][1],a=e[d][2];for(var h=!0,o=0;o<t.length;o++)(!1&a||r>=a)&&Object.keys(n.O).every((e=>n.O[e](t[o])))?t.splice(o--,1):(h=!1,a<r&&(r=a));if(h){e.splice(d--,1);var l=s();void 0!==l&&(i=l)}}return i}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[t,s,a]},n.n=e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return n.d(i,{a:i}),i},n.d=(e,i)=>{for(var t in i)n.o(i,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n.j=691,n.p="/dist/",(()=>{var e={691:0};n.O.j=i=>0===e[i];var i=(i,t)=>{var s,a,r=t[0],h=t[1],o=t[2],l=0;if(r.some((i=>0!==e[i]))){for(s in h)n.o(h,s)&&(n.m[s]=h[s]);if(o)var d=o(n)}for(i&&i(t);l<r.length;l++)a=r[l],n.o(e,a)&&e[a]&&e[a][0](),e[r[l]]=0;return n.O(d)},t=self.webpackChunknextcloud=self.webpackChunknextcloud||[];t.forEach(i.bind(null,0)),t.push=i.bind(null,t.push.bind(t))})();var a=n.O(void 0,[820],(()=>n(35270)));a=n.O(a)})();
//# sourceMappingURL=files_sharing-files_sharing.js.map?v=12005e0b36b84107915b