1
2
|
(()=>{var t,e,s,a={58296:(t,e,s)=>{"use strict";var a=s(21777),r=s(85471),n=s(59892),i=s(88837),o=s(53334),l=s(85168),d=s(32051),c=s(67607),g=s(5212),u=s(82182),m=s(71654);const p={userVisible:!0,userAssignable:!0,canAssign:!0};var h=s(65043),y=s(63814),v=s(60669);const b=(0,y.dC)("dav"),f=(0,v.UU)(b),A=t=>{f.setHeaders({"X-Requested-With":"XMLHttpRequest",requesttoken:t??""})};(0,a.zo)(A),A((0,a.do)());const T=(0,s(35947).YK)().setApp("systemtags").detectUser().build();var C=s(61338),_=s(56760);var w;!function(t){t.Public="Public",t.Restricted="Restricted",t.Invisible="Invisible"}(w||(w={}));const x=[{id:w.Public,label:(0,o.Tl)("systemtags","Public")},{id:w.Restricted,label:(0,o.Tl)("systemtags","Restricted")},{id:w.Invisible,label:(0,o.Tl)("systemtags","Invisible")}],N=(t,e)=>({[[!0,!0].join(",")]:w.Public,[[!0,!1].join(",")]:w.Restricted,[[!1,!1].join(",")]:w.Invisible}[[t,e].join(",")]),S=r.Ay.extend({name:"SystemTagForm",components:{NcButton:d.A,NcLoadingIcon:n.A,NcSelect:c.A,NcSelectTags:g.A,NcTextField:u.A},props:{tags:{type:Array,required:!0}},data:()=>({loading:!1,tagLevelOptions:x,selectedTag:null,errorMessage:"",tagName:"",tagLevel:w.Public}),watch:{selectedTag(t){this.tagName=t?t.displayName:"",this.tagLevel=t?N(t.userVisible,t.userAssignable):w.Public}},computed:{isCreating(){return null===this.selectedTag},isCreateDisabled(){return""===this.tagName},isUpdateDisabled(){return""===this.tagName||this.selectedTag?.displayName===this.tagName&&N(this.selectedTag?.userVisible,this.selectedTag?.userAssignable)===this.tagLevel},isResetDisabled(){return this.isCreating?""===this.tagName&&this.tagLevel===w.Public:null===this.selectedTag},userVisible(){return{[w.Public]:!0,[w.Restricted]:!0,[w.Invisible]:!1}[this.tagLevel]},userAssignable(){return{[w.Public]:!0,[w.Restricted]:!1,[w.Invisible]:!1}[this.tagLevel]},tagProperties(){return{displayName:this.tagName,userVisible:this.userVisible,userAssignable:this.userAssignable}}},methods:{t:o.Tl,async handleSubmit(){this.isCreating?await this.create():await this.update()},async create(){const t={...p,...this.tagProperties};this.loading=!0;try{const e=await(async t=>{const e=(t=>{if("name"in t&&!("displayName"in t))return{...t};const e={...t};return e.name=e.displayName,delete e.displayName,e})(t);try{const{headers:s}=await f.customRequest("/systemtags",{method:"POST",data:e}),a=s.get("content-location");if(a)return(0,C.Ic)("systemtags:tag:created",t),(t=>{const e=t.indexOf("?");e>0&&(t=t.substring(0,e));const s=t.split("/");let a;do{a=s[s.length-1],s.pop()}while(!a&&s.length>0);return Number(a)})(a);throw T.error((0,o.t)("systemtags",'Missing "Content-Location" header')),new Error((0,o.t)("systemtags",'Missing "Content-Location" header'))}catch(t){if(409===t?.response?.status)throw T.error((0,o.t)("systemtags","A tag with the same name already exists"),{error:t}),new Error((0,o.t)("systemtags","A tag with the same name already exists"));throw T.error((0,o.t)("systemtags","Failed to create tag"),{error:t}),new Error((0,o.t)("systemtags","Failed to create tag"))}})(t),s={...t,id:e};this.$emit("tag:created",s),(0,l.Te)((0,o.Tl)("systemtags","Created tag")),this.reset()}catch(t){this.errorMessage=(0,o.Tl)("systemtags","Failed to create tag")}this.loading=!1},async update(){if(null===this.selectedTag)return;const t={...this.selectedTag,...this.tagProperties};this.loading=!0;try{await(async t=>{const e="/systemtags/"+t.id,s=`<?xml version="1.0"?>\n\t<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">\n\t\t<d:set>\n\t\t\t<d:prop>\n\t\t\t\t<oc:display-name>${t.displayName}</oc:display-name>\n\t\t\t\t<oc:user-visible>${t.userVisible}</oc:user-visible>\n\t\t\t\t<oc:user-assignable>${t.userAssignable}</oc:user-assignable>\n\t\t\t\t<nc:color>${t?.color||null}</nc:color>\n\t\t\t</d:prop>\n\t\t</d:set>\n\t</d:propertyupdate>`;try{await f.customRequest(e,{method:"PROPPATCH",data:s}),(0,C.Ic)("systemtags:tag:updated",t)}catch(t){throw T.error((0,o.t)("systemtags","Failed to update tag"),{error:t}),new Error((0,o.t)("systemtags","Failed to update tag"))}})(t),this.selectedTag=t,this.$emit("tag:updated",t),(0,l.Te)((0,o.Tl)("systemtags","Updated tag")),this.$refs.tagNameInput?.focus()}catch(t){this.errorMessage=(0,o.Tl)("systemtags","Failed to update tag")}this.loading=!1},async handleDelete(){if(null!==this.selectedTag){this.loading=!0;try{await(async t=>{const e="/systemtags/"+t.id;try{await f.deleteFile(e),(0,C.Ic)("systemtags:tag:deleted",t)}catch(t){throw T.error((0,o.t)("systemtags","Failed to delete tag"),{error:t}),new Error((0,o.t)("systemtags","Failed to delete tag"))}})(this.selectedTag),this.$emit("tag:deleted",this.selectedTag),(0,l.Te)((0,o.Tl)("systemtags","Deleted tag")),this.reset()}catch(t){this.errorMessage=(0,o.Tl)("systemtags","Failed to delete tag")}this.loading=!1}},reset(){this.selectedTag=null,this.errorMessage="",this.tagName="",this.tagLevel=w.Public,this.$refs.tagNameInput?.focus()}}});var R=s(85072),P=s.n(R),k=s(97825),I=s.n(k),L=s(77659),O=s.n(L),D=s(55056),F=s.n(D),j=s(10540),E=s.n(j),M=s(41113),$=s.n(M),U=s(91302),B={};B.styleTagTransform=$(),B.setAttributes=F(),B.insert=O().bind(null,"head"),B.domAPI=I(),B.insertStyleElement=E(),P()(U.A,B),U.A&&U.A.locals&&U.A.locals;var V=s(14486);const q=(0,V.A)(S,(function(){var t=this,e=t._self._c;return t._self._setupProxy,e("form",{staticClass:"system-tag-form",attrs:{disabled:t.loading,"aria-labelledby":"system-tag-form-heading"},on:{submit:function(e){return e.preventDefault(),t.handleSubmit.apply(null,arguments)},reset:t.reset}},[e("h4",{attrs:{id:"system-tag-form-heading"}},[t._v("\n\t\t"+t._s(t.t("systemtags","Create or edit tags"))+"\n\t")]),t._v(" "),e("div",{staticClass:"system-tag-form__group"},[e("label",{attrs:{for:"system-tags-input"}},[t._v(t._s(t.t("systemtags","Search for a tag to edit")))]),t._v(" "),e("NcSelectTags",{attrs:{"input-id":"system-tags-input",placeholder:t.t("systemtags","Collaborative tags …"),"fetch-tags":!1,options:t.tags,multiple:!1,passthru:""},scopedSlots:t._u([{key:"no-options",fn:function(){return[t._v("\n\t\t\t\t"+t._s(t.t("systemtags","No tags to select"))+"\n\t\t\t")]},proxy:!0}]),model:{value:t.selectedTag,callback:function(e){t.selectedTag=e},expression:"selectedTag"}})],1),t._v(" "),e("div",{staticClass:"system-tag-form__group"},[e("label",{attrs:{for:"system-tag-name"}},[t._v(t._s(t.t("systemtags","Tag name")))]),t._v(" "),e("NcTextField",{ref:"tagNameInput",attrs:{id:"system-tag-name",value:t.tagName,error:Boolean(t.errorMessage),"helper-text":t.errorMessage,"label-outside":""},on:{"update:value":function(e){t.tagName=e}}})],1),t._v(" "),e("div",{staticClass:"system-tag-form__group"},[e("label",{attrs:{for:"system-tag-level"}},[t._v(t._s(t.t("systemtags","Tag level")))]),t._v(" "),e("NcSelect",{attrs:{"input-id":"system-tag-level",options:t.tagLevelOptions,reduce:t=>t.id,clearable:!1,disabled:t.loading},model:{value:t.tagLevel,callback:function(e){t.tagLevel=e},expression:"tagLevel"}})],1),t._v(" "),e("div",{staticClass:"system-tag-form__row"},[t.isCreating?e("NcButton",{attrs:{"native-type":"submit",disabled:t.isCreateDisabled||t.loading}},[t._v("\n\t\t\t"+t._s(t.t("systemtags","Create"))+"\n\t\t")]):[e("NcButton",{attrs:{"native-type":"submit",disabled:t.isUpdateDisabled||t.loading}},[t._v("\n\t\t\t\t"+t._s(t.t("systemtags","Update"))+"\n\t\t\t")]),t._v(" "),e("NcButton",{attrs:{disabled:t.loading},on:{click:t.handleDelete}},[t._v("\n\t\t\t\t"+t._s(t.t("systemtags","Delete"))+"\n\t\t\t")])],t._v(" "),e("NcButton",{attrs:{"native-type":"reset",disabled:t.isResetDisabled||t.loading}},[t._v("\n\t\t\t"+t._s(t.t("systemtags","Reset"))+"\n\t\t")]),t._v(" "),t.loading?e("NcLoadingIcon",{attrs:{name:t.t("systemtags","Loading …"),size:32}}):t._e()],2)])}),[],!1,null,"5f3682a2",null).exports;var Y=s(32981);const z={name:"SystemTagsCreationControl",components:{NcCheckboxRadioSwitch:s(32073).A},setup:()=>({t:o.t}),data:()=>({systemTagsCreationRestrictedToAdmin:(0,Y.C)("settings","restrictSystemTagsCreationToAdmin",!1)}),methods:{async updateSystemTagsDefault(t){try{const e=await(async t=>{const e=t?"1":"0",s=(0,y.KT)("/apps/provisioning_api/api/v1/config/apps/{appId}/{key}",{appId:"systemtags",key:"restrict_creation_to_admin"});return await(0,_.C5)(),(await h.Ay.post(s,{value:e})).data})(t);console.debug("updateSystemTagsDefault",e),this.handleResponse({isRestricted:t,status:e.ocs?.meta?.status})}catch(t){this.handleResponse({errorMessage:(0,o.t)("settings","Unable to update setting"),error:t})}},handleResponse(t){let{isRestricted:e,status:s,errorMessage:a,error:r}=t;if("ok"===s)return this.systemTagsCreationRestrictedToAdmin=e,void(0,l.Te)(e?(0,o.t)("settings","System tag creation is now restricted to administrators"):(0,o.t)("settings","System tag creation is now allowed for everybody"));a&&((0,l.Qg)(a),T.error(a,r))}}},H=(0,V.A)(z,(function(){var t=this,e=t._self._c;return e("div",{attrs:{id:"system-tags-creation-control"}},[e("h4",{staticClass:"inlineblock"},[t._v("\n\t\t"+t._s(t.t("settings","System tag management"))+"\n\t")]),t._v(" "),e("p",{staticClass:"settings-hint"},[t._v("\n\t\t"+t._s(t.t("settings","If enabled, only administrators can create and edit tags. Accounts can still assign and remove them from files."))+"\n\t")]),t._v(" "),e("NcCheckboxRadioSwitch",{attrs:{type:"switch",checked:t.systemTagsCreationRestrictedToAdmin},on:{"update:checked":[function(e){t.systemTagsCreationRestrictedToAdmin=e},t.updateSystemTagsDefault]}},[t._v("\n\t\t"+t._s(t.t("settings","Restrict tag creation and editing to administrators"))+"\n\t")])],1)}),[],!1,null,null,null).exports,K=r.Ay.extend({name:"SystemTagsSection",components:{NcLoadingIcon:n.A,NcSettingsSection:i.A,SystemTagForm:q,SystemTagsCreationControl:H},data:()=>({loadingTags:!1,tags:[]}),async created(){this.loadingTags=!0;try{this.tags=await(async()=>{try{const{data:t}=await f.getDirectoryContents("/systemtags",{data:'<?xml version="1.0"?>\n<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">\n\t<d:prop>\n\t\t<oc:id />\n\t\t<oc:display-name />\n\t\t<oc:user-visible />\n\t\t<oc:user-assignable />\n\t\t<oc:can-assign />\n\t\t<d:getetag />\n\t\t<nc:color />\n\t</d:prop>\n</d:propfind>',details:!0,glob:"/systemtags/*"});return(t=>t.map((t=>{let{props:e}=t;return Object.fromEntries(Object.entries(e).map((t=>{let[e,s]=t;return[(0,m.A)(e),"displayName"===(0,m.A)(e)?String(s):s]})))})))(t)}catch(t){throw T.error((0,o.t)("systemtags","Failed to load tags"),{error:t}),new Error((0,o.t)("systemtags","Failed to load tags"))}})()}catch(t){(0,l.Qg)((0,o.Tl)("systemtags","Failed to load tags"))}this.loadingTags=!1},methods:{t:o.Tl,handleCreate(t){this.tags.unshift(t)},handleUpdate(t){const e=this.tags.findIndex((e=>e.id===t.id));this.tags.splice(e,1),this.tags.unshift(t)},handleDelete(t){const e=this.tags.findIndex((e=>e.id===t.id));this.tags.splice(e,1)}}}),Q=(0,V.A)(K,(function(){var t=this,e=t._self._c;return t._self._setupProxy,e("NcSettingsSection",{attrs:{name:t.t("systemtags","Collaborative tags"),description:t.t("systemtags","Collaborative tags are available for all users. Restricted tags are visible to users but cannot be assigned by them. Invisible tags are for internal use, since users cannot see or assign them.")}},[e("SystemTagsCreationControl"),t._v(" "),t.loadingTags?e("NcLoadingIcon",{attrs:{name:t.t("systemtags","Loading collaborative tags …"),size:32}}):e("SystemTagForm",{attrs:{tags:t.tags},on:{"tag:created":t.handleCreate,"tag:updated":t.handleUpdate,"tag:deleted":t.handleDelete}})],1)}),[],!1,null,null,null).exports;s.nc=(0,a.aV)(),(new(r.Ay.extend(Q))).$mount("#vue-admin-systemtags")},91302:(t,e,s)=>{"use strict";s.d(e,{A:()=>o});var a=s(71354),r=s.n(a),n=s(76314),i=s.n(n)()(r());i.push([t.id,".system-tag-form[data-v-5f3682a2]{display:flex;flex-direction:column;max-width:400px;gap:8px 0}.system-tag-form__group[data-v-5f3682a2]{display:flex;flex-direction:column}.system-tag-form__row[data-v-5f3682a2]{margin-top:8px;display:flex;gap:0 4px}","",{version:3,sources:["webpack://./apps/systemtags/src/components/SystemTagForm.vue"],names:[],mappings:"AACA,kCACC,YAAA,CACA,qBAAA,CACA,eAAA,CACA,SAAA,CAEA,yCACC,YAAA,CACA,qBAAA,CAGD,uCACC,cAAA,CACA,YAAA,CACA,SAAA",sourcesContent:["\n.system-tag-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tmax-width: 400px;\n\tgap: 8px 0;\n\n\t&__group {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t}\n\n\t&__row {\n\t\tmargin-top: 8px;\n\t\tdisplay: flex;\n\t\tgap: 0 4px;\n\t}\n}\n"],sourceRoot:""}]);const o=i},42634:()=>{},63779:()=>{},77199:()=>{},59169:()=>{},86833:()=>{}},r={};function n(t){var e=r[t];if(void 0!==e)return e.exports;var s=r[t]={id:t,loaded:!1,exports:{}};return a[t].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}n.m=a,t=[],n.O=(e,s,a,r)=>{if(!s){var i=1/0;for(c=0;c<t.length;c++){s=t[c][0],a=t[c][1],r=t[c][2];for(var o=!0,l=0;l<s.length;l++)(!1&r||i>=r)&&Object.keys(n.O).every((t=>n.O[t](s[l])))?s.splice(l--,1):(o=!1,r<i&&(i=r));if(o){t.splice(c--,1);var d=a();void 0!==d&&(e=d)}}return e}r=r||0;for(var c=t.length;c>0&&t[c-1][2]>r;c--)t[c]=t[c-1];t[c]=[s,a,r]},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.f={},n.e=t=>Promise.all(Object.keys(n.f).reduce(((e,s)=>(n.f[s](t,e),e)),[])),n.u=t=>t+"-"+t+".js?v="+{2441:"fc741cf57e9647f370a3",5862:"142cd48ca8ec32e57725",7874:"cd16576625b0c6e0d277"}[t],n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),e={},s="nextcloud:",n.l=(t,a,r,i)=>{if(e[t])e[t].push(a);else{var o,l;if(void 0!==r)for(var d=document.getElementsByTagName("script"),c=0;c<d.length;c++){var g=d[c];if(g.getAttribute("src")==t||g.getAttribute("data-webpack")==s+r){o=g;break}}o||(l=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,n.nc&&o.setAttribute("nonce",n.nc),o.setAttribute("data-webpack",s+r),o.src=t),e[t]=[a];var u=(s,a)=>{o.onerror=o.onload=null,clearTimeout(m);var r=e[t];if(delete e[t],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach((t=>t(a))),s)return s(a)},m=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),l&&document.head.appendChild(o)}},n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),n.j=6349,(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var s=e.getElementsByTagName("script");if(s.length)for(var a=s.length-1;a>-1&&(!t||!/^http(s?):/.test(t));)t=s[a--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),(()=>{n.b=document.baseURI||self.location.href;var t={6349:0};n.f.j=(e,s)=>{var a=n.o(t,e)?t[e]:void 0;if(0!==a)if(a)s.push(a[2]);else{var r=new Promise(((s,r)=>a=t[e]=[s,r]));s.push(a[2]=r);var i=n.p+n.u(e),o=new Error;n.l(i,(s=>{if(n.o(t,e)&&(0!==(a=t[e])&&(t[e]=void 0),a)){var r=s&&("load"===s.type?"missing":s.type),i=s&&s.target&&s.target.src;o.message="Loading chunk "+e+" failed.\n("+r+": "+i+")",o.name="ChunkLoadError",o.type=r,o.request=i,a[1](o)}}),"chunk-"+e,e)}},n.O.j=e=>0===t[e];var e=(e,s)=>{var a,r,i=s[0],o=s[1],l=s[2],d=0;if(i.some((e=>0!==t[e]))){for(a in o)n.o(o,a)&&(n.m[a]=o[a]);if(l)var c=l(n)}for(e&&e(s);d<i.length;d++)r=i[d],n.o(t,r)&&t[r]&&t[r][0](),t[r]=0;return n.O(c)},s=self.webpackChunknextcloud=self.webpackChunknextcloud||[];s.forEach(e.bind(null,0)),s.push=e.bind(null,s.push.bind(s))})(),n.nc=void 0;var i=n.O(void 0,[4208],(()=>n(58296)));i=n.O(i)})();
//# sourceMappingURL=systemtags-admin.js.map?v=8ca661e4ef84d3184c61
|