oip-common 0.0.3 → 0.0.4
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.
- package/package.json +1 -1
- package/src/api/http-client.ts +26 -26
- package/src/components/db-migration/db-migration.component.ts +3 -1
- package/src/components/db-migration.component.ts +11 -10
- package/src/components/menu/menu-item-create-dialog.component.ts +7 -7
- package/src/components/menu/menu-item-edit-dialog.component.ts +7 -6
- package/src/components/profile.component.ts +4 -3
- package/src/user-api/http-client.ts +27 -25
package/package.json
CHANGED
package/src/api/http-client.ts
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { inject, Injectable } from "@angular/core";
|
|
14
|
-
import { LayoutService,
|
|
15
|
-
|
|
14
|
+
import { LayoutService, } from "../services/app.layout.service"
|
|
15
|
+
import { SecurityService } from "../services/security.service";
|
|
16
16
|
export type QueryParamsType = Record<string | number, any>;
|
|
17
17
|
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
|
|
18
18
|
|
|
@@ -64,7 +64,7 @@ export enum ContentType {
|
|
|
64
64
|
Text = "text/plain",
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
@Injectable({
|
|
67
|
+
@Injectable({providedIn: "root"})
|
|
68
68
|
export class HttpClient<SecurityDataType = unknown> {
|
|
69
69
|
protected securityService = inject(SecurityService);
|
|
70
70
|
protected layoutService = inject(LayoutService);
|
|
@@ -202,16 +202,16 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
202
202
|
};
|
|
203
203
|
|
|
204
204
|
public request = async <T = any, E = any>({
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
205
|
+
body,
|
|
206
|
+
secure,
|
|
207
|
+
path,
|
|
208
|
+
type,
|
|
209
|
+
query,
|
|
210
|
+
format,
|
|
211
|
+
baseUrl,
|
|
212
|
+
cancelToken,
|
|
213
|
+
...params
|
|
214
|
+
}: FullRequestParams): Promise<T> => {
|
|
215
215
|
const secureParams =
|
|
216
216
|
((typeof secure === "boolean" ? secure : this.baseApiParams.secure) &&
|
|
217
217
|
this.securityWorker &&
|
|
@@ -229,7 +229,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
229
229
|
headers: {
|
|
230
230
|
...(requestParams.headers || {}),
|
|
231
231
|
...(type && type !== ContentType.FormData
|
|
232
|
-
? {
|
|
232
|
+
? {"Content-Type": type}
|
|
233
233
|
: {}),
|
|
234
234
|
},
|
|
235
235
|
signal:
|
|
@@ -252,18 +252,18 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
252
252
|
const data = !responseFormat
|
|
253
253
|
? r
|
|
254
254
|
: await response[responseFormat]()
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
255
|
+
.then((data) => {
|
|
256
|
+
if (r.ok) {
|
|
257
|
+
r.data = data;
|
|
258
|
+
} else {
|
|
259
|
+
r.error = data;
|
|
260
|
+
}
|
|
261
|
+
return r;
|
|
262
|
+
})
|
|
263
|
+
.catch((e) => {
|
|
264
|
+
r.error = e;
|
|
265
|
+
return r;
|
|
266
|
+
});
|
|
267
267
|
|
|
268
268
|
if (cancelToken) {
|
|
269
269
|
this.abortControllers.delete(cancelToken);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, inject, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
-
import { BaseModuleComponent, NoSettingsDto, SecurityComponent } from 'oip-common';
|
|
3
2
|
import { TagModule } from 'primeng/tag';
|
|
4
3
|
import { ConfirmationService, SharedModule } from 'primeng/api';
|
|
5
4
|
import { TableModule } from 'primeng/table';
|
|
@@ -11,6 +10,9 @@ import { ConfirmDialog } from 'primeng/confirmdialog';
|
|
|
11
10
|
import { NgIf } from '@angular/common';
|
|
12
11
|
import { Tooltip } from 'primeng/tooltip';
|
|
13
12
|
import { ActivatedRoute } from '@angular/router';
|
|
13
|
+
import { BaseModuleComponent } from "../base-module.component";
|
|
14
|
+
import { NoSettingsDto } from "../../dtos/no-settings.dto";
|
|
15
|
+
import { SecurityComponent } from "../security.component";
|
|
14
16
|
|
|
15
17
|
export interface MigrationDto {
|
|
16
18
|
name: string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
-
import { BaseModuleComponent, NoSettingsDto, SecurityComponent } from 'oip-common';
|
|
3
2
|
import { TagModule } from 'primeng/tag';
|
|
4
3
|
import { ConfirmationService, SharedModule } from 'primeng/api';
|
|
5
4
|
import { TableModule } from 'primeng/table';
|
|
@@ -10,6 +9,9 @@ import { FormsModule } from '@angular/forms';
|
|
|
10
9
|
import { ConfirmDialog } from 'primeng/confirmdialog';
|
|
11
10
|
import { NgIf } from '@angular/common';
|
|
12
11
|
import { Tooltip } from 'primeng/tooltip';
|
|
12
|
+
import { BaseModuleComponent } from "./base-module.component";
|
|
13
|
+
import { NoSettingsDto } from "../dtos/no-settings.dto";
|
|
14
|
+
import { SecurityComponent } from "./security.component";
|
|
13
15
|
|
|
14
16
|
export interface MigrationDto {
|
|
15
17
|
name: string;
|
|
@@ -39,7 +41,7 @@ export interface ApplyMigrationRequest {
|
|
|
39
41
|
selector: 'db-migration',
|
|
40
42
|
template: `
|
|
41
43
|
<div *ngIf="isContent" class="card" style="height: 100%">
|
|
42
|
-
<p-confirmDialog
|
|
44
|
+
<p-confirmDialog/>
|
|
43
45
|
<div>
|
|
44
46
|
<h5>Migration manager</h5>
|
|
45
47
|
<div class="flex flex-row gap-2">
|
|
@@ -49,14 +51,14 @@ export interface ApplyMigrationRequest {
|
|
|
49
51
|
severity="secondary"
|
|
50
52
|
tooltipPosition="bottom"
|
|
51
53
|
[outlined]="true"
|
|
52
|
-
(click)="refreshAction()"
|
|
54
|
+
(click)="refreshAction()"/>
|
|
53
55
|
<p-button
|
|
54
56
|
icon="pi pi-filter-slash"
|
|
55
57
|
pTooltip="Clean filter"
|
|
56
58
|
severity="secondary"
|
|
57
59
|
tooltipPosition="bottom"
|
|
58
60
|
[outlined]="true"
|
|
59
|
-
(click)="dt.clear()"
|
|
61
|
+
(click)="dt.clear()"/>
|
|
60
62
|
</div>
|
|
61
63
|
<div>
|
|
62
64
|
<p-table #dt dataKey="name" editMode="row" size="small" [scrollable]="true" [value]="data">
|
|
@@ -64,7 +66,7 @@ export interface ApplyMigrationRequest {
|
|
|
64
66
|
<tr>
|
|
65
67
|
<th pSortableColumn="name" scope="col">
|
|
66
68
|
Migration name
|
|
67
|
-
<p-columnFilter display="menu" field="name" type="text"
|
|
69
|
+
<p-columnFilter display="menu" field="name" type="text"/>
|
|
68
70
|
</th>
|
|
69
71
|
<th scope="col">Applied</th>
|
|
70
72
|
<th scope="col">Exist</th>
|
|
@@ -89,7 +91,7 @@ export interface ApplyMigrationRequest {
|
|
|
89
91
|
</td>
|
|
90
92
|
<td>
|
|
91
93
|
@if (rowData.exist) {
|
|
92
|
-
<p-button icon="pi pi-check" severity="success" [rounded]="true" [text]="true"
|
|
94
|
+
<p-button icon="pi pi-check" severity="success" [rounded]="true" [text]="true"/>
|
|
93
95
|
}
|
|
94
96
|
</td>
|
|
95
97
|
<td>
|
|
@@ -116,15 +118,14 @@ export interface ApplyMigrationRequest {
|
|
|
116
118
|
</div>
|
|
117
119
|
</div>
|
|
118
120
|
@if (isSecurity) {
|
|
119
|
-
<security [controller]="controller" [id]="id"
|
|
121
|
+
<security [controller]="controller" [id]="id"/>
|
|
120
122
|
}
|
|
121
123
|
`,
|
|
122
124
|
providers: [ConfirmationService]
|
|
123
125
|
})
|
|
124
126
|
export class DbMigrationComponent
|
|
125
127
|
extends BaseModuleComponent<NoSettingsDto, NoSettingsDto>
|
|
126
|
-
implements OnInit, OnDestroy
|
|
127
|
-
{
|
|
128
|
+
implements OnInit, OnDestroy {
|
|
128
129
|
data: MigrationDto[];
|
|
129
130
|
|
|
130
131
|
async ngOnInit() {
|
|
@@ -148,7 +149,7 @@ export class DbMigrationComponent
|
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
async applyMigration(rowData: MigrationDto) {
|
|
151
|
-
const request = {
|
|
152
|
+
const request = {name: rowData.name} as ApplyMigrationRequest;
|
|
152
153
|
return this.baseDataService.sendRequest(`api/${this.controller}/apply-migration`, 'POST', request);
|
|
153
154
|
}
|
|
154
155
|
}
|
|
@@ -4,10 +4,10 @@ import { DialogModule } from 'primeng/dialog';
|
|
|
4
4
|
import { InputTextModule } from 'primeng/inputtext';
|
|
5
5
|
import { SelectModule } from 'primeng/select';
|
|
6
6
|
import { FormsModule } from '@angular/forms';
|
|
7
|
-
import { MenuService } from 'oip-common';
|
|
8
7
|
import { TranslatePipe } from '@ngx-translate/core';
|
|
9
8
|
import { AddModuleInstanceDto, IntKeyValueDto } from '../../api/data-contracts';
|
|
10
9
|
import { Menu } from '../../api/Menu';
|
|
10
|
+
import { MenuService } from "../../services/app.menu.service";
|
|
11
11
|
|
|
12
12
|
@Component({
|
|
13
13
|
selector: 'menu-item-create-dialog',
|
|
@@ -30,14 +30,14 @@ import { Menu } from '../../api/Menu';
|
|
|
30
30
|
id="oip-menu-item-create-dialog-parent-input"
|
|
31
31
|
pInputText
|
|
32
32
|
readonly
|
|
33
|
-
[ngModel]="menuService.contextMenuItem?.label"
|
|
33
|
+
[ngModel]="menuService.contextMenuItem?.label"/>
|
|
34
34
|
</div>
|
|
35
35
|
}
|
|
36
36
|
<div class="flex items-center gap-4 mb-4">
|
|
37
37
|
<label class="font-semibold w-1/3" for="oip-menu-item-create-label">
|
|
38
38
|
{{ 'menuItemCreateDialogComponent.label' | translate }}
|
|
39
39
|
</label>
|
|
40
|
-
<input autocomplete="off" class="flex-auto" id="oip-menu-item-create-label" pInputText [(ngModel)]="label"
|
|
40
|
+
<input autocomplete="off" class="flex-auto" id="oip-menu-item-create-label" pInputText [(ngModel)]="label"/>
|
|
41
41
|
</div>
|
|
42
42
|
<div class="flex items-center gap-4 mb-4">
|
|
43
43
|
<label class="font-semibold w-1/3" for="oip-menu-item-create-module">
|
|
@@ -51,14 +51,14 @@ import { Menu } from '../../api/Menu';
|
|
|
51
51
|
optionValue="key"
|
|
52
52
|
placeholder="{{ 'menuItemCreateDialogComponent.selectModule' | translate }}"
|
|
53
53
|
[options]="modules"
|
|
54
|
-
[(ngModel)]="selectModule"
|
|
54
|
+
[(ngModel)]="selectModule"/>
|
|
55
55
|
</div>
|
|
56
56
|
<div class="flex items-center gap-4 mb-4">
|
|
57
57
|
<label class="font-semibold w-1/3" for="oip-menu-item-create-dialog-icon">
|
|
58
58
|
{{ 'menuItemCreateDialogComponent.icon' | translate }}
|
|
59
59
|
</label>
|
|
60
60
|
<i class="{{ selectIcon }}"></i>
|
|
61
|
-
<input class="flex-auto" id="oip-menu-item-create-dialog-icon" pInputText [(ngModel)]="selectIcon"
|
|
61
|
+
<input class="flex-auto" id="oip-menu-item-create-dialog-icon" pInputText [(ngModel)]="selectIcon"/>
|
|
62
62
|
</div>
|
|
63
63
|
<div class="flex justify-end gap-2">
|
|
64
64
|
<p-button
|
|
@@ -66,12 +66,12 @@ import { Menu } from '../../api/Menu';
|
|
|
66
66
|
label="{{ 'menuItemCreateDialogComponent.cancel' | translate }}"
|
|
67
67
|
severity="secondary"
|
|
68
68
|
(click)="changeVisible()"
|
|
69
|
-
(keydown)="changeVisible()"
|
|
69
|
+
(keydown)="changeVisible()"/>
|
|
70
70
|
<p-button
|
|
71
71
|
id="oip-menu-item-create-save"
|
|
72
72
|
label="{{ 'menuItemCreateDialogComponent.save' | translate }}"
|
|
73
73
|
(click)="save()"
|
|
74
|
-
(keydown)="save()"
|
|
74
|
+
(keydown)="save()"/>
|
|
75
75
|
</div>
|
|
76
76
|
</p-dialog>
|
|
77
77
|
`
|
|
@@ -3,7 +3,8 @@ import { ButtonModule } from 'primeng/button';
|
|
|
3
3
|
import { DialogModule } from 'primeng/dialog';
|
|
4
4
|
import { InputTextModule } from 'primeng/inputtext';
|
|
5
5
|
import { FormsModule } from '@angular/forms';
|
|
6
|
-
import { MenuService
|
|
6
|
+
import { MenuService } from '../../services/app.menu.service'
|
|
7
|
+
import { SecurityDataService, } from '../../services/security-data.service'
|
|
7
8
|
import { TranslatePipe } from '@ngx-translate/core';
|
|
8
9
|
import { EditModuleInstanceDto } from '../../dtos/edit-module-instance.dto';
|
|
9
10
|
import { MultiSelectModule } from 'primeng/multiselect';
|
|
@@ -27,7 +28,7 @@ import { MultiSelectModule } from 'primeng/multiselect';
|
|
|
27
28
|
class="flex-auto"
|
|
28
29
|
id="oip-menu-item-edit-dialog-menu-input"
|
|
29
30
|
pInputText
|
|
30
|
-
[(ngModel)]="item.label"
|
|
31
|
+
[(ngModel)]="item.label"/>
|
|
31
32
|
</div>
|
|
32
33
|
|
|
33
34
|
<div class="flex items-center gap-4 mb-4">
|
|
@@ -35,7 +36,7 @@ import { MultiSelectModule } from 'primeng/multiselect';
|
|
|
35
36
|
{{ 'menuItemEditDialogComponent.icon' | translate }}
|
|
36
37
|
</label>
|
|
37
38
|
<i class="{{ item.icon }}"></i>
|
|
38
|
-
<input class="flex-auto" id="oip-menu-item-edit-dialog-icon" pInputText [(ngModel)]="item.icon"
|
|
39
|
+
<input class="flex-auto" id="oip-menu-item-edit-dialog-icon" pInputText [(ngModel)]="item.icon"/>
|
|
39
40
|
</div>
|
|
40
41
|
|
|
41
42
|
<div class="flex items-center gap-4 mb-4">
|
|
@@ -49,7 +50,7 @@ import { MultiSelectModule } from 'primeng/multiselect';
|
|
|
49
50
|
placeholder="Select roles"
|
|
50
51
|
[maxSelectedLabels]="10"
|
|
51
52
|
[options]="roles"
|
|
52
|
-
[(ngModel)]="item.viewRoles"
|
|
53
|
+
[(ngModel)]="item.viewRoles"/>
|
|
53
54
|
</div>
|
|
54
55
|
|
|
55
56
|
<div class="flex justify-end gap-2">
|
|
@@ -58,12 +59,12 @@ import { MultiSelectModule } from 'primeng/multiselect';
|
|
|
58
59
|
label="{{ 'menuItemEditDialogComponent.cancel' | translate }}"
|
|
59
60
|
severity="secondary"
|
|
60
61
|
(click)="changeVisible()"
|
|
61
|
-
(keydown)="changeVisible()"
|
|
62
|
+
(keydown)="changeVisible()"/>
|
|
62
63
|
<p-button
|
|
63
64
|
id="oip-menu-item-edit-dialog-save-edit-button"
|
|
64
65
|
label="{{ 'menuItemEditDialogComponent.save' | translate }}"
|
|
65
66
|
(click)="save()"
|
|
66
|
-
(keydown)="save()"
|
|
67
|
+
(keydown)="save()"/>
|
|
67
68
|
</div>
|
|
68
69
|
</p-dialog>
|
|
69
70
|
`
|
|
@@ -2,7 +2,8 @@ import { Component, inject } from '@angular/core';
|
|
|
2
2
|
import { FileUploadModule } from 'primeng/fileupload';
|
|
3
3
|
import { ImageModule } from 'primeng/image';
|
|
4
4
|
import { AvatarModule } from 'primeng/avatar';
|
|
5
|
-
import { MsgService
|
|
5
|
+
import { MsgService } from "../services/msg.service";
|
|
6
|
+
import { UserService } from "../services/user.service";
|
|
6
7
|
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
|
7
8
|
|
|
8
9
|
@Component({
|
|
@@ -15,7 +16,7 @@ import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
|
|
15
16
|
id="oip-user-profile-photo-avatar"
|
|
16
17
|
shape="circle"
|
|
17
18
|
size="xlarge"
|
|
18
|
-
[image]="userService.photoLoaded ? userService.photo : null"
|
|
19
|
+
[image]="userService.photoLoaded ? userService.photo : null"/>
|
|
19
20
|
<div class="mt-2">
|
|
20
21
|
<p-fileupload
|
|
21
22
|
accept="image/*"
|
|
@@ -28,7 +29,7 @@ import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
|
|
28
29
|
url="/api/user-profile/post-user-photo"
|
|
29
30
|
withCredentials="true"
|
|
30
31
|
[auto]="true"
|
|
31
|
-
(onUpload)="onBasicUploadAuto($event)"
|
|
32
|
+
(onUpload)="onBasicUploadAuto($event)"/>
|
|
32
33
|
</div>
|
|
33
34
|
`
|
|
34
35
|
})
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { inject, Injectable } from '@angular/core';
|
|
14
|
-
import { LayoutService
|
|
14
|
+
import { LayoutService } from '../services/app.layout.service';
|
|
15
|
+
import { SecurityService } from '../services/security.service';
|
|
15
16
|
|
|
16
17
|
export type QueryParamsType = Record<string | number, any>;
|
|
17
18
|
export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>;
|
|
@@ -58,7 +59,7 @@ export enum ContentType {
|
|
|
58
59
|
Text = 'text/plain'
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
@Injectable({
|
|
62
|
+
@Injectable({providedIn: 'root'})
|
|
62
63
|
export class HttpClient<SecurityDataType = unknown> {
|
|
63
64
|
protected securityService = inject(SecurityService);
|
|
64
65
|
public baseUrl: string = '';
|
|
@@ -75,6 +76,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
75
76
|
const storageData = localStorage.getItem('0-oip-client');
|
|
76
77
|
return JSON.parse(storageData)?.authnResult?.access_token;
|
|
77
78
|
}
|
|
79
|
+
|
|
78
80
|
private getLanguage(): string {
|
|
79
81
|
// Получаем язык из localStorage или используем значение по умолчанию
|
|
80
82
|
return localStorage.getItem('user-language') || 'en';
|
|
@@ -189,16 +191,16 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
189
191
|
};
|
|
190
192
|
|
|
191
193
|
public request = async <T = any, E = any>({
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
194
|
+
body,
|
|
195
|
+
secure,
|
|
196
|
+
path,
|
|
197
|
+
type,
|
|
198
|
+
query,
|
|
199
|
+
format,
|
|
200
|
+
baseUrl,
|
|
201
|
+
cancelToken,
|
|
202
|
+
...params
|
|
203
|
+
}: FullRequestParams): Promise<T> => {
|
|
202
204
|
const secureParams =
|
|
203
205
|
((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) &&
|
|
204
206
|
this.securityWorker &&
|
|
@@ -213,7 +215,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
213
215
|
...requestParams,
|
|
214
216
|
headers: {
|
|
215
217
|
...(requestParams.headers || {}),
|
|
216
|
-
...(type && type !== ContentType.FormData ? {
|
|
218
|
+
...(type && type !== ContentType.FormData ? {'Content-Type': type} : {})
|
|
217
219
|
},
|
|
218
220
|
signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
|
|
219
221
|
body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body)
|
|
@@ -227,18 +229,18 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
227
229
|
const data = !responseFormat
|
|
228
230
|
? r
|
|
229
231
|
: await response[responseFormat]()
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
232
|
+
.then((data) => {
|
|
233
|
+
if (r.ok) {
|
|
234
|
+
r.data = data;
|
|
235
|
+
} else {
|
|
236
|
+
r.error = data;
|
|
237
|
+
}
|
|
238
|
+
return r;
|
|
239
|
+
})
|
|
240
|
+
.catch((e) => {
|
|
241
|
+
r.error = e;
|
|
242
|
+
return r;
|
|
243
|
+
});
|
|
242
244
|
|
|
243
245
|
if (cancelToken) {
|
|
244
246
|
this.abortControllers.delete(cancelToken);
|