3 lines
17 KiB
JavaScript
3 lines
17 KiB
JavaScript
import{d as v,a as A,t as h,g as l,_ as C,M as F,u as g,s as w}from"./vue.runtime.esm-Ct3_M7aQ.chunk.mjs";import{m as r}from"./index-XmYygNaN.chunk.mjs";import{u as k}from"./video-rmrjCz0n.chunk.mjs";import{a as N,u as S,s as O}from"./filters-DO7HFMym.chunk.mjs";import{N as x}from"./NcActionButton-CuVNJJtW-78GF8FR5.chunk.mjs";import{n as B,s as p,f as $,N as f,q as c,k as I,h as M,m as L,ag as u,ah as d}from"./index-BMeBqg0T.chunk.mjs";import{N as D}from"./NcEmptyContent-C3BLUUdi.chunk.mjs";import{j as P,P as b,n as y,z as T,E as U,x as H,G as E,J as Y,D as V}from"./icons-VGG7keIQ.chunk.mjs";import{A as j}from"./ActionFavorite-bRkKTDIn.chunk.mjs";import{A as _}from"./AlbumForm-B5HQDBP6.chunk.mjs";import{N as R}from"./NcListItem-DfaWGP5A-eZQtYwBb.chunk.mjs";import{N as z}from"./NcVNodes-C0MrhmVc.chunk.mjs";import{N as K}from"./NcUserBubble-B3-E-5F5-PCL0TJHA.chunk.mjs";import{F as Q}from"./FetchCollectionsMixin-CqTYuk_r.chunk.mjs";import{F as q}from"./FileComponent-Z0cvFFM3.chunk.mjs";import{F as J,a as G}from"./FilesSelectionMixin-JLsUiKnU.chunk.mjs";import{H as W}from"./HeaderNavigation-Drss-bOM.chunk.mjs";import{F as X}from"./FetchFilesMixin-Dh0XuSuT.chunk.mjs";import{F as Z}from"./FilesByMonthMixin-BmZxTSkI.chunk.mjs";import"./preload-helper-Dh9HmuEY.chunk.mjs";import"./index-VV9wNENq.chunk.mjs";import"./dialog-DMSB8C_5.chunk.mjs";import"./index-CeB-M9CM.chunk.mjs";import"./PhotosFiltersInput-V84ZfLNi.chunk.mjs";import"./NcSelect-CjUzohn5-BzxyFHzp.chunk.mjs";import"./NcAvatar-YSp2ORHc-k3rtAvRh.chunk.mjs";import"./useModelMigration-EhAWvqDD-wVDp4GUR.chunk.mjs";import"./NcDateTimePicker-CijBajMH.chunk.mjs";import"./NcDialog-CKgpZOiy-Yt0iPUKp.chunk.mjs";import"./NcDateTime-DshRFtUU-DhtBMvqa.chunk.mjs";import"./collectionFetcher-Bc_5r3B7.chunk.mjs";import"./NcTextField-o_8gWurX-D9H3ZKW0.chunk.mjs";import"./index-x9vhq81Z.chunk.mjs";import"./FetchCollectionContentMixin-BXizDLoQ.chunk.mjs";import"./AbortControllerMixin-KqbYNBDv.chunk.mjs";import"./NcCheckboxRadioSwitch-VeztTzpz-CXqdOpK4.chunk.mjs";import"./fileFetcher-EOUUgMjG.chunk.mjs";import"./PhotoSearch-DdDD9daK.chunk.mjs";const tt={name:"NcListItem",components:{NcActions:p,NcCounterBubble:R,NcVNodes:z},props:{details:{type:String,default:""},name:{type:String,default:void 0},exact:{type:Boolean,default:!1},to:{type:[String,Object],default:null},href:{type:String,default:"#"},target:{type:String,default:""},anchorId:{type:String,default:""},bold:{type:Boolean,default:!1},compact:{type:Boolean,default:!1},active:{type:Boolean,default:!1},linkAriaLabel:{type:String,default:""},actionsAriaLabel:{type:String,default:void 0},counterNumber:{type:[Number,String],default:0},counterType:{type:String,default:"",validator(t){return["highlighted","outlined",""].indexOf(t)!==-1}},forceDisplayActions:{type:Boolean,default:!1},forceMenu:{type:Boolean,default:!1},oneLine:{type:Boolean,default:!1}},emits:["click","update:menuOpen"],setup(){const[t]=window._oc_config?.version.split(".",2)??[];return{isLegacy:t&&Number.parseInt(t)<30}},data(){return{hovered:!1,hasActions:!1,hasSubname:!1,displayActionsOnHoverFocus:!1,menuOpen:!1,hasIndicator:!1,hasDetails:!1}},computed:{showAdditionalElements(){return!this.displayActionsOnHoverFocus||this.forceDisplayActions},showDetails(){return(this.details!==""||this.hasDetails)&&(!this.displayActionsOnHoverFocus||this.forceDisplayActions)}},watch:{menuOpen(t){!t&&!this.hovered&&(this.displayActionsOnHoverFocus=!1)}},mounted(){this.checkSlots()},updated(){this.checkSlots()},methods:{onClick(t,e,s){this.$emit("click",t),!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&s&&(e?.(t),t.preventDefault())},showActions(){this.hasActions&&(this.displayActionsOnHoverFocus=!0),this.hovered=!1},hideActions(){this.displayActionsOnHoverFocus=!1},handleBlur(t){this.menuOpen||this.$refs["list-item"].contains(t.relatedTarget)||this.hideActions()},handleMouseleave(){this.menuOpen||(this.displayActionsOnHoverFocus=!1),this.hovered=!1},handleMouseover(){this.showActions(),this.hovered=!0},handleActionsUpdateOpen(t){this.menuOpen=t,this.$emit("update:menuOpen",t)},checkSlots(){this.hasActions!==!!this.$slots.actions&&(this.hasActions=!!this.$slots.actions),this.hasSubname!==!!this.$slots.subname&&(this.hasSubname=!!this.$slots.subname),this.hasIndicator!==!!this.$slots.indicator&&(this.hasIndicator=!!this.$slots.indicator),this.hasDetails!==!!this.$slots.details&&(this.hasDetails=!!this.$slots.details)}}};var et=function(){var t=this,e=t._self._c;return e(t.to?"router-link":"NcVNodes",{tag:"component",attrs:{custom:t.to?!0:null,to:t.to,exact:t.to?t.exact:null},scopedSlots:t._u([{key:"default",fn:function({href:s,navigate:i,isActive:o}){return[e("li",{staticClass:"list-item__wrapper",class:{"list-item__wrapper--active":o||t.active}},[e("div",{ref:"list-item",staticClass:"list-item",class:{"list-item--compact":t.compact,"list-item--legacy":t.isLegacy,"list-item--one-line":t.oneLine},on:{mouseover:t.handleMouseover,mouseleave:t.handleMouseleave}},[e("a",{staticClass:"list-item__anchor",attrs:{id:t.anchorId||void 0,"aria-label":t.linkAriaLabel,href:s||t.href,target:t.target||(t.href==="#"?void 0:"_blank"),rel:t.href==="#"?void 0:"noopener noreferrer"},on:{focus:t.showActions,focusout:t.handleBlur,click:function(a){return t.onClick(a,i,s)},keydown:function(a){return!a.type.indexOf("key")&&t._k(a.keyCode,"esc",27,a.key,["Esc","Escape"])?null:t.hideActions.apply(null,arguments)}}},[t._t("icon"),e("div",{staticClass:"list-item-content"},[e("div",{staticClass:"list-item-content__main"},[e("div",{staticClass:"list-item-content__name"},[t._t("name",function(){return[t._v(t._s(t.name))]})],2),t.hasSubname?e("div",{staticClass:"list-item-content__subname",class:{"list-item-content__subname--bold":t.bold}},[t._t("subname")],2):t._e()]),e("div",{staticClass:"list-item-content__details"},[t.showDetails?e("div",{staticClass:"list-item-details__details"},[t._t("details",function(){return[t._v(t._s(t.details))]})],2):t._e(),t.counterNumber||t.hasIndicator?e("div",{directives:[{name:"show",rawName:"v-show",value:t.showAdditionalElements,expression:"showAdditionalElements"}],staticClass:"list-item-details__extra"},[t.counterNumber?e("NcCounterBubble",{staticClass:"list-item-details__counter",attrs:{active:o||t.active,type:t.counterType}},[t._v(" "+t._s(t.counterNumber)+" ")]):t._e(),t.hasIndicator?e("span",{staticClass:"list-item-details__indicator"},[t._t("indicator")],2):t._e()],1):t._e()])])],2),t.$slots["extra-actions"]?e("div",{staticClass:"list-item-content__extra-actions"},[t._t("extra-actions")],2):t._e(),e("div",{directives:[{name:"show",rawName:"v-show",value:t.forceDisplayActions||t.displayActionsOnHoverFocus,expression:"forceDisplayActions || displayActionsOnHoverFocus"}],staticClass:"list-item-content__actions",on:{focusout:t.handleBlur}},[e("NcActions",{ref:"actions",attrs:{primary:o||t.active,"force-menu":t.forceMenu,"aria-label":t.actionsAriaLabel},on:{"update:open":t.handleActionsUpdateOpen},scopedSlots:t._u([t.$slots["actions-icon"]?{key:"icon",fn:function(){return[t._t("actions-icon")]},proxy:!0}:null],null,!0)},[t._t("actions")],2)],1),t.$slots.extra?e("div",{staticClass:"list-item__extra"},[t._t("extra")],2):t._e()])])]}}],null,!0)})},st=[],ot=B(tt,et,st,!1,null,"40599719");const it=ot.exports,at=v({name:"AlbumPicker",components:{Plus:b,ImageMultipleOutline:P,NcButton:f,NcListItem:it,NcLoadingIcon:$,NcUserBubble:K,AlbumForm:_},filters:{toCoverUrl(t){return C(`/apps/photos/api/v1/preview/${t}?x=64&y=64`)}},mixins:[Q],data(){return{showAlbumCreationForm:!1}},computed:{albums(){return this.$store.getters.albums},sharedAlbums(){return this.$store.getters.sharedAlbums},allAlbums(){return[...Object.values(this.albums),...Object.values(this.sharedAlbums)]}},mounted(){this.fetchAlbumList()},methods:{async fetchAlbumList(){await this.fetchCollections(`/photos/${l()?.uid}/albums`,c),await this.fetchCollections(`/photos/${l()?.uid}/sharedalbums`,c)},albumCreatedHandler(){this.showAlbumCreationForm=!1,this.fetchAlbumList()},pickAlbum(t){this.$emit("album-picked",t)},isSharedAlbum(t){return t.path.match(/^\/photos\/.+\/sharedalbums\//)!==null},originalName(t){return this.isSharedAlbum(t)?t.basename.replace(new RegExp(`\\(${t.attributes.collaborators[0].id}\\)$`),""):t.basename},t:h,n:A}});var nt=function(){var t=this,e=t._self._c;return t._self._setupProxy,t.showAlbumCreationForm?e("AlbumForm",{attrs:{"display-back-button":!0,title:t.t("photos","New album")},on:{back:function(s){t.showAlbumCreationForm=!1},done:t.albumCreatedHandler}}):e("div",{staticClass:"album-picker"},[e("h2",[t._v(" "+t._s(t.t("photos","Add to Album"))+" "),t.loadingCollections?e("NcLoadingIcon",{staticClass:"loading-icon"}):t._e()],1),e("ul",{staticClass:"albums-container"},t._l(t.allAlbums,function(s){return e("NcListItem",{key:s.attributes.filename,staticClass:"album",attrs:{name:t.originalName(s),"aria-label":t.t("photos","Add selection to album {albumName}",{albumName:s.basename})},on:{click:function(i){return t.pickAlbum(s)}},scopedSlots:t._u([{key:"subname",fn:function(){return[t._v(" "+t._s(t.n("photos","%n item","%n photos and videos",s.attributes.nbItems))+" "),t.isSharedAlbum(s)?[t._v(" ⸱ "+t._s(t.t("photos","Shared by"))+" "),e("NcUserBubble",{attrs:{"display-name":s.attributes.collaborators[0].label,user:s.attributes.collaborators[0].id}})]:t._e()]},proxy:!0}],null,!0)},[e("template",{slot:"icon"},[s.attributes["last-photo"]!==-1?e("img",{staticClass:"album__image",attrs:{src:t._f("toCoverUrl")(s.attributes["last-photo"])}}):e("div",{staticClass:"album__image album__image--placeholder"},[e("ImageMultipleOutline",{attrs:{size:32}})],1)])],2)}),1),e("NcButton",{staticClass:"new-album-button",attrs:{"aria-label":t.t("photos","Create a new album."),type:"tertiary"},on:{click:function(s){t.showAlbumCreationForm=!0}},scopedSlots:t._u([{key:"icon",fn:function(){return[e("Plus")]},proxy:!0}],null,!1,1489515321)},[t._v(" "+t._s(t.t("photos","Create new album"))+" ")])],1)},lt=[],rt=y(at,nt,lt,!1,null,"e4a49d0b");const ct=rt.exports;async function m(t,e){await I.head(t);const s=document.createElement("a");s.download=e??"",s.href=t,s.click()}function ut(t,e){const s=t.split("/").filter(Boolean),i=e.split("/").filter(Boolean);let o="";for(const[a,n]of s.entries()){if(a>=e.length||n!==i[a])break;o=`${o}${o===""?"":"/"}${n}`}return o}async function dt(t){let e;if(t.length===1)if(t[0].type===F.File){await m(t[0].encodedSource,t[0].displayname);return}else e=new URL(t[0].encodedSource),e.searchParams.append("accept","zip");else{e=new URL(t[0].encodedSource);let s=e.pathname;for(const o of t.slice(1))s=ut(s,new URL(o.encodedSource).pathname);e.pathname=s;const i=t.map(o=>decodeURIComponent(o.encodedSource.slice(e.href.length+1)));e.searchParams.append("accept","zip"),e.searchParams.append("files",JSON.stringify(i))}e.pathname.at(-1)!=="/"&&(e.pathname=`${e.pathname}/`),await m(e.href)}const mt={name:"TimelineView",components:{DeleteOutline:V,PlusBoxMultipleOutline:Y,DownloadOutline:E,Close:H,Plus:b,FolderAlertOutline:U,NcEmptyContent:D,NcModal:L,NcActions:p,NcActionButton:x,NcButton:f,AlbumForm:_,AlbumPicker:ct,FilesListViewer:G,FileComponent:q,ActionFavorite:j,HeaderNavigation:W,PhotosSourceLocationsSettings:N,AlertCircleOutline:T},filters:{dateMonth(t){return r(t,"YYYYMM").format("MMMM")},dateYear(t){return r(t,"YYYYMM").format("YYYY")}},mixins:[X,J,Z],beforeRouteLeave(t,e,s){this.appContent?.scrollTo(0,0),s(),Object.keys(this.selectedFilters).forEach(i=>{this.selectedFilters[i]=[]})},props:{onlyFavorites:{type:Boolean,default:!1},mimesType:{type:Array,default:()=>M},onThisDay:{type:Boolean,default:!1},rootTitle:{type:String,required:!0}},setup(){const t=k(),e=S(),{selectedFilters:s,filtersQuery:i}=O(e);return{isMobile:t,selectedFilters:s,filtersQuery:i}},data(){return{loadingCount:0,showAlbumCreationForm:!1,showAlbumPicker:!1,appContent:document.getElementById("app-content-vue"),showFilters:!1}},computed:{files(){return this.$store.state.files.files},createAlbumButtonLabel(){return Object.keys(this.selectedFilters).length>0?this.t("photos","Create new album from filters"):this.t("photos","Create new album")}},watch:{filtersQuery(){this.resetFetchFilesState(),this.getContent()}},mounted(){w(d,this.handleUserConfigChange)},destroyed(){g(d,this.handleUserConfigChange)},methods:{getContent(){this.fetchFiles({mimesType:this.mimesType,onThisDay:this.onThisDay,onlyFavorites:this.onlyFavorites,extraFilters:this.filtersQuery})},openViewer(t){window.OCA.Viewer.open({fileInfo:u(this.files[t]),list:Object.values(this.fileIdsByMonth).flat().map(e=>u(this.files[e]))})},openUploader(){},async addSelectionToAlbum(t){this.showAlbumPicker=!1,await this.$store.dispatch("addFilesToCollection",{collectionFileName:t.root+t.path,fileIdsToAdd:this.selectedFileIds})},async deleteSelection(){const t=this.selectedFileIds;this.onUncheckFiles(t),this.fetchedFileIds=this.fetchedFileIds.filter(e=>!t.includes(e)),await this.$store.dispatch("deleteFiles",t)},handleUserConfigChange({key:t}){t==="photosSourceFolders"&&this.resetFetchFilesState()},handleFormCreationDone({album:t}){this.showAlbumCreationForm=!1,this.$router.push(`/albums/${t.basename}`)},downloadSelectedFiles(){const t=this.selectedFileIds;this.onUncheckFiles(t),dt(t.map(e=>this.files[e]))},t:h}};var ht=function(){var t=this,e=t._self._c;return t.errorFetchingFiles?e("div",{staticClass:"timeline__empty-content"},[t.errorFetchingFiles===404?e("NcEmptyContent",{attrs:{name:t.t("photos","One of the source folders does not exist")}},[e("FolderAlertOutline",{attrs:{slot:"icon"},slot:"icon"}),e("PhotosSourceLocationsSettings",{staticClass:"timeline__update_source_directory",attrs:{slot:"action"},slot:"action"})],1):e("NcEmptyContent",{attrs:{name:t.t("photos","An error occurred")}},[e("AlertCircleOutline",{attrs:{slot:"icon"},slot:"icon"})],1)],1):e("div",{staticClass:"timeline"},[e("HeaderNavigation",{key:"navigation",attrs:{loading:t.loadingCount>0,path:"/",title:t.rootTitle,"root-title":t.rootTitle},on:{refresh:t.resetFetchFilesState}},[e("div",{staticClass:"timeline__header__left"},[t.selectedFileIds.length===0?e("NcButton",{ref:"newAlbumButton",attrs:{"aria-label":t.createAlbumButtonLabel,"data-cy-header-action":"create-album"},on:{click:function(s){t.showAlbumCreationForm=!0}},scopedSlots:t._u([{key:"icon",fn:function(){return[e("PlusBoxMultipleOutline")]},proxy:!0}],null,!1,2448450972)},[t._v(" "+t._s(t.createAlbumButtonLabel)+" ")]):[e("NcButton",{attrs:{"close-after-click":!0,type:"primary","aria-label":t.t("photos","Add to album"),"data-cy-header-action":"add-to-album"},on:{click:function(s){t.showAlbumPicker=!0}},scopedSlots:t._u([{key:"icon",fn:function(){return[e("Plus")]},proxy:!0},t.isMobile?null:{key:"default",fn:function(){return[t._v(" "+t._s(t.t("photos","Add to album"))+" ")]},proxy:!0}],null,!0)}),t.selectedFileIds.length>0?e("NcButton",{attrs:{"aria-label":t.t("photos","Unselect all"),"data-cy-header-action":"unselect-all"},on:{click:t.resetSelection},scopedSlots:t._u([{key:"icon",fn:function(){return[e("Close")]},proxy:!0},t.isMobile?null:{key:"default",fn:function(){return[t._v(" "+t._s(t.t("photos","Unselect all"))+" ")]},proxy:!0}],null,!0)}):t._e(),e("NcActions",{attrs:{"aria-label":t.t("photos","Open actions menu")}},[e("NcActionButton",{attrs:{"data-cy-header-action":"download-selection","close-after-click":!0,"aria-label":t.t("photos","Download selected files")},on:{click:t.downloadSelectedFiles},scopedSlots:t._u([{key:"icon",fn:function(){return[e("DownloadOutline")]},proxy:!0}])},[t._v(" "+t._s(t.t("photos","Download selected files"))+" ")]),e("ActionFavorite",{attrs:{"selected-file-ids":t.selectedFileIds}}),e("NcActionButton",{attrs:{"close-after-click":!0,"aria-label":t.t("photos","Delete selection"),"data-cy-header-action":"delete-selection"},on:{click:t.deleteSelection},scopedSlots:t._u([{key:"icon",fn:function(){return[e("DeleteOutline")]},proxy:!0}])},[t._v(" "+t._s(t.t("photos","Delete selection"))+" ")])],1)]],2)]),e("FilesListViewer",{ref:"filesListViewer",staticClass:"timeline__file-list",attrs:{"container-element":t.appContent,"file-ids-by-section":t.fileIdsByMonth,sections:t.monthsList,loading:t.loadingFiles,"base-height":t.isMobile?120:200,"empty-message":t.t("photos","No photos or videos in here")},on:{"need-content":t.getContent},scopedSlots:t._u([{key:"default",fn:function({file:s,isHeader:i,distance:o}){return[i?e("h2",{staticClass:"section-header",attrs:{id:`file-picker-section-header-${s.id}`}},[e("b",[t._v(t._s(t._f("dateMonth")(s.id)))]),t._v(" "+t._s(t._f("dateYear")(s.id))+" ")]):e("FileComponent",{attrs:{file:t.files[s.id],"allow-selection":!0,selected:t.selection[s.id]===!0,distance:o},on:{click:t.openViewer,"select-toggled":t.onFileSelectToggle}})]}}])}),t.showAlbumCreationForm?e("NcModal",{key:"albumCreationForm",attrs:{"label-id":"new-album-form","set-return-focus":t.$refs.newAlbumButton?.$el},on:{close:function(s){t.showAlbumCreationForm=!1}}},[e("h2",{staticClass:"timeline__heading"},[t._v(" "+t._s(t.t("photos","New album"))+" ")]),e("AlbumForm",{attrs:{"filters-value":t.selectedFilters},on:{done:t.handleFormCreationDone}})],1):t._e(),t.showAlbumPicker?e("NcModal",{key:"albumPicker",attrs:{"label-id":"album-picker"},on:{close:function(s){t.showAlbumPicker=!1}}},[e("AlbumPicker",{on:{"album-picked":t.addSelectionToAlbum}})],1):t._e()],1)},pt=[],ft=y(mt,ht,pt,!1,null,"3cbe5aa3");const te=ft.exports;export{te as default};
|
||
//# sourceMappingURL=TimelineView-oBWAVriN.chunk.mjs.map
|