photos/js/photos-src_components_Colle...

3 lines
16 KiB
JavaScript

/*! For license information please see photos-src_components_Collection_CollectionContent_vue-src_components_PhotosPicker_vue.js.LICENSE.txt */
"use strict";(self.webpackChunkphotos=self.webpackChunkphotos||[]).push([["src_components_Collection_CollectionContent_vue-src_components_PhotosPicker_vue"],{66951:(t,e,n)=>{n.d(e,{Z:()=>m});var o=n(5656),i=n(65358),s=n(59537),l=n(45086),a=n(3301),r=n(81067),d=n(2161),c=n(80351),p=n.n(c),h=n(30319);var u=n(32114);const m={name:"FetchFilesMixin",mixins:[n(69363).Z],data:()=>({errorFetchingFiles:null,loadingFiles:!1,doneFetchingFiles:!1,fetchSemaphore:new u.Z(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 c=await this.fetchSemaphore.acquire();try{this.errorFetchingFiles=null,this.loadingFiles=!0;const n=200,c=await async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t={firstResult:0,nbResults:200,mimesType:a.Oj,onThisDay:!1,onlyFavorites:!1,...t};const e=t.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")),""),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>":"",s=t.onThisDay?"<d:or>".concat(Array(20).fill(1).map(((t,e)=>{const n=p()(Date.now()).startOf("day").subtract(3,"d").subtract(e+1,"y"),o=p()(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(p().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(o.format(p().defaultFormatUtc),"</d:literal>\n\t\t\t\t</d:lt>\n\t\t\t</d:and>")})).join("\n"),"</d:or>"):"",c=h.Z.state.userConfig.photosSourceFolders.map((t=>"\n\t\t\t<d:scope>\n\t\t\t\t<d:href>".concat((0,i.RQ)(o._o,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'.concat(d.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").concat(c,"\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(e,"\n\t\t\t\t\t\t\t</d:or>\n\t\t\t\t\t\t\t").concat(n,"\n\t\t\t\t\t\t\t").concat(s,"\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>").concat(t.nbResults,"</d:nresults>\n\t\t\t\t\t\t<ns:firstresult>").concat(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 r.ZP.getDirectoryContents("",t)).data.map((t=>(0,l.AX)(t)))}({firstResult:this.fetchedFileIds.length,nbResults:n,...t,signal:this.abortController.signal});c.length!==n&&(this.doneFetchingFiles=!0);const u=c.map((t=>t.fileid)).filter((t=>!this.fetchedFileIds.includes(t.toString())));return this.fetchedFileIds.push(...u.map((t=>t.toString())).filter((t=>!e.includes(t)))),this.$store.dispatch("appendFiles",c),s.Z.debug("[FetchFilesMixin] Fetched ".concat(u.length," new files: "),u),u}catch(t){var u;if(404===(null===(u=t.response)||void 0===u?void 0:u.status)){const e=h.Z.state.userConfig.photosSourceFolders;for(const n of e){var m,g;if(null!==(null===(m=t.response)||void 0===m||null===(g=m.data)||void 0===g?void 0:g.match("File with name /".concat(n," could not be located")))){s.Z.debug("The ".concat(n," folder does not exist, creating it."));try{return await(0,o.rp)().createDirectory((0,i.RQ)(o._o,n)),this.resetFetchFilesState(),[]}catch(t){this.errorFetchingFiles=404,s.Z.error("Fail to create source directory",{error:t})}}}}else{if("ERR_CANCELED"===t.code)return[];this.errorFetchingFiles=t}s.Z.error("Error fetching files",{error:t})}finally{this.loadingFiles=!1,this.fetchSemaphore.release(c)}return[]},resetFetchFilesState(){this.doneFetchingFiles=!1,this.errorFetchingFiles=null,this.loadingFiles=!1,this.fetchedFileIds=[]}}}},28391:(t,e,n)=>{n.d(e,{Z:()=>o});const o={name:"FilesByMonthMixin",computed:{fileIdsByMonth(){const t={};for(const n of this.fetchedFileIds){const o=this.files[n];var e;if(o)t[o.month]=null!==(e=t[o.month])&&void 0!==e?e:[],t[o.month].push(o.fileid)}return Object.keys(t).forEach((e=>t[e].sort(this.sortFilesByTimestamp))),t},monthsList(){return Object.keys(this.fileIdsByMonth).sort(((t,e)=>t>e?-1:1))}},methods:{sortFilesByTimestamp(t,e){return this.files[t].timestamp>this.files[e].timestamp?-1:1}}}},41935:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(87537),i=n.n(o),s=n(23645),l=n.n(s)()(i());l.push([t.id,".collection[data-v-550e2ad4]{display:flex;flex-direction:column}.collection__media[data-v-550e2ad4]{padding:0 64px}@media only screen and (max-width: 1200px){.collection__media[data-v-550e2ad4]{padding:0 4px}}","",{version:3,sources:["webpack://./src/components/Collection/CollectionContent.vue"],names:[],mappings:"AAEA,6BACC,YAAA,CACA,qBAAA,CAEA,oCACC,cAAA,CAEA,2CAHD,oCAIE,aAAA,CAAA",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.collection {\n\tdisplay: flex;\n\tflex-direction: column;\n\n\t&__media {\n\t\tpadding: 0 64px;\n\n\t\t@media only screen and (max-width: 1200px) {\n\t\t\tpadding: 0 4px;\n\t\t}\n\t}\n}\n'],sourceRoot:""}]);const a=l},99429:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(87537),i=n.n(o),s=n(23645),l=n.n(s)()(i());l.push([t.id,"[data-v-b044636c] .photos-picker{-webkit-padding-end:0 !important;padding-inline-end:0 !important}.photos-picker__navigation__month[data-v-b044636c]{margin:4px}.photos-picker__navigation__month-select[data-v-b044636c]{flex:1;-webkit-padding-end:12px;padding-inline-end:12px;-webkit-padding-after:6px;padding-block-end:6px}.photos-picker__file-list[data-v-b044636c]{flex-grow:1;min-width:0;height:100%;padding:0 4px}.photos-picker__file-list--placeholder[data-v-b044636c]{background:var(--color-primary-element-light);border-radius:var(--border-radius-large)}.photos-picker__file-list .section-header[data-v-b044636c]{font-weight:bold;font-size:20px;padding:8px 0 4px 0}.photos-picker__file-list[data-v-b044636c] .empty-content{position:absolute;width:100%;margin-top:0;height:100%;display:flex;flex-direction:column;justify-content:center}","",{version:3,sources:["webpack://./src/components/PhotosPicker.vue"],names:[],mappings:"AAEA,iCAEC,gCAAA,CAAA,+BAAA,CAMC,mDAEC,UAAA,CAGD,0DACC,MAAA,CAEA,wBAAA,CAAA,uBAAA,CACA,yBAAA,CAAA,qBAAA,CAIF,2CACC,WAAA,CACA,WAAA,CACA,WAAA,CACA,aAAA,CAEA,wDACC,6CAAA,CACA,wCAAA,CAGD,2DACC,gBAAA,CACA,cAAA,CACA,mBAAA,CAGD,0DACC,iBAAA,CACA,UAAA,CACA,YAAA,CACA,WAAA,CACA,YAAA,CACA,qBAAA,CACA,sBAAA",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:deep(.photos-picker) {\n\t// remove padding to move scrollbar to the very end\n\tpadding-inline-end: 0 !important;\n}\n\n.photos-picker {\n\n\t&__navigation {\n\t\t&__month {\n\t\t\t// For focus-visible outline\n\t\t\tmargin: 4px;\n\t\t}\n\n\t\t&__month-select {\n\t\t\tflex: 1;\n\t\t\t// align with other content\n\t\t\tpadding-inline-end: 12px;\n\t\t\tpadding-block-end: 6px;\n\t\t}\n\t}\n\n\t&__file-list {\n\t\tflex-grow: 1;\n\t\tmin-width: 0;\n\t\theight: 100%;\n\t\tpadding: 0 4px;\n\n\t\t&--placeholder {\n\t\t\tbackground: var(--color-primary-element-light);\n\t\t\tborder-radius: var(--border-radius-large);\n\t\t}\n\n\t\t.section-header {\n\t\t\tfont-weight: bold;\n\t\t\tfont-size: 20px;\n\t\t\tpadding: 8px 0 4px 0;\n\t\t}\n\n\t\t:deep .empty-content {\n\t\t\tposition: absolute;\n\t\t\twidth: 100%;\n\t\t\tmargin-top: 0;\n\t\t\theight: 100%;\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\tjustify-content: center;\n\t\t}\n\t}\n}\n'],sourceRoot:""}]);const a=l},70877:(t,e,n)=>{n.d(e,{Z:()=>k});var o=n(84320),i=n(99147),s=n(64882),l=n(31352),a=n(98171),r=n(97519),d=n(64811);const c={name:"CollectionContent",components:{AlertCircle:o.Z,FolderMultipleImage:i.Z,NcEmptyContent:s.SL,FilesListViewer:r.Z,File:d.Z},mixins:[a.Z,s.tq],props:{collection:{type:Object,default:()=>{}},collectionFileIds:{type:Array,required:!0},loading:{type:Boolean,default:!1},allowSelection:{type:Boolean,default:!0},error:{type:[Error,Number],default:null}},data:()=>({appContent:document.getElementById("app-content-vue")}),computed:{files(){return this.$store.getters.files},sortedCollectionFileIds(){return this.collectionFileIds.toSorted(((t,e)=>this.files[t].timestamp<this.files[e].timestamp?-1:1))}},methods:{openViewer(t){const e=this.files[t];OCA.Viewer.open({fileInfo:e,list:this.sortedCollectionFileIds.map((t=>this.files[t])).filter((t=>!t.sectionHeader)),loadMore:e.loadMore?async()=>await e.loadMore(!0):()=>[],canLoop:e.canLoop})},t:l.Iu}};var p=n(93379),h=n.n(p),u=n(7795),m=n.n(u),g=n(90569),A=n.n(g),f=n(3565),C=n.n(f),F=n(19216),y=n.n(F),_=n(44589),v=n.n(_),b=n(41935),x={};x.styleTagTransform=v(),x.setAttributes=C(),x.insert=A().bind(null,"head"),x.domAPI=m(),x.insertStyleElement=y();h()(b.Z,x);b.Z&&b.Z.locals&&b.Z.locals;const k=(0,n(51900).Z)(c,(function(){var t=this,e=t._self._c;return void 0===t.collection&&!t.loading||404===t.error?e("NcEmptyContent",{staticClass:"empty-content-with-illustration",attrs:{name:t.t("photos","This collection does not exist")}},[e("FolderMultipleImage",{attrs:{slot:"icon"},slot:"icon"})],1):t.error?e("NcEmptyContent",{attrs:{name:t.t("photos","An error occurred")}},[e("AlertCircle",{attrs:{slot:"icon"},slot:"icon"})],1):e("div",{staticClass:"collection"},[t._t("header",null,{selectedFileIds:t.selectedFileIds,resetSelection:t.resetSelection}),t._v(" "),0!==t.sortedCollectionFileIds.length||t.loading?t._e():t._t("empty-content"),t._v(" "),void 0!==t.collection?e("FilesListViewer",{staticClass:"collection__media",attrs:{"container-element":t.appContent,"file-ids":t.sortedCollectionFileIds,"base-height":t.isMobile?120:200,loading:t.loading},scopedSlots:t._u([{key:"default",fn:function(n){let{file:o,distance:i}=n;return e("File",{attrs:{file:t.files[o.id],"allow-selection":t.allowSelection,selected:!0===t.selection[o.id],distance:i},on:{click:t.openViewer,"select-toggled":t.onFileSelectToggle}})}}],null,!1,3813029717)}):t._e()],2)}),[],!1,null,"550e2ad4",null).exports},45947:(t,e,n)=>{n.d(e,{Z:()=>S});var o=n(57873),i=n(64882),s=n(20144),l=n(20629),a=n(80351),r=n.n(a),d=n(85109),c=n(97519),p=n(64811),h=n(66951),u=n(98171),m=n(28391),g=n(3301);const A=(0,s.aZ)({name:"PhotosPicker",components:{File:p.Z,FilesListViewer:c.Z,ImagePlus:d.Z,NcButton:i.P2,NcDialog:i.a0,NcLoadingIcon:i.lb,NcSelect:i.QG,UploadPicker:o.e},mixins:[h.Z,m.Z,u.Z],props:{open:{type:Boolean,default:!0},name:{type:String,required:!0},destination:{type:String,required:!0},blacklistIds:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},emits:["files-picked","update:open"],setup:()=>({isMobile:(0,i.dD)()}),data:()=>({allowedMimes:g.ZP,targetMonth:null,uploadContext:{route:"albumpicker"}}),computed:{...(0,l.Se)(["files"])},watch:{monthsList(t){null===this.targetMonth&&(this.targetMonth=t[0])}},methods:{onFocusOut(t){null===t.relatedTarget&&t.target.focus({preventScroll:!0})},getFiles(){this.fetchFiles({},this.blacklistIds)},refreshFiles(){this.fetchFiles({firstResult:0},[...this.blacklistIds,...this.fetchedFileIds],!0)},emitPickedEvent(){this.$emit("files-picked",this.selectedFileIds)},dateMonthAndYear(t){return this.isMobile?r()(t,"YYYYMM").format("MMM YYYY"):r()(t,"YYYYMM").format("MMMM YYYY")},photosLocationFolder(){return this.$store.state.userConfig.photosLocationFolder}}});var f=n(93379),C=n.n(f),F=n(7795),y=n.n(F),_=n(90569),v=n.n(_),b=n(3565),x=n.n(b),k=n(19216),w=n.n(k),M=n(44589),T=n.n(M),Z=n(99429),I={};I.styleTagTransform=T(),I.setAttributes=x(),I.insert=v().bind(null,"head"),I.domAPI=y(),I.insertStyleElement=w();C()(Z.Z,I);Z.Z&&Z.Z.locals&&Z.Z.locals;const S=(0,n(51900).Z)(A,(function(){var t=this,e=t._self._c;t._self._setupProxy;return e("NcDialog",{attrs:{"content-classes":"photos-picker",name:t.name,open:t.open,"out-transition":"",size:"large"},on:{"update:open":e=>t.$emit("update:open",e)},scopedSlots:t._u([{key:"navigation",fn:function(n){let{isCollapsed:o}=n;return[o?e("NcSelect",{staticClass:"photos-picker__navigation__month-select",attrs:{"aria-label-listbox":t.t("photos","Dates"),clearable:!1,"input-label":t.t("photos","Jump to specific date in list"),options:t.monthsList},scopedSlots:t._u([{key:"selected-option",fn:function(e){let{label:n}=e;return[t._v("\n\t\t\t\t"+t._s(t.dateMonthAndYear(n))+"\n\t\t\t")]}},{key:"option",fn:function(e){let{label:n}=e;return[t._v("\n\t\t\t\t"+t._s(t.dateMonthAndYear(n))+"\n\t\t\t")]}}],null,!0),model:{value:t.targetMonth,callback:function(e){t.targetMonth=e},expression:"targetMonth"}}):e("ul",{attrs:{"aria-label":t.t("photos","Dates")}},t._l(t.monthsList,(function(n){return e("li",{key:n,staticClass:"photos-picker__navigation__month"},[e("NcButton",{attrs:{type:t.targetMonth===n?"secondary":"tertiary","aria-label":t.t("photos","Jump to {date}",{date:t.dateMonthAndYear(n)})},on:{click:function(e){t.targetMonth=n}}},[t._v("\n\t\t\t\t\t"+t._s(t.dateMonthAndYear(n))+"\n\t\t\t\t")])],1)})),0)]}},{key:"actions",fn:function(){return[e("UploadPicker",{attrs:{accept:t.allowedMimes,context:t.uploadContext,destination:t.photosLocationFolder,multiple:!0},on:{uploaded:t.refreshFiles}}),t._v(" "),e("NcButton",{attrs:{type:"primary",disabled:t.loading||0===t.selectedFileIds.length},on:{click:t.emitPickedEvent},scopedSlots:t._u([{key:"icon",fn:function(){return[t.loading?t._e():e("ImagePlus"),t._v(" "),t.loading?e("NcLoadingIcon"):t._e()]},proxy:!0}])},[t._v("\n\t\t\t"+t._s(t.t("photos","Add to {destination}",{destination:t.destination}))+"\n\t\t")])]},proxy:!0}])},[t._v(" "),t._v(" "),e("FilesListViewer",{staticClass:"photos-picker__file-list",class:{"photos-picker__file-list--placeholder":0===t.monthsList.length},attrs:{"file-ids-by-section":t.fileIdsByMonth,"empty-message":t.t("photos","There are no photos or videos yet!"),sections:t.monthsList,loading:t.loadingFiles,"base-height":100,"section-header-height":50,"scroll-to-section":t.targetMonth},on:{"need-content":t.getFiles},nativeOn:{focusout:function(e){return t.onFocusOut.apply(null,arguments)}},scopedSlots:t._u([{key:"default",fn:function(n){let{file:o,height:i,isHeader:s,distance:l}=n;return[s?e("h3",{staticClass:"section-header",style:{height:"".concat(i,"px")},attrs:{id:"photos-picker-section-header-".concat(o.id)}},[t._v("\n\t\t\t\t"+t._s(t.dateMonthAndYear(o.id))+"\n\t\t\t")]):e("File",{attrs:{file:t.files[o.id],"allow-selection":!0,selected:!0===t.selection[o.id],distance:l},on:{"select-toggled":t.onFileSelectToggle}})]}}])})],1)}),[],!1,null,"b044636c",null).exports}}]);
//# sourceMappingURL=photos-src_components_Collection_CollectionContent_vue-src_components_PhotosPicker_vue.js.map?v=ffe21867ec160f61c0bb