nextcloud/dist/files-sidebar.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

2 lines
62 KiB
JavaScript
Raw Permalink Normal View History

(()=>{var e,i,r,a={958:(e,i,r)=>{"use strict";var a=r(53334),s=r(85471),n=r(9165),o=r(21777),l=r(65043),c=r(87485),d=r(85168),u=r(61338),p=r(35810),f=r(71225),h=r(63814),m=r(40715),g=r(74692),E=r.n(g),A=r(57505),T=r(29333),I=r(4604),b=r(11275),v=r(6695),y=r(77764),N=r(81222),_=r(88289),C=r(5212),w=r(1822);const O=(0,w.c)();async function S(t){const e=(0,w.l)(),i=await O.stat(`${(0,w.g)()}${t}`,{details:!0,data:e});return(0,w.r)(i.data)}var L=r(35947);const R=(0,L.YK)().setApp("systemtags").detectUser().build();r(56760);var D=r(71654);const F={userVisible:!0,userAssignable:!0,canAssign:!0};function P(t){return t.map(t=>{let{props:e}=t;return Object.fromEntries(Object.entries(e).map(t=>{let[e,i]=t;return[(0,D.A)(e),"displayName"===(0,D.A)(e)?String(i):i]}))})}function x(t){if("name"in t&&!("displayName"in t))return{...t};const e={...t};return e.name=e.displayName,delete e.displayName,e}var M=r(45505);const $=(0,h.dC)("dav"),U=(0,M.UU)($);function B(t){U.setHeaders({"X-Requested-With":"XMLHttpRequest",requesttoken:t??""})}(0,o.zo)(B),B((0,o.do)());const V='<?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>';async function H(t){const e="/systemtags-relations/files/"+t;try{const{data:t}=await U.getDirectoryContents(e,{data:V,details:!0,glob:"/systemtags-relations/files/*/*"});return P(t)}catch(t){throw R.error((0,a.t)("systemtags","Failed to load tags for file"),{error:t}),new Error((0,a.t)("systemtags","Failed to load tags for file"))}}async function G(t,e){const i="/systemtags-relations/files/"+e+"/"+t.id,r=x(t);try{await U.customRequest(i,{method:"PUT",data:r})}catch(t){throw R.error((0,a.t)("systemtags","Failed to set tag for file"),{error:t}),new Error((0,a.t)("systemtags","Failed to set tag for file"))}}const k=s.Ay.extend({name:"SystemTags",components:{NcLoadingIcon:_.A,NcSelectTags:C.A},props:{fileId:{type:Number,required:!0},disabled:{type:Boolean,default:!1}},data:()=>({sortedTags:[],selectedTags:[],loadingTags:!1,loading:!1}),watch:{fileId:{immediate:!0,async handler(){this.loadingTags=!0;try{this.selectedTags=await H(this.fileId)}catch(t){(0,d.Qg)((0,a.t)("systemtags","Failed to load selected tags")),R.error("Failed to load selected tags",{error:t})}this.loadingTags=!1}}},async created(){try{const t=await async function(){try{const{data:t}=await U.getDirectoryContents("/systemtags",{data:V,details:!0,glob:"/systemtags/*"});return P(t)}catch(t){throw R.error((0,a.t)("systemtags","Failed to load tags"),{error:t}),new Error((0,a.t)("systemtags","Failed to load tags"))}}(),e=await async function(){const t=(0,h.Jv)("/apps/systemtags/lastused");try{const{data:e}=await l.Ay.get(t);return e.map(Number)}catch(t){throw R.error((0,a.t)("systemtags","Failed to load last used tags"),{error:t}),new Error((0,a.t)("systemtags","Failed to load last used tags"))}}(),i=[],r=[];for(const a of t)e.includes(a.id)?i.push(a):r.push(a);const s=(t,i)=>e.indexOf(t.id)-e.indexOf(i.id);i.sort(s),this.sortedTags=[...i,...r]}catch(t){(0,d.Qg)((0,a.t)("systemtags","Failed to load tags")),R.error("Failed to load tags",{error:t})}},mounted(){(0,u.B1)("systemtags:node:updated",this.onTagUpdated)},methods:{t:a.t,createOption(t){for(const e of this.sortedTags){const{displayName:i,...r}=e;if(i===t&&Object.entries(r).every(t=>{let[e,i]=t;return F[e]===i}))return e}return{...F,displayName:t}},handleInput(t){this.selectedTags=t.filter(t=>Boolean(t.id))},async handleSelect(t){const e=t[t.length-1];if(!e.id)return;const i=e;this.loading=!0;try{await G(i,this.fileId);const t=(t,e)=>t.id===i.id?-1:e.id===i.id?1:0;this.sortedTags.sort(t)}catch(t){(0,d.Qg)((0,a.t)("systemtags","Failed to select tag")),R.error("Failed to select tag",{error:t})}this.loading=!1,this.updateAndDispatchNodeTagsEvent(this.fileId)},async handleCreate(t){this.loading=!0;try{const e=await async function(t,e){const i=x(t),r=await
//# sourceMappingURL=files-sidebar.js.map?v=d334ded7f5759ba217a6