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,15 @@
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';
12
+ import * as i1$3 from '@angular/router';
10
13
 
11
14
  class AsideButtonComponent {
12
15
  constructor() {
@@ -598,8 +601,178 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
598
601
  type: Output
599
602
  }] } });
600
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
+
601
773
  class LoginFormComponent {
602
- constructor(fb) {
774
+ constructor(fb, baseService) {
775
+ this.baseService = baseService;
603
776
  this.background = true;
604
777
  this.email = new EventEmitter();
605
778
  this.password = new EventEmitter();
@@ -609,13 +782,14 @@ class LoginFormComponent {
609
782
  });
610
783
  }
611
784
  login(data) {
785
+ this.baseService.webLogin(data.controls['email'].value, data.controls['password'].value);
612
786
  this.email.emit(data.controls['email'].value);
613
787
  this.password.emit(data.controls['password'].value);
614
788
  this.loginForm.controls['email'].setValue('');
615
789
  this.loginForm.controls['password'].setValue('');
616
790
  }
617
791
  }
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 });
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 });
619
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: `
620
794
  <div [ngClass]="{'with-background': background}" class="form-container">
621
795
 
@@ -702,7 +876,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
702
876
 
703
877
  </div>
704
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"] }]
705
- }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }]; }, propDecorators: { background: [{
879
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: BaseService }]; }, propDecorators: { background: [{
706
880
  type: Input
707
881
  }], image: [{
708
882
  type: Input
@@ -928,53 +1102,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
928
1102
  }]
929
1103
  }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
930
1104
 
931
- class StorageService {
932
- constructor() {
933
- this.currentSession = null;
934
- this.localStorageService = localStorage;
935
- this.currentSession = this.loadSessionData();
1105
+ class RedirectGuard {
1106
+ constructor(router) {
1107
+ this.router = router;
936
1108
  }
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();
1109
+ canActivate(route, state) {
1110
+ window.location.href = route.data['externalUrl'];
1111
+ return true;
968
1112
  }
969
1113
  }
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 []; } });
1114
+ 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 });
1115
+ RedirectGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: RedirectGuard });
1116
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: RedirectGuard, decorators: [{
1117
+ type: Injectable
1118
+ }], ctorParameters: function () { return [{ type: i1$3.Router }]; } });
978
1119
 
979
1120
  class SwitchService {
980
1121
  constructor() {
@@ -990,61 +1131,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
990
1131
  }]
991
1132
  }], ctorParameters: function () { return []; } });
992
1133
 
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
1134
  class CoreModule {
1049
1135
  }
1050
1136
  CoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -1054,7 +1140,8 @@ CoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13
1054
1140
  CourseService,
1055
1141
  StorageService,
1056
1142
  UserService,
1057
- SwitchService
1143
+ SwitchService,
1144
+ RedirectGuard
1058
1145
  ] });
1059
1146
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, decorators: [{
1060
1147
  type: NgModule,
@@ -1064,7 +1151,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
1064
1151
  CourseService,
1065
1152
  StorageService,
1066
1153
  UserService,
1067
- SwitchService
1154
+ SwitchService,
1155
+ RedirectGuard
1068
1156
  ]
1069
1157
  }]
1070
1158
  }] });
@@ -1110,5 +1198,5 @@ class UserLoginRs {
1110
1198
  * Generated bundle index. Do not edit.
1111
1199
  */
1112
1200
 
1113
- export { AsideButtonComponent, ButtonComponent, CheckboxComponent, ComponentsModule, CoreModule, CourseService, DatalistComponent, DesignSystemModule, InputComponent, LevelButtonComponent, LevelTextComponent, LoginFormComponent, ParameterService, RadioComponent, SelectComponent, Session, StorageService, SwitchService, TextLinkComponent, UserLoginRs, UserRs, UserService };
1201
+ 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
1202
  //# sourceMappingURL=iptdevs-design-system.mjs.map