photos/js/photos-src_components_Faces...

3 lines
10 KiB
JavaScript

/*! For license information please see photos-src_components_Faces_FaceCover_vue.js.LICENSE.txt */
"use strict";(self.webpackChunkphotos=self.webpackChunkphotos||[]).push([["src_components_Faces_FaceCover_vue"],{46116:(e,t,a)=>{a.d(t,{Z:()=>o});var n=a(20629),i=a(86492),s=a.n(i);const o={name:"FaceCoverMixin",computed:{...(0,n.Se)(["faces","facesFiles","files"])},methods:{getFaceCover(e){return JSON.parse(s().decode(this.faces[e].props["face-preview-image"]||"{}"))},getCoverStyle(e){const t=this.getFaceCover(e);if(!t||!t.detection)return{};const a=t.detection,n=Math.max(1,1/a.width*.4),i=100*(a.x+a.width/2),s=100*(a.y+a.height/2);return{width:"100%",transform:"translate(calc( var(--photos-face-width)/2 - ".concat(i,"% ), calc( var(--photos-face-width)/2 - ").concat(s,"% )) scale(").concat(n,")"),transformOrigin:"".concat(i,"% ").concat(s,"%")}}}}},99751:(e,a,n)=>{n.d(a,{Z:()=>p});var i=n(20629),s=n(64024),o=n(77958),r=n(81067),c=n(59537),l=n(2161),d=n(45086),A=n(69363),h=n(86492),f=n.n(h);const p={name:"FetchFacesMixin",data:()=>({errorFetchingFaces:null,loadingFaces:!1,errorFetchingFiles:null,loadingFiles:!1}),mixins:[A.Z],async beforeMount(){this.fetchFaces()},computed:{...(0,i.Se)(["faces"])},methods:{...(0,i.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 r.ZP.getDirectoryContents("/recognize/".concat(null===(e=(0,o.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,s.x2)(t("photos","Failed to fetch faces list."))}finally{this.loadingFaces=!1}},async fetchFaceContent(e,t){if(!this.loadingFiles&&(t||!this.facesFiles[e]||!this.facesFiles[e].length))try{var a;this.errorFetchingFiles=null,this.loadingFiles=!0;let{data:t}=await r.ZP.getDirectoryContents("/recognize/".concat(null===(a=(0,o.ts)())||void 0===a?void 0:a.uid,"/faces/").concat(e),{data:l.Z,details:!0,signal:this.abortController.signal});t=t.map((e=>(0,d.AX)(e))).map((e=>({...e,filename:f().decode(e.realpath).replace("/".concat((0,o.ts)().uid,"/files"),"/files/".concat((0,o.ts)().uid))}))).map((e=>({...e,faceDetections:JSON.parse(f().decode(e.faceDetections))})));const n=t.map((e=>""+e.fileid));this.appendFiles(t),t.length>0&&await this.$store.commit("addFilesToFace",{faceName:e,fileIdsToAdd:n}),c.Z.debug("[FetchFacesMixin] Fetched ".concat(n.length," new files: "),n)}catch(e){e.response&&e.response.status&&(404===e.response.status?this.errorFetchingFiles=404:this.errorFetchingFiles=e),c.Z.error("Error fetching face files",{error:e})}finally{this.loadingFiles=!1}},async fetchUnassignedFaces(e){if(!this.loadingFiles&&(e||!this.unassignedFiles||!this.unassignedFiles.length))try{var t;this.errorFetchingFiles=null,this.loadingFiles=!0;let{data:e}=await r.ZP.getDirectoryContents("/recognize/".concat(null===(t=(0,o.ts)())||void 0===t?void 0:t.uid,"/unassigned-faces"),{data:l.Z,details:!0,signal:this.abortController.signal});e=e.map((e=>(0,d.AX)(e))).map((e=>({...e,filename:f().decode(e.realpath).replace("/".concat((0,o.ts)().uid,"/files"),"/files/".concat((0,o.ts)().uid))}))).map((e=>({...e,faceDetections:JSON.parse(f().decode(e.faceDetections))})));const a=e.map((e=>""+e.fileid));this.appendFiles(e),e.length>0&&await this.$store.commit("addUnassignedFiles",{fileIdsToAdd:a}),c.Z.debug("[FetchFacesMixin] Fetched ".concat(a.length," new unassigned files: "),a)}catch(e){e.response&&e.response.status&&(404===e.response.status?this.errorFetchingFiles=404:this.errorFetchingFiles=e),c.Z.error("Error fetching unassigned files",{error:e})}finally{this.loadingFiles=!1}},async fetchUnassignedFacesCount(){try{var e;const{data:t}=await r.ZP.stat("/recognize/".concat(null===(e=(0,o.ts)())||void 0===e?void 0:e.uid,"/unassigned-faces"),{data:l.Z,details:!0,signal:this.abortController.signal}),a=Number(t.props.nbItems);await this.$store.commit("setUnassignedFilesCount",a),c.Z.debug("[FetchFacesMixin] Fetched unassigned files count: ",a)}catch(e){c.Z.error("Error fetching unassigned files count",{error:e})}}}}},9747:(e,t,a)=>{a.d(t,{Z:()=>r});var n=a(87537),i=a.n(n),s=a(23645),o=a.n(s)()(i());o.push([e.id,".face-cover[data-v-f77c54d0]{display:flex;flex-direction:column;padding:10px;border-radius:var(--border-radius-large)}.face-cover__crop-container[data-v-f77c54d0]{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-f77c54d0]{width:95px;height:95px;--photos-face-width: 95px}}.face-cover[data-v-f77c54d0]:hover,.face-cover[data-v-f77c54d0]:focus{background:var(--color-background-hover)}.face-cover__details[data-v-f77c54d0]{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-f77c54d0]{width:95px}}.face-cover__details__first-line[data-v-f77c54d0]{display:flex;height:2em;overflow:hidden;text-overflow:ellipsis}.face-cover__details__second-line[data-v-f77c54d0]{margin-top:6px;color:var(--color-text-maxcontrast)}.face-cover__details__name[data-v-f77c54d0]{flex-grow:1;margin:0;font-weight:bold;font-size:20px;line-height:30px;color:var(--color-main-text)}.face-cover--small *[data-v-f77c54d0]{font-size:15px !important}.face-cover--small .face-cover__details[data-v-f77c54d0]{width:60px !important}.face-cover--small .face-cover__crop-container[data-v-f77c54d0]{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,CACA,gBAAA,CACA,cAAA,CACA,gBAAA,CACA,4BAAA,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\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 r=o},4294:(e,t,a)=>{a.d(t,{Z:()=>_});var n=a(20629),i=a(11480),s=a(99751),o=a(46116);const r={name:"FaceCover",mixins:[s.Z,o.Z],props:{baseName:{type:String,required:!0},small:{type:Boolean,default:!1}},data:()=>({observer:null}),computed:{...(0,n.Se)(["files","faces","facesFiles"]),face(){return this.faces[this.baseName]},coverUrl(){return this.cover?(0,i.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=a(93379),l=a.n(c),d=a(7795),A=a.n(d),h=a(90569),f=a.n(h),p=a(3565),C=a.n(p),g=a(19216),v=a.n(g),m=a(44589),u=a.n(m),x=a(9747),F={};F.styleTagTransform=u(),F.setAttributes=C(),F.insert=f().bind(null,"head"),F.domAPI=A(),F.insertStyleElement=v();l()(x.Z,F);x.Z&&x.Z.locals&&x.Z.locals;const _=(0,a(51900).Z)(r,(function(){var e=this,t=e._self._c;return t("div",{class:["face-cover",e.small&&"face-cover--small"],on:{click:function(t){return e.$emit("click")}}},[t("div",{staticClass:"face-cover__crop-container"},[t("img",{ref:"image",staticClass:"face-cover__image",style:e.coverDimensions,attrs:{src:e.coverUrl}})]),e._v(" "),t("div",{staticClass:"face-cover__details"},[e.baseName.match(/^[0-9]+$/)?e._e():t("div",{staticClass:"face-cover__details__first-line"},[t("span",{staticClass:"face-cover__details__name"},[e._v("\n\t\t\t\t"+e._s(e.baseName)+"\n\t\t\t")])]),e._v(" "),e.small?e._e():t("div",{staticClass:"face-cover__details__second-line"},[e._v("\n\t\t\t"+e._s(e.n("photos","%n photos","%n photos",e.face.props.nbItems))+"\n\t\t")])])])}),[],!1,null,"f77c54d0",null).exports}}]);
//# sourceMappingURL=photos-src_components_Faces_FaceCover_vue.js.map?v=7a57403c2dbed8013947