Skip to content

Commit

Permalink
conditional if, else, switch migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Pop John committed Jul 15, 2024
1 parent 5036ee0 commit 1fc53c4
Show file tree
Hide file tree
Showing 34 changed files with 616 additions and 643 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
<!-- Copyright 2024 Cisco Systems, Inc. and its affiliates
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
-->
SPDX-License-Identifier: Apache-2.0
-->

<div class="items-wrapper">
<ng-container *ngIf="recordsDataService.records$ | async as records">
<mat-card class="ms-card comparison-item" *ngFor="let item of records; index as i">
<div class="item-wrapper">
<div msUseEllipsis>{{ item.recordName }}</div>
<div class="record-summary-buttons-wrapper">
<button mat-icon-button color="primary" (click)="viewRecord(item)">
<mat-icon fontSet="ms" fontIcon="icon-Eye" class="mat-primary"></mat-icon>
</button>
<button mat-icon-button color="primary" (click)="editRecord(i, item)">
<mat-icon fontSet="ms" fontIcon="icon-PencilSimple" class="mat-primary"></mat-icon>
</button>
<button mat-icon-button color="error" (click)="removeRecord(i)">
<mat-icon class="mat-error">delete</mat-icon>
</button>
</div>
@if (recordsDataService.records$ | async; as records) { @for (item of records; track item; let i = $index) {
<mat-card class="ms-card comparison-item">
<div class="item-wrapper">
<div msUseEllipsis>{{ item.recordName }}</div>
<div class="record-summary-buttons-wrapper">
<button mat-icon-button color="primary" (click)="viewRecord(item)">
<mat-icon fontSet="ms" fontIcon="icon-Eye" class="mat-primary"></mat-icon>
</button>
<button mat-icon-button color="primary" (click)="editRecord(i, item)">
<mat-icon fontSet="ms" fontIcon="icon-PencilSimple" class="mat-primary"></mat-icon>
</button>
<button mat-icon-button color="error" (click)="removeRecord(i)">
<mat-icon class="mat-error">delete</mat-icon>
</button>
</div>
</mat-card>
</ng-container>
</div>
</mat-card>
} }
</div>
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!-- Copyright 2024 Cisco Systems, Inc. and its affiliates
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
-->
SPDX-License-Identifier: Apache-2.0
-->

<mat-expansion-panel expanded="true">
<mat-expansion-panel-header>
Expand All @@ -27,14 +27,16 @@
<td mat-cell *matCellDef="let record">{{ record.recordName }}</td>
</ng-container>

<ng-container *ngFor="let column of displayedColumns.slice(1)" [matColumnDef]="column">
@for (column of displayedColumns.slice(1); track column) {
<ng-container [matColumnDef]="column">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
{{ column | parametersLabel }}
</th>
<td mat-cell *matCellDef="let record">
{{ record[column] | emptyTableField }}
</td>
</ng-container>
}

<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns" class="hover-highlight"></tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!-- Copyright 2024 Cisco Systems, Inc. and its affiliates
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
-->
SPDX-License-Identifier: Apache-2.0
-->

<div class="title-wrapper">
<p class="heading-primary-title title">Algorithm Comparison for</p>
Expand All @@ -22,11 +22,11 @@
<div class="form-field-container w-56 mt-2">
<mat-form-field appearance="outline">
<mat-select [formControlName]="ALGORITHM_TYPE_CONTROL_NAME" placeholder="Select a run record">
<mat-option
*ngFor="let algorithmType of algorithmTypesOptions; trackBy: trackByAlgorithmType"
[value]="algorithmType.key">
@for (algorithmType of algorithmTypesOptions; track algorithmType.key) {
<mat-option [value]="algorithmType.key">
{{ algorithmType.value }}
</mat-option>
}
</mat-select>
</mat-form-field>
</div>
Expand All @@ -46,23 +46,18 @@
<mat-divider></mat-divider>
</div>

<ng-container *ngIf="(recordsDataService.records$ | async)!.length > 0; else noData">
<ms-algorithm-comparison-list></ms-algorithm-comparison-list>
<div class="mt-4 mb-4">
<mat-divider></mat-divider>
</div>

<ms-algorithm-comparison-table></ms-algorithm-comparison-table>

<div class="mt-4 mb-4">
<mat-divider></mat-divider>
</div>

<ms-algorithm-comparison-chart></ms-algorithm-comparison-chart>
</ng-container>

<ng-template #noData>
<div class="no-data-wrapper">
<ms-empty-state title="No data selected"></ms-empty-state>
</div>
</ng-template>
@if ((recordsDataService.records$ | async)!.length > 0) {
<ms-algorithm-comparison-list></ms-algorithm-comparison-list>
<div class="mt-4 mb-4">
<mat-divider></mat-divider>
</div>
<ms-algorithm-comparison-table></ms-algorithm-comparison-table>
<div class="mt-4 mb-4">
<mat-divider></mat-divider>
</div>
<ms-algorithm-comparison-chart></ms-algorithm-comparison-chart>
} @else {
<div class="no-data-wrapper">
<ms-empty-state title="No data selected"></ms-empty-state>
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { take } from 'rxjs';
import { KeyValueObject } from '../../../../services/client/models/key-value/key-value.interface-dto';
import { AlgorithmType } from '../../../model-compression/models/enums/algorithms.enum';
import { DrawerClose, DrawerService, DrawerStatus } from '../../../shared/components/ms-drawer';
import { DrawerActionTypeEnum } from '../../../shared/components/ms-drawer/models/drawer-action-type.enum';
Expand Down Expand Up @@ -101,8 +100,4 @@ export class AlgorithmComparisonComponent implements OnInit {
this.recordsDataService.algorithmType = algorithmType;
});
}

trackByAlgorithmType(_: number, algorithmType: KeyValueObject<string>): any {
return algorithmType.key;
}
}
Loading

0 comments on commit 1fc53c4

Please sign in to comment.