iptdevs-design-system 1.3.4 → 1.3.7

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,12 +1,14 @@
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';
11
+ import * as i1$3 from '@angular/router';
10
12
 
11
13
  class AsideButtonComponent {
12
14
  constructor() {
@@ -598,8 +600,175 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
598
600
  type: Output
599
601
  }] } });
600
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
+ async webLogin(user, password) {
712
+ let request = {
713
+ user: user,
714
+ password: password
715
+ };
716
+ this.userService.login(request).subscribe(response => {
717
+ switch (response.message.code) {
718
+ case 1:
719
+ Swal.fire({
720
+ 'title': '<p style="font-family: Poppins"">Perfect!</p>',
721
+ 'html': '<p style="font-family: Poppins"">Succesfull login</p>',
722
+ 'icon': 'success',
723
+ });
724
+ const loginRegisterUser = {
725
+ token: response.data.token,
726
+ user: response.data,
727
+ };
728
+ this.storageService.setCurrentSession(loginRegisterUser);
729
+ break;
730
+ case 2:
731
+ Swal.fire({
732
+ 'title': '<p style="font-family: Poppins"">Warning!</p>',
733
+ 'html': '<p style="font-family: Poppins"">The data does not correspond to a user registered in our system, please review them.</p>',
734
+ 'icon': 'warning',
735
+ });
736
+ break;
737
+ case 3:
738
+ Swal.fire({
739
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
740
+ 'html': '<p style="font-family: Poppins"">The input data does not meet the established parameters.</p>',
741
+ 'icon': 'error',
742
+ });
743
+ break;
744
+ default:
745
+ Swal.fire({
746
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
747
+ 'html': '<p style="font-family: Poppins"">An unexpected error has occurred</p>',
748
+ 'icon': 'error',
749
+ });
750
+ break;
751
+ }
752
+ return true;
753
+ });
754
+ }
755
+ getUserRole() {
756
+ let user = this.storageService.getCurrentUser()?.role;
757
+ return user === undefined ? -1 : Math.floor(user / 10);
758
+ }
759
+ }
760
+ 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 });
761
+ BaseService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, providedIn: 'root' });
762
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, decorators: [{
763
+ type: Injectable,
764
+ args: [{
765
+ providedIn: 'root',
766
+ }]
767
+ }], ctorParameters: function () { return [{ type: UserService }, { type: StorageService }]; } });
768
+
601
769
  class LoginFormComponent {
602
- constructor(fb) {
770
+ constructor(fb, baseService) {
771
+ this.baseService = baseService;
603
772
  this.background = true;
604
773
  this.email = new EventEmitter();
605
774
  this.password = new EventEmitter();
@@ -609,13 +778,14 @@ class LoginFormComponent {
609
778
  });
610
779
  }
611
780
  login(data) {
781
+ this.baseService.webLogin(data.controls['email'].value, data.controls['password'].value);
612
782
  this.email.emit(data.controls['email'].value);
613
783
  this.password.emit(data.controls['password'].value);
614
784
  this.loginForm.controls['email'].setValue('');
615
785
  this.loginForm.controls['password'].setValue('');
616
786
  }
617
787
  }
618
- 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 });
788
+ 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 });
619
789
  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: `
620
790
  <div [ngClass]="{'with-background': background}" class="form-container">
621
791
 
@@ -702,7 +872,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
702
872
 
703
873
  </div>
704
874
  `, 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"] }]
705
- }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }]; }, propDecorators: { background: [{
875
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: BaseService }]; }, propDecorators: { background: [{
706
876
  type: Input
707
877
  }], image: [{
708
878
  type: Input
@@ -928,53 +1098,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
928
1098
  }]
929
1099
  }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
930
1100
 
931
- class StorageService {
932
- constructor() {
933
- this.currentSession = null;
934
- this.localStorageService = localStorage;
935
- this.currentSession = this.loadSessionData();
1101
+ class RedirectGuard {
1102
+ constructor(router) {
1103
+ this.router = router;
936
1104
  }
937
- setCurrentSession(session) {
938
- this.currentSession = session;
939
- this.localStorageService.setItem('606a7d4e73650b75ebb06972e77d6cc4', JSON.stringify(session));
940
- }
941
- loadSessionData() {
942
- var sessionStr = this.localStorageService.getItem('606a7d4e73650b75ebb06972e77d6cc4');
943
- return (sessionStr) ? JSON.parse(sessionStr) : null;
944
- }
945
- getCurrentSession() {
946
- return this.currentSession;
947
- }
948
- removeCurrentSession() {
949
- this.localStorageService.removeItem('606a7d4e73650b75ebb06972e77d6cc4');
950
- this.currentSession = null;
951
- }
952
- getCurrentUser() {
953
- var session = this.getCurrentSession();
954
- return (session && session.user) ? session.user : null;
955
- }
956
- ;
957
- isAuthenticated() {
958
- return (this.getCurrentToken() != null) ? true : false;
959
- }
960
- ;
961
- getCurrentToken() {
962
- var session = this.getCurrentSession();
963
- return (session && session.token) ? session.token : null;
964
- }
965
- ;
966
- logout() {
967
- this.removeCurrentSession();
1105
+ canActivate(route, state) {
1106
+ window.location.href = route.data['externalUrl'];
1107
+ return true;
968
1108
  }
969
1109
  }
970
- StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
971
- StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, providedIn: 'root' });
972
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, decorators: [{
973
- type: Injectable,
974
- args: [{
975
- providedIn: 'root',
976
- }]
977
- }], ctorParameters: function () { return []; } });
1110
+ RedirectGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: RedirectGuard, deps: [{ token: i1$3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
1111
+ RedirectGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: RedirectGuard });
1112
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: RedirectGuard, decorators: [{
1113
+ type: Injectable
1114
+ }], ctorParameters: function () { return [{ type: i1$3.Router }]; } });
978
1115
 
