mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-30 10:13:16 +00:00
1 line
No EOL
19 KiB
JavaScript
Vendored
1 line
No EOL
19 KiB
JavaScript
Vendored
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[33],{98379:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>n});i(82364);function o(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return s(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return s(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,o=new Array(e);i<e;i++)o[i]=t[i];return o}const n={props:["collection-id","collection-title","collection-description","collection-visibility","profile-id","profile-username"],components:{intersect:i(78423).default},data:function(){return{collection:{},config:window.App.config,loaded:!1,posts:[],ids:[],user:!1,owner:!1,title:this.collectionTitle,description:this.collectionDescription,visibility:this.collectionVisibility,photoId:"",postsList:[],loadingPostList:!1,addingPostToCollection:!1,markedForDeletion:[],canLoadMore:!1,isIntersecting:!1,page:1}},beforeMount:function(){this.fetchCollection()},methods:{enterIntersect:function(){this.isIntersecting||(this.isIntersecting=!0,this.page++,this.fetchItems())},statusUrl:function(t){return"/i/web/post/"+t.id},fetchCollection:function(){var t=this;axios.get("/api/local/collection/"+this.collectionId).then((function(e){t.collection=e.data,t.collection.post_count>9&&(t.canLoadMore=!0),t.fetchCurrentUser()}))},fetchCurrentUser:function(){var t=this;1==document.querySelectorAll("body")[0].classList.contains("loggedIn")?axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(e){t.user=e.data,t.owner=t.user.id==t.profileId,window._sharedData.curUser=e.data,window.App.util.navatar(),t.fetchItems()})):this.fetchItems()},fetchItems:function(){var t=this;axios.get("/api/local/collection/items/"+this.collectionId,{params:{page:this.page}}).then((function(e){var i;if(0==e.data.length)return console.log("no items found"),t.loaded=!0,t.isIntersecting=!1,void(t.canLoadMore=!1);var s=e.data.filter((function(e){return-1==t.ids.indexOf(e.id)}));(i=t.posts).push.apply(i,o(s)),t.ids=t.posts.map((function(t){return t.id})),t.loaded=!0,t.isIntersecting=!1,0==s.length&&(t.canLoadMore=!1)}))},previewUrl:function(t){return t&&t.sensitive?"/storage/no-preview.png?v="+(new Date).getTime():t.media_attachments[0].url},previewBackground:function(t){return"background-image: url("+this.previewUrl(t)+");"},addToCollection:function(){var t=this;this.loadingPostList=!0,0==this.postsList.length?axios.get("/api/pixelfed/v1/accounts/"+this.profileId+"/statuses",{params:{min_id:1,limit:24}}).then((function(e){t.postsList=e.data.filter((function(e){return-1==t.ids.indexOf(e.id)})).splice(0,9),t.loadingPostList=!1,t.$refs.addPhotoModal.show()})).catch((function(e){t.loadingPostList=!1,swal("An Error Occured","We cannot process your request at this time, please try again later.","error")})):(this.$refs.addPhotoModal.show(),this.loadingPostList=!1)},pushId:function(){var t=this,e=this.config.uploader.max_collection_length,i=this;if(this.posts.length>=e)swal("Error","You can only add "+e+" posts per collection","error");else{var s=this.photoId,n=window.location.origin,a=s.split("/");s.slice(0,n.length)!==n&&(swal("Invalid URL","You can only add posts from this instance","error"),this.photoId=""),s.slice(0,n.length+3)===n+"/p/"&&6===a.length||(swal("Invalid URL","Invalid URL","error"),this.photoId=""),axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:a[5]}).then((function(t){var e;(e=i.ids).push.apply(e,o(a[5]))})).catch((function(e){swal("Invalid URL","The post you entered was invalid","error"),t.photoId=""})),i.$refs.addPhotoModal.hide()}},editCollection:function(){this.$refs.editModal.show()},deleteCollection:function(){0!=this.owner&&(window.confirm("Are you sure you want to delete this collection?")&&axios.delete("/api/local/collection/"+this.collectionId).then((function(t){window.location.href="/"})))},publishCollection:function(){0!=this.owner&&(window.confirm("Are you sure you want to publish this collection?")&&axios.post("/api/local/collection/"+this.collectionId+"/publish",{title:this.title,description:this.description,visibility:this.visibility}).then((function(t){console.log(t.data)})))},updateCollection:function(){var t=this;this.closeModals(),axios.post("/api/local/collection/"+this.collectionId,{title:this.title,description:this.description,visibility:this.visibility}).then((function(e){t.collection=e.data}))},showEditPhotosModal:function(){this.$refs.editModal.hide(),this.$refs.editPhotosModal.show()},markPhotoForDeletion:function(t){-1==this.markedForDeletion.indexOf(t)?this.markedForDeletion.push(t):this.markedForDeletion=this.markedForDeletion.filter((function(e){return e!=t}))},confirmDeletion:function(){var t=this,e=this;window.confirm("Are you sure you want to delete this?")&&(this.markedForDeletion.forEach((function(i){axios.delete("/api/local/collection/item",{params:{collection_id:e.collectionId,post_id:i}}).then((function(o){e.removeItem(i),t.collection.post_count=t.collection.post_count-1,t.closeModals()})).catch((function(t){swal("Oops!","An error occured with your request, please try again later.","error")}))})),this.markedForDeletion=[])},removeItem:function(t){this.posts=this.posts.filter((function(e){return e.id!=t}))},addRecentId:function(t){var e=this;axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:t.id}).then((function(t){e.closeModals(),e.posts.push(t.data),e.collection.post_count++})).catch((function(t){swal("Oops!","An error occured, please try selecting another post.","error"),e.photoId=""}))},timeago:function(t){return App.util.format.timeAgo(t)},closeModals:function(){this.$refs.editModal.hide(),this.$refs.addPhotoModal.hide(),this.$refs.editPhotosModal.hide()},getPreviewUrl:function(t){if(!t.media_attachments||!t.media_attachments.length)return"/storage/no-preview.png";var e=t.media_attachments[0];return e.preview_url.endsWith("storage/no-preview.png")?"image"===e.type?e.url:"/storage/no-preview.png":e.preview_url}}}},55386:(t,e,i)=>{Vue.component("collection-component",i(44051).default)},1023:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>n});var o=i(23645),s=i.n(o)()((function(t){return t[1]}));s.push([t.id,".dims[data-v-84d54b88]{background:rgba(0,0,0,.68);bottom:0;left:0;position:absolute;right:0;top:0;z-index:300}.scrollbar-hidden[data-v-84d54b88]::-webkit-scrollbar{display:none}.delete-border[data-v-84d54b88]{border:4px solid red}.delete-border .square-content[data-v-84d54b88]{background-blend-mode:screen;background-color:red}.info-overlay-text-field[data-v-84d54b88]{font-size:13.5px;margin-bottom:2px}@media(min-width:768px){.info-overlay-text-field[data-v-84d54b88]{font-size:20px;margin-bottom:15px}}.feed .card.info-overlay[data-v-84d54b88]{margin-bottom:2rem}",""]);const n=s},49490:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>l});var o=i(93379),s=i.n(o),n=i(1023),a={insert:"head",singleton:!1};s()(n.default,a);const l=n.default.locals||{}},44051:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>a});var o=i(46381),s=i(33195),n={};for(const t in s)"default"!==t&&(n[t]=()=>s[t]);i.d(e,n);i(70249);const a=(0,i(51900).default)(s.default,o.render,o.staticRenderFns,!1,null,"84d54b88",null).exports},33195:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>n});var o=i(98379),s={};for(const t in o)"default"!==t&&(s[t]=()=>o[t]);i.d(e,s);const n=o.default},70249:(t,e,i)=>{"use strict";i.r(e);var o=i(49490),s={};for(const t in o)"default"!==t&&(s[t]=()=>o[t]);i.d(e,s)},46381:(t,e,i)=>{"use strict";i.r(e);var o=i(24271),s={};for(const t in o)"default"!==t&&(s[t]=()=>o[t]);i.d(e,s)},24271:(t,e,i)=>{"use strict";i.r(e),i.d(e,{render:()=>o,staticRenderFns:()=>s});var o=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"w-100 h-100"},[t.loaded?t._e():i("div",{staticClass:"d-flex justify-content-center align-items-center",staticStyle:{height:"80vh"}},[i("img",{attrs:{src:"/img/pixelfed-icon-grey.svg"}})]),t._v(" "),t.loaded?i("div",{staticClass:"row mt-3"},[i("div",{staticClass:"col-12 p-0 mb-3"},[t.owner&&!t.collection.published_at?i("div",[t._m(0)]):t._e()]),t._v(" "),i("div",{staticClass:"col-12 p-0 mb-3"},[i("picture",{staticClass:"d-flex align-items-center justify-content-center"},[i("div",{staticClass:"dims"}),t._v(" "),i("div",{staticClass:"text-white",staticStyle:{"z-index":"500",position:"absolute"}},[i("p",{staticClass:"display-4 text-center pt-3"},[t._v(t._s(t.title||"Untitled Collection"))]),t._v(" "),i("p",{staticClass:"lead text-center mb-3"},[t._v(t._s(t.description))]),t._v(" "),i("p",{staticClass:"text-center"},[t.owner&&"public"!=t.collection.visibility?i("span",["draft"==t.collection.visibility?i("span",{staticClass:"btn btn-outline-light btn-sm text-capitalize py-0",staticStyle:{"font-size":"10px"}},[i("i",{staticClass:"far fa-lock"}),t._v(" Draft\n\t\t\t\t\t\t\t")]):"private"==t.collection.visibility?i("span",{staticClass:"btn btn-outline-light btn-sm text-capitalize py-0",staticStyle:{"font-size":"10px"}},[t._v("\n\t\t\t\t\t\t\t\tFollowers Only\n\t\t\t\t\t\t\t")]):t._e(),t._v(" "),i("span",[t._v("·")])]):t._e(),t._v(" "),i("span",[t._v(t._s(t.collection.post_count)+" photos")]),t._v(" "),i("span",[t._v("·")]),t._v(" "),i("span",[t._v("by "),i("a",{staticClass:"font-weight-bold text-white",attrs:{href:"/"+t.profileUsername}},[t._v(t._s(t.profileUsername))])])]),t._v(" "),1==t.owner?i("p",{staticClass:"pt-3 text-center"},[i("span",[i("button",{staticClass:"btn btn-outline-light btn-sm",attrs:{onclick:"this.blur();"},on:{click:function(e){return e.preventDefault(),t.addToCollection.apply(null,arguments)}}},[0==t.loadingPostList?i("span",[t._v("Add Photo")]):i("span",{staticClass:"px-4"},[t._m(1)])]),t._v("\n\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t"),i("button",{staticClass:"btn btn-outline-light btn-sm",attrs:{onclick:"this.blur();"},on:{click:function(e){return e.preventDefault(),t.editCollection.apply(null,arguments)}}},[t._v("Edit")]),t._v("\n\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t"),i("button",{staticClass:"btn btn-outline-light btn-sm",on:{click:function(e){return e.preventDefault(),t.deleteCollection.apply(null,arguments)}}},[t._v("Delete")])])]):t._e()]),t._v(" "),t.posts&&t.posts.length?i("img",{staticStyle:{width:"100%",height:"400px","object-fit":"cover"},attrs:{src:t.previewUrl(t.posts[0]),alt:""}}):i("div",{staticClass:"bg-info",staticStyle:{width:"100%",height:"400px"}})])]),t._v(" "),i("div",{staticClass:"col-12 p-0"},[t.posts&&t.posts.length>0?i("div",{staticClass:"row px-3 px-md-0"},[t._l(t.posts,(function(e,o){return i("div",{staticClass:"col-6 col-md-4 feed"},[e.hasOwnProperty("pf_type")&&"video"==e.pf_type?i("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:t.statusUrl(e)}},[i("div",{staticClass:"square"},[i("div",{staticClass:"square-content"},[t._m(2,!0),t._v(" "),i("blur-hash-canvas",{staticClass:"rounded",attrs:{width:"32",height:"32",hash:e.media_attachments[0].blurhash}})],1)])]):e.sensitive?i("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:t.statusUrl(e)}},[i("div",{staticClass:"square"},[i("div",{staticClass:"square-content"},[t._m(3,!0),t._v(" "),i("blur-hash-canvas",{staticClass:"rounded",attrs:{width:"32",height:"32",hash:e.media_attachments[0].blurhash}})],1)])]):i("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:t.statusUrl(e)}},[i("div",{staticClass:"square"},[i("div",{staticClass:"square-content"},[i("blur-hash-image",{staticClass:"rounded",attrs:{width:"32",height:"32",hash:e.media_attachments[0].blurhash,src:t.previewUrl(e)}})],1)])])])})),t._v(" "),t.canLoadMore?i("div",{staticClass:"col-12"},[i("intersect",{on:{enter:t.enterIntersect}},[i("div",{staticClass:"card card-body shadow-none border"},[i("div",{staticClass:"d-flex justify-content-center align-items-center flex-column"},[i("b-spinner",{attrs:{variant:"muted"}}),t._v(" "),i("p",{staticClass:"text-lighter small mt-2 mb-0"},[t._v("Loading more...")])],1)])])],1):t._e()],2):t._e()])]):t._e(),t._v(" "),i("b-modal",{ref:"editModal",attrs:{id:"edit-modal","hide-footer":"",centered:"",title:"Edit Collection","body-class":""}},[i("form",[i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Title")]),t._v(" "),i("input",{directives:[{name:"model",rawName:"v-model",value:t.title,expression:"title"}],staticClass:"form-control",attrs:{type:"text",id:"title",placeholder:"Untitled Collection"},domProps:{value:t.title},on:{input:function(e){e.target.composing||(t.title=e.target.value)}}})]),t._v(" "),i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"description"}},[t._v("Description")]),t._v(" "),i("textarea",{directives:[{name:"model",rawName:"v-model",value:t.description,expression:"description"}],staticClass:"form-control",attrs:{id:"description",placeholder:"Add a description here ...",rows:"3"},domProps:{value:t.description},on:{input:function(e){e.target.composing||(t.description=e.target.value)}}})]),t._v(" "),i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"visibility"}},[t._v("Visibility")]),t._v(" "),i("select",{directives:[{name:"model",rawName:"v-model",value:t.visibility,expression:"visibility"}],staticClass:"custom-select",on:{change:function(e){var i=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.visibility=e.target.multiple?i:i[0]}}},[i("option",{attrs:{value:"public"}},[t._v("Public")]),t._v(" "),i("option",{attrs:{value:"private"}},[t._v("Followers Only")]),t._v(" "),i("option",{attrs:{value:"draft"}},[t._v("Draft")])])]),t._v(" "),i("div",{staticClass:"d-flex justify-content-between align-items-center pt-3"},[i("a",{staticClass:"text-primary font-weight-bold text-decoration-none",attrs:{href:"#"},on:{click:function(e){return e.preventDefault(),t.showEditPhotosModal.apply(null,arguments)}}},[t._v("\n\t\t\t\t\tEdit Photos\n\t\t\t\t")]),t._v(" "),t.collection.published_at?i("div",[i("button",{staticClass:"btn btn-primary btn-sm py-1 font-weight-bold px-3 float-right",attrs:{type:"button"},on:{click:function(e){return e.preventDefault(),t.updateCollection.apply(null,arguments)}}},[t._v("\n\t\t\t\t\t\tSave\n\t\t\t\t\t")])]):i("div",{staticClass:"float-right"},[i("button",{staticClass:"btn btn-outline-primary btn-sm py-1 font-weight-bold px-3",attrs:{type:"button"},on:{click:function(e){return e.preventDefault(),t.publishCollection.apply(null,arguments)}}},[t._v("\n\t\t\t\t\t\tPublish\n\t\t\t\t\t")]),t._v(" "),i("button",{staticClass:"btn btn-primary btn-sm py-1 font-weight-bold px-3",attrs:{type:"button"},on:{click:function(e){return e.preventDefault(),t.updateCollection.apply(null,arguments)}}},[t._v("\n\t\t\t\t\t\tSave\n\t\t\t\t\t")])])])])]),t._v(" "),i("b-modal",{ref:"addPhotoModal",attrs:{id:"add-photo-modal","hide-footer":"",centered:"",title:"Add Photo","body-class":"m-3"}},[i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Add Recent Post")]),t._v(" "),t.postsList.length>0?i("div",{staticClass:"row m-1"},[t._l(t.postsList,(function(e,o){return i("div",{key:"postList-"+o,staticClass:"col-4 p-1 cursor-pointer",on:{click:function(i){return t.addRecentId(e)}}},[i("div",{staticClass:"square border"},[i("div",{staticClass:"square-content",style:"background-image: url("+t.getPreviewUrl(e)+");"})])])})),t._v(" "),i("div",{staticClass:"col-12"},[i("hr")])],2):t._e()]),t._v(" "),i("form",[i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Add Post by URL")]),t._v(" "),i("input",{directives:[{name:"model",rawName:"v-model",value:t.photoId,expression:"photoId"}],staticClass:"form-control",attrs:{type:"text",placeholder:"https://pixelfed.dev/p/admin/1"},domProps:{value:t.photoId},on:{input:function(e){e.target.composing||(t.photoId=e.target.value)}}}),t._v(" "),i("p",{staticClass:"help-text small text-muted"},[t._v("Only local, public posts can be added")])]),t._v(" "),i("button",{staticClass:"btn btn-primary btn-sm py-1 font-weight-bold px-3 float-right",attrs:{type:"button"},on:{click:function(e){return e.preventDefault(),t.pushId.apply(null,arguments)}}},[t.addingPostToCollection?i("span",{staticClass:"px-4"},[i("div",{staticClass:"spinner-border spinner-border-sm",attrs:{role:"status"}},[i("span",{staticClass:"sr-only"},[t._v("Loading...")])])]):i("span",[t._v("\n\t\t\t\t\tAdd Photo\n\t\t\t\t")])])])]),t._v(" "),i("b-modal",{ref:"editPhotosModal",attrs:{id:"edit-photos-modal","hide-footer":"",centered:"",title:"Edit Collection Photos","body-class":"m-3"}},[i("div",{staticClass:"form-group"},[i("p",{staticClass:"font-weight-bold text-dark text-center"},[t._v("Select a Photo to Delete")]),t._v(" "),t.posts.length>0?i("div",{staticClass:"row m-1 scrollbar-hidden",staticStyle:{"max-height":"350px","overflow-y":"auto"}},t._l(t.posts,(function(e,o){return i("div",{key:"plm-"+o,staticClass:"col-4 p-1 cursor-pointer"},[i("div",{class:[-1==t.markedForDeletion.indexOf(e.id)?"square":"square delete-border"],on:{click:function(i){return t.markPhotoForDeletion(e.id)}}},[i("div",{staticClass:"square-content",style:"background-image: url("+e.media_attachments[0].url+");"})])])})),0):t._e(),t._v(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:t.markedForDeletion.length>0,expression:"markedForDeletion.length > 0"}]},[i("button",{staticClass:"btn btn-primary font-weight-bold py-0 btn-block mb-0 mt-4",attrs:{type:"button"},on:{click:function(e){return e.preventDefault(),t.confirmDeletion.apply(null,arguments)}}},[t._v("Delete "+t._s(t.markedForDeletion.length)+" "+t._s(1==t.markedForDeletion.length?"photo":"photos"))])])])])],1)},s=[function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"alert alert-danger d-flex justify-content-center"},[i("div",{staticClass:"media align-items-center"},[i("i",{staticClass:"far fa-exclamation-triangle fa-3x mr-3"}),t._v(" "),i("div",{staticClass:"media-body"},[i("p",{staticClass:"font-weight-bold mb-0"},[t._v("\n\t\t\t\t\t\t\t\tThis collection is unpublished.\n\t\t\t\t\t\t\t")]),t._v(" "),i("p",{staticClass:"small mb-0"},[t._v("\n\t\t\t\t\t\t\t\tThis collection is not visible to anyone else until you publish it. "),i("br"),t._v("\n\t\t\t\t\t\t\t\tTo publish, click on the "),i("strong",[t._v("Edit")]),t._v(" button and then click on the "),i("strong",[t._v("Publish")]),t._v(" button.\n\t\t\t\t\t\t\t")])])])])},function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"spinner-border spinner-border-sm",attrs:{role:"status"}},[i("span",{staticClass:"sr-only"},[t._v("Loading...")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"info-overlay-text-label rounded"},[e("h5",{staticClass:"text-white m-auto font-weight-bold"},[e("span",[e("span",{staticClass:"far fa-video fa-2x p-2 d-flex-inline"})])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"info-overlay-text-label rounded"},[e("h5",{staticClass:"text-white m-auto font-weight-bold"},[e("span",[e("span",{staticClass:"far fa-eye-slash fa-lg p-2 d-flex-inline"})])])])}]}},t=>{t.O(0,[898],(()=>{return e=55386,t(t.s=e);var e}));t.O()}]); |