Go-Back-Skeleton/public/js/chunk-0c1a0121.27155d4a.js
2019-01-01 23:03:09 +01:00

2 lines
No EOL
17 KiB
JavaScript

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-0c1a0121"],{2621:function(t,e){e.f=Object.getOwnPropertySymbols},"2e29":function(t,e,n){},"40aa":function(t,e,n){"use strict";var a=n("97e9"),i=n.n(a);i.a},"52a7":function(t,e){e.f={}.propertyIsEnumerable},"6ec0":function(t,e,n){},7333:function(t,e,n){"use strict";var a=n("0d58"),i=n("2621"),s=n("52a7"),r=n("4bf8"),c=n("626a"),o=Object.assign;t.exports=!o||n("79e5")(function(){var t={},e={},n=Symbol(),a="abcdefghijklmnopqrst";return t[n]=7,a.split("").forEach(function(t){e[t]=t}),7!=o({},t)[n]||Object.keys(o({},e)).join("")!=a})?function(t,e){var n=r(t),o=arguments.length,u=1,l=i.f,d=s.f;while(o>u){var h,v=c(arguments[u++]),p=l?a(v).concat(l(v)):a(v),f=p.length,m=0;while(f>m)d.call(v,h=p[m++])&&(n[h]=v[h])}return n}:o},"8c88":function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("v-container",[n("v-snackbar",{staticClass:"text-capitalize",attrs:{timeout:3e3,top:"",color:t.snackColor},model:{value:t.snack,callback:function(e){t.snack=e},expression:"snack"}},[t._v("\n "+t._s(t.snackText)+"\n "),n("v-btn",{attrs:{outline:""},on:{click:function(e){t.snack=!1}}},[n("v-icon",[t._v("close")])],1)],1),n("v-toolbar",{attrs:{flat:"",color:"white"}},[n("v-toolbar-title",[t._v("Accounts")]),n("v-divider",{staticClass:"mx-2",attrs:{inset:"",vertical:""}}),n("v-spacer"),n("v-dialog",{attrs:{"max-width":"500px"},model:{value:t.dialog,callback:function(e){t.dialog=e},expression:"dialog"}},[n("v-btn",{staticClass:"mb-2",attrs:{slot:"activator",color:"primary",dark:""},slot:"activator"},[t._v("New Account")]),n("v-card",[n("v-card-title",[n("span",{staticClass:"headline"},[t._v(t._s(t.formTitle))])]),n("v-card-text",[n("v-container",{attrs:{"grid-list-md":""}},[n("v-form",{ref:"accountForm",attrs:{wrap:""}},[n("v-text-field",{attrs:{label:"Name",rules:t.nameRules},model:{value:t.editedAccount.name,callback:function(e){t.$set(t.editedAccount,"name",e)},expression:"editedAccount.name"}}),n("v-text-field",{attrs:{label:"Email",rules:t.emailRules},model:{value:t.editedAccount.email,callback:function(e){t.$set(t.editedAccount,"email",e)},expression:"editedAccount.email"}}),n("v-switch",{attrs:{label:"Active",color:"primary"},model:{value:t.editedAccount.active,callback:function(e){t.$set(t.editedAccount,"active",e)},expression:"editedAccount.active"}}),n("v-checkbox",{attrs:{multiple:"",label:"Admin",value:"admin",color:"primary"},model:{value:t.editedAccount.roles,callback:function(e){t.$set(t.editedAccount,"roles",e)},expression:"editedAccount.roles"}})],1)],1)],1),n("v-card-actions",[n("v-spacer"),n("v-btn",{on:{click:t.close}},[t._v("Cancel")]),n("v-btn",{attrs:{color:"primary"},on:{click:t.save}},[t._v("Save")])],1)],1)],1)],1),n("v-data-table",{staticClass:"elevation-1",attrs:{headers:t.headers,items:t.accounts,pagination:t.pagination,"total-items":t.totalAccounts,loading:t.loading},on:{"update:pagination":function(e){t.pagination=e}},scopedSlots:t._u([{key:"items",fn:function(e){return[n("tr",[n("td",{staticClass:"columnIcon"},[n("v-icon",[t._v(t._s(e.item.active?"check_box":"check_box_outline_blank"))])],1),n("td",{staticClass:"columnIcon"},[e.item.roles.includes("admin")?n("v-icon",[t._v("security")]):t._e()],1),n("td",{on:{click:function(t){e.expanded=!e.expanded}}},[t._v(t._s(e.item.name))]),n("td",[t._v(t._s(e.item.email))]),n("td",[t._v(t._s(t._f("formatDate")(e.item.last_login)))]),n("td",{staticClass:"justify-center layout px-0"},[n("v-icon",{staticClass:"mr-2",attrs:{small:""},on:{click:function(n){t.editAccount(e.item)}}},[t._v("edit")]),n("v-icon",{attrs:{small:""},on:{click:function(n){t.deleteAccount(e.item)}}},[t._v("delete")])],1)])]}},{key:"expand",fn:function(e){return[n("v-card",{attrs:{flat:""}},[n("v-card-text",[t._v("Created: "+t._s(t._f("formatDate")(e.item.created_at)))]),n("v-card-text",[t._v("Last Login: "+t._s(t._f("formatDate")(e.item.last_login)))])],1)]}}])})],1)},i=[],s=n("be94"),r=(n("f751"),n("96cf"),n("1da1")),c=(n("7f7f"),n("d4ec")),o=n("99de"),u=n("7e84"),l=n("262e"),d=n("9072"),h=n("c5fa"),v=function(t){function e(t,n,a){var i;return Object(c["a"])(this,e),i=Object(o["a"])(this,Object(u["a"])(e).call(this,n)),i.name=i.constructor.name,i.errorCode=t,i.message=n,i.fields=JSON.parse(a),i}return Object(l["a"])(e,t),e}(Object(d["a"])(Error)),p={getAccounts:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,h["a"].get("/admin/accounts",e);case 3:return n=t.sent,t.abrupt("return",n.data);case 7:throw t.prev=7,t.t0=t["catch"](0),new v(t.t0.response.status,t.t0.response.data.error);case 10:case"end":return t.stop()}},t,this,[[0,7]])}));function e(e){return t.apply(this,arguments)}return e}(),createAccount:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,h["a"].post("/admin/accounts",e);case 3:return n=t.sent,t.abrupt("return",n.data);case 7:throw t.prev=7,t.t0=t["catch"](0),new v(t.t0.response.status,t.t0.response.data.error,t.t0.response.data.errors);case 10:case"end":return t.stop()}},t,this,[[0,7]])}));function e(e){return t.apply(this,arguments)}return e}(),updateAccount:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,h["a"].put("/admin/accounts/".concat(e.id),e);case 3:return n=t.sent,t.abrupt("return",n.data);case 7:throw t.prev=7,t.t0=t["catch"](0),new v(t.t0.response.status,t.t0.response.data.error,t.t0.response.data.errors);case 10:case"end":return t.stop()}},t,this,[[0,7]])}));function e(e){return t.apply(this,arguments)}return e}(),deleteAccount:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,h["a"].delete("/admin/accounts/".concat(e));case 3:return n=t.sent,t.abrupt("return",n.data);case 7:throw t.prev=7,t.t0=t["catch"](0),new v(t.t0.response.status,t.t0.response.data.error);case 10:case"end":return t.stop()}},t,this,[[0,7]])}));function e(e){return t.apply(this,arguments)}return e}(),updateToken:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,h["a"].put("/api/account/token/".concat(e.id),e);case 3:return n=t.sent,t.abrupt("return",n.data);case 7:throw t.prev=7,t.t0=t["catch"](0),new v(t.t0.response.status,t.t0.response.data.error);case 10:case"end":return t.stop()}},t,this,[[0,7]])}));function e(e){return t.apply(this,arguments)}return e}(),deleteToken:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,h["a"].delete("/api/account/token/".concat(e));case 3:return n=t.sent,t.abrupt("return",n.data);case 7:throw t.prev=7,t.t0=t["catch"](0),new v(t.t0.response.status,t.t0.response.data.error);case 10:case"end":return t.stop()}},t,this,[[0,7]])}));function e(e){return t.apply(this,arguments)}return e}()},f={name:"admin-accounts",data:function(){var t=this;return{accounts:[],totalAccounts:0,loading:!0,pagination:{},headers:[{text:"Active",value:"active",sortable:!0},{text:"Admin",value:"admin",sortable:!1},{text:"Name",align:"left",value:"name"},{text:"Email",align:"left",value:"email"},{text:"Last Login",align:"left",value:"last_login"}],dialog:!1,editedIndex:-1,editedAccount:{name:"",email:"",roles:["user"],active:!0},defaultAccount:{name:"",email:"",roles:["user"],active:!0},errors:{},snack:!1,snackColor:"",snackText:"",nameRules:[function(t){return!!t||"Name is required"},function(t){return t&&t.length<=100||"Name must be less than 100 characters"},function(){return!t.errors.name||t.errors.name}],emailRules:[function(t){return!!t||"E-mail is required"},function(t){return/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(t)||"E-mail must be valid"},function(){return!t.errors.email||t.errors.email}]}},watch:{dialog:function(t){t||this.close()},pagination:{handler:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(){var e;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,this.getAccounts();case 2:e=t.sent,this.accounts=e.accounts,this.totalAccounts=e.count;case 5:case"end":return t.stop()}},t,this)}));function e(){return t.apply(this,arguments)}return e}(),depp:!0}},computed:{formTitle:function(){return-1===this.editedIndex?"New Account":"Edit Account"}},methods:{getAccounts:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(){var e,n,a,i,s,r,c,o,u;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return this.loading=!0,t.prev=1,e=this.pagination,n=e.sortBy,a=e.descending,i=e.page,s=e.rowsPerPage,r={page:i,limit:-1===s?0:s,order:(n||"")+(a?" desc":"")},t.next=6,p.getAccounts(r);case 6:return c=t.sent,o=c.accounts,u=c.count,t.abrupt("return",{accounts:o,count:u});case 12:t.prev=12,t.t0=t["catch"](1),console.log("could not get accounts data",t.t0);case 15:return t.prev=15,this.loading=!1,t.finish(15);case 18:case"end":return t.stop()}},t,this,[[1,12,15,18]])}));function e(){return t.apply(this,arguments)}return e}(),editAccount:function(t){this.editedIndex=this.accounts.indexOf(t),this.editedAccount=Object.assign({},t),this.dialog=!0},close:function(){var t=this;this.dialog=!1,setTimeout(function(){t.editedAccount=Object.assign({},t.defaultAccount),t.editedIndex=-1,t.$refs.accountForm.reset()},250)},save:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(){var e,n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:if(!(this.editedIndex>-1)){t.next=17;break}return t.prev=1,t.next=4,p.updateAccount(Object.assign({},this.editedAccount));case 4:e=t.sent,Object.assign(this.accounts[this.editedIndex],e),this.close(),this.snackSuccess("account updated"),t.next=15;break;case 10:t.prev=10,t.t0=t["catch"](1),this.errors=Object(s["a"])({},t.t0.fields),this.$refs.accountForm.validate(),this.snackError(t.t0.message);case 15:t.next=31;break;case 17:return t.prev=17,t.next=20,p.createAccount(Object.assign({},this.editedAccount));case 20:n=t.sent,this.accounts.push(n),this.close(),this.snackSuccess("account created"),t.next=31;break;case 26:t.prev=26,t.t1=t["catch"](17),this.errors=Object(s["a"])({},t.t1.fields),this.$refs.accountForm.validate(),this.snackError(t.t1.message);case 31:case"end":return t.stop()}},t,this,[[1,10],[17,26]])}));function e(){return t.apply(this,arguments)}return e}(),deleteAccount:function(){var t=Object(r["a"])(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){while(1)switch(t.prev=t.next){case 0:if(n=this.accounts.indexOf(e),!confirm("Are you sure you want to dele this account?")){t.next=11;break}return t.prev=2,t.next=5,p.deleteAccount(this.accounts[n].id);case 5:this.snackSuccess("account deleted"),t.next=11;break;case 8:t.prev=8,t.t0=t["catch"](2),this.snackError("failed to delete account");case 11:case"end":return t.stop()}},t,this,[[2,8]])}));function e(e){return t.apply(this,arguments)}return e}(),snackSuccess:function(t){this.snack=!0,this.snackColor="success",this.snackText=t},snackError:function(t){this.snack=!0,this.snackColor="error",this.snackText=t}}},m=f,g=(n("40aa"),n("2877")),b=n("6544"),w=n.n(b),k=n("8336"),x=n("b0af"),A=n("99d9"),y=n("12b2"),_=n("ac7c"),C=n("a523"),O=n("8fea"),j=(n("6ec0"),n("c69d")),S=n("30d4"),R=n("14ec"),$=n("e949"),T=n("261e"),E=n("98a1"),V=n("c584"),I=n("80d2"),B=n("bfc5"),D=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t};function L(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var P={name:"v-dialog",directives:{ClickOutside:V["a"]},mixins:[j["a"],S["a"],R["a"],$["a"],T["a"],E["a"]],props:{disabled:Boolean,persistent:Boolean,fullscreen:Boolean,fullWidth:Boolean,noClickAnimation:Boolean,light:Boolean,dark:Boolean,maxWidth:{type:[String,Number],default:"none"},origin:{type:String,default:"center center"},width:{type:[String,Number],default:"auto"},scrollable:Boolean,transition:{type:[String,Boolean],default:"dialog-transition"}},data:function(){return{animate:!1,animateTimeout:null,stackClass:"v-dialog__content--active",stackMinZIndex:200}},computed:{classes:function(){var t;return t={},L(t,("v-dialog "+this.contentClass).trim(),!0),L(t,"v-dialog--active",this.isActive),L(t,"v-dialog--persistent",this.persistent),L(t,"v-dialog--fullscreen",this.fullscreen),L(t,"v-dialog--scrollable",this.scrollable),L(t,"v-dialog--animated",this.animate),t},contentClasses:function(){return{"v-dialog__content":!0,"v-dialog__content--active":this.isActive}}},watch:{isActive:function(t){t?(this.show(),this.hideScroll()):(this.removeOverlay(),this.unbind())},fullscreen:function(t){this.isActive&&(t?(this.hideScroll(),this.removeOverlay(!1)):(this.showScroll(),this.genOverlay()))}},mounted:function(){this.isBooted=this.isActive,this.isActive&&this.show()},beforeDestroy:function(){"undefined"!==typeof window&&this.unbind()},methods:{animateClick:function(){var t=this;this.animate=!1,this.$nextTick(function(){t.animate=!0,clearTimeout(t.animateTimeout),t.animateTimeout=setTimeout(function(){return t.animate=!1},150)})},closeConditional:function(t){return!(this.$refs.content.contains(t.target)||!this.isActive)&&(this.persistent?(this.noClickAnimation||this.overlay!==t.target||this.animateClick(),!1):Object(I["k"])(this.$refs.content)>=this.getMaxZIndex())},hideScroll:function(){this.fullscreen?document.documentElement.classList.add("overflow-y-hidden"):R["a"].methods.hideScroll.call(this)},show:function(){!this.fullscreen&&!this.hideOverlay&&this.genOverlay(),this.$refs.content.focus(),this.$listeners.keydown&&this.bind()},bind:function(){window.addEventListener("keydown",this.onKeydown)},unbind:function(){window.removeEventListener("keydown",this.onKeydown)},onKeydown:function(t){this.$emit("keydown",t)}},render:function(t){var e=this,n=[],a={class:this.classes,ref:"dialog",directives:[{name:"click-outside",value:function(){return e.isActive=!1},args:{closeConditional:this.closeConditional,include:this.getOpenDependentElements}},{name:"show",value:this.isActive}],on:{click:function(t){t.stopPropagation()}}};this.fullscreen||(a.style={maxWidth:"none"===this.maxWidth?void 0:Object(I["b"])(this.maxWidth),width:"auto"===this.width?void 0:Object(I["b"])(this.width)}),this.$slots.activator&&n.push(t("div",{staticClass:"v-dialog__activator",class:{"v-dialog__activator--disabled":this.disabled},on:{click:function(t){t.stopPropagation(),e.disabled||(e.isActive=!e.isActive)}}},[this.$slots.activator]));var i=t("div",a,this.showLazyContent(this.$slots.default));return this.transition&&(i=t("transition",{props:{name:this.transition,origin:this.origin}},[i])),n.push(t("div",{class:this.contentClasses,attrs:D({tabIndex:"-1"},this.getScopeIdAttrs()),style:{zIndex:this.activeZIndex},ref:"content"},[this.$createElement(B["a"],{props:{root:!0,light:this.light,dark:this.dark}},[i])])),t("div",{staticClass:"v-dialog__container",style:{display:!this.$slots.activator||this.fullWidth?"block":"inline-block"}},n)}},N=n("ce7e"),F=n("4bd4"),W=n("132d"),z=n("2db4"),K=n("9910"),q=(n("94a7"),n("2e29"),n("5368")),J=n("c341"),Z=n("0789"),M=n("490a"),G=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},H={name:"v-switch",directives:{Touch:J["a"]},mixins:[q["a"]],props:{loading:{type:[Boolean,String],default:!1}},computed:{classes:function(){return{"v-input--selection-controls v-input--switch":!0}},switchData:function(){return this.setTextColor(this.loading?void 0:this.computedColor,{class:this.themeClasses})}},methods:{genDefaultSlot:function(){return[this.genSwitch(),this.genLabel()]},genSwitch:function(){return this.$createElement("div",{staticClass:"v-input--selection-controls__input"},[this.genInput("checkbox",this.$attrs),this.genRipple(this.setTextColor(this.computedColor,{directives:[{name:"touch",value:{left:this.onSwipeLeft,right:this.onSwipeRight}}]})),this.$createElement("div",G({staticClass:"v-input--switch__track"},this.switchData)),this.$createElement("div",G({staticClass:"v-input--switch__thumb"},this.switchData),[this.genProgress()])])},genProgress:function(){return this.$createElement(Z["b"],{},[!1===this.loading?null:this.$slots.progress||this.$createElement(M["a"],{props:{color:!0===this.loading||""===this.loading?this.color||"primary":this.loading,size:16,width:2,indeterminate:!0}})])},onSwipeLeft:function(){this.isActive&&this.onChange()},onSwipeRight:function(){this.isActive||this.onChange()},onKeydown:function(t){(t.keyCode===I["n"].left&&this.isActive||t.keyCode===I["n"].right&&!this.isActive)&&this.onChange()}}},Q=n("2677"),U=n("71d9"),X=n("2a7f"),Y=Object(g["a"])(m,a,i,!1,null,"607deaa2",null);Y.options.__file="Accounts.vue";e["default"]=Y.exports;w()(Y,{VBtn:k["a"],VCard:x["a"],VCardActions:A["a"],VCardText:A["b"],VCardTitle:y["a"],VCheckbox:_["a"],VContainer:C["a"],VDataTable:O["a"],VDialog:P,VDivider:N["a"],VForm:F["a"],VIcon:W["a"],VSnackbar:z["a"],VSpacer:K["a"],VSwitch:H,VTextField:Q["a"],VToolbar:U["a"],VToolbarTitle:X["b"]})},"97e9":function(t,e,n){},f751:function(t,e,n){var a=n("5ca1");a(a.S+a.F,"Object",{assign:n("7333")})}}]);
//# sourceMappingURL=chunk-0c1a0121.27155d4a.js.map