@kuzntsv/uikit 0.0.4 → 0.0.5

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.
Files changed (188) hide show
  1. package/ng-package.json +8 -0
  2. package/package.json +12 -23
  3. package/{auth/auth.types.d.ts → src/auth/auth.types.ts} +2 -1
  4. package/{auth/components/index.d.ts → src/auth/components/index.ts} +1 -1
  5. package/src/auth/components/login-form/login-form.component.html +57 -0
  6. package/src/auth/components/login-form/login-form.component.scss +37 -0
  7. package/src/auth/components/login-form/login-form.component.ts +48 -0
  8. package/src/auth/components/login-page/login-page.component.html +13 -0
  9. package/src/auth/components/login-page/login-page.component.scss +0 -0
  10. package/src/auth/components/login-page/login-page.component.ts +71 -0
  11. package/src/auth/components/permit-form/permit-form.component.html +11 -0
  12. package/src/auth/components/permit-form/permit-form.component.scss +44 -0
  13. package/src/auth/components/permit-form/permit-form.component.ts +47 -0
  14. package/src/auth/directives/disable-if-role.directive.ts +24 -0
  15. package/src/auth/directives/disable-if-unauthorized.directive.ts +19 -0
  16. package/src/auth/directives/hide-if-role-not.directive.ts +28 -0
  17. package/src/auth/directives/hide-if-unauthorized.directive.ts +19 -0
  18. package/{auth/directives/index.d.ts → src/auth/directives/index.ts} +4 -4
  19. package/{auth/index.d.ts → src/auth/index.ts} +4 -4
  20. package/src/auth/models/user.ts +8 -0
  21. package/src/auth/services/auth-guard.service.ts +33 -0
  22. package/src/auth/services/auth-role.service.ts +18 -0
  23. package/src/auth/services/auth-user.service.ts +59 -0
  24. package/src/auth/services/auth.service.ts +222 -0
  25. package/{auth/services/index.d.ts → src/auth/services/index.ts} +5 -5
  26. package/src/auth/services/role-guard.service.ts +27 -0
  27. package/{base/base-classes/base-class.d.ts → src/base/base-classes/base-class.ts} +3 -3
  28. package/src/base/base-classes/base-edit-class.ts +50 -0
  29. package/src/base/base-classes/base-edit-dialog-data.ts +10 -0
  30. package/src/base/base-classes/base-entity-action.ts +11 -0
  31. package/src/base/base-classes/base-filter-class.ts +12 -0
  32. package/src/base/base-classes/base-nav-bar-menu-class.ts +27 -0
  33. package/src/base/base-classes/base-page-class.ts +405 -0
  34. package/src/base/base-classes/base-service-class.ts +67 -0
  35. package/{base/base-classes/index.d.ts → src/base/base-classes/index.ts} +8 -8
  36. package/src/base/base-toolbar/base-toolbar.service.ts +12 -0
  37. package/src/base/base-toolbar/components/base-toolbar.component.html +90 -0
  38. package/src/base/base-toolbar/components/base-toolbar.component.scss +0 -0
  39. package/src/base/base-toolbar/components/base-toolbar.component.ts +133 -0
  40. package/src/base/base-toolbar/components/index.ts +1 -0
  41. package/{base/index.d.ts → src/base/index.ts} +3 -2
  42. package/src/base/interfaces/alert-service.interface.ts +49 -0
  43. package/src/base/interfaces/index.ts +1 -0
  44. package/src/core/animations/animations.service.spec.ts +28 -0
  45. package/src/core/animations/animations.service.ts +33 -0
  46. package/{core/animations/index.d.ts → src/core/animations/index.ts} +2 -2
  47. package/src/core/animations/route.animations.ts +81 -0
  48. package/{core/index.d.ts → src/core/index.ts} +1 -1
  49. package/{guards/index.d.ts → src/guards/index.ts} +1 -1
  50. package/src/guards/redirect-guard.ts +18 -0
  51. package/{loader/index.d.ts → src/loader/index.ts} +3 -2
  52. package/src/loader/loader.service.ts +34 -0
  53. package/src/loader/progress-spinner.component.ts +49 -0
  54. package/{models/deserializable.model.d.ts → src/models/deserializable.model.ts} +3 -3
  55. package/src/models/environment.model.ts +12 -0
  56. package/{models/index.d.ts → src/models/index.ts} +3 -3
  57. package/src/models/sec-user-view.model.ts +37 -0
  58. package/src/models/sec-user.model.ts +28 -0
  59. package/{pipes/index.d.ts → src/pipes/index.ts} +3 -3
  60. package/src/pipes/safe.pipe.ts +14 -0
  61. package/src/pipes/time.pipe.spec.ts +8 -0
  62. package/src/pipes/time.pipe.ts +19 -0
  63. package/src/pipes/truncate.pipe.spec.ts +8 -0
  64. package/src/pipes/truncate.pipe.ts +16 -0
  65. package/{public-api.d.ts → src/public-api.ts} +14 -10
  66. package/src/services/alert.service.ts +43 -0
  67. package/src/services/avatar.service.ts +18 -0
  68. package/src/services/export.service.ts +66 -0
  69. package/{services/index.d.ts → src/services/index.ts} +4 -4
  70. package/src/services/local-storage-service.ts +25 -0
  71. package/src/services/log.service.ts +25 -0
  72. package/src/services/time.service.ts +11 -0
  73. package/src/shared/chip-input-autocomplete/chip-input-autocomplete.component.css +3 -0
  74. package/src/shared/chip-input-autocomplete/chip-input-autocomplete.component.html +35 -0
  75. package/src/shared/chip-input-autocomplete/chip-input-autocomplete.component.ts +102 -0
  76. package/{shared/chip-input-autocomplete/index.d.ts → src/shared/chip-input-autocomplete/index.ts} +2 -2
  77. package/{shared/chip-input-autocomplete/models/chip-item.d.ts → src/shared/chip-input-autocomplete/models/chip-item.ts} +4 -4
  78. package/{shared/chip-input-autocomplete/models/index.d.ts → src/shared/chip-input-autocomplete/models/index.ts} +1 -1
  79. package/src/shared/date-range-filter/date-range-filter.component.html +14 -0
  80. package/src/shared/date-range-filter/date-range-filter.component.scss +3 -0
  81. package/src/shared/date-range-filter/date-range-filter.component.ts +96 -0
  82. package/{shared/date-range-filter/index.d.ts → src/shared/date-range-filter/index.ts} +2 -2
  83. package/src/shared/date-range-filter/models/date-formats.ts +13 -0
  84. package/src/shared/date-range-filter/models/date-range.ts +13 -0
  85. package/{shared/date-range-filter/models/index.d.ts → src/shared/date-range-filter/models/index.ts} +2 -2
  86. package/src/shared/dialog/dialog.component.css +0 -0
  87. package/src/shared/dialog/dialog.component.html +9 -0
  88. package/src/shared/dialog/dialog.component.ts +32 -0
  89. package/{shared/dialog/index.d.ts → src/shared/dialog/index.ts} +2 -2
  90. package/src/shared/dialog/models/dialog-action.ts +6 -0
  91. package/{shared/dialog/models/dialog-data.d.ts → src/shared/dialog/models/dialog-data.ts} +8 -7
  92. package/{shared/dialog/models/index.d.ts → src/shared/dialog/models/index.ts} +2 -2
  93. package/src/shared/dialog-confirm/dialog-confirm.component.ts +36 -0
  94. package/src/shared/dialog-confirm/index.ts +1 -0
  95. package/{shared/index.d.ts → src/shared/index.ts} +8 -8
  96. package/{shared/navbar/index.d.ts → src/shared/navbar/index.ts} +1 -1
  97. package/src/shared/navbar/navbar.html +26 -0
  98. package/src/shared/navbar/navbar.scss +33 -0
  99. package/src/shared/navbar/navbar.ts +96 -0
  100. package/{shared/not-found/index.d.ts → src/shared/not-found/index.ts} +1 -1
  101. package/src/shared/not-found/not-found.component.css +6 -0
  102. package/src/shared/not-found/not-found.component.html +3 -0
  103. package/src/shared/not-found/not-found.component.ts +14 -0
  104. package/{shared/select-autocomplete-with-virtual-scroll/index.d.ts → src/shared/select-autocomplete-with-virtual-scroll/index.ts} +1 -1
  105. package/{shared/select-autocomplete-with-virtual-scroll/models/index.d.ts → src/shared/select-autocomplete-with-virtual-scroll/models/index.ts} +1 -1
  106. package/{shared/select-autocomplete-with-virtual-scroll/models/select-item.d.ts → src/shared/select-autocomplete-with-virtual-scroll/models/select-item.ts} +4 -4
  107. package/src/shared/select-autocomplete-with-virtual-scroll/select-autocomplete-with-virtual-scroll.component.css +7 -0
  108. package/src/shared/select-autocomplete-with-virtual-scroll/select-autocomplete-with-virtual-scroll.component.html +32 -0
  109. package/src/shared/select-autocomplete-with-virtual-scroll/select-autocomplete-with-virtual-scroll.component.ts +162 -0
  110. package/{shared/select-with-group/index.d.ts → src/shared/select-with-group/index.ts} +2 -2
  111. package/{shared/select-with-group/models/index.d.ts → src/shared/select-with-group/models/index.ts} +2 -2
  112. package/{shared/select-with-group/models/select-group.d.ts → src/shared/select-with-group/models/select-group.ts} +6 -5
  113. package/{shared/select-with-group/models/select-item.d.ts → src/shared/select-with-group/models/select-item.ts} +4 -4
  114. package/src/shared/select-with-group/select-with-group.component.css +3 -0
  115. package/src/shared/select-with-group/select-with-group.component.html +20 -0
  116. package/src/shared/select-with-group/select-with-group.component.ts +62 -0
  117. package/src/shared/table/get-any/mat-table.component.ts +132 -0
  118. package/src/shared/table/get-any/mat-table.html +87 -0
  119. package/{shared/table/index.d.ts → src/shared/table/index.ts} +4 -3
  120. package/src/shared/table/models/column-options.interface.ts +26 -0
  121. package/{shared/table/models/context-menu-options.interface.d.ts → src/shared/table/models/context-menu-options.interface.ts} +23 -22
  122. package/{shared/table/models/index.d.ts → src/shared/table/models/index.ts} +2 -2
  123. package/src/shared/table/table.component.css +92 -0
  124. package/src/shared/table/table.component.html +139 -0
  125. package/src/shared/table/table.component.ts +218 -0
  126. package/src/shared/table/table.state.ts +15 -0
  127. package/src/types/index.ts +1 -0
  128. package/{types/types.d.ts → src/types/types.ts} +4 -6
  129. package/tsconfig.lib.json +15 -0
  130. package/tsconfig.lib.prod.json +11 -0
  131. package/tsconfig.spec.json +15 -0
  132. package/auth/components/login-form/login-form.component.d.ts +0 -16
  133. package/auth/components/login-page/login-page.component.d.ts +0 -29
  134. package/auth/components/permit-form/permit-form.component.d.ts +0 -18
  135. package/auth/directives/disable-if-role.directive.d.ts +0 -12
  136. package/auth/directives/disable-if-unauthorized.directive.d.ts +0 -13
  137. package/auth/directives/hide-if-role-not.directive.d.ts +0 -12
  138. package/auth/directives/hide-if-unauthorized.directive.d.ts +0 -13
  139. package/auth/models/user.d.ts +0 -7
  140. package/auth/services/auth-guard.service.d.ts +0 -2
  141. package/auth/services/auth-role.service.d.ts +0 -10
  142. package/auth/services/auth-user.service.d.ts +0 -35
  143. package/auth/services/auth.service.d.ts +0 -44
  144. package/auth/services/role-guard.service.d.ts +0 -2
  145. package/base/base-classes/base-edit-class.d.ts +0 -17
  146. package/base/base-classes/base-edit-dialog-data.d.ts +0 -9
  147. package/base/base-classes/base-entity-action.d.ts +0 -10
  148. package/base/base-classes/base-filter-class.d.ts +0 -7
  149. package/base/base-classes/base-nav-bar-menu-class.d.ts +0 -11
  150. package/base/base-classes/base-page-class.d.ts +0 -117
  151. package/base/base-classes/base-service-class.d.ts +0 -23
  152. package/base/base-toolbar/base-toolbar.service.d.ts +0 -7
  153. package/base/base-toolbar/components/base-toolbar.component.d.ts +0 -67
  154. package/base/interfaces/alert-service.interface.d.ts +0 -44
  155. package/base/interfaces/index.d.ts +0 -1
  156. package/core/animations/animations.service.d.ts +0 -10
  157. package/core/animations/route.animations.d.ts +0 -6
  158. package/fesm2022/kuzntsv-uikit.mjs +0 -2466
  159. package/fesm2022/kuzntsv-uikit.mjs.map +0 -1
  160. package/guards/redirect-guard.d.ts +0 -8
  161. package/index.d.ts +0 -5
  162. package/loader/loader.service.d.ts +0 -11
  163. package/loader/progress-spinner.component.d.ts +0 -9
  164. package/models/environment.model.d.ts +0 -12
  165. package/models/sec-user-view.model.d.ts +0 -16
  166. package/models/sec-user.model.d.ts +0 -12
  167. package/pipes/safe.pipe.d.ts +0 -10
  168. package/pipes/time.pipe.d.ts +0 -7
  169. package/pipes/truncate.pipe.d.ts +0 -7
  170. package/services/alert.service.d.ts +0 -16
  171. package/services/avatar.service.d.ts +0 -11
  172. package/services/export.service.d.ts +0 -9
  173. package/services/local-storage-service.d.ts +0 -10
  174. package/services/log.service.d.ts +0 -10
  175. package/shared/chip-input-autocomplete/chip-input-autocomplete.component.d.ts +0 -28
  176. package/shared/date-range-filter/date-range-filter.component.d.ts +0 -22
  177. package/shared/date-range-filter/models/date-formats.d.ts +0 -11
  178. package/shared/date-range-filter/models/date-range.d.ts +0 -5
  179. package/shared/dialog/dialog.component.d.ts +0 -11
  180. package/shared/dialog/models/dialog-action.d.ts +0 -6
  181. package/shared/navbar/navbar.d.ts +0 -24
  182. package/shared/not-found/not-found.component.d.ts +0 -6
  183. package/shared/select-autocomplete-with-virtual-scroll/select-autocomplete-with-virtual-scroll.component.d.ts +0 -27
  184. package/shared/select-with-group/select-with-group.component.d.ts +0 -21
  185. package/shared/table/models/column-options.interface.d.ts +0 -26
  186. package/shared/table/table.component.d.ts +0 -75
  187. package/shared/table/table.state.d.ts +0 -11
  188. package/types/index.d.ts +0 -1
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/uikit",
4
+ "assets": ["./assets"],
5
+ "lib": {
6
+ "entryFile": "src/public-api.ts"
7
+ }
8
+ }
package/package.json CHANGED
@@ -1,23 +1,12 @@
1
- {
2
- "name": "@kuzntsv/uikit",
3
- "version": "0.0.4",
4
- "peerDependencies": {
5
- "@angular/common": "^19.2.0",
6
- "@angular/core": "^19.2.0"
7
- },
8
- "dependencies": {
9
- "tslib": "^2.3.0"
10
- },
11
- "sideEffects": false,
12
- "module": "fesm2022/kuzntsv-uikit.mjs",
13
- "typings": "index.d.ts",
14
- "exports": {
15
- "./package.json": {
16
- "default": "./package.json"
17
- },
18
- ".": {
19
- "types": "./index.d.ts",
20
- "default": "./fesm2022/kuzntsv-uikit.mjs"
21
- }
22
- }
23
- }
1
+ {
2
+ "name": "@kuzntsv/uikit",
3
+ "version": "0.0.5",
4
+ "peerDependencies": {
5
+ "@angular/common": "^19.2.0",
6
+ "@angular/core": "^19.2.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.8.1"
10
+ },
11
+ "sideEffects": false
12
+ }
@@ -1 +1,2 @@
1
- export type AuthPermission = 'VIEW' | 'EDIT' | 'CREATE' | 'DELETE';
1
+ // Типы доступа в приложении
2
+ export type AuthPermission = 'VIEW' | 'EDIT' | 'CREATE' | 'DELETE';
@@ -1 +1 @@
1
- export * from './login-page/login-page.component';
1
+ export * from './login-page/login-page.component';
@@ -0,0 +1,57 @@
1
+ <mat-card appearance="outlined">
2
+ <mat-card-header>
3
+ <mat-card-title>
4
+ Авторизация
5
+ </mat-card-title>
6
+ </mat-card-header>
7
+ <mat-card-content>
8
+ <form [formGroup]="form" (ngSubmit)="submit()">
9
+ <p>
10
+ <mat-form-field>
11
+ <mat-label>Имя пользователя</mat-label>
12
+ <input type="text" pattern="[A-Za-z]{1,}.[A-Za-z]{1,}.[A-Za-z]*"
13
+ matInput
14
+ autocomplete="on"
15
+ name="login-form-username"
16
+ placeholder="Имя пользователя"
17
+ formControlName="username">
18
+ @if (form.controls['username'].hasError('pattern')) {
19
+ <mat-error>
20
+ Пожалуйста, используйте требуемый формат (Пример: a.p.petrov)
21
+ </mat-error>
22
+ }
23
+ @if (form.controls['username'].hasError('required')) {
24
+ <mat-error>
25
+ Пожалуйста, заполните это поле
26
+ </mat-error>
27
+ }
28
+ </mat-form-field>
29
+ </p>
30
+
31
+ <p>
32
+ <mat-form-field>
33
+ <mat-label>Пароль</mat-label>
34
+ <input [type]="hide ? 'password' : 'text'" matInput placeholder="Пароль" formControlName="password">
35
+ <mat-icon class="watcher" matSuffix (mousedown)="hide=false" (mouseup)="hide=true"
36
+ >{{ hide ? 'visibility_off' : 'visibility'}}</mat-icon>
37
+ @if (form.controls['password'].hasError('required')) {
38
+ <mat-error>
39
+ Пожалуйста, заполните это поле
40
+ </mat-error>
41
+ }
42
+ </mat-form-field>
43
+ </p>
44
+
45
+ @if (errorMessage) {
46
+ <p class="loginError">
47
+ {{ errorMessage }}
48
+ </p>
49
+ }
50
+
51
+ <p class="loginButtons">
52
+ <button type="submit" mat-button mat-stroked-button color="primary" [disabled]="isDisabled">Войти</button>
53
+ </p>
54
+
55
+ </form>
56
+ </mat-card-content>
57
+ </mat-card>
@@ -0,0 +1,37 @@
1
+ :host {
2
+ display: flex;
3
+ justify-content: center;
4
+ margin: 32px 0;
5
+ }
6
+
7
+ .mat-mdc-form-field {
8
+ width: 100%;
9
+ min-width: 300px;
10
+ }
11
+
12
+ mat-card-header {
13
+ justify-content: center;
14
+ }
15
+
16
+ /* TODO(mdc-migration): The following rule targets internal classes of card that may no longer apply for the MDC version. */
17
+ mat-card-content {
18
+ font-size: 16px;
19
+ }
20
+
21
+ .loginError {
22
+ padding: 16px;
23
+ width: 300px;
24
+ color: white;
25
+ background-color: red;
26
+ }
27
+
28
+ .loginButtons {
29
+ display: flex;
30
+ flex-direction: row;
31
+ justify-content: flex-end;
32
+ }
33
+
34
+ .watcher {
35
+ cursor: default;
36
+ }
37
+
@@ -0,0 +1,48 @@
1
+
2
+ import { Component, EventEmitter, Input, Output } from '@angular/core';
3
+ import { FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
4
+ import { MatButton } from '@angular/material/button';
5
+ import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from '@angular/material/card';
6
+ import { MatError, MatFormField, MatLabel, MatSuffix } from '@angular/material/form-field';
7
+ import { MatIcon } from '@angular/material/icon';
8
+ import { MatInput } from '@angular/material/input';
9
+
10
+ import { Authenticate } from '../../models/user';
11
+
12
+ @Component({
13
+ selector: 'ngx-uik-login-form',
14
+ templateUrl: 'login-form.component.html',
15
+ styleUrls: ['login-form.component.scss'],
16
+ imports: [MatCard, MatCardHeader, MatCardTitle, MatCardContent, FormsModule, ReactiveFormsModule, MatFormField, MatLabel, MatInput, MatError, MatIcon, MatSuffix, MatButton]
17
+ })
18
+ export class LoginFormComponent {
19
+ @Input() errorMessage: string = '';
20
+
21
+ @Output() submitted = new EventEmitter<Authenticate>();
22
+ hide = true;
23
+
24
+ form: FormGroup = new FormGroup({
25
+ username: new FormControl('', [Validators.required]),
26
+ password: new FormControl('', [Validators.required]),
27
+ });
28
+
29
+ isDisabled = false;
30
+
31
+ constructor() { }
32
+
33
+ @Input()
34
+ set pending(isPending: boolean) {
35
+ this.isDisabled = isPending;
36
+ if (isPending) {
37
+ this.form.disable();
38
+ } else {
39
+ this.form.enable();
40
+ }
41
+ }
42
+
43
+ submit() {
44
+ if (this.form.valid) {
45
+ this.submitted.emit(this.form.value);
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,13 @@
1
+ @if (!isKiosk) {
2
+ <ngx-uik-login-form
3
+ (submitted)="onSubmit($event)"
4
+ [pending]="pending"
5
+ [errorMessage]="error">
6
+ </ngx-uik-login-form>
7
+ }
8
+ @if (isKiosk) {
9
+ <ngx-uik-permit-form
10
+ (submitted)="onSubmitPermit($event)"
11
+ >
12
+ </ngx-uik-permit-form>
13
+ }
@@ -0,0 +1,71 @@
1
+ import { Component, OnDestroy, OnInit } from '@angular/core';
2
+ import { ActivatedRoute } from '@angular/router';
3
+ import { Subscription } from 'rxjs';
4
+
5
+ import { LoaderService } from '../../../loader';
6
+ import { Authenticate } from '../../models/user';
7
+ import { AuthService } from '../../services/auth.service';
8
+ import { PermitFormComponent } from '../permit-form/permit-form.component';
9
+ import { LoginFormComponent } from '../login-form/login-form.component';
10
+
11
+ @Component({
12
+ selector: 'ngx-uik-login-page',
13
+ templateUrl: 'login-page.component.html',
14
+ styleUrls: ['login-page.component.scss'],
15
+ imports: [LoginFormComponent, PermitFormComponent]
16
+ })
17
+ export class LoginPageComponent implements OnInit, OnDestroy {
18
+ pending: boolean = false;
19
+ error: string = '';
20
+ isKiosk: boolean = false;
21
+ /** Идентификатор АС */
22
+ idCas: number = 0;
23
+ /** Подписка на Идентификатор АС */
24
+ sub: Subscription;
25
+ /** Url страницы, с которой был переход (после входа вернет на неё) */
26
+ returnUrl: string = '';
27
+
28
+ constructor(private authService: AuthService,
29
+ private route: ActivatedRoute,
30
+ private loaderService: LoaderService
31
+ ) {
32
+ this.sub = this.route.data.subscribe(data => {
33
+ this.idCas = data['idCas'];
34
+ });
35
+ }
36
+
37
+ ngOnInit() {
38
+ if (localStorage.getItem('id_human') || localStorage.getItem('kiosk-keyboard-layout')) {
39
+ // this.isKiosk = true;
40
+ }
41
+ this.route.queryParams.subscribe(params => {
42
+ this.returnUrl = params['returnUrl'];
43
+ //console.log('constructor this.returnUrl = ', this.returnUrl);
44
+ //this.returnUrl = this.returnUrl.slice(this.returnUrl.lastIndexOf('returnUrl=') + 'returnUrl='.length);
45
+ //console.log('constructor NEW this.returnUrl = ', this.returnUrl);
46
+ });
47
+
48
+ }
49
+
50
+ ngOnDestroy(): void {
51
+ this.sub.unsubscribe();
52
+ }
53
+
54
+ onSubmitError() {
55
+ return () => {
56
+ this.pending = false;
57
+ this.loaderService.hide();
58
+ };
59
+ }
60
+
61
+ onSubmit($event: Authenticate) {
62
+ this.loaderService.show();
63
+ this.pending = true;
64
+ this.authService.login($event.username, $event.password, this.idCas, this.returnUrl, this.onSubmitError());
65
+ }
66
+
67
+ onSubmitPermit($event: string) {
68
+ const permit = $event;
69
+ this.authService.loginByPermit(permit, this.idCas, this.returnUrl);
70
+ }
71
+ }
@@ -0,0 +1,11 @@
1
+ <mat-card appearance="outlined">
2
+ <mat-card-header>
3
+ <mat-card-title>
4
+ Приложите пропуск
5
+ </mat-card-title>
6
+ </mat-card-header>
7
+ <mat-card-content>
8
+ <div class="permit"></div>
9
+ </mat-card-content>
10
+ </mat-card>
11
+ <input #hidy class="hidy" type="text" (keydown)="onKeydown($event)"/>
@@ -0,0 +1,44 @@
1
+ $asset-path: '../../assets/images';
2
+
3
+ :host {
4
+ display: flex;
5
+ justify-content: center;
6
+ margin: 32px 0;
7
+ }
8
+
9
+ .mat-mdc-form-field {
10
+ width: 100%;
11
+ min-width: 300px;
12
+ }
13
+
14
+ /* TODO(mdc-migration): The following rule targets internal classes of card that may no longer apply for the MDC version. */
15
+ mat-card-title,
16
+ mat-card-content {
17
+ display: flex;
18
+ justify-content: center;
19
+ }
20
+
21
+ /* TODO(mdc-migration): The following rule targets internal classes of card that may no longer apply for the MDC version. */
22
+ mat-card-content {
23
+ font-size: 16px;
24
+ }
25
+
26
+ div.permit {
27
+ border: none;
28
+ width: 300px;
29
+ background-size: 300px;
30
+ height: 180px;
31
+ }
32
+
33
+ div.permit button div{
34
+ margin-bottom: 200px;
35
+ color: black;
36
+ font-size: 34px;
37
+ }
38
+
39
+ input.hidy {
40
+ opacity: 0;
41
+ position: absolute;
42
+ left: -200px;
43
+ top: -200px;
44
+ }
@@ -0,0 +1,47 @@
1
+ import { Component, ElementRef, EventEmitter, HostListener, OnInit, Output, ViewChild } from '@angular/core';
2
+ import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from '@angular/material/card';
3
+
4
+ @Component({
5
+ selector: 'ngx-uik-permit-form',
6
+ templateUrl: 'permit-form.component.html',
7
+ styleUrls: ['permit-form.component.scss'],
8
+ imports: [MatCard, MatCardHeader, MatCardTitle, MatCardContent]
9
+ })
10
+ export class PermitFormComponent implements OnInit {
11
+ @ViewChild('hidy') hidy: ElementRef | undefined;
12
+
13
+ @Output() submitted = new EventEmitter<string>();
14
+
15
+ private mouseEvent = MouseEvent;
16
+
17
+ constructor() {
18
+ }
19
+
20
+ @HostListener('document:mouseup', ['$event'])
21
+ mouseHandling() {
22
+ this.hidy?.nativeElement.focus();
23
+ }
24
+
25
+ ngOnInit() {
26
+ // Обнуляем значение Input
27
+ if (this.hidy) {
28
+ this.hidy.nativeElement.value = null;
29
+ this.hidy.nativeElement.focus();
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Поле ввода
35
+ *
36
+ * @param событие нажатия на клавишу
37
+ */
38
+ onKeydown(event: any): void {
39
+ if (event.key === 'Enter') {
40
+ const permit = this.hidy?.nativeElement.value;
41
+ if (permit) {
42
+ this.submitted.emit(permit);
43
+ }
44
+ }
45
+ }
46
+
47
+ }
@@ -0,0 +1,24 @@
1
+ import { Directive, Input, OnInit, ElementRef } from '@angular/core';
2
+ import { AuthService } from '../services/auth.service';
3
+
4
+ @Directive({
5
+ selector: '[ngxUikDisableIfRole]',
6
+ standalone: true
7
+ })
8
+ export class DisableIfRoleDirective implements OnInit {
9
+ @Input('ngxUikDisableIfRole') role: string = '';
10
+
11
+ constructor(private el: ElementRef, private authService: AuthService) { }
12
+
13
+ ngOnInit() {
14
+ this.authService.roles$.subscribe((userRoles) => {
15
+ if (this.role) {
16
+ if (!this.authService.hasRole(userRoles, this.role)) {
17
+ this.el.nativeElement.disabled = true;
18
+ } else {
19
+ this.el.nativeElement.disabled = false;
20
+ }
21
+ }
22
+ });
23
+ }
24
+ }
@@ -0,0 +1,19 @@
1
+ import { Directive, Input, OnInit, ElementRef } from '@angular/core';
2
+ import { AuthPermission } from '../auth.types';
3
+ import { AuthService } from '../services/auth.service';
4
+
5
+ @Directive({
6
+ selector: '[ngxUikDisableIfUnauthorized]',
7
+ standalone: true
8
+ })
9
+ export class DisableIfUnauthorizedDirective implements OnInit {
10
+ @Input('ngxUikDisableIfUnauthorized') permission: AuthPermission | undefined;
11
+
12
+ constructor(private el: ElementRef, private authservice: AuthService) { }
13
+
14
+ ngOnInit() {
15
+ if (this.permission && !this.authservice.hasPermission(this.permission)) {
16
+ this.el.nativeElement.disabled = true;
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,28 @@
1
+ import { Directive, OnInit, ElementRef, Input } from '@angular/core';
2
+ import { AuthService } from '../services/auth.service';
3
+
4
+ @Directive({
5
+ selector: '[ngxUikHideIfRoleNot]',
6
+ standalone: true
7
+ })
8
+ export class HideIfRoleNotDirective implements OnInit {
9
+ @Input('ngxUikHideIfRoleNot') roles: string[] = [];
10
+
11
+ constructor(private el: ElementRef, private authService: AuthService) { }
12
+
13
+ // Элемент скрывается, если у пользователя нет ни одной роли из перереданных в "roles"
14
+ // или в списке "roles" есть роль "hideRole".
15
+ ngOnInit() {
16
+ if (this.roles) {
17
+ this.authService.roles$.subscribe((userRoles) => {
18
+ const isHide = this.authService.isHideElement(this.roles, userRoles);
19
+
20
+ if (isHide) {
21
+ this.el.nativeElement.style.display = 'none';
22
+ } else {
23
+ this.el.nativeElement.style.display = 'inherit';
24
+ }
25
+ });
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,19 @@
1
+ import { Directive, OnInit, ElementRef, Input } from '@angular/core';
2
+ import { AuthService } from '../services/auth.service';
3
+ import { AuthPermission } from '../auth.types';
4
+
5
+ @Directive({
6
+ selector: '[ngxUikHideIfUnauthorized]',
7
+ standalone: true
8
+ })
9
+ export class HideIfUnauthorizedDirective implements OnInit {
10
+ @Input('ngxUikHideIfUnauthorized') permission: AuthPermission | undefined;
11
+
12
+ constructor(private el: ElementRef, private authService: AuthService) { }
13
+
14
+ ngOnInit() {
15
+ if (this.permission && !this.authService.hasPermission(this.permission)) {
16
+ this.el.nativeElement.style.display = 'none';
17
+ }
18
+ }
19
+ }
@@ -1,4 +1,4 @@
1
- export * from './disable-if-unauthorized.directive';
2
- export * from './hide-if-unauthorized.directive';
3
- export * from './disable-if-role.directive';
4
- export * from './hide-if-role-not.directive';
1
+ export * from './disable-if-unauthorized.directive';
2
+ export * from './hide-if-unauthorized.directive';
3
+ export * from './disable-if-role.directive';
4
+ export * from './hide-if-role-not.directive';
@@ -1,4 +1,4 @@
1
- export * from './components';
2
- export * from './auth.types';
3
- export * from './directives';
4
- export * from './services';
1
+ export * from './components';
2
+ export * from './auth.types';
3
+ export * from './directives';
4
+ export * from './services';
@@ -0,0 +1,8 @@
1
+ export interface Authenticate {
2
+ username: string;
3
+ password: string;
4
+ }
5
+
6
+ export interface User {
7
+ name: string;
8
+ }
@@ -0,0 +1,33 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
3
+
4
+ import { AuthService } from './auth.service';
5
+
6
+ @Injectable({
7
+ providedIn: 'root'
8
+ })
9
+ class AuthGuardService {
10
+
11
+ constructor(private auth: AuthService,
12
+ private router: Router) {
13
+ }
14
+
15
+ canActivate(route: ActivatedRouteSnapshot,
16
+ state: RouterStateSnapshot
17
+ ) {
18
+ const isLogin = this.auth.loggedIn$.value;
19
+ if (!isLogin) {
20
+ console.log('state.url =', state.url);
21
+
22
+ // Если не зарегистрирован вернуть в форму авторизации
23
+ this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } });
24
+ }
25
+
26
+ return isLogin;
27
+ }
28
+ }
29
+
30
+ export const authGuard: CanActivateFn = (
31
+ route: ActivatedRouteSnapshot,
32
+ state: RouterStateSnapshot
33
+ ) => inject(AuthGuardService).canActivate(route, state);
@@ -0,0 +1,18 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Injectable } from '@angular/core';
3
+
4
+ @Injectable({
5
+ providedIn: 'root'
6
+ })
7
+ // Вычисление разрешений на модули по ролям
8
+ export class RoleService {
9
+ // Указываем какой сервер использовать
10
+ baseRoute = 'mainApi/';
11
+
12
+ constructor(private http: HttpClient) { }
13
+
14
+ // Получить роли пользователя
15
+ getRoles() {
16
+ return this.http.get(this.baseRoute + 'jwt/webroles');
17
+ }
18
+ }
@@ -0,0 +1,59 @@
1
+ import { Injectable } from '@angular/core';
2
+ /**
3
+ * Сущность пользователя из API
4
+ */
5
+ export class User {
6
+ id: number = 0;
7
+ username: string = '';
8
+ firstName: string = '';
9
+ lastName: string = '';
10
+ prof: string = '';
11
+ depart: number = 0;
12
+ area: string = '';
13
+ tabnum: string = '';
14
+ mail: string = '';
15
+ phone: string = '';
16
+ roles: string = '';
17
+ rolesArray: string[] = [];
18
+ roleList: string[] = [];
19
+ idHuman: string = '';
20
+ token: string = '';
21
+ // Время действия токена
22
+ expires_in: number = 0;
23
+ }
24
+ @Injectable({
25
+ providedIn: 'root'
26
+ })
27
+ /**
28
+ * Сервис для работы с объектом в local Storage
29
+ */
30
+ export class UserService {
31
+ private user: User;
32
+ constructor() {
33
+ if (localStorage.getItem('sed_currentUser')) {
34
+ this.user = JSON.parse(localStorage.getItem('sed_currentUser') || '');
35
+ } else {
36
+ this.user = new User();
37
+ }
38
+ }
39
+
40
+ get dept(): number {
41
+ return this.user?.depart;
42
+ }
43
+
44
+ /** Получить данные о пользователе */
45
+ get userData(): User {
46
+ return this.user;
47
+ }
48
+
49
+ /** Изменить данные пользователя в localStorage */
50
+ set userData(user: User) {
51
+ localStorage.setItem('sed_currentUser', JSON.stringify(user));
52
+ this.user = JSON.parse(localStorage.getItem('sed_currentUser') || '');
53
+ }
54
+
55
+ /** Удаляет данные о пользователе из localStorage. */
56
+ removeUser() {
57
+ localStorage.removeItem('sed_currentUser');
58
+ }
59
+ }