Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Improve angular control flow #8117

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions src/main/webapp/app/admin/audits/audits.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,24 @@ <h4 jhiTranslate="audits.filter.title">Filter by date</h4>
</div>
</div>
</div>
@if (audits?.length === 0) {
<div class="alert alert-warning">
<span jhiTranslate="audits.notFound">No audit found</span>
</div>
}
@if (audits && audits.length > 0) {
@if (audits?.length) {
<div class="table-responsive">
<table class="table table-sm table-striped" aria-describedby="audits-page-heading">
<thead>
@switch (canLoad()) {
@case (true) {
<tr jhiSort [(predicate)]="predicate" [(ascending)]="ascending" (sortChange)="transition()">
<th scope="col" jhiSortBy="auditEventDate"><span jhiTranslate="audits.table.header.date">Date</span> <fa-icon [icon]="faSort" /></th>
<th scope="col" jhiSortBy="principal"><span jhiTranslate="audits.table.header.principal">User</span> <fa-icon [icon]="faSort" /></th>
<th scope="col" jhiSortBy="auditEventType"><span jhiTranslate="audits.table.header.status">State</span> <fa-icon [icon]="faSort" /></th>
<th scope="col"><span jhiTranslate="audits.table.header.data">Extra data</span></th>
</tr>
}
@case (false) {
<tr>
<th scope="col"><span jhiTranslate="audits.table.header.date">Date</span></th>
<th scope="col"><span jhiTranslate="audits.table.header.principal">User</span></th>
<th scope="col"><span jhiTranslate="audits.table.header.status">State</span></th>
<th scope="col"><span jhiTranslate="audits.table.header.data">Extra data</span></th>
</tr>
}
@if (canLoad) {
<tr jhiSort [(predicate)]="predicate" [(ascending)]="ascending" (sortChange)="transition()">
<th scope="col" jhiSortBy="auditEventDate"><span jhiTranslate="audits.table.header.date">Date</span> <fa-icon [icon]="faSort" /></th>
<th scope="col" jhiSortBy="principal"><span jhiTranslate="audits.table.header.principal">User</span> <fa-icon [icon]="faSort" /></th>
<th scope="col" jhiSortBy="auditEventType"><span jhiTranslate="audits.table.header.status">State</span> <fa-icon [icon]="faSort" /></th>
<th scope="col"><span jhiTranslate="audits.table.header.data">Extra data</span></th>
</tr>
} @else {
<tr>
<th scope="col"><span jhiTranslate="audits.table.header.date">Date</span></th>
<th scope="col"><span jhiTranslate="audits.table.header.principal">User</span></th>
<th scope="col"><span jhiTranslate="audits.table.header.status">State</span></th>
<th scope="col"><span jhiTranslate="audits.table.header.data">Extra data</span></th>
</tr>
}
</thead>
<tbody>
Expand All @@ -64,8 +56,6 @@ <h4 jhiTranslate="audits.filter.title">Filter by date</h4>
</tbody>
</table>
</div>
}
@if (audits && audits.length > 0) {
<div>
<div class="row justify-content-center">
<jhi-item-count [params]="{ page: page, totalItems: totalItems, itemsPerPage: itemsPerPage }" />
Expand All @@ -79,9 +69,13 @@ <h4 jhiTranslate="audits.filter.title">Filter by date</h4>
[rotate]="true"
[boundaryLinks]="true"
(pageChange)="transition()"
[disabled]="!canLoad()"
[disabled]="!canLoad"
/>
</div>
</div>
} @else {
<div class="alert alert-warning">
<span jhiTranslate="audits.notFound">No audit found</span>
</div>
}
</div>
7 changes: 5 additions & 2 deletions src/main/webapp/app/admin/audits/audits.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class AuditsComponent implements OnInit {
predicate!: string;
ascending!: boolean;
toDate = '';
canLoad: boolean;

// page information
page = 1;
Expand All @@ -40,15 +41,16 @@ export class AuditsComponent implements OnInit {
ngOnInit(): void {
this.toDate = this.today();
this.fromDate = this.previousMonth();
this.canLoad = this.calculateCanLoad();
this.handleNavigation();
}

canLoad(): boolean {
calculateCanLoad(): boolean {
return this.fromDate !== '' && this.toDate !== '';
}

transition(): void {
if (this.canLoad()) {
if (this.canLoad) {
this.router.navigate(['/admin/audits'], {
queryParams: {
page: this.page,
Expand Down Expand Up @@ -90,6 +92,7 @@ export class AuditsComponent implements OnInit {
if (params.get('to')) {
this.toDate = this.datePipe.transform(params.get('to'), this.dateFormat)!;
}
this.canLoad = this.calculateCanLoad();
this.loadData();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ <h3 id="garbageCollectorMetrics" jhiTranslate="metrics.jvm.gc.title">Garbage col
<div class="col-md-9">Classes loaded</div>
<div class="col-md-3 text-right">{{ garbageCollectorMetrics.classesLoaded }}</div>
</div>
}
@if (garbageCollectorMetrics) {
<div class="row">
<div class="col-md-9">Classes unloaded</div>
<div class="col-md-3 text-right">{{ garbageCollectorMetrics.classesUnloaded }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,64 +22,60 @@ <h2>
<th></th>
</tr>
</thead>
@if (notifications) {
<tbody>
@for (notification of notifications; track trackIdentity($index, notification)) {
<tr>
<td>{{ notification.id }}</td>
<td>{{ notification.title }}</td>
<td>{{ notification.text }}</td>
<td>{{ notification.type }}</td>
<td>
@switch (getNotificationState(notification)) {
@case (ACTIVE) {
<span class="badge bg-success">
{{ 'artemisApp.systemNotification.active' | artemisTranslate }}
</span>
}
@case (EXPIRED) {
<span class="badge bg-danger">
{{ 'artemisApp.systemNotification.expired' | artemisTranslate }}
</span>
}
@case (SCHEDULED) {
<span class="badge bg-info">
{{ 'artemisApp.systemNotification.scheduled' | artemisTranslate }}
</span>
}
<tbody>
@for (notification of notifications; track trackIdentity($index, notification)) {
<tr>
<td>{{ notification.id }}</td>
<td>{{ notification.title }}</td>
<td>{{ notification.text }}</td>
<td>{{ notification.type }}</td>
<td>
@switch (getNotificationState(notification)) {
@case (ACTIVE) {
<span class="badge bg-success">
{{ 'artemisApp.systemNotification.active' | artemisTranslate }}
</span>
}
</td>
<td>{{ notification.notificationDate | artemisDate }}</td>
<td>{{ notification.expireDate | artemisDate }}</td>
<td class="text-end">
<div class="btn-group flex-btn-group-container">
<a id="viewButton" [routerLink]="['./', notification.id]" class="btn btn-info btn-sm">
<fa-icon [icon]="faEye" />
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</a>
<a id="editButton" [routerLink]="['./', notification.id, 'edit']" queryParamsHandling="merge" class="btn btn-warning btn-sm">
<fa-icon [icon]="faWrench" />
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</a>
<button
jhiDeleteButton
[entityTitle]="!!notification.title ? notification.title : ''"
deleteQuestion="artemisApp.systemNotification.delete.question"
(delete)="deleteNotification(notification.id!)"
[dialogError]="dialogError$"
>
<fa-icon [icon]="faTimes" />
</button>
</div>
</td>
</tr>
}
</tbody>
}
@case (EXPIRED) {
<span class="badge bg-danger">
{{ 'artemisApp.systemNotification.expired' | artemisTranslate }}
</span>
}
@case (SCHEDULED) {
<span class="badge bg-info">
{{ 'artemisApp.systemNotification.scheduled' | artemisTranslate }}
</span>
}
}
</td>
<td>{{ notification.notificationDate | artemisDate }}</td>
<td>{{ notification.expireDate | artemisDate }}</td>
<td class="text-end">
<div class="btn-group flex-btn-group-container">
<a id="viewButton" [routerLink]="['./', notification.id]" class="btn btn-info btn-sm">
<fa-icon [icon]="faEye" />
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</a>
<a id="editButton" [routerLink]="['./', notification.id, 'edit']" queryParamsHandling="merge" class="btn btn-warning btn-sm">
<fa-icon [icon]="faWrench" />
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</a>
<button
jhiDeleteButton
[entityTitle]="!!notification.title ? notification.title : ''"
deleteQuestion="artemisApp.systemNotification.delete.question"
(delete)="deleteNotification(notification.id!)"
[dialogError]="dialogError$"
>
<fa-icon [icon]="faTimes" />
</button>
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
}
@if (notifications) {
<div>
<div class="row justify-content-center">
<jhi-item-count [params]="{ page: page, totalItems: totalItems, itemsPerPage: itemsPerPage }" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ <h2>
<ngb-highlight [result]="user.name" [term]="searchTerm" />
</td>
<td>
@if (!user.activated) {
<button class="btn btn-danger btn-sm" (click)="setActive(user, true)" jhiTranslate="artemisApp.userManagement.deactivated">
Deactivated
</button>
}
@if (user.activated) {
<button
class="btn btn-success btn-sm"
Expand All @@ -162,6 +157,10 @@ <h2>
>
Activated
</button>
} @else {
<button class="btn btn-danger btn-sm" (click)="setActive(user, true)" jhiTranslate="artemisApp.userManagement.deactivated">
Deactivated
</button>
}
</td>
<td>{{ user.langKey }}</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<h3 class="top-container flex-wrap flex-lg-nowrap">
<!--back button only used in assessment dashboard-->
<div class="row-container me-2">
@if (!isTestRun) {
<span jhiTranslate="artemisApp.assessment.assessment">Assessment</span>
}
@if (isTestRun) {
<span jhiTranslate="artemisApp.assessment.testRunAssessment">Test Run Assessment</span>
} @else {
<span jhiTranslate="artemisApp.assessment.assessment">Assessment</span>
}
@if (isIllegalSubmission) {
<span class="badge bg-danger ms-3" style="font-size: 65%" jhiTranslate="artemisApp.assessment.assessmentIllegalSubmission">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,10 @@ <h2>
<a class="th-link">{{ 'artemisApp.complaint.listOfComplaints.studentLogin' | artemisTranslate }}</a>
<fa-icon [icon]="faSort" />
</th>
}
@if (course?.isAtLeastInstructor) {
<th jhiSortBy="student.name">
<a class="th-link">{{ 'artemisApp.complaint.listOfComplaints.studentName' | artemisTranslate }}</a>
<fa-icon [icon]="faSort" />
</th>
}
@if (course?.isAtLeastInstructor) {
<th jhiSortBy="complaintResponse.reviewer.name">
<a class="th-link">{{ 'artemisApp.complaint.listOfComplaints.reviewerName' | artemisTranslate }}</a>
<fa-icon [icon]="faSort" />
Expand Down Expand Up @@ -147,13 +143,9 @@ <h2>
<td>
<span>{{ complaint.student?.login }}</span>
</td>
}
@if (course?.isAtLeastInstructor) {
<td>
<span>{{ complaint.student?.name }}</span>
</td>
}
@if (course?.isAtLeastInstructor) {
<td>
<span>{{ complaint.complaintResponse?.reviewer?.name }}</span>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<span class="sr-only">{{ 'loading' | artemisTranslate }}</span>
</div>
</div>
}
@if (!isLoading) {
} @else {
<div class="container">
<div class="d-flex align-items-center">
<h3>{{ 'artemisApp.competency.createCompetency.title' | artemisTranslate }}</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<span class="sr-only">{{ 'loading' | artemisTranslate }}</span>
</div>
</div>
}
@if (!isLoading) {
} @else {
<div class="container">
<h3>{{ 'artemisApp.competency.editCompetency.title' | artemisTranslate }}</h3>
<jhi-competency-form
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<div class="row mt-3 g-3">
<div class="col-12 col-md-6 col-lg-7 mt-0">
@if (!isExamMode) {
<span style="font-size: 16px" jhiTranslate="artemisApp.assessmentDashboard.exerciseTable.courseInformation"></span>
}
@if (isExamMode) {
<span style="font-size: 16px" jhiTranslate="artemisApp.assessmentDashboard.exerciseTable.examInformation"></span>
} @else {
<span style="font-size: 16px" jhiTranslate="artemisApp.assessmentDashboard.exerciseTable.courseInformation"></span>
}
<!-- chart -->
@if (numberOfSubmissions.total !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<span class="sr-only">{{ 'loading' | artemisTranslate }}</span>
</div>
</div>
}
@if (!isLoading) {
} @else {
<div>
@for (node of path; track node; let last = $last) {
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ <h5><span jhiTranslate="artemisApp.studentExams.summary">Student Summary</span><
<a class="btn btn-primary summery ms-4" [routerLink]="'./summary'">
<span jhiTranslate="artemisApp.exam.summary">Summary</span>
</a>
}
@if (course?.isAtLeastInstructor) {
<div ngbTooltip="{{ 'artemisApp.examTimeline.disabledTooltip' | artemisTranslate }}" [disableTooltip]="studentExam?.submitted!">
<button class="btn btn-primary mb-auto ms-5" [routerLink]="'./exam-timeline'" [disabled]="!studentExam.submitted">
<span jhiTranslate="artemisApp.examTimeline.breadcrumb">Timeline</span>
Expand Down
Loading
Loading