iptdevs-design-system 1.3.5 → 1.3.8

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,12 @@
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 { __awaiter } from 'tslib';
9
+ import Swal from 'sweetalert2';
8
10
  import * as i1$2 from '@angular/common/http';
9
11
  import { HttpHeaders } from '@angular/common/http';
10
12
  import * as i1$3 from '@angular/router';
@@ -599,8 +601,178 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
599
601
  type: Output
600
602
  }] } });
601
603
 
604
+ class UserService {
605
+ constructor(http) {
606
+ this.http = http;
607
+ this.SERVICE_URL = 'https://iptdev.com.co/lab/users/api/';
608
+ }
609
+ login(userLogin) {
610
+ let serviceUrl = this.SERVICE_URL + 'post/login';
611
+ this.generateRequestParams(userLogin);
612
+ return this.http.post(serviceUrl, this.httpOptions);
613
+ }
614
+ resetPassword(resetPassword) {
615
+ let serviceUrl = this.SERVICE_URL + 'reset/password';
616
+ this.generateRequestParams(resetPassword);
617
+ return this.http.post(serviceUrl, this.httpOptions);
618
+ }
619
+ register(user) {
620
+ let serviceUrl = this.SERVICE_URL + 'post/create/web';
621
+ this.generateRequestParams(user);
622
+ return this.http.post(serviceUrl, this.httpOptions);
623
+ }
624
+ registerIndex(register) {
625
+ let serviceUrl = this.SERVICE_URL + 'post/create/marketing';
626
+ this.generateRequestParams(register);
627
+ return this.http.post(serviceUrl, this.httpOptions);
628
+ }
629
+ registerDashboard(user) {
630
+ let serviceUrl = this.SERVICE_URL + 'post/create/dashboard';
631
+ this.generateRequestParams(user);
632
+ return this.http.post(serviceUrl, this.httpOptions);
633
+ }
634
+ getAvailableTeachers(token) {
635
+ let serviceUrl = this.SERVICE_URL + 'post/obtain/teachers';
636
+ this.generateRequestParams(token);
637
+ return this.http.post(serviceUrl, this.httpOptions);
638
+ }
639
+ getUserByIdCard(value) {
640
+ let serviceUrl = this.SERVICE_URL + 'user/id_card/' + value;
641
+ return this.http.get(serviceUrl);
642
+ }
643
+ generateRequestParams(param) {
644
+ this.httpOptions = {
645
+ header: new HttpHeaders(),
646
+ params: param,
647
+ };
648
+ }
649
+ }
650
+ 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 });
651
+ UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, providedIn: 'root' });
652
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, decorators: [{
653
+ type: Injectable,
654
+ args: [{
655
+ providedIn: 'root',
656
+ }]
657
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
658
+
659
+ class StorageService {
660
+ constructor() {
661
+ this.currentSession = null;
662
+ this.localStorageService = localStorage;
663
+ this.currentSession = this.loadSessionData();
664
+ }
665
+ setCurrentSession(session) {
666
+ this.currentSession = session;
667
+ this.localStorageService.setItem('606a7d4e73650b75ebb06972e77d6cc4', JSON.stringify(session));
668
+ }
669
+ loadSessionData() {
670
+ var sessionStr = this.localStorageService.getItem('606a7d4e73650b75ebb06972e77d6cc4');
671
+ return (sessionStr) ? JSON.parse(sessionStr) : null;
672
+ }
673
+ getCurrentSession() {
674
+ return this.currentSession;
675
+ }
676
+ removeCurrentSession() {
677
+ this.localStorageService.removeItem('606a7d4e73650b75ebb06972e77d6cc4');
678
+ this.currentSession = null;
679
+ }
680
+ getCurrentUser() {
681
+ var session = this.getCurrentSession();
682
+ return (session && session.user) ? session.user : null;
683
+ }
684
+ ;
685
+ isAuthenticated() {
686
+ return (this.getCurrentToken() != null) ? true : false;
687
+ }
688
+ ;
689
+ getCurrentToken() {
690
+ var session = this.getCurrentSession();
691
+ return (session && session.token) ? session.token : null;
692
+ }
693
+ ;
694
+ logout() {
695
+ this.removeCurrentSession();
696
+ }
697
+ }
698
+ StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
699
+ StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, providedIn: 'root' });
700
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, decorators: [{
701
+ type: Injectable,
702
+ args: [{
703
+ providedIn: 'root',
704
+ }]
705
+ }], ctorParameters: function () { return []; } });
706
+
707
+ class BaseService {
708
+ constructor(userService, storageService) {
709
+ this.userService = userService;
710
+ this.storageService = storageService;
711
+ }
712
+ webLogin(user, password) {
713
+ return __awaiter(this, void 0, void 0, function* () {
714
+ let request = {
715
+ user: user,
716
+ password: password
717
+ };
718
+ this.userService.login(request).subscribe(response => {
719
+ switch (response.message.code) {
720
+ case 1:
721
+ Swal.fire({
722
+ 'title': '<p style="font-family: Poppins"">Perfect!</p>',
723
+ 'html': '<p style="font-family: Poppins"">Succesfull login</p>',
724
+ 'icon': 'success',
725
+ });
726
+ const loginRegisterUser = {
727
+ token: response.data.token,
728
+ user: response.data,
729
+ };
730
+ this.storageService.setCurrentSession(loginRegisterUser);
731
+ break;
732
+ case 2:
733
+ Swal.fire({
734
+ 'title': '<p style="font-family: Poppins"">Warning!</p>',
735
+ 'html': '<p style="font-family: Poppins"">The data does not correspond to a user registered in our system, please review them.</p>',
736
+ 'icon': 'warning',
737
+ });
738
+ break;
739
+ case 3:
740
+ Swal.fire({
741
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
742
+ 'html': '<p style="font-family: Poppins"">The input data does not meet the established parameters.</p>',
743
+ 'icon': 'error',
744
+ });
745
+ break;
746
+ default:
747
+ Swal.fire({
748
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
749
+ 'html': '<p style="font-family: Poppins"">An unexpected error has occurred</p>',
750
+ 'icon': 'error',
751
+ });
752
+ break;
753
+ }
754
+ return true;
755
+ });
756
+ });
757
+ }
758
+ getUserRole() {
759
+ var _a;
760
+ let user = (_a = this.storageService.getCurrentUser()) === null || _a === void 0 ? void 0 : _a.role;
761
+ return user === undefined ? -1 : Math.floor(user / 10);
762
+ }
763
+ }
764
+ 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 });
765
+ BaseService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, providedIn: 'root' });
766
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, decorators: [{
767
+ type: Injectable,
768
+ args: [{
769
+ providedIn: 'root',
770
+ }]
771
+ }], ctorParameters: function () { return [{ type: UserService }, { type: StorageService }]; } });
772
+
602
773
  class LoginFormComponent {
603
- constructor(fb) {
774
+ constructor(fb, baseService) {
775
+ this.baseService = baseService;
604
776
  this.background = true;
605
777
  this.email = new EventEmitter();
606
778
  this.password = new EventEmitter();
@@ -610,13 +782,14 @@ class LoginFormComponent {
610
782
  });
611
783
  }
612
784
  login(data) {
785
+ this.baseService.webLogin(data.controls['email'].value, data.controls['password'].value);
613
786
  this.email.emit(data.controls['email'].value);
614
787
  this.password.emit(data.controls['password'].value);
615
788
  this.loginForm.controls['email'].setValue('');
616
789
  this.loginForm.controls['password'].setValue('');
617
790
  }
618
791
  }
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 });
792
+ 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
793
  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
