federatedfilesharing-external.mjs 2.5 KB

12
  1. /*! third party licenses: dist/vendor.LICENSE.txt */
  2. import{b_ as h,bZ as s}from"./core-common.mjs";window.OCA.Sharing=window.OCA.Sharing||{},window.OCA.Sharing.showAddExternalDialog=function(e,o,i){const n=e.remote,r=e.ownerDisplayName||e.owner,a=e.name,l=n.replace(/^https?:\/\//,"").replace(/\/$/,"");o?window.OC.dialogs.prompt(t("files_sharing","Do you want to add the remote share {name} from {owner}@{remote}?",{name:a,owner:r,remote:l}),t("files_sharing","Remote share"),function(d,f){e.password=f,i(d,e)},!0,t("files_sharing","Remote share password"),!0).then(this._adjustDialog):window.OC.dialogs.confirm(t("files_sharing","Do you want to add the remote share {name} from {owner}@{remote}?",{name:a,owner:r,remote:l}),t("files_sharing","Remote share"),function(d){i(d,e)},!0).then(this._adjustDialog)},window.OCA.Sharing._adjustDialog=function(){const e=$(".oc-dialog:visible"),o=e.find("button");e.find(".ui-icon").remove(),o.eq(1).text(t("core","Cancel")),o.eq(2).text(t("files_sharing","Add remote share"))};const w=function(){var e,o,i;if(!((i=(o=(e=window==null?void 0:window.OCP)==null?void 0:e.Files)==null?void 0:o.Router)!=null&&i.goToRoute)){window.location.reload();return}window.OCP.Files.Router.goToRoute(null,{...window.OCP.Files.Router.params,fileid:void 0},{...window.OCP.Files.Router.query,dir:"/",openfile:void 0})},c=function(){const e=window.OC.Util.History.parseUrlQuery();if(e.remote&&e.token&&e.name){const o=function(i,n){const r=n.password||"";i&&$.post(s("apps/federatedfilesharing/askForFederatedShare"),{remote:n.remote,token:n.token,owner:n.owner,ownerDisplayName:n.ownerDisplayName||n.owner,name:n.name,password:r}).done(function(a){a.hasOwnProperty("legacyMount")?w():window.OC.Notification.showTemporary(a.message)}).fail(function(a){window.OC.Notification.showTemporary(JSON.parse(a.responseText).message)})};location.hash="",e.passwordProtected=parseInt(e.protected,10)===1,window.OCA.Sharing.showAddExternalDialog(e,e.passwordProtected,o)}},p=function(){$.get(s("/apps/files_sharing/api/externalShares"),{},function(e){let o;for(o=0;o<e.length;++o)window.OCA.Sharing.showAddExternalDialog(e[o],!1,function(i,n){i?$.post(s("/apps/files_sharing/api/externalShares"),{id:n.id}).then(function(){w()}):$.ajax({url:s("/apps/files_sharing/api/externalShares/"+n.id),type:"DELETE"})})})};c(),h("federatedfilesharing","notificationsEnabled",!0)!==!0&&p(),$("body").on("window.OCA.Notification.Action",function(e){e.notification.app==="files_sharing"&&e.notification.object_type==="remote_share"&&e.action.type==="POST"&&w()});