mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-23 06:51:27 +00:00
1 line
No EOL
9.8 KiB
JavaScript
Vendored
1 line
No EOL
9.8 KiB
JavaScript
Vendored
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{17:function(t,i,e){t.exports=e("iBgk")},GicU:function(t,i,e){"use strict";e.r(i);var o={props:["collection-id","profile-id"],data:function(){return{loaded:!1,limit:8,step:1,title:"",description:"",visibility:"private",collection:{title:"",description:"",visibility:"public"},id:"",posts:[],tab:"add",tabs:["all","add","order"],recentPosts:[],selectedPost:""}},beforeMount:function(){var t=this;axios.get("/api/local/collection/"+this.collectionId).then((function(i){t.collection=i.data}))},mounted:function(){this.fetchRecentPosts(),this.fetchItems()},methods:{addToIds:function(t){var i=this;axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:t}).then((function(t){i.fetchItems(),i.fetchRecentPosts(),i.tab="all",i.id=""})).catch((function(t){swal("Invalid URL","The post you entered was invalid","error"),i.id=""}))},fetchItems:function(){var t=this;axios.get("/api/local/collection/items/"+this.collectionId).then((function(i){t.posts=i.data,t.loaded=!0}))},addId:function(){if(this.posts.length>=18)swal("Error","You can only add 18 posts per collection","error");else{var t=this.id,i=window.location.origin,e=t.split("/");t.slice(0,i.length)!==i&&(swal("Invalid URL","You can only add posts from this instance","error"),this.id=""),t.slice(0,i.length+3)===i+"/p/"&&6===e.length||(swal("Invalid URL","Invalid URL","error"),this.id=""),this.addToIds(e[5])}},previewUrl:function(t){return t.sensitive?"/storage/no-preview.png?v="+(new Date).getTime():t.media_attachments[0].preview_url},previewBackground:function(t){return"background-image: url("+this.previewUrl(t)+");background-size:cover;"},fetchRecentPosts:function(){var t=this;axios.get("/api/pixelfed/v1/accounts/"+this.profileId+"/statuses",{params:{only_media:!0,min_id:1}}).then((function(i){t.recentPosts=i.data.filter((function(i){var e=t.posts.map((function(t){return t.id}));return"public"==i.visibility&&0==i.sensitive&&-1==e.indexOf(i.id)})).slice(0,3)}))},selectPost:function(t){this.selectedPost=t.id,this.id=t.url},publish:function(){0!=this.posts.length?axios.post("/api/local/collection/"+this.collectionId+"/publish",{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then((function(t){window.location.href=t.data})).catch((function(t){swal("Something went wrong","There was a problem with your request, please try again later.","error")})):swal("Error","You cannot publish an empty collection")},save:function(){axios.post("/api/local/collection/"+this.collectionId,{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then((function(t){swal("Saved!","You have successfully saved this collection.","success")}))},deleteCollection:function(){window.confirm("Are you sure you want to delete this collection?")&&axios.delete("/api/local/collection/"+this.collectionId).then((function(t){window.location.href="/"}))}}},s=e("KHd+"),l=Object(s.a)(o,(function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{staticClass:"container"},[t.loaded?e("div",{staticClass:"row"},[t._m(0),t._v(" "),e("div",{staticClass:"col-12 col-md-4 pt-3"},[e("div",{staticClass:"card rounded-0 shadow-none border ",staticStyle:{"min-height":"440px"}},[e("div",{staticClass:"card-body"},[e("div",[e("form",[e("div",{staticClass:"form-group"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Title")]),t._v(" "),e("input",{directives:[{name:"model",rawName:"v-model",value:t.collection.title,expression:"collection.title"}],staticClass:"form-control",attrs:{type:"text",id:"title",placeholder:"Collection Title"},domProps:{value:t.collection.title},on:{input:function(i){i.target.composing||t.$set(t.collection,"title",i.target.value)}}})]),t._v(" "),e("div",{staticClass:"form-group"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"description"}},[t._v("Description")]),t._v(" "),e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.collection.description,expression:"collection.description"}],staticClass:"form-control",attrs:{id:"description",placeholder:"Example description here",rows:"3"},domProps:{value:t.collection.description},on:{input:function(i){i.target.composing||t.$set(t.collection,"description",i.target.value)}}})]),t._v(" "),e("div",{staticClass:"form-group"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"visibility"}},[t._v("Visibility")]),t._v(" "),e("select",{directives:[{name:"model",rawName:"v-model",value:t.collection.visibility,expression:"collection.visibility"}],staticClass:"custom-select",on:{change:function(i){var e=Array.prototype.filter.call(i.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.collection,"visibility",i.target.multiple?e:e[0])}}},[e("option",{attrs:{value:"public"}},[t._v("Public")]),t._v(" "),e("option",{attrs:{value:"private"}},[t._v("Followers Only")])])])]),t._v(" "),e("hr"),t._v(" "),e("p",[t.posts.length>0?e("button",{staticClass:"btn btn-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.publish}},[t._v("Publish")]):e("button",{staticClass:"btn btn-primary font-weight-bold btn-block disabled",attrs:{type:"button",disabled:""}},[t._v("Publish")])]),t._v(" "),e("p",[e("button",{staticClass:"btn btn-outline-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.save}},[t._v("Save")])]),t._v(" "),e("p",{staticClass:"mb-0"},[e("button",{staticClass:"btn btn-outline-secondary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.deleteCollection}},[t._v("Delete")])])])])])]),t._v(" "),e("div",{staticClass:"col-12 col-md-8 pt-3"},[e("div",[e("ul",{staticClass:"nav nav-tabs"},[e("li",{staticClass:"nav-item"},[e("a",{class:["add"==t.tab?"nav-link font-weight-bold bg-white active":"nav-link font-weight-bold text-muted"],attrs:{href:"#"},on:{click:function(i){i.preventDefault(),t.tab="add"}}},[t._v("Add Posts")])]),t._v(" "),e("li",{staticClass:"nav-item"},[e("a",{class:["all"==t.tab?"nav-link font-weight-bold bg-white active":"nav-link font-weight-bold text-muted"],attrs:{href:"#"},on:{click:function(i){i.preventDefault(),t.tab="all"}}},[t._v("Preview")])])])]),t._v(" "),e("div",{staticClass:"card rounded-0 shadow-none border border-top-0"},[e("div",{staticClass:"card-body",staticStyle:{height:"460px","overflow-y":"auto"}},["all"==t.tab?e("div",{staticClass:"row"},t._l(t.posts,(function(i,o){return e("div",{staticClass:"col-4 p-1"},[e("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:i.url}},[e("div",{staticClass:"square"},["photo:album"==i.pf_type?e("span",{staticClass:"float-right mr-3 post-icon"},[e("i",{staticClass:"fas fa-images fa-2x"})]):t._e(),t._v(" "),"video"==i.pf_type?e("span",{staticClass:"float-right mr-3 post-icon"},[e("i",{staticClass:"fas fa-video fa-2x"})]):t._e(),t._v(" "),"video:album"==i.pf_type?e("span",{staticClass:"float-right mr-3 post-icon"},[e("i",{staticClass:"fas fa-film fa-2x"})]):t._e(),t._v(" "),e("div",{staticClass:"square-content",style:t.previewBackground(i)}),t._v(" "),e("div",{staticClass:"info-overlay-text"},[e("h5",{staticClass:"text-white m-auto font-weight-bold"},[e("span",[e("span",{staticClass:"far fa-heart fa-lg p-2 d-flex-inline"}),t._v(" "),e("span",{staticClass:"d-flex-inline"},[t._v(t._s(i.favourites_count))])]),t._v(" "),e("span",[e("span",{staticClass:"fas fa-retweet fa-lg p-2 d-flex-inline"}),t._v(" "),e("span",{staticClass:"d-flex-inline"},[t._v(t._s(i.reblogs_count))])])])])])])])})),0):t._e(),t._v(" "),"add"==t.tab?e("div",[e("div",{staticClass:"form-group"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Add Post by URL")]),t._v(" "),e("input",{directives:[{name:"model",rawName:"v-model",value:t.id,expression:"id"}],staticClass:"form-control",attrs:{type:"text",placeholder:"https://pixelfed.dev/p/admin/1"},domProps:{value:t.id},on:{input:function(i){i.target.composing||(t.id=i.target.value)}}}),t._v(" "),e("p",{staticClass:"help-text small text-muted"},[t._v("Only local, public posts can be added")])]),t._v(" "),e("div",{staticClass:"form-group pt-4"},[e("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Add Recent Post")]),t._v(" "),e("div",t._l(t.recentPosts,(function(i,o){return e("div",{class:[t.selectedPost==i.id?"box-shadow border border-warning d-inline-block m-1":"d-inline-block m-1"],on:{click:function(e){return t.selectPost(i)}}},[e("div",{staticClass:"cursor-pointer",style:"width: 175px; height: 175px; "+t.previewBackground(i)})])})),0)]),t._v(" "),e("hr"),t._v(" "),e("button",{staticClass:"btn btn-primary font-weight-bold btn-block",attrs:{type:"button"},on:{click:t.addId}},[t._v("Add Post")])]):t._e(),t._v(" "),"order"==t.tab?e("div"):t._e()])])])]):t._e()])}),[function(){var t=this.$createElement,i=this._self._c||t;return i("div",{staticClass:"col-12 col-md-6 offset-md-3 pt-5"},[i("div",{staticClass:"text-center pb-4"},[i("h1",[this._v("Create Collection")])])])}],!1,null,null,null);i.default=l.exports},"KHd+":function(t,i,e){"use strict";function o(t,i,e,o,s,l,n,a){var c,r="function"==typeof t?t.options:t;if(i&&(r.render=i,r.staticRenderFns=e,r._compiled=!0),o&&(r.functional=!0),l&&(r._scopeId="data-v-"+l),n?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(n)},r._ssrRegister=c):s&&(c=a?function(){s.call(this,this.$root.$options.shadowRoot)}:s),c)if(r.functional){r._injectStyles=c;var d=r.render;r.render=function(t,i){return c.call(i),d(t,i)}}else{var p=r.beforeCreate;r.beforeCreate=p?[].concat(p,c):[c]}return{exports:t,options:r}}e.d(i,"a",(function(){return o}))},iBgk:function(t,i,e){Vue.component("collection-compose",e("GicU").default)}},[[17,0]]]); |