photos/js/photos-src_mixins_FetchFile...

3 lines
17 KiB
JavaScript

/*! For license information please see photos-src_mixins_FetchFilesMixin_js-src_components_Faces_FaceMergeForm_vue.js.LICENSE.txt */
"use strict";(self.webpackChunkphotos=self.webpackChunkphotos||[]).push([["src_mixins_FetchFilesMixin_js-src_components_Faces_FaceMergeForm_vue"],{46116:(t,e,n)=>{n.d(e,{Z:()=>r});var a=n(20629),s=n(86492),i=n.n(s);const r={name:"FaceCoverMixin",computed:{...(0,a.Se)(["faces","facesFiles","files"])},methods:{getFaceCover(t){return JSON.parse(i().decode(this.faces[t].props["face-preview-image"]||"{}"))},getCoverStyle(t){const e=this.getFaceCover(t);if(!e||!e.detection)return{};const n=e.detection,a=Math.max(1,1/n.width*.4),s=100*(n.x+n.width/2),i=100*(n.y+n.height/2);return{width:"100%",transform:"translate(calc( var(--photos-face-width)/2 - ".concat(s,"% ), calc( var(--photos-face-width)/2 - ").concat(i,"% )) scale(").concat(a,")"),transformOrigin:"".concat(s,"% ").concat(i,"%")}}}}},99751:(e,n,a)=>{a.d(n,{Z:()=>f});var s=a(20629),i=a(64024),r=a(77958),o=a(81067),c=a(59537),l=a(2161),d=a(94236),h=a(69363),p=a(86492),A=a.n(p);const f={name:"FetchFacesMixin",data:()=>({errorFetchingFaces:null,loadingFaces:!1,errorFetchingFiles:null,loadingFiles:!1}),mixins:[h.Z],async beforeMount(){this.fetchFaces()},computed:{...(0,s.Se)(["faces"])},methods:{...(0,s.nv)(["appendFiles"]),async fetchFaces(){if(!this.loadingFaces&&!Object.keys(this.faces).length)try{var e;this.loadingFaces=!0,this.errorFetchingFaces=null;const{data:t}=await o.ZP.getDirectoryContents("/recognize/".concat(null===(e=(0,r.ts)())||void 0===e?void 0:e.uid,"/faces/"),{data:l.Z,details:!0,signal:this.abortController.signal});this.$store.dispatch("addFaces",{faces:t}),c.Z.debug("[FetchFacesMixin] Fetched ".concat(t.length," new faces: "),t)}catch(e){e.response&&e.response.status&&(404===e.response.status?this.errorFetchingFaces=404:this.errorFetchingFaces=e),c.Z.error(t("photos","Failed to fetch faces list."),{error:e}),(0,i.x2)(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{var n;this.errorFetchingFiles=null,this.loadingFiles=!0;let{data:e}=await o.ZP.getDirectoryContents("/recognize/".concat(null===(n=(0,r.ts)())||void 0===n?void 0:n.uid,"/faces/").concat(t),{data:l.Z,details:!0,signal:this.abortController.signal});e=e.map((t=>(0,d.AX)(t))).map((t=>({...t,filename:A().decode(t.realpath).replace("/".concat((0,r.ts)().uid,"/files"),"/files/".concat((0,r.ts)().uid))}))).map((t=>({...t,faceDetections:JSON.parse(A().decode(t.faceDetections))})));const a=e.map((t=>""+t.fileid));this.appendFiles(e),e.length>0&&await this.$store.commit("addFilesToFace",{faceName:t,fileIdsToAdd:a}),c.Z.debug("[FetchFacesMixin] Fetched ".concat(a.length," new files: "),a)}catch(t){t.response&&t.response.status&&(404===t.response.status?this.errorFetchingFiles=404:this.errorFetchingFiles=t),c.Z.error("Error fetching face files",{error:t})}finally{this.loadingFiles=!1}},async fetchUnassignedFaces(t){if(!this.loadingFiles&&(t||!this.unassignedFiles||!this.unassignedFiles.length))try{var e;this.errorFetchingFiles=null,this.loadingFiles=!0;let{data:t}=await o.ZP.getDirectoryContents("/recognize/".concat(null===(e=(0,r.ts)())||void 0===e?void 0:e.uid,"/unassigned-faces"),{data:l.Z,details:!0,signal:this.abortController.signal});t=t.map((t=>(0,d.AX)(t))).map((t=>({...t,filename:A().decode(t.realpath).replace("/".concat((0,r.ts)().uid,"/files"),"/files/".concat((0,r.ts)().uid))}))).map((t=>({...t,faceDetections:JSON.parse(A().decode(t.faceDetections))})));const n=t.map((t=>""+t.fileid));this.appendFiles(t),t.length>0&&await this.$store.commit("addUnassignedFiles",{fileIdsToAdd:n}),c.Z.debug("[FetchFacesMixin] Fetched ".concat(n.length," new unassigned files: "),n)}catch(t){t.response&&t.response.status&&(404===t.response.status?this.errorFetchingFiles=404:this.errorFetchingFiles=t),c.Z.error("Error fetching unassigned files",{error:t})}finally{this.loadingFiles=!1}},async fetchUnassignedFacesCount(){try{var t;const{data:e}=await o.ZP.stat("/recognize/".concat(null===(t=(0,r.ts)())||void 0===t?void 0:t.uid,"/unassigned-faces"),{data:l.Z,details:!0,signal:this.abortController.signal}),n=Number(e.props.nbItems);await this.$store.commit("setUnassignedFilesCount",n),c.Z.debug("[FetchFacesMixin] Fetched unassigned files count: ",n)}catch(t){c.Z.error("Error fetching unassigned files count",{error:t})}}}}},66951:(t,e,n)=>{n.d(e,{Z:()=>p});var a=n(59537),s=n(94236),i=n(77958),r=n(3301),o=n(81067),c=n(2161),l=n(80351),d=n.n(l);var h=n(32114);const p={name:"FetchFilesMixin",mixins:[n(69363).Z],data:()=>({errorFetchingFiles:null,loadingFiles:!1,doneFetchingFiles:!1,fetchSemaphore:new h.Z(1),fetchedFileIds:[]}),watch:{$route(){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]:[],l=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.doneFetchingFiles&&!l||this.loadingFiles)return[];const h=await this.fetchSemaphore.acquire();try{this.errorFetchingFiles=null,this.loadingFiles=!0;const l=200,h=await async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e={firstResult:0,nbResults:200,mimesType:r.Oj,onThisDay:!1,onlyFavorites:!1,...e};const n="/files/".concat((0,i.ts)().uid),a=e.mimesType.reduce(((t,e)=>"".concat(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>").concat(e,"</d:literal>\n\t\t</d:eq>\n\t")),""),l=e.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>":"",h=e.onThisDay?"<d:or>".concat(Array(20).fill(1).map(((t,e)=>{const n=d()(Date.now()).startOf("day").subtract(3,"d").subtract(e+1,"y"),a=d()(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>".concat(n.format(d().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>").concat(a.format(d().defaultFormatUtc),"</d:literal>\n\t\t\t\t</d:lt>\n\t\t\t</d:and>")})).join("\n"),"</d:or>"):"";return e=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'.concat(c.N,"\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<d:scope>\n\t\t\t\t\t\t\t<d:href>").concat(n,"/").concat(t,"</d:href>\n\t\t\t\t\t\t\t<d:depth>infinity</d:depth>\n\t\t\t\t\t\t</d:scope>\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").concat(a,"\n\t\t\t\t\t\t\t</d:or>\n\t\t\t\t\t\t\t").concat(l,"\n\t\t\t\t\t\t\t").concat(h,"\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</d:orderby>\n\t\t\t\t\t<d:limit>\n\t\t\t\t\t\t<d:nresults>").concat(e.nbResults,"</d:nresults>\n\t\t\t\t\t\t<ns:firstresult>").concat(e.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},e),(await o.ZP.getDirectoryContents("",e)).data.map((t=>(0,s.AX)(t)))}(t,{firstResult:this.fetchedFileIds.length,nbResults:l,...e,signal:this.abortController.signal});h.length!==l&&(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=>!n.includes(t)))),this.$store.dispatch("appendFiles",h),a.Z.debug("[FetchFilesMixin] Fetched ".concat(p.length," new files: "),p),p}catch(t){var p;if(404===(null===(p=t.response)||void 0===p?void 0:p.status))this.errorFetchingFiles=404;else{if("ERR_CANCELED"===t.code)return[];this.errorFetchingFiles=t}a.Z.error("Error fetching files",{error:t}),console.error(t)}finally{this.loadingFiles=!1,this.fetchSemaphore.release(h)}return[]},resetFetchFilesState(){this.doneFetchingFiles=!1,this.errorFetchingFiles=null,this.loadingFiles=!1,this.fetchedFileIds=[]}}}},83062:(t,e,n)=>{n.d(e,{Z:()=>o});var a=n(87537),s=n.n(a),i=n(23645),r=n.n(i)()(s());r.push([t.id,".face-cover[data-v-5cb97458]{display:flex;flex-direction:column;padding:10px;border-radius:var(--border-radius-large)}.face-cover__crop-container[data-v-5cb97458]{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-5cb97458]{width:95px;height:95px;--photos-face-width: 95px}}.face-cover[data-v-5cb97458]:hover,.face-cover[data-v-5cb97458]:focus{background:var(--color-background-hover)}.face-cover__details[data-v-5cb97458]{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-5cb97458]{width:95px}}.face-cover__details__first-line[data-v-5cb97458]{display:flex;height:2em;overflow:hidden;text-overflow:ellipsis}.face-cover__details__second-line[data-v-5cb97458]{margin-top:6px;color:var(--color-text-maxcontrast)}.face-cover__details__name[data-v-5cb97458]{flex-grow:1;margin:0}.face-cover--small *[data-v-5cb97458]{font-size:15px !important}.face-cover--small .face-cover__details[data-v-5cb97458]{width:60px !important}.face-cover--small .face-cover__crop-container[data-v-5cb97458]{width:60px !important;height:60px !important;--photos-face-width: 60px !important}","",{version:3,sources:["webpack://./src/mixins/FaceCover.scss"],names:[],mappings:"AAqBA,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,CAMF,sCACC,yBAAA,CAED,yDACC,qBAAA,CAED,gEACC,qBAAA,CACA,sBAAA,CACA,oCAAA",sourcesContent:["/**\n * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net>\n *\n * @author Marcel Klehr <mklehr@gmx.net>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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}\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}"],sourceRoot:""}]);const o=r},3640:(t,e,n)=>{n.d(e,{Z:()=>o});var a=n(87537),s=n.n(a),i=n(23645),r=n.n(i)()(s());r.push([t.id,".face-list[data-v-33326436]{display:flex;flex-direction:row;height:350px;flex-wrap:wrap;padding:12px}.loader[data-v-33326436]{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},84647:(t,e,n)=>{n.d(e,{Z:()=>b});var a=n(20629),s=n(79753),i=n(99751),r=n(46116);const o={name:"FaceCover",mixins:[i.Z,r.Z],props:{baseName:{type:String,required:!0},small:{type:Boolean,default:!1}},data:()=>({observer:null}),computed:{...(0,a.Se)(["files","faces","facesFiles"]),face(){return this.faces[this.baseName]},coverUrl(){return this.cover?(0,s.nu)("/apps/photos/api/v1/preview/".concat(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(93379),l=n.n(c),d=n(7795),h=n.n(d),p=n(90569),A=n.n(p),f=n(3565),m=n.n(f),g=n(19216),u=n.n(g),v=n(44589),F=n.n(v),C=n(83062),x={};x.styleTagTransform=F(),x.setAttributes=m(),x.insert=A().bind(null,"head"),x.domAPI=h(),x.insertStyleElement=u();l()(C.Z,x);C.Z&&C.Z.locals&&C.Z.locals;const b=(0,n(51900).Z)(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("h2",{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,"5cb97458",null).exports},35406:(t,e,n)=>{n.d(e,{Z:()=>x});var a=n(20629),s=n(46116),i=n(99751);const r={name:"FaceMergeForm",components:{FaceCover:n(84647).Z},mixins:[s.Z,i.Z],props:{firstFace:{type:String,required:!0}},data:()=>({loading:!1}),computed:{...(0,a.Se)(["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(93379),c=n.n(o),l=n(7795),d=n.n(l),h=n(90569),p=n.n(h),A=n(3565),f=n.n(A),m=n(19216),g=n.n(m),u=n(44589),v=n.n(u),F=n(3640),C={};C.styleTagTransform=v(),C.setAttributes=f(),C.insert=p().bind(null,"head"),C.domAPI=d(),C.insertStyleElement=g();c()(F.Z,C);F.Z&&F.Z.locals&&F.Z.locals;const x=(0,n(51900).Z)(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,"33326436",null).exports}}]);
//# sourceMappingURL=photos-src_mixins_FetchFilesMixin_js-src_components_Faces_FaceMergeForm_vue.js.map?v=fd0d2fa58a4cc5054fa0