794
  <div [ngClass]="{'with-background': background}" class="form-container">
622
795
 
@@ -703,7 +876,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
703
876
 
704
877
  </div>
705
878
  `, 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: [{
879
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: BaseService }]; }, propDecorators: { background: [{
707
880
  type: Input
708
881
  }], image: [{
709
882
  type: Input
@@ -944,54 +1117,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
944
1117
  type: Injectable
945
1118
  }], ctorParameters: function () { return [{ type: i1$3.Router }]; } });
946
1119
 
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
1120
  class SwitchService {
996
1121
  constructor() {
997
1122
  this.$modal = new EventEmitter();
@@ -1006,61 +1131,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
1006
1131
  }]
1007
1132
  }], ctorParameters: function () { return []; } });
1008
1133
 
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
1134
  class CoreModule {
1065
1135
  }
1066
1136
  CoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -1071,7 +1141,8 @@ CoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13
1071
1141
  StorageService,
1072
1142
  UserService,
1073
1143
  SwitchService,
1074
- RedirectGuard
1144
+ RedirectGuard,
1145
+ BaseService
1075
1146
  ] });
1076
1147
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, decorators: [{
1077
1148
  type: NgModule,
@@ -1082,7 +1153,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
1082
1153
  StorageService,
1083
1154
  UserService,
1084
1155
  SwitchService,
1085
- RedirectGuard
1156
+ RedirectGuard,
1157
+ BaseService
1086
1158
  ]
1087
1159
  }]
1088
1160
  }] });
@@ -1128,5 +1200,5 @@ class UserLoginRs {
1128
1200
  * Generated bundle index. Do not edit.
1129
1201
  */
1130
1202
 
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 };
1203
+ 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
1204
  //# sourceMappingURL=iptdevs-design-system.mjs.map