-
Notifications
You must be signed in to change notification settings - Fork 0
/
13-es2015.f002311f6949af8b9067.js
1 lines (1 loc) · 10.8 KB
/
13-es2015.f002311f6949af8b9067.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{frJI:function(e,t,i){"use strict";i.r(t),i.d(t,"ImagesModule",(function(){return R}));var r=i("ofXK"),a=i("tyNb"),o=i("/sur"),c=i("fXoL"),n=i("1kSV"),s=i("htnc");function l(e,t){1&e&&(c.Sb(0,"div",14),c.Sb(1,"div",15),c.Sb(2,"span",16),c.Bc(3,"Loading..."),c.Rb(),c.Rb(),c.Rb())}function b(e,t){if(1&e){const e=c.Tb();c.Sb(0,"tr"),c.Sb(1,"th",20),c.Bc(2),c.Rb(),c.Sb(3,"td"),c.Ob(4,"img",21),c.Bc(5),c.Rb(),c.Sb(6,"td"),c.Bc(7),c.Rb(),c.Sb(8,"td"),c.Bc(9),c.Rb(),c.Sb(10,"td"),c.Sb(11,"button",22),c.ec("click",(function(){c.tc(e);const i=t.$implicit;return c.gc(2).deleteImage(i)})),c.Ob(12,"i",23),c.Rb(),c.Sb(13,"button",24),c.ec("click",(function(){c.tc(e);const i=t.$implicit;return c.gc(2).updateImage(i)})),c.Ob(14,"i",25),c.Rb(),c.Rb(),c.Rb()}if(2&e){const e=t.$implicit,i=t.index;c.Ab(2),c.Cc(i+1),c.Ab(2),c.lc("src",e.fileUrl,c.uc),c.Ab(1),c.Dc(" ",e.codigo," "),c.Ab(2),c.Cc(e.descripcion),c.Ab(2),c.Cc(e.categoria)}}function d(e,t){if(1&e&&(c.Sb(0,"table",17),c.Sb(1,"thead"),c.Sb(2,"tr"),c.Sb(3,"th",18),c.Bc(4,"#"),c.Rb(),c.Sb(5,"th",18),c.Bc(6,"Codigo"),c.Rb(),c.Sb(7,"th",18),c.Bc(8,"Descripci\xf3n"),c.Rb(),c.Sb(9,"th",18),c.Bc(10,"Categoria"),c.Rb(),c.Sb(11,"th",18),c.Bc(12,"#Tags"),c.Rb(),c.Rb(),c.Rb(),c.Sb(13,"tbody"),c.zc(14,b,15,5,"tr",19),c.Rb(),c.Rb()),2&e){const e=c.gc();c.Ab(14),c.lc("ngForOf",e.images)}}function g(e,t){1&e&&(c.Sb(0,"div",26),c.Sb(1,"h5",27),c.Bc(2,"Modal title"),c.Rb(),c.Sb(3,"button",28),c.ec("click",(function(){return t.$implicit.dismiss("Cross click")})),c.Sb(4,"span",29),c.Bc(5,"\xd7"),c.Rb(),c.Rb(),c.Rb(),c.Sb(6,"div",30),c.Sb(7,"p"),c.Bc(8,"One fine body\u2026"),c.Rb(),c.Rb(),c.Sb(9,"div",31),c.Sb(10,"button",32),c.ec("click",(function(){return t.$implicit.close("Close click")})),c.Bc(11,"Close"),c.Rb(),c.Rb())}let p=(()=>{class e{constructor(e,t,i){this.modalService=e,this.imageService=t,this.router=i,this.page=1,this.pageSize=10,this.collectionSize=0,this.cargaCompleted=!0,this.sweetAlert=new o.a,this.widthClase=!1,this.getAllImages()}ngOnInit(){}getAllImages(){this.cargaCompleted=!1,this.imageService.getAllImages().subscribe(e=>{this.collectionSize=e.length,this.images=e.map((e,t)=>Object.assign({idx:t+1},e)).slice((this.page-1)*this.pageSize,(this.page-1)*this.pageSize+this.pageSize),this.cargaCompleted=!0})}agregarImage(){this.router.navigate(["/admin/images/addImage"])}deleteImage(e){this.sweetAlert.dialogAlertQuestion(e.codigo).then(t=>{if(t.value){let t;t=this.imageService.deleteImageById(e,e.fileUrl),this.showDialog(t,e.descripcion)}})}updateImage(e){this.router.navigate(["/admin/images",e.id])}showDialog(e,t){e.then(e=>{e&&this.sweetAlert.dialogAlertSuccess(t)}).catch(e=>{e&&this.sweetAlert.dialogAlertError(t)})}abrirModal(e){this.modalService.open(e,{backdropClass:"back-color-success"})}openVerticallyCentered(e){this.modalService.open(e,{centered:!0})}}return e.\u0275fac=function(t){return new(t||e)(c.Nb(n.a),c.Nb(s.a),c.Nb(a.b))},e.\u0275cmp=c.Hb({type:e,selectors:[["app-images-list"]],decls:19,vars:5,consts:[[1,"d-flex","justify-content-between","flex-wrap","flex-md-nowrap","align-items-center","pt-3","pb-2","mb-3","border-bottom"],[1,"h2"],[1,"btn-toolbar","mb-2","mb-md-0"],[1,"btn-group","mr-2"],["type","button",1,"btn","btn-sm","btn-outline-secondary",3,"click"],[1,"card"],[1,"card-body"],[1,"card-title"],[1,"linea"],["class","text-center",4,"ngIf"],["class","table table-striped",4,"ngIf"],[1,"d-flex","pagination","justify-content-end"],[3,"collectionSize","page","pageSize","pageChange"],["content",""],[1,"text-center"],["role","status",1,"spinner-border","text-success",2,"width","3rem","height","3rem"],[1,"sr-only"],[1,"table","table-striped"],["scope","col"],[4,"ngFor","ngForOf"],["scope","row"],[1,"mr-2",2,"width","40px",3,"src"],[1,"btn","btn-danger","mr-1",3,"click"],["aria-hidden","true",1,"fa","fa-window-close"],[1,"btn","btn-secondary",3,"click"],["aria-hidden","true",1,"fa","fa-pencil-square"],[1,"modal-header"],[1,"modal-title"],["type","button","aria-label","Close",1,"close",3,"click"],["aria-hidden","true"],[1,"modal-body"],[1,"modal-footer"],["type","button",1,"btn","btn-light",3,"click"]],template:function(e,t){1&e&&(c.Sb(0,"div",0),c.Sb(1,"h3",1),c.Bc(2,"Imagenes"),c.Rb(),c.Sb(3,"div",2),c.Sb(4,"div",3),c.Sb(5,"button",4),c.ec("click",(function(){return t.agregarImage()})),c.Bc(6,"Agregar"),c.Rb(),c.Rb(),c.Rb(),c.Rb(),c.Sb(7,"div"),c.Sb(8,"div",5),c.Sb(9,"div",6),c.Sb(10,"h5",7),c.Bc(11,"Lista"),c.Rb(),c.Ob(12,"hr",8),c.zc(13,l,4,0,"div",9),c.zc(14,d,15,1,"table",10),c.Sb(15,"div",11),c.Sb(16,"ngb-pagination",12),c.ec("pageChange",(function(e){return t.page=e}))("pageChange",(function(){return t.getAllImages()})),c.Rb(),c.Rb(),c.Rb(),c.Rb(),c.zc(17,g,12,0,"ng-template",null,13,c.Ac),c.Rb()),2&e&&(c.Ab(13),c.lc("ngIf",!t.cargaCompleted),c.Ab(1),c.lc("ngIf",t.cargaCompleted),c.Ab(2),c.lc("collectionSize",t.collectionSize)("page",t.page)("pageSize",t.pageSize))},directives:[r.k,n.d,r.j],styles:[".linea{background-color:#2a3886;height:2px;bottom:0}.btn-s-radius{border:none;border-radius:0;margin:.4rem;box-shadow:2px 1px 12px #c2c6cf}.back-color-success{background-color:#80baec}.back-color-modify{background-color:#ad7fa7}"],encapsulation:2}),e})();var m=i("3Pt+"),u=i("LazK");function h(e,t){if(1&e&&(c.Sb(0,"option",28),c.Bc(1),c.Rb()),2&e){const e=t.$implicit;c.lc("value",e.cod),c.Ab(1),c.Cc(e.cod)}}let f=(()=>{class e{constructor(e,t,i,r,a){this.fb=e,this.imageService=t,this.activateRouter=i,this.router=r,this.categoriaService=a,this.urlImg="/assets/images/drop.png",this.sweetAlert=new o.a,this.cargarFormulario()}ngOnInit(){this.getAllCategories(),this.idImage=this.activateRouter.snapshot.params.idImage,this.idImage&&this.imageService.getOneImage(this.idImage).subscribe(e=>{this.cargarDataFormulario(e)})}cargarFormulario(){this.formulario=this.fb.group({codigo:["",m.n.required],descripcion:["",m.n.required],categoria:[""]})}cargarDataFormulario(e){this.formulario.setValue({codigo:e.codigo,descripcion:e.descripcion,categoria:e.categoria}),this.urlImg=e.fileUrl,this.fileImg=e.fileUrl,this.fileImgOriginal=e.fileUrl}limpiarFormulario(){this.formulario.reset({codigo:"",descripcion:"",categoria:""}),this.fileImg=null}getAllCategories(){this.categoriaService.getAllCategories().subscribe(e=>{this.categories=e})}get codigoNoValido(){return this.validarCampos("codigo")}get descripcionNoValido(){return this.validarCampos("descripcion")}validarCampos(e){return this.formulario.get(e).invalid&&this.formulario.get(e).touched}cargarImage(e){const t=e.target.files[0];if(e.target.files&&t){const e=new FileReader;e.onload=e=>{this.urlImg=e.target.result},e.readAsDataURL(t),this.fileImg=t}else console.log("formato desconocido")}cancelarAddAndUpdate(){this.router.navigate(["../../images"],{relativeTo:this.activateRouter})}addAndUpdate(){if(this.formulario.invalid)return Object.values(this.formulario.controls).forEach(e=>{e.markAsTouched()});this.sweetAlert.dialogAlertWait();let e=!1;const t=this.formulario.value;this.idImage?this.fileImg===this.fileImgOriginal?(t.fileUrl=this.fileImgOriginal,e=this.imageService.updateImage(t,this.idImage)):(t.id=this.idImage,e=this.imageService.updateImage(t,this.idImage,this.fileImg,this.fileImgOriginal)):e=this.imageService.addImage(t,this.fileImg),this.showDialog(e,t.codigo)}showDialog(e,t){e?(this.sweetAlert.dialogAlertSuccess(t),this.limpiarFormulario(),this.cancelarAddAndUpdate()):this.sweetAlert.dialogAlertError(t)}}return e.\u0275fac=function(t){return new(t||e)(c.Nb(m.b),c.Nb(s.a),c.Nb(a.a),c.Nb(a.b),c.Nb(u.a))},e.\u0275cmp=c.Hb({type:e,selectors:[["app-image"]],decls:38,vars:7,consts:[[1,"card"],[1,"card-body"],[1,"card-title"],[1,"linea"],[3,"formGroup","ngSubmit"],[1,"form-row"],[1,"form-group","col-md-6"],["for","inputEmail4"],["formControlName","codigo","name","codigo","type","text",1,"form-control"],["for","inputPassword4"],["formControlName","descripcion","name","descripcion","type","text",1,"form-control"],[1,"form-group","col-md-12"],["for","inputState"],["formControlName","categoria","name","categoria","id","inputState",1,"form-control"],[3,"value",4,"ngFor","ngForOf"],[1,"form-group"],[1,"card","mb-3",2,"max-width","540px"],[1,"card-header","bg-transparent","border-success"],[1,"upload-btn-wrapper"],[1,"btn"],["type","file","accept",".png, .jpg","name","myfile",3,"change"],[1,"row"],[1,"col-md-8"],[1,"card-body","text-center"],["alt","",2,"width","50%",3,"src"],[1,"float-right"],["type","button",1,"btn","btn-danger","btn-s-radius",3,"click"],["type","submit",1,"btn","btn-primary","btn-s-radius"],[3,"value"]],template:function(e,t){1&e&&(c.Sb(0,"div",0),c.Sb(1,"div",1),c.Sb(2,"h5",2),c.Bc(3,"Nuevo Imagen"),c.Rb(),c.Ob(4,"hr",3),c.Sb(5,"div"),c.Sb(6,"form",4),c.ec("ngSubmit",(function(){return t.addAndUpdate()})),c.Sb(7,"div",5),c.Sb(8,"div",6),c.Sb(9,"label",7),c.Bc(10,"Codigo"),c.Rb(),c.Ob(11,"input",8),c.Rb(),c.Sb(12,"div",6),c.Sb(13,"label",9),c.Bc(14,"Descripcion"),c.Rb(),c.Ob(15,"input",10),c.Rb(),c.Rb(),c.Sb(16,"div",5),c.Sb(17,"div",11),c.Sb(18,"label",12),c.Bc(19,"Categoria"),c.Rb(),c.Sb(20,"select",13),c.zc(21,h,2,2,"option",14),c.Rb(),c.Rb(),c.Rb(),c.Sb(22,"div",15),c.Sb(23,"div",16),c.Sb(24,"div",17),c.Sb(25,"div",18),c.Sb(26,"button",19),c.Bc(27,"Importar"),c.Rb(),c.Sb(28,"input",20),c.ec("change",(function(e){return t.cargarImage(e)})),c.Rb(),c.Rb(),c.Rb(),c.Sb(29,"div",21),c.Sb(30,"div",22),c.Sb(31,"div",23),c.Ob(32,"img",24),c.Rb(),c.Rb(),c.Rb(),c.Rb(),c.Rb(),c.Sb(33,"div",25),c.Sb(34,"button",26),c.ec("click",(function(){return t.cancelarAddAndUpdate()})),c.Bc(35,"Cancelar"),c.Rb(),c.Sb(36,"button",27),c.Bc(37,"Guardar"),c.Rb(),c.Rb(),c.Rb(),c.Rb(),c.Rb(),c.Rb()),2&e&&(c.Ab(6),c.lc("formGroup",t.formulario),c.Ab(5),c.Fb("is-invalid",t.codigoNoValido),c.Ab(4),c.Fb("is-invalid",t.descripcionNoValido),c.Ab(6),c.lc("ngForOf",t.categories),c.Ab(11),c.lc("src",t.urlImg,c.uc))},directives:[m.p,m.i,m.d,m.a,m.h,m.c,m.m,r.j,m.j,m.o],styles:[".upload-btn-wrapper[_ngcontent-%COMP%]{position:relative;overflow:hidden;display:inline-block}.upload-btn-wrapper[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]{border:2px solid grey;color:grey;background-color:#fff;padding:5px 15px;border-radius:5px;font-size:15px;font-weight:700}.upload-btn-wrapper[_ngcontent-%COMP%] input[type=file][_ngcontent-%COMP%]{font-size:30px;position:absolute;left:0;top:0;opacity:0;cursor:pointer}"]}),e})();const S=[{path:"",component:(()=>{class e{constructor(){}ngOnInit(){}}return e.\u0275fac=function(t){return new(t||e)},e.\u0275cmp=c.Hb({type:e,selectors:[["app-images"]],decls:1,vars:0,template:function(e,t){1&e&&c.Ob(0,"router-outlet")},directives:[a.f],styles:[""]}),e})(),children:[{path:"",component:p},{path:"addImage",component:f},{path:":idImage",component:f}]}];let v=(()=>{class e{}return e.\u0275mod=c.Lb({type:e}),e.\u0275inj=c.Kb({factory:function(t){return new(t||e)},imports:[[a.e.forChild(S)],a.e]}),e})(),R=(()=>{class e{}return e.\u0275mod=c.Lb({type:e}),e.\u0275inj=c.Kb({factory:function(t){return new(t||e)},imports:[[r.c,v,m.e,m.k,n.b]]}),e})()}}]);