Skip to content

Commit 48c11f9

Browse files
committed
🛠️openapi refactoring
1 parent 67c8bcc commit 48c11f9

19 files changed

Lines changed: 133 additions & 80 deletions

File tree

‎frontend/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
99
"test": "ng test",
10-
"generate:backend": "openapi-generator-cli generate -i ../openapi/backend.yml -g typescript-angular -o client/backend",
10+
"generate:backend": "openapi-generator-cli generate -i ../openapi/backend.yml -g typescript-angular -o client/backend --additional-properties=useSingleRequestParameter=true",
1111
"lint": "ng lint"
1212
},
1313
"private": true,
@@ -50,4 +50,4 @@
5050
"typescript": "~5.7.2",
5151
"typescript-eslint": "8.27.0"
5252
}
53-
}
53+
}

‎frontend/src/app/pages/administration/groups/group-create/group-create.service.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class GroupCreateService {
1818

1919
create(rawValue: GroupCreateDto): void {
2020
this.createLoading.set(true);
21-
this.groupService.groupControllerCreateGroup(rawValue)
21+
this.groupService.groupControllerCreateGroup({groupCreateDto: rawValue})
2222
.subscribe({
2323
next: (group) => {
2424
this.createLoading.set(false);

‎frontend/src/app/pages/administration/groups/group-detail/group-detail.service.ts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ export class GroupDetailService {
4040
this.usersTransferLoading.set(true);
4141
this.rolesTransferLoading.set(true);
4242

43-
this.groupService.groupControllerGetGroup(id)
43+
this.groupService.groupControllerGetGroup({id})
4444
.pipe(
4545
tap((group) => this.group.set(group)),
46-
mergeMap(() => this.groupService.groupControllerGetMembers(id)),
46+
mergeMap(() => this.groupService.groupControllerGetMembers({id})),
4747
tap((data) => this.users.set(data.users.map((user) => ({
4848
user,
4949
member: data.members.some(x => x.id === user.id)
@@ -82,7 +82,7 @@ export class GroupDetailService {
8282
const group = this.group();
8383
if (group) {
8484
this.updateLoading.set(true);
85-
this.groupService.groupControllerUpdateGroup(group.id, rawValue)
85+
this.groupService.groupControllerUpdateGroup({id: group.id, groupUpdateDto: rawValue})
8686
.subscribe({
8787
next: (group) => {
8888
this.updateLoading.set(false);
@@ -101,7 +101,7 @@ export class GroupDetailService {
101101
const group = this.group();
102102
if (group) {
103103
this.deleteLoading.set(true);
104-
this.groupService.groupControllerDeleteGroup(group.id)
104+
this.groupService.groupControllerDeleteGroup({id: group.id})
105105
.subscribe({
106106
next: () => {
107107
this.deleteLoading.set(false);
@@ -120,13 +120,13 @@ export class GroupDetailService {
120120
this.usersTransferLoading.set(true);
121121
from([users]).pipe(
122122
mergeMap((users) =>
123-
forkJoin(users.map((user) => add ?
124-
this.groupService.groupControllerAddMemberToGroup(this.group()!.id, user) :
125-
this.groupService.groupControllerRemoveMemberFromGroup(this.group()!.id, user)))
123+
forkJoin(users.map((userId) => add ?
124+
this.groupService.groupControllerAddMemberToGroup({id: this.group()!.id, userId}) :
125+
this.groupService.groupControllerRemoveMemberFromGroup({id: this.group()!.id, userId})))
126126
),
127-
mergeMap(() => this.groupService.groupControllerGetGroup(this.group()!.id)),
127+
mergeMap(() => this.groupService.groupControllerGetGroup({id: this.group()!.id})),
128128
tap((group) => this.group.set(group)),
129-
mergeMap(() => this.groupService.groupControllerGetMembers(this.group()!.id)),
129+
mergeMap(() => this.groupService.groupControllerGetMembers({id: this.group()!.id})),
130130
tap((data) => this.users.set(data.users.map((user) => ({
131131
user,
132132
member: data.members.some(x => x.id === user.id)
@@ -148,10 +148,10 @@ export class GroupDetailService {
148148
from([roles]).pipe(
149149
mergeMap((roles) =>
150150
forkJoin(roles.map((role) => add ?
151-
this.groupService.groupControllerAddRoleToGroup(this.group()!.id, role) :
152-
this.groupService.groupControllerRemoveRoleFromGroup(this.group()!.id, role)))
151+
this.groupService.groupControllerAddRoleToGroup({id: this.group()!.id, role}) :
152+
this.groupService.groupControllerRemoveRoleFromGroup({id: this.group()!.id, role})))
153153
),
154-
mergeMap(() => this.groupService.groupControllerGetGroup(this.group()!.id)),
154+
mergeMap(() => this.groupService.groupControllerGetGroup({id: this.group()!.id})),
155155
tap((group) => this.group.set(group)),
156156
mergeMap(() => this.groupService.groupControllerGetRoles()),
157157
tap((data) => this.roles.set(data.map((role) => ({

‎frontend/src/app/pages/administration/groups/groups.service.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export class GroupsService {
2020
this.groupsLoading.set(true);
2121
this.groupService.groupControllerGetCount()
2222
.subscribe((count) => this.total.set(count.count));
23-
this.groupService.groupControllerGetGroups(this.itemsPerPage(), this.page() * this.itemsPerPage())
23+
this.groupService.groupControllerGetGroups({
24+
limit: this.itemsPerPage(),
25+
offset: this.page() * this.itemsPerPage(),
26+
})
2427
.subscribe({
2528
next: (groups) => {
2629
this.groups.set(groups);

‎frontend/src/app/pages/administration/users/user-create/user-create.service.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class UserCreateService {
1818

1919
create(rawValue: UserCreateDto) {
2020
this.createLoading.set(true);
21-
this.userService.userControllerCreateUser(rawValue)
21+
this.userService.userControllerCreateUser({userCreateDto: rawValue})
2222
.subscribe({
2323
next: (user) => {
2424
this.createLoading.set(false);

‎frontend/src/app/pages/administration/users/user-detail/user-detail.service.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export class UserDetailService {
3434

3535
load(id: string) {
3636
this.loading.set(true);
37-
this.userService.userControllerGetUser(id)
37+
this.userService.userControllerGetUser({id})
3838
.pipe(
3939
tap((user) => this.user.set(user)),
40-
mergeMap(() => this.userService.userControllerGetGroups(id)),
40+
mergeMap(() => this.userService.userControllerGetGroups({id})),
4141
tap((data) => this.groups.set(data.groups.map((group) => ({
4242
group,
4343
member: data.members.some(x => x.id === group.id)
@@ -63,7 +63,7 @@ export class UserDetailService {
6363
const user = this.user();
6464
if (user) {
6565
this.updateLoading.set(true);
66-
this.userService.userControllerUpdateUser(user.id, rawValue)
66+
this.userService.userControllerUpdateUser({id: user.id, userUpdateDto: rawValue})
6767
.subscribe({
6868
next: (user) => {
6969
this.updateLoading.set(false);
@@ -82,13 +82,13 @@ export class UserDetailService {
8282
this.groupsTransferLoading.set(true);
8383
from([groups]).pipe(
8484
mergeMap((users) =>
85-
forkJoin(users.map((group) => add ?
86-
this.userService.userControllerAddUserToGroup(this.user()!.id, group) :
87-
this.userService.userControllerRemoveUserFromGroup(this.user()!.id, group)))
85+
forkJoin(users.map((groupId) => add ?
86+
this.userService.userControllerAddUserToGroup({id: this.user()!.id, groupId}) :
87+
this.userService.userControllerRemoveUserFromGroup({id: this.user()!.id, groupId})))
8888
),
89-
mergeMap(() => this.userService.userControllerGetUser(this.user()!.id)),
89+
mergeMap(() => this.userService.userControllerGetUser({id: this.user()!.id})),
9090
tap((user) => this.user.set(user)),
91-
mergeMap(() => this.userService.userControllerGetGroups(this.user()!.id)),
91+
mergeMap(() => this.userService.userControllerGetGroups({id: this.user()!.id})),
9292
tap((data) => this.groups.set(data.groups.map((group) => ({
9393
group,
9494
member: data.members.some(x => x.id === group.id)
@@ -109,7 +109,7 @@ export class UserDetailService {
109109
const user = this.user();
110110
if (user) {
111111
this.deleteLoading.set(true);
112-
this.userService.userControllerDeleteUser(user.id)
112+
this.userService.userControllerDeleteUser({id: user.id})
113113
.subscribe({
114114
next: () => {
115115
this.deleteLoading.set(false);

‎frontend/src/app/pages/administration/users/users.service.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export class UsersService {
2020
this.usersLoading.set(true);
2121
this.userService.userControllerGetCount()
2222
.subscribe((count) => this.total.set(count.count));
23-
this.userService.userControllerGetUsers(this.itemsPerPage(), this.page() * this.itemsPerPage())
23+
this.userService.userControllerGetUsers({
24+
limit: this.itemsPerPage(),
25+
offset: this.page() * this.itemsPerPage(),
26+
})
2427
.subscribe({
2528
next: (users) => {
2629
this.users.set(users);

‎frontend/src/app/pages/base/locations/location-create/location-create.service.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class LocationCreateService {
3737

3838
create(rawValue: LocationCreateDto) {
3939
this.createLoading.set(true);
40-
this.locationService.locationControllerCreate(rawValue)
40+
this.locationService.locationControllerCreate({locationCreateDto: rawValue})
4141
.subscribe({
4242
next: (entity) => {
4343
this.createLoading.set(false);
@@ -54,7 +54,10 @@ export class LocationCreateService {
5454
loadParents() {
5555
this.parentsIsLoading.set(true);
5656
this.locationService
57-
.locationControllerGetAll(this.selectCount, 0, undefined, undefined, this.parentsSearch)
57+
.locationControllerGetAll({
58+
searchTerm: this.parentsSearch,
59+
limit: this.selectCount,
60+
})
5861
.subscribe({
5962
next: (parents) => {
6063
this.parentsIsLoading.set(false);

‎frontend/src/app/pages/base/locations/location-detail/location-detail.service.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class LocationDetailService {
4646
load(id: number) {
4747
this.id = id;
4848
this.loading.set(true);
49-
this.locationService.locationControllerGetOne(id)
49+
this.locationService.locationControllerGetOne({id})
5050
.subscribe({
5151
next: (newEntity) => {
5252
this.location.set(newEntity);
@@ -72,7 +72,7 @@ export class LocationDetailService {
7272
const entity = this.location();
7373
if (entity) {
7474
this.updateLoading.set(true);
75-
this.locationService.locationControllerUpdate(entity.id, rawValue)
75+
this.locationService.locationControllerUpdate({id: entity.id, locationUpdateDto: rawValue})
7676
.subscribe({
7777
next: (newEntity) => {
7878
this.updateLoading.set(false);
@@ -91,7 +91,7 @@ export class LocationDetailService {
9191
const entity = this.location();
9292
if (entity) {
9393
this.deleteLoading.set(true);
94-
this.locationService.locationControllerDelete(entity.id)
94+
this.locationService.locationControllerDelete({id: entity.id})
9595
.subscribe({
9696
next: () => {
9797
this.deleteLoading.set(false);
@@ -109,7 +109,10 @@ export class LocationDetailService {
109109
loadParents() {
110110
this.parentsIsLoading.set(true);
111111
this.locationService
112-
.locationControllerGetAll(this.selectCount, 0, undefined, undefined, this.parentsSearch)
112+
.locationControllerGetAll({
113+
searchTerm: this.parentsSearch,
114+
limit: this.selectCount,
115+
})
113116
.subscribe({
114117
next: (parents) => {
115118
this.parentsIsLoading.set(false);

‎frontend/src/app/pages/base/locations/locations.service.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class LocationsService {
1616
locationsLoadError = signal(false);
1717
sortCol?: string;
1818
sortDir?: string;
19-
searchTerm$ = new BehaviorSubject<{propagate: boolean, value: string}>({propagate: true, value: ''});
19+
searchTerm$ = new BehaviorSubject<{ propagate: boolean, value: string }>({propagate: true, value: ''});
2020
private searchTerm?: string;
2121

2222

@@ -38,9 +38,15 @@ export class LocationsService {
3838

3939
load() {
4040
this.locationsLoading.set(true);
41-
this.locationService.locationControllerGetCount(this.searchTerm)
41+
this.locationService.locationControllerGetCount({searchTerm: this.searchTerm})
4242
.subscribe((count) => this.total.set(count.count));
43-
this.locationService.locationControllerGetAll(this.itemsPerPage, (this.page - 1) * this.itemsPerPage, this.sortCol, this.sortDir, this.searchTerm)
43+
this.locationService.locationControllerGetAll({
44+
limit: this.itemsPerPage,
45+
offset: (this.page - 1) * this.itemsPerPage,
46+
sortCol: this.sortCol,
47+
sortDir: this.sortDir,
48+
searchTerm: this.searchTerm
49+
})
4450
.subscribe({
4551
next: (users) => {
4652
this.locations.set(users);

0 commit comments

Comments
 (0)