-
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathphotos-src_mixins_FetchFilesMixin_js-src_components_Faces_FaceMergeForm_vue.js
More file actions
2 lines (2 loc) · 16.2 KB
/
photos-src_mixins_FetchFilesMixin_js-src_components_Faces_FaceMergeForm_vue.js
File metadata and controls
2 lines (2 loc) · 16.2 KB
1
2
"use strict";(self.webpackChunkphotos=self.webpackChunkphotos||[]).push([["src_mixins_FetchFilesMixin_js-src_components_Faces_FaceMergeForm_vue"],{34003:(t,e,n)=>{n.d(e,{A:()=>r});var s=n(95353),i=n(66067),a=n.n(i);const r={name:"FaceCoverMixin",computed:{...(0,s.L8)(["faces","facesFiles","files"])},methods:{getFaceCover(t){return JSON.parse(a().decode(this.faces[t].props["face-preview-image"]||"{}"))},getCoverStyle(t){const e=this.getFaceCover(t);if(!e||!e.detection)return{};const n=e.detection,s=Math.max(1,1/n.width*.4),i=100*(n.x+n.width/2),a=100*(n.y+n.height/2);return{width:"100%",transform:`translate(calc( var(--photos-face-width)/2 - ${i}% ), calc( var(--photos-face-width)/2 - ${a}% )) scale(${s})`,transformOrigin:`${i}% ${a}%`}}}}},44671:(e,n,s)=>{s.d(n,{A:()=>f});var i=s(95353),a=s(85168),r=s(21777),o=s(59006),c=s(63360),l=s(83456),d=s(83984),A=s(58637),h=s(66067),p=s.n(h);const f={name:"FetchFacesMixin",data:()=>({errorFetchingFaces:null,loadingFaces:!1,errorFetchingFiles:null,loadingFiles:!1}),mixins:[A.A],async beforeMount(){this.fetchFaces()},computed:{...(0,i.L8)(["faces"])},methods:{...(0,i.i0)(["appendFiles"]),async fetchFaces(){if(!this.loadingFaces&&!Object.keys(this.faces).length)try{this.loadingFaces=!0,this.errorFetchingFaces=null;const{data:t}=await o.Ay.getDirectoryContents(`/recognize/${(0,r.HW)()?.uid}/faces/`,{data:l.A,details:!0,signal:this.abortController.signal});this.$store.dispatch("addFaces",{faces:t}),c.A.debug(`[FetchFacesMixin] Fetched ${t.length} new faces: `,t)}catch(e){e.response&&e.response.status&&(404===e.response.status?this.errorFetchingFaces=404:this.errorFetchingFaces=e),c.A.error(t("photos","Failed to fetch faces list."),{error:e}),(0,a.Qg)(t("photos","Failed to fetch faces list."))}finally{this.loadingFaces=!1}},async fetchFaceContent(t,e){if(!this.loadingFiles&&(e||!this.facesFiles[t]||!this.facesFiles[t].length))try{this.errorFetchingFiles=null,this.loadingFiles=!0;let{data:e}=await o.Ay.getDirectoryContents(`/recognize/${(0,r.HW)()?.uid}/faces/${t}`,{data:l.A,details:!0,signal:this.abortController.signal});e=e.map((t=>(0,d.JR)(t))).map((t=>({...t,filename:p().decode(t.realpath).replace(`/${(0,r.HW)().uid}/files`,`/files/${(0,r.HW)().uid}`)}))).map((t=>({...t,faceDetections:JSON.parse(p().decode(t.faceDetections))})));const n=e.map((t=>""+t.fileid));this.appendFiles(e),e.length>0&&await this.$store.commit("addFilesToFace",{faceName:t,fileIdsToAdd:n}),c.A.debug(`[FetchFacesMixin] Fetched ${n.length} new files: `,n)}catch(t){t.response&&t.response.status&&(404===t.response.status?this.errorFetchingFiles=404:this.errorFetchingFiles=t),c.A.error("Error fetching face files",{error:t})}finally{this.loadingFiles=!1}},async fetchUnassignedFaces(t){if(!this.loadingFiles&&(t||!this.unassignedFiles||!this.unassignedFiles.length))try{this.errorFetchingFiles=null,this.loadingFiles=!0;let{data:t}=await o.Ay.getDirectoryContents(`/recognize/${(0,r.HW)()?.uid}/unassigned-faces`,{data:l.A,details:!0,signal:this.abortController.signal});t=t.map((t=>(0,d.JR)(t))).map((t=>({...t,filename:p().decode(t.realpath).replace(`/${(0,r.HW)().uid}/files`,`/files/${(0,r.HW)().uid}`)}))).map((t=>({...t,faceDetections:JSON.parse(p().decode(t.faceDetections))})));const e=t.map((t=>""+t.fileid));this.appendFiles(t),t.length>0&&await this.$store.commit("addUnassignedFiles",{fileIdsToAdd:e}),c.A.debug(`[FetchFacesMixin] Fetched ${e.length} new unassigned files: `,e)}catch(t){t.response&&t.response.status&&(404===t.response.status?this.errorFetchingFiles=404:this.errorFetchingFiles=t),c.A.error("Error fetching unassigned files",{error:t})}finally{this.loadingFiles=!1}},async fetchUnassignedFacesCount(){try{const{data:t}=await o.Ay.stat(`/recognize/${(0,r.HW)()?.uid}/unassigned-faces`,{data:l.A,details:!0,signal:this.abortController.signal}),e=Number(t.props.nbItems);await this.$store.commit("setUnassignedFilesCount",e),c.A.debug("[FetchFacesMixin] Fetched unassigned files count: ",e)}catch(t){c.A.error("Error fetching unassigned files count",{error:t})}}}}},96285:(t,e,n)=>{n.d(e,{A:()=>p});var s=n(93002),i=n(71225),a=n(63360),r=n(83984),o=n(98429),c=n(59006),l=n(83456),d=n(51651),A=n(76783);var h=n(31445);const p={name:"FetchFilesMixin",mixins:[n(58637).A],data:()=>({errorFetchingFiles:null,loadingFiles:!1,doneFetchingFiles:!1,fetchSemaphore:new h.A(1),fetchedFileIds:[]}),watch:{"$route.path"(){this.resetFetchFilesState()}},methods:{async fetchFiles(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.doneFetchingFiles&&!n||this.loadingFiles)return[];const h=await this.fetchSemaphore.acquire();try{this.errorFetchingFiles=null,this.loadingFiles=!0;const n=200,h=await async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t={firstResult:0,nbResults:200,mimesType:o.J_,onThisDay:!1,onlyFavorites:!1,...t};const e=t.mimesType.reduce(((t,e)=>`${t}\n\t\t<d:eq>\n\t\t\t<d:prop>\n\t\t\t\t<d:getcontenttype/>\n\t\t\t</d:prop>\n\t\t\t<d:literal>${e}</d:literal>\n\t\t</d:eq>\n\t`),""),n=t.onlyFavorites?"<d:eq>\n\t\t\t\t<d:prop>\n\t\t\t\t\t<oc:favorite/>\n\t\t\t\t</d:prop>\n\t\t\t\t<d:literal>1</d:literal>\n\t\t\t</d:eq>":"",a=t.onThisDay?`<d:or>${Array(20).fill(1).map(((t,e)=>{const n=(0,d.A)(Date.now()).startOf("day").subtract(3,"d").subtract(e+1,"y"),s=(0,d.A)(Date.now()).endOf("day").add(3,"d").subtract(e+1,"y");return`<d:and>\n\t\t\t\t<d:gt>\n\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t<d:getlastmodified />\n\t\t\t\t\t</d:prop>\n\t\t\t\t\t<d:literal>${n.format(d.A.defaultFormatUtc)}</d:literal>\n\t\t\t\t</d:gt>\n\t\t\t\t<d:lt>\n\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t<d:getlastmodified />\n\t\t\t\t\t</d:prop>\n\t\t\t\t\t<d:literal>${s.format(d.A.defaultFormatUtc)}</d:literal>\n\t\t\t\t</d:lt>\n\t\t\t</d:and>`})).join("\n")}</d:or>`:"",h=A.A.state.userConfig.photosSourceFolders.map((t=>`\n\t\t\t<d:scope>\n\t\t\t\t<d:href>${(0,i.HS)(s.lJ,t)}</d:href>\n\t\t\t\t<d:depth>infinity</d:depth>\n\t\t\t</d:scope>`)).join("\n");return t=Object.assign({method:"SEARCH",headers:{"content-Type":"text/xml"},data:`<?xml version="1.0" encoding="UTF-8"?>\n\t\t\t<d:searchrequest xmlns:d="DAV:"\n\t\t\t\txmlns:oc="http://owncloud.org/ns"\n\t\t\t\txmlns:nc="http://nextcloud.org/ns"\n\t\t\t\txmlns:ns="https://github.com/icewind1991/SearchDAV/ns"\n\t\t\t\txmlns:ocs="http://open-collaboration-services.org/ns">\n\t\t\t\t<d:basicsearch>\n\t\t\t\t\t<d:select>\n\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t${l.x}\n\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t</d:select>\n\t\t\t\t\t<d:from>\n\t\t\t\t\t\t${h}\n\t\t\t\t\t</d:from>\n\t\t\t\t\t<d:where>\n\t\t\t\t\t\t<d:and>\n\t\t\t\t\t\t\t<d:or>\n\t\t\t\t\t\t\t\t${e}\n\t\t\t\t\t\t\t</d:or>\n\t\t\t\t\t\t\t${n}\n\t\t\t\t\t\t\t${a}\n\t\t\t\t\t\t</d:and>\n\t\t\t\t\t</d:where>\n\t\t\t\t\t<d:orderby>\n\t\t\t\t\t\t<d:order>\n\t\t\t\t\t\t\t<d:prop><nc:metadata-photos-original_date_time/></d:prop>\n\t\t\t\t\t\t\t<d:descending/>\n\t\t\t\t\t\t</d:order>\n\t\t\t\t\t\t<d:order>\n\t\t\t\t\t\t\t<d:prop><d:getlastmodified/></d:prop>\n\t\t\t\t\t\t\t<d:descending/>\n\t\t\t\t\t\t</d:order>\n\t\t\t\t\t</d:orderby>\n\t\t\t\t\t<d:limit>\n\t\t\t\t\t\t<d:nresults>${t.nbResults}</d:nresults>\n\t\t\t\t\t\t<ns:firstresult>${t.firstResult}</ns:firstresult>\n\t\t\t\t\t</d:limit>\n\t\t\t\t</d:basicsearch>\n\t\t\t</d:searchrequest>`,deep:!0,details:!0},t),(await c.Ay.getDirectoryContents("",t)).data.map((t=>(0,r.JR)(t)))}({firstResult:this.fetchedFileIds.length,nbResults:n,...t,signal:this.abortController.signal});h.length!==n&&(this.doneFetchingFiles=!0);const p=h.map((t=>t.fileid)).filter((t=>!this.fetchedFileIds.includes(t.toString())));return this.fetchedFileIds.push(...p.map((t=>t.toString())).filter((t=>!e.includes(t)))),this.$store.dispatch("appendFiles",h),a.A.debug(`[FetchFilesMixin] Fetched ${p.length} new files: `,p),p}catch(t){if(404===t.response?.status){const e=A.A.state.userConfig.photosSourceFolders;for(const n of e)if(null!==t.response?.data?.match(`File with name /${n} could not be located`)){a.A.debug(`The ${n} folder does not exist, creating it.`);try{return await(0,s.H4)().createDirectory((0,i.HS)(s.lJ,n)),this.resetFetchFilesState(),[]}catch(t){this.errorFetchingFiles=404,a.A.error("Fail to create source directory",{error:t})}}}else{if(t instanceof DOMException&&t.code===t.ABORT_ERR)return[];this.errorFetchingFiles=t}a.A.error("Error fetching files",{error:t})}finally{this.loadingFiles=!1,this.fetchSemaphore.release(h)}return[]},resetFetchFilesState(){this.doneFetchingFiles=!1,this.errorFetchingFiles=null,this.loadingFiles=!1,this.fetchedFileIds=[]}}}},62702:(t,e,n)=>{n.d(e,{A:()=>o});var s=n(71354),i=n.n(s),a=n(76314),r=n.n(a)()(i());r.push([t.id,".face-cover[data-v-71f53f04]{display:flex;flex-direction:column;padding:10px;border-radius:var(--border-radius-large)}.face-cover__crop-container[data-v-71f53f04]{overflow:hidden;width:128px;height:128px;border-radius:128px;position:relative;background:var(--color-background-darker);--photos-face-width: 128px}@media only screen and (max-width: 1020px){.face-cover__crop-container[data-v-71f53f04]{width:95px;height:95px;--photos-face-width: 95px}}.face-cover[data-v-71f53f04]:hover,.face-cover[data-v-71f53f04]:focus{background:var(--color-background-hover)}.face-cover__details[data-v-71f53f04]{display:flex;flex-direction:column;width:128px;margin-top:4px;text-align:center}@media only screen and (max-width: 1020px){.face-cover__details[data-v-71f53f04]{width:95px}}.face-cover__details__first-line[data-v-71f53f04]{display:flex;height:2em;overflow:hidden;text-overflow:ellipsis}.face-cover__details__second-line[data-v-71f53f04]{margin-top:6px;color:var(--color-text-maxcontrast)}.face-cover__details__name[data-v-71f53f04]{flex-grow:1;margin:0;font-weight:bold;font-size:20px;line-height:30px;color:var(--color-main-text)}.face-cover--small *[data-v-71f53f04]{font-size:15px !important}.face-cover--small .face-cover__details[data-v-71f53f04]{width:60px !important}.face-cover--small .face-cover__crop-container[data-v-71f53f04]{width:60px !important;height:60px !important;--photos-face-width: 60px !important}","",{version:3,sources:["webpack://./src/mixins/FaceCover.scss"],names:[],mappings:"AAIA,6BACC,YAAA,CACA,qBAAA,CACA,YAAA,CACA,wCAAA,CAEA,6CACC,eAAA,CACA,WAAA,CACA,YAAA,CACA,mBAAA,CACA,iBAAA,CACA,yCAAA,CACA,0BAAA,CAEA,2CATD,6CAUE,UAAA,CACA,WAAA,CACA,yBAAA,CAAA,CAIF,sEACC,wCAAA,CAGD,sCACC,YAAA,CACA,qBAAA,CACA,WAAA,CACA,cAAA,CACA,iBAAA,CAEA,2CAPD,sCAQE,UAAA,CAAA,CAGD,kDACC,YAAA,CACA,UAAA,CACA,eAAA,CACA,sBAAA,CAGD,mDACC,cAAA,CACA,mCAAA,CAGD,4CACC,WAAA,CACA,QAAA,CACA,gBAAA,CACA,cAAA,CACA,gBAAA,CACA,4BAAA,CAMF,sCACC,yBAAA,CAED,yDACC,qBAAA,CAED,gEACC,qBAAA,CACA,sBAAA,CACA,oCAAA",sourcesContent:["/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n.face-cover {\n\tdisplay: flex;\n\tflex-direction: column;\n\tpadding: 10px;\n\tborder-radius: var(--border-radius-large);\n\n\t&__crop-container {\n\t\toverflow: hidden;\n\t\twidth: 128px;\n\t\theight: 128px;\n\t\tborder-radius: 128px;\n\t\tposition: relative;\n\t\tbackground: var(--color-background-darker);\n\t\t--photos-face-width: 128px;\n\n\t\t@media only screen and (max-width: 1020px) {\n\t\t\twidth: 95px;\n\t\t\theight: 95px;\n\t\t\t--photos-face-width: 95px;\n\t\t}\n\t}\n\n\t&:hover, &:focus {\n\t\tbackground: var(--color-background-hover);\n\t}\n\n\t&__details {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\twidth: 128px;\n\t\tmargin-top: 4px;\n\t\ttext-align: center;\n\n\t\t@media only screen and (max-width: 1020px) {\n\t\t\twidth: 95px;\n\t\t}\n\n\t\t&__first-line {\n\t\t\tdisplay: flex;\n\t\t\theight: 2em;\n\t\t\toverflow: hidden;\n\t\t\ttext-overflow: ellipsis;\n\t\t}\n\n\t\t&__second-line {\n\t\t\tmargin-top: 6px;\n\t\t\tcolor: var(--color-text-maxcontrast);\n\t\t}\n\n\t\t&__name {\n\t\t\tflex-grow: 1;\n\t\t\tmargin: 0;\n\t\t\tfont-weight: bold;\n\t\t\tfont-size: 20px;\n\t\t\tline-height: 30px;\n\t\t\tcolor: var(--color-main-text);\n\t\t}\n\t}\n}\n\n.face-cover--small {\n\t* {\n\t\tfont-size: 15px !important;\n\t}\n\t.face-cover__details {\n\t\twidth: 60px !important;\n\t}\n\t.face-cover__crop-container {\n\t\twidth: 60px !important;\n\t\theight: 60px !important;\n\t\t--photos-face-width: 60px !important;\n\t}\n}\n"],sourceRoot:""}]);const o=r},3556:(t,e,n)=>{n.d(e,{A:()=>o});var s=n(71354),i=n.n(s),a=n(76314),r=n.n(a)()(i());r.push([t.id,".face-list[data-v-0b556b72]{display:flex;flex-direction:row;height:350px;flex-wrap:wrap;padding:12px}.loader[data-v-0b556b72]{margin:25% auto}","",{version:3,sources:["webpack://./src/components/Faces/FaceMergeForm.vue"],names:[],mappings:"AAEA,4BACC,YAAA,CACA,kBAAA,CACA,YAAA,CACA,cAAA,CACA,YAAA,CAGD,yBACC,eAAA",sourcesContent:['$sizes: ("400": ("count": 3, "marginTop": 66, "marginW": 8), "700": ("count": 4, "marginTop": 66, "marginW": 8), "1024": ("count": 5, "marginTop": 66, "marginW": 44), "1280": ("count": 4, "marginTop": 66, "marginW": 44), "1440": ("count": 5, "marginTop": 88, "marginW": 66), "1600": ("count": 6, "marginTop": 88, "marginW": 66), "2048": ("count": 7, "marginTop": 88, "marginW": 66), "2560": ("count": 8, "marginTop": 88, "marginW": 88), "3440": ("count": 9, "marginTop": 88, "marginW": 88), "max": ("count": 10, "marginTop": 88, "marginW": 88));\n\n.face-list {\n\tdisplay: flex;\n\tflex-direction: row;\n\theight: 350px;\n\tflex-wrap: wrap;\n\tpadding: 12px;\n}\n\n.loader {\n\tmargin: 25% auto;\n}\n'],sourceRoot:""}]);const o=r},10462:(t,e,n)=>{n.d(e,{A:()=>b});var s=n(95353),i=n(63814),a=n(44671),r=n(34003);const o={name:"FaceCover",mixins:[a.A,r.A],props:{baseName:{type:String,required:!0},small:{type:Boolean,default:!1}},data:()=>({observer:null}),computed:{...(0,s.L8)(["files","faces","facesFiles"]),face(){return this.faces[this.baseName]},coverUrl(){return this.cover?(0,i.Jv)(`/apps/photos/api/v1/preview/${this.cover.fileid}?x=512&y=512`):""},cover(){return this.getFaceCover(this.face.basename)},coverDimensions(){return this.cover?this.getCoverStyle(this.face.basename):{}}}};var c=n(85072),l=n.n(c),d=n(97825),A=n.n(d),h=n(77659),p=n.n(h),f=n(55056),g=n.n(f),m=n(10540),u=n.n(m),C=n(41113),F=n.n(C),v=n(62702),x={};x.styleTagTransform=F(),x.setAttributes=g(),x.insert=p().bind(null,"head"),x.domAPI=A(),x.insertStyleElement=u();l()(v.A,x);v.A&&v.A.locals&&v.A.locals;const b=(0,n(14486).A)(o,(function(){var t=this,e=t._self._c;return e("div",{class:["face-cover",t.small&&"face-cover--small"],on:{click:function(e){return t.$emit("click")}}},[e("div",{staticClass:"face-cover__crop-container"},[e("img",{ref:"image",staticClass:"face-cover__image",style:t.coverDimensions,attrs:{src:t.coverUrl}})]),t._v(" "),e("div",{staticClass:"face-cover__details"},[t.baseName.match(/^[0-9]+$/)?t._e():e("div",{staticClass:"face-cover__details__first-line"},[e("span",{staticClass:"face-cover__details__name"},[t._v("\n\t\t\t\t"+t._s(t.baseName)+"\n\t\t\t")])]),t._v(" "),t.small?t._e():e("div",{staticClass:"face-cover__details__second-line"},[t._v("\n\t\t\t"+t._s(t.n("photos","%n photos","%n photos",t.face.props.nbItems))+"\n\t\t")])])])}),[],!1,null,"71f53f04",null).exports},26362:(t,e,n)=>{n.d(e,{A:()=>x});var s=n(95353),i=n(34003),a=n(44671);const r={name:"FaceMergeForm",components:{FaceCover:n(10462).A},mixins:[i.A,a.A],props:{firstFace:{type:String,required:!0}},data:()=>({loading:!1}),computed:{...(0,s.L8)(["files","faces","facesFiles"]),filteredFaces(){return Object.values(this.faces).filter((t=>t.basename!==this.firstFace)).sort(((t,e)=>t.props.nbItems&&e.props.nbItems?e.props.nbItems-t.props.nbItems:this.facesFiles[e.basename]&&this.facesFiles[t.basename]?this.facesFiles[e.basename].length-this.facesFiles[t.basename].length:0))}},methods:{handleSelect(t){this.$emit("select",t),this.loading=!0}}};var o=n(85072),c=n.n(o),l=n(97825),d=n.n(l),A=n(77659),h=n.n(A),p=n(55056),f=n.n(p),g=n(10540),m=n.n(g),u=n(41113),C=n.n(u),F=n(3556),v={};v.styleTagTransform=C(),v.setAttributes=f(),v.insert=h().bind(null,"head"),v.domAPI=d(),v.insertStyleElement=m();c()(F.A,v);F.A&&F.A.locals&&F.A.locals;const x=(0,n(14486).A)(r,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"merge-form face-list"},t._l(t.filteredFaces,(function(n){return e("FaceCover",{key:n.basename,attrs:{"base-name":n.basename,small:""},on:{click:function(e){return t.handleSelect(n.basename)}}})})),1)}),[],!1,null,"0b556b72",null).exports}}]);
//# sourceMappingURL=photos-src_mixins_FetchFilesMixin_js-src_components_Faces_FaceMergeForm_vue.js.map?v=5638d97d45dc1671e089