979
1116
  class SwitchService {
980
1117
  constructor() {
@@ -990,61 +1127,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
990
1127
  }]
991
1128
  }], ctorParameters: function () { return []; } });
992
1129
 
993
- class UserService {
994
- constructor(http) {
995
- this.http = http;
996
- this.SERVICE_URL = 'https://iptdev.com.co/lab/users/api/';
997
- }
998
- login(userLogin) {
999
- let serviceUrl = this.SERVICE_URL + 'post/login';
1000
- this.generateRequestParams(userLogin);
1001
- return this.http.post(serviceUrl, this.httpOptions);
1002
- }
1003
- resetPassword(resetPassword) {
1004
- let serviceUrl = this.SERVICE_URL + 'reset/password';
1005
- this.generateRequestParams(resetPassword);
1006
- return this.http.post(serviceUrl, this.httpOptions);
1007
- }
1008
- register(user) {
1009
- let serviceUrl = this.SERVICE_URL + 'post/create/web';
1010
- this.generateRequestParams(user);
1011
- return this.http.post(serviceUrl, this.httpOptions);
1012
- }
1013
- registerIndex(register) {
1014
- let serviceUrl = this.SERVICE_URL + 'post/create/marketing';
1015
- this.generateRequestParams(register);
1016
- return this.http.post(serviceUrl, this.httpOptions);
1017
- }
1018
- registerDashboard(user) {
1019
- let serviceUrl = this.SERVICE_URL + 'post/create/dashboard';
1020
- this.generateRequestParams(user);
1021
- return this.http.post(serviceUrl, this.httpOptions);
1022
- }
1023
- getAvailableTeachers(token) {
1024
- let serviceUrl = this.SERVICE_URL + 'post/obtain/teachers';
1025
- this.generateRequestParams(token);
1026
- return this.http.post(serviceUrl, this.httpOptions);
1027
- }
1028
- getUserByIdCard(value) {
1029
- let serviceUrl = this.SERVICE_URL + 'user/id_card/' + value;
1030
- return this.http.get(serviceUrl);
1031
- }
1032
- generateRequestParams(param) {
1033
- this.httpOptions = {
1034
- header: new HttpHeaders(),
1035
- params: param,
1036
- };
1037
- }
1038
- }
1039
- 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 });
1040
- UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, providedIn: 'root' });
1041
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, decorators: [{
1042
- type: Injectable,
1043
- args: [{
1044
- providedIn: 'root',
1045
- }]
1046
- }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
1047
-
1048
1130
  class CoreModule {
1049
1131
  }
1050
1132
  CoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -1054,7 +1136,8 @@ CoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13
1054
1136
  CourseService,
1055
1137
  StorageService,
1056
1138
  UserService,
1057
- SwitchService
1139
+ SwitchService,
1140
+ RedirectGuard
1058
1141
  ] });
1059
1142
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, decorators: [{
1060
1143
  type: NgModule,
@@ -1064,7 +1147,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
1064
1147
  CourseService,
1065
1148
  StorageService,
1066
1149
  UserService,
1067
- SwitchService
1150
+ SwitchService,
1151
+ RedirectGuard
1068
1152
  ]
1069
1153
  }]
1070
1154
  }] });
@@ -1110,5 +1194,5 @@ class UserLoginRs {
1110
1194
  * Generated bundle index. Do not edit.
1111
1195
  */
1112
1196
 
1113
- export { AsideButtonComponent, ButtonComponent, CheckboxComponent, ComponentsModule, CoreModule, CourseService, DatalistComponent, DesignSystemModule, InputComponent, LevelButtonComponent, LevelTextComponent, LoginFormComponent, ParameterService, RadioComponent, SelectComponent, Session, StorageService, SwitchService, TextLinkComponent, UserLoginRs, UserRs, UserService };
1197
+ export { AsideButtonComponent, ButtonComponent, CheckboxComponent, ComponentsModule, CoreModule, CourseService, DatalistComponent, DesignSystemModule, InputComponent, LevelButtonComponent, LevelTextComponent, LoginFormComponent, ParameterService, RadioComponent, RedirectGuard, SelectComponent, Session, StorageService, SwitchService, TextLinkComponent, UserLoginRs, UserRs, UserService };
1114
1198
  //# sourceMappingURL=iptdevs-design-system.mjs.map