Skip to content

Commit 3490c9c

Browse files
committed
Persist selected container platform in local storage
1 parent 2535dc7 commit 3490c9c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/app/features/containers/pages/container/container.component.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, inject, Injector, runInInjectionContext, signal, Signal } from "@angular/core";
1+
import { Component, effect, inject, Injector, runInInjectionContext, signal, Signal } from "@angular/core";
22
import { DockerHubImage } from '../../../../models/docker-hub-image';
33
import { DockerHubTag } from '../../../../models/docker-hub-tag';
44
import { ActivatedRoute, RouterLink } from "@angular/router";
@@ -52,10 +52,21 @@ export class ContainerComponent {
5252
{ name: 'Docker', value: 'docker', icon: 'assets/icons/logos/docker-mark-blue.svg' },
5353
{ name: 'Podman', value: 'podman', icon: 'assets/icons/logos/podman.svg' },
5454
];
55-
selectedContainerPlatform = signal<number>(0);
55+
selectedContainerPlatform = signal<number>(
56+
(i => i === -1 ? 0 : i)(this.containerPlatforms.findIndex(
57+
p => p.value === localStorage.getItem('containerPlatform')
58+
))
59+
);
5660

5761
constructor() {
5862
this.isDarkTheme = this.themeService.isDarkTheme();
63+
64+
// Persist selected container platform in local storage
65+
effect(() => {
66+
const index = this.selectedContainerPlatform();
67+
const value = this.containerPlatforms[index]?.value;
68+
localStorage.setItem('containerPlatform', value);
69+
});
5970
}
6071

6172
ngOnInit() {

0 commit comments

Comments
 (0)