iptdevs-design-system 1.3.6 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Component, Input, Output, NgModule, Injectable } from '@angular/core';
2
+ import { EventEmitter, Component, Input, Output, Injectable, NgModule } from '@angular/core';
3
3
  import { BrowserModule } from '@angular/platform-browser';
4
4
  import * as i1 from '@angular/common';
5
5
  import { CommonModule } from '@angular/common';
6
6
  import * as i1$1 from '@angular/forms';
7
7
  import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
8
+ import Swal from 'sweetalert2';
8
9
  import * as i1$2 from '@angular/common/http';
9
10
  import { HttpHeaders } from '@angular/common/http';
10
11
  import * as i1$3 from '@angular/router';
@@ -599,8 +600,185 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
599
600
  type: Output
600
601
  }] } });
601
602
 
603
+ class UserService {
604
+ constructor(http) {
605
+ this.http = http;
606
+ this.SERVICE_URL = 'https://iptdev.com.co/lab/users/api/';
607
+ }
608
+ login(userLogin) {
609
+ let serviceUrl = this.SERVICE_URL + 'post/login';
610
+ this.generateRequestParams(userLogin);
611
+ return this.http.post(serviceUrl, this.httpOptions);
612
+ }
613
+ resetPassword(resetPassword) {
614
+ let serviceUrl = this.SERVICE_URL + 'reset/password';
615
+ this.generateRequestParams(resetPassword);
616
+ return this.http.post(serviceUrl, this.httpOptions);
617
+ }
618
+ register(user) {
619
+ let serviceUrl = this.SERVICE_URL + 'post/create/web';
620
+ this.generateRequestParams(user);
621
+ return this.http.post(serviceUrl, this.httpOptions);
622
+ }
623
+ registerIndex(register) {
624
+ let serviceUrl = this.SERVICE_URL + 'post/create/marketing';
625
+ this.generateRequestParams(register);
626
+ return this.http.post(serviceUrl, this.httpOptions);
627
+ }
628
+ registerDashboard(user) {
629
+ let serviceUrl = this.SERVICE_URL + 'post/create/dashboard';
630
+ this.generateRequestParams(user);
631
+ return this.http.post(serviceUrl, this.httpOptions);
632
+ }
633
+ getAvailableTeachers(token) {
634
+ let serviceUrl = this.SERVICE_URL + 'post/obtain/teachers';
635
+ this.generateRequestParams(token);
636
+ return this.http.post(serviceUrl, this.httpOptions);
637
+ }
638
+ getUserByIdCard(value) {
639
+ let serviceUrl = this.SERVICE_URL + 'user/id_card/' + value;
640
+ return this.http.get(serviceUrl);
641
+ }
642
+ generateRequestParams(param) {
643
+ this.httpOptions = {
644
+ header: new HttpHeaders(),
645
+ params: param,
646
+ };
647
+ }
648
+ }
649
+ UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
650
+ UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, providedIn: 'root' });
651
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, decorators: [{
652
+ type: Injectable,
653
+ args: [{
654
+ providedIn: 'root',
655
+ }]
656
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
657
+
658
+ class StorageService {
659
+ constructor() {
660
+ this.currentSession = null;
661
+ this.localStorageService = localStorage;
662
+ this.currentSession = this.loadSessionData();
663
+ }
664
+ setCurrentSession(session) {
665
+ this.currentSession = session;
666
+ this.localStorageService.setItem('606a7d4e73650b75ebb06972e77d6cc4', JSON.stringify(session));
667
+ }
668
+ loadSessionData() {
669
+ var sessionStr = this.localStorageService.getItem('606a7d4e73650b75ebb06972e77d6cc4');
670
+ return (sessionStr) ? JSON.parse(sessionStr) : null;
671
+ }
672
+ getCurrentSession() {
673
+ return this.currentSession;
674
+ }
675
+ removeCurrentSession() {
676
+ this.localStorageService.removeItem('606a7d4e73650b75ebb06972e77d6cc4');
677
+ this.currentSession = null;
678
+ }
679
+ getCurrentUser() {
680
+ var session = this.getCurrentSession();
681
+ return (session && session.user) ? session.user : null;
682
+ }
683
+ ;
684
+ isAuthenticated() {
685
+ return (this.getCurrentToken() != null) ? true : false;
686
+ }
687
+ ;
688
+ getCurrentToken() {
689
+ var session = this.getCurrentSession();
690
+ return (session && session.token) ? session.token : null;
691
+ }
692
+ ;
693
+ logout() {
694
+ this.removeCurrentSession();
695
+ }
696
+ }
697
+ StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
698
+ StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, providedIn: 'root' });
699
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, decorators: [{
700
+ type: Injectable,
701
+ args: [{
702
+ providedIn: 'root',
703
+ }]
704
+ }], ctorParameters: function () { return []; } });
705
+
706
+ class BaseService {
707
+ constructor(userService, storageService) {
708
+ this.userService = userService;
709
+ this.storageService = storageService;
710
+ }
711
+ webLogin(user, password) {
712
+ let request = {
713
+ user: user,
714
+ password: password
715
+ };
716
+ let service = this.userService;
717
+ let storage = this.storageService;
718
+ return new Promise(function (resolve, reject) {
719
+ service.login(request).subscribe(response => {
720
+ switch (response.message.code) {
721
+ case 1:
722
+ Swal.fire({
723
+ 'title': '<p style="font-family: Poppins"">Perfect!</p>',
724
+ 'html': '<p style="font-family: Poppins"">Succesfull login</p>',
725
+ 'icon': 'success',
726
+ });
727
+ const loginRegisterUser = {
728
+ token: response.data.token,
729
+ user: response.data,
730
+ };
731
+ storage.setCurrentSession(loginRegisterUser);
732
+ resolve(true);
733
+ break;
734
+ case 2:
735
+ Swal.fire({
736
+ 'title': '<p style="font-family: Poppins"">Warning!</p>',
737
+ 'html': '<p style="font-family: Poppins"">The data does not correspond to a user registered in our system, please review them.</p>',
738
+ 'icon': 'warning',
739
+ });
740
+ resolve(false);
741
+ break;
742
+ case 3:
743
+ Swal.fire({
744
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
745
+ 'html': '<p style="font-family: Poppins"">The input data does not meet the established parameters.</p>',
746
+ 'icon': 'error',
747
+ });
748
+ resolve(false);
749
+ break;
750
+ default:
751
+ Swal.fire({
752
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
753
+ 'html': '<p style="font-family: Poppins"">An unexpected error has occurred</p>',
754
+ 'icon': 'error',
755
+ });
756
+ resolve(false);
757
+ break;
758
+ }
759
+ reject('Unhandled exception');
760
+ });
761
+ });
762
+ }
763
+ getUserRole() {
764
+ let user = this.storageService.getCurrentUser()?.role;
765
+ return user === undefined ? -1 : Math.floor(user / 10);
766
+ }
767
+ loginService(request) {
768
+ }
769
+ }
770
+ BaseService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, deps: [{ token: UserService }, { token: StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
771
+ BaseService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, providedIn: 'root' });
772
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, decorators: [{
773
+ type: Injectable,
774
+ args: [{
775
+ providedIn: 'root',
776
+ }]
777
+ }], ctorParameters: function () { return [{ type: UserService }, { type: StorageService }]; } });
778
+
602
779
  class LoginFormComponent {
603
- constructor(fb) {
780
+ constructor(fb, baseService) {
781
+ this.baseService = baseService;
604
782
  this.background = true;
605
783
  this.email = new EventEmitter();
606
784
  this.password = new EventEmitter();
@@ -610,13 +788,14 @@ class LoginFormComponent {
610
788
  });
611
789
  }
612
790
  login(data) {
791
+ this.baseService.webLogin(data.controls['email'].value, data.controls['password'].value);
613
792
  this.email.emit(data.controls['email'].value);
614
793
  this.password.emit(data.controls['password'].value);
615
794
  this.loginForm.controls['email'].setValue('');
616
795
  this.loginForm.controls['password'].setValue('');
617
796
  }
618
797
  }
