fix: namespace localStorage keys with username
parent
744e721598
commit
c5010fca0a
|
|
@ -7,6 +7,7 @@ import { HttpClient } from "@angular/common/http";
|
||||||
import { ToastrService } from "ngx-toastr";
|
import { ToastrService } from "ngx-toastr";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { ConfigService } from '@services/config.service';
|
import { ConfigService } from '@services/config.service';
|
||||||
|
import { AuthService } from '@services/auth.service';
|
||||||
import {DeployMethodConfigDialogComponent} from "./deploy-method-config-dialog/deploy-method-config-dialog.component";
|
import {DeployMethodConfigDialogComponent} from "./deploy-method-config-dialog/deploy-method-config-dialog.component";
|
||||||
import { CreateTaskComponent } from "../../../../commands/commands-task/create-task/create-task.component";
|
import { CreateTaskComponent } from "../../../../commands/commands-task/create-task/create-task.component";
|
||||||
import { MatDialog } from "@angular/material/dialog";
|
import { MatDialog } from "@angular/material/dialog";
|
||||||
|
|
@ -19,6 +20,7 @@ import { QueueConfirmationModalComponent } from "../../../../../shared/queue-con
|
||||||
})
|
})
|
||||||
export class DeployImageComponent implements OnInit {
|
export class DeployImageComponent implements OnInit {
|
||||||
public translate = inject(TranslateService);
|
public translate = inject(TranslateService);
|
||||||
|
public authService = inject(AuthService);
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
@Output() dataChange = new EventEmitter<any>();
|
@Output() dataChange = new EventEmitter<any>();
|
||||||
|
|
||||||
|
|
@ -153,11 +155,12 @@ export class DeployImageComponent implements OnInit {
|
||||||
this.runScriptContext = params['runScriptContext'] ? JSON.parse(params['runScriptContext']) : null;
|
this.runScriptContext = params['runScriptContext'] ? JSON.parse(params['runScriptContext']) : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const savedAction = localStorage.getItem('deploy_postDeployAction');
|
const username = this.authService.username || 'default';
|
||||||
|
const savedAction = localStorage.getItem(`deploy_postDeployAction_${username}`);
|
||||||
if (savedAction) {
|
if (savedAction) {
|
||||||
this.postDeployAction = savedAction;
|
this.postDeployAction = savedAction;
|
||||||
}
|
}
|
||||||
const savedPxePermanent = localStorage.getItem('deploy_pxePermanent');
|
const savedPxePermanent = localStorage.getItem(`deploy_pxePermanent_${username}`);
|
||||||
if (savedPxePermanent !== null) {
|
if (savedPxePermanent !== null) {
|
||||||
this.pxePermanent = savedPxePermanent === 'true';
|
this.pxePermanent = savedPxePermanent === 'true';
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +174,8 @@ export class DeployImageComponent implements OnInit {
|
||||||
(response: any) => {
|
(response: any) => {
|
||||||
this.pxeTemplates = response?.['hydra:member'] || [];
|
this.pxeTemplates = response?.['hydra:member'] || [];
|
||||||
|
|
||||||
const savedTemplateUuid = localStorage.getItem('deploy_selectedPxeTemplateUuid');
|
const username = this.authService.username || 'default';
|
||||||
|
const savedTemplateUuid = localStorage.getItem(`deploy_selectedPxeTemplateUuid_${username}`);
|
||||||
if (savedTemplateUuid && this.postDeployAction === 'pxeTemplate') {
|
if (savedTemplateUuid && this.postDeployAction === 'pxeTemplate') {
|
||||||
const match = this.pxeTemplates.find(t => t.uuid === savedTemplateUuid);
|
const match = this.pxeTemplates.find(t => t.uuid === savedTemplateUuid);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
@ -541,10 +545,11 @@ export class DeployImageComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private enqueuePostDeployActions() {
|
private enqueuePostDeployActions() {
|
||||||
localStorage.setItem('deploy_postDeployAction', this.postDeployAction);
|
const username = this.authService.username || 'default';
|
||||||
localStorage.setItem('deploy_pxePermanent', String(this.pxePermanent));
|
localStorage.setItem(`deploy_postDeployAction_${username}`, this.postDeployAction);
|
||||||
|
localStorage.setItem(`deploy_pxePermanent_${username}`, String(this.pxePermanent));
|
||||||
if (this.selectedPxeTemplate?.uuid) {
|
if (this.selectedPxeTemplate?.uuid) {
|
||||||
localStorage.setItem('deploy_selectedPxeTemplateUuid', this.selectedPxeTemplate.uuid);
|
localStorage.setItem(`deploy_selectedPxeTemplateUuid_${username}`, this.selectedPxeTemplate.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.postDeployAction === 'none') {
|
if (this.postDeployAction === 'none') {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue