Skip to content
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
1 change: 1 addition & 0 deletions modules/ui/src/app/pages/devices/devices.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[content]="content"
[itemTemplate]="itemTemplate"
[actions]="vm.actions"
[actionsFn]="actions(vm.actions)"
[entities]="vm.devices"
[isOpenEntityForm]="isOpenDeviceForm"
[initialEntity]="vm.selectedDevice"
Expand Down
17 changes: 14 additions & 3 deletions modules/ui/src/app/pages/devices/devices.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
* limitations under the License.
*/
import {
ChangeDetectorRef,
Component,
ElementRef,
inject,
OnDestroy,
OnInit,
ChangeDetectorRef,
inject,
viewChild,
} from '@angular/core';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import {
Device,
DeviceAction,
DeviceStatus,
DeviceView,
TestModule,
} from '../../model/device';
Expand All @@ -49,7 +50,7 @@ import { MatInputModule } from '@angular/material/input';
import { DeviceItemComponent } from '../../components/device-item/device-item.component';
import { EmptyPageComponent } from '../../components/empty-page/empty-page.component';
import { ListLayoutComponent } from '../../components/list-layout/list-layout.component';
import { EntityActionResult } from '../../model/entity-action';
import { EntityAction, EntityActionResult } from '../../model/entity-action';
import { NoEntitySelectedComponent } from '../../components/no-entity-selected/no-entity-selected.component';
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { CanComponentDeactivate } from '../../guards/can-deactivate.guard';
Expand Down Expand Up @@ -253,6 +254,16 @@ export class DevicesComponent
};
}

actions(actions: EntityAction[]) {
return (device: Device) => {
// expired device can only be removed
if (device.status === DeviceStatus.INVALID) {
return [{ action: DeviceAction.Delete, icon: 'delete' }];
}
return actions;
};
}

private openCloseDialog() {
const dialogRef = this.dialog.open(SimpleDialogComponent, {
ariaLabel: 'Discard the Device changes',
Expand Down