619
- LoginFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: LoginFormComponent, deps: [{ token: i1$1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
798
+ LoginFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: LoginFormComponent, deps: [{ token: i1$1.FormBuilder }, { token: BaseService }], target: i0.ɵɵFactoryTarget.Component });
620
799
  LoginFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.3", type: LoginFormComponent, selector: "ipt-login-form", inputs: { background: "background", image: "image" }, outputs: { email: "email", password: "password" }, ngImport: i0, template: `
621
800
  <div [ngClass]="{'with-background': background}" class="form-container">
622
801
 
@@ -703,7 +882,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
703
882
 
704
883
  </div>
705
884
  `, styles: [".form-container{display:grid;grid-template-columns:1fr;justify-items:center;width:350px}.with-background{background-color:#fff;border-radius:25px;box-shadow:#32325d40 0 50px 100px -20px,#0000004d 0 30px 60px -30px}h2{color:#1c77f7}hr{width:80%}form{margin-bottom:60px;display:grid;grid-template-columns:1fr;grid-gap:30px;gap:30px;width:100%}.button-container{margin-bottom:70px;align-items:center;display:flex;gap:50px}footer{background-color:#1c77f7;border-top-left-radius:25px;border-top-right-radius:25px;width:100%;height:100px;display:flex;align-items:center;justify-content:center}\n"] }]
706
- }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }]; }, propDecorators: { background: [{
885
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: BaseService }]; }, propDecorators: { background: [{
707
886
  type: Input
708
887
  }], image: [{
709
888
  type: Input
@@ -944,54 +1123,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
944
1123
  type: Injectable
945
1124
  }], ctorParameters: function () { return [{ type: i1$3.Router }]; } });
946
1125
 
947
- class StorageService {
948
- constructor() {
949
- this.currentSession = null;
950
- this.localStorageService = localStorage;
951
- this.currentSession = this.loadSessionData();
952
- }
953
- setCurrentSession(session) {
954
- this.currentSession = session;
955
- this.localStorageService.setItem('606a7d4e73650b75ebb06972e77d6cc4', JSON.stringify(session));
956
- }
957
- loadSessionData() {
958
- var sessionStr = this.localStorageService.getItem('606a7d4e73650b75ebb06972e77d6cc4');
959
- return (sessionStr) ? JSON.parse(sessionStr) : null;
960
- }
961
- getCurrentSession() {
962
- return this.currentSession;
963
- }
964
- removeCurrentSession() {
965
- this.localStorageService.removeItem('606a7d4e73650b75ebb06972e77d6cc4');
966
- this.currentSession = null;
967
- }
968
- getCurrentUser() {
969
- var session = this.getCurrentSession();
970
- return (session && session.user) ? session.user : null;
971
- }
972
- ;
973
- isAuthenticated() {
974
- return (this.getCurrentToken() != null) ? true : false;
975
- }
976
- ;
977
- getCurrentToken() {
978
- var session = this.getCurrentSession();
979
- return (session && session.token) ? session.token : null;
980
- }
981
- ;
982
- logout() {
983
- this.removeCurrentSession();
984
- }
985
- }
986
- StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
987
- StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, providedIn: 'root' });
988
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, decorators: [{
989
- type: Injectable,
990
- args: [{
991
- providedIn: 'root',
992
- }]
993
- }], ctorParameters: function () { return []; } });
994
-
995
1126
  class SwitchService {
996
1127
  constructor() {
997
1128
  this.$modal = new EventEmitter();
@@ -1006,61 +1137,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
1006
1137
  }]
1007
1138
  }], ctorParameters: function () { return []; } });
1008
1139
 
1009
- class UserService {
1010
- constructor(http) {
1011
- this.http = http;
1012
- this.SERVICE_URL = 'https://iptdev.com.co/lab/users/api/';
1013
- }
1014
- login(userLogin) {
1015
- let serviceUrl = this.SERVICE_URL + 'post/login';
1016
- this.generateRequestParams(userLogin);
1017
- return this.http.post(serviceUrl, this.httpOptions);
1018
- }
1019
- resetPassword(resetPassword) {
1020
- let serviceUrl = this.SERVICE_URL + 'reset/password';
1021
- this.generateRequestParams(resetPassword);
1022
- return this.http.post(serviceUrl, this.httpOptions);
1023
- }
1024
- register(user) {
1025
- let serviceUrl = this.SERVICE_URL + 'post/create/web';
1026
- this.generateRequestParams(user);
1027
- return this.http.post(serviceUrl, this.httpOptions);
1028
- }
1029
- registerIndex(register) {
1030
- let serviceUrl = this.SERVICE_URL + 'post/create/marketing';
1031
- this.generateRequestParams(register);
1032
- return this.http.post(serviceUrl, this.httpOptions);
1033
- }
1034
- registerDashboard(user) {
1035
- let serviceUrl = this.SERVICE_URL + 'post/create/dashboard';
1036
- this.generateRequestParams(user);
1037
- return this.http.post(serviceUrl, this.httpOptions);
1038
- }
1039
- getAvailableTeachers(token) {
1040
- let serviceUrl = this.SERVICE_URL + 'post/obtain/teachers';
1041
- this.generateRequestParams(token);
1042
- return this.http.post(serviceUrl, this.httpOptions);
1043
- }
1044
- getUserByIdCard(value) {
1045
- let serviceUrl = this.SERVICE_URL + 'user/id_card/' + value;
1046
- return this.http.get(serviceUrl);
1047
- }
1048
- generateRequestParams(param) {
1049
- this.httpOptions = {
1050
- header: new HttpHeaders(),
1051
- params: param,
1052
- };
1053
- }
1054
- }
1055
- UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1056
- UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, providedIn: 'root' });
1057
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, decorators: [{
1058
- type: Injectable,
1059
- args: [{
1060
- providedIn: 'root',
1061
- }]
1062
- }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
1063
-
1064
1140
  class CoreModule {
1065
1141
  }
1066
1142
  CoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -1071,7 +1147,8 @@ CoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13
1071
1147
  StorageService,
1072
1148
  UserService,
1073
1149
  SwitchService,
1074
- RedirectGuard
1150
+ RedirectGuard,
1151
+ BaseService
1075
1152
  ] });
1076
1153
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, decorators: [{
1077
1154
  type: NgModule,
@@ -1082,7 +1159,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
1082
1159
  StorageService,
1083
1160
  UserService,
1084
1161
  SwitchService,
1085
- RedirectGuard
1162
+ RedirectGuard,
1163
+ BaseService
1086
1164
  ]
1087
1165
  }]
1088
1166
  }] });
@@ -1128,5 +1206,5 @@ class UserLoginRs {
1128
1206
  * Generated bundle index. Do not edit.
1129
1207
  */
1130
1208
 
1131
- export { AsideButtonComponent, ButtonComponent, CheckboxComponent, ComponentsModule, CoreModule, CourseService, DatalistComponent, DesignSystemModule, InputComponent, LevelButtonComponent, LevelTextComponent, LoginFormComponent, ParameterService, RadioComponent, RedirectGuard, SelectComponent, Session, StorageService, SwitchService, TextLinkComponent, UserLoginRs, UserRs, UserService };
1209
+ export { AsideButtonComponent, BaseService, ButtonComponent, CheckboxComponent, ComponentsModule, CoreModule, CourseService, DatalistComponent, DesignSystemModule, InputComponent, LevelButtonComponent, LevelTextComponent, LoginFormComponent, ParameterService, RadioComponent, RedirectGuard, SelectComponent, Session, StorageService, SwitchService, TextLinkComponent, UserLoginRs, UserRs, UserService };
1132
1210
  //# sourceMappingURL=iptdevs-design-system.mjs.map