Skip to content

Commit

Permalink
fix: small issues on apps-page (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephGit authored Dec 19, 2024
1 parent e150b3b commit 6c60664
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<a href="/AMW_web/pages/editResourceView.xhtml?ctx=1&id={{ app.id }}">{{ app.name }}</a>
</td>
<td class="align-middle ps-4 w-10 border-0 py-2">
<a href="/AMW_web/pages/editResourceView.xhtml?ctx=1&id={{ app.release.id }}">{{ app.release.name }}</a>
<a href="/AMW_web/pages/editResourceView.xhtml?ctx=1&id={{ app.id }}">{{ app.release.name }}</a>
</td>
</tr>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
} }
</tbody>
</table>
} @else {
<div class="empty-container">No results found in database</div>
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ table .w-10 {
table .w-90 {
width: 90%;
}

.empty-container {
padding: 1em;
text-align: center;
}
2 changes: 1 addition & 1 deletion AMW_angular/io/src/app/apps/apps.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-loading-indicator [isLoading]="isLoading"></app-loading-indicator>
<app-loading-indicator [isLoading]="isLoading()"></app-loading-indicator>
<app-page>
<div class="page-title">Apps</div>
<div class="page-content">
Expand Down
14 changes: 7 additions & 7 deletions AMW_angular/io/src/app/apps/apps.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, computed, inject, OnDestroy, OnInit, Signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, inject, OnDestroy, OnInit, signal, Signal } from '@angular/core';
import { BehaviorSubject, skip, Subject, take } from 'rxjs';
import { LoadingIndicatorComponent } from '../shared/elements/loading-indicator.component';
import { AsyncPipe } from '@angular/common';
Expand All @@ -22,7 +22,6 @@ import { ResourceService } from '../resource/resource.service';
import { Resource } from '../resource/resource';
import { AppCreate } from './app-create';
import { ButtonComponent } from '../shared/button/button.component';
import { offset } from '@popperjs/core';

@Component({
selector: 'app-apps',
Expand Down Expand Up @@ -63,7 +62,10 @@ export class AppsComponent implements OnInit, OnDestroy {
private error$ = new BehaviorSubject<string>('');
private destroy$ = new Subject<void>();

isLoading = false;
showLoader = signal(false);
isLoading = computed(() => {
return this.appServers() === undefined || this.showLoader();
});

permissions = computed(() => {
if (this.authService.restrictions().length > 0) {
Expand Down Expand Up @@ -111,7 +113,7 @@ export class AppsComponent implements OnInit, OnDestroy {
}

saveAppServer(appServer: AppServer) {
this.isLoading = true;
this.showLoader.set(true);
this.appsService
.createAppServer(appServer)
.pipe(takeUntil(this.destroy$))
Expand All @@ -124,13 +126,12 @@ export class AppsComponent implements OnInit, OnDestroy {
},
complete: () => {
this.appsService.refreshData();
this.isLoading = false;
},
});
}

saveApp(app: AppCreate) {
this.isLoading = true;
this.showLoader.set(true);
this.appsService
.createApp(app)
.pipe(takeUntil(this.destroy$))
Expand All @@ -139,7 +140,6 @@ export class AppsComponent implements OnInit, OnDestroy {
error: (e) => this.error$.next(e.toString()),
complete: () => {
this.appsService.refreshData();
this.isLoading = false;
},
});
}
Expand Down
6 changes: 5 additions & 1 deletion AMW_angular/io/src/app/apps/apps.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export class AppsService extends BaseService {
.pipe(catchError(this.handleError))
.pipe(
map((response: HttpResponse<AppServer[]>) => {
this.count.set(Number(response.headers.get('x-total-count')));
if (response.body.length <= 0) {
this.count.set(0);
} else {
this.count.set(Number(response.headers.get('x-total-count')));
}
return response.body;
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Tuple<List<ResourceEntity>, Long> getAppServersWithApps(Integer startIndex, Inte

if (maxResult != null) {
query.setMaxResults(maxResult);
}
}

return new Tuple<>(query.getResultList(), totalCount);
}
Expand Down

0 comments on commit 6c60664

Please sign in to comment.