fix(console): create org without password, storage prefix for pinned projects (#543)

* fix storage prefix, org create

* lint

* storage fix granted project
This commit is contained in:
Max Peintner
2020-07-31 09:49:36 +02:00
committed by GitHub
parent 22ba33c2ef
commit 22d4fc8872
8 changed files with 29 additions and 28 deletions
@@ -2,8 +2,10 @@ import { animate, animateChild, keyframes, query, stagger, style, transition, tr
import { SelectionModel } from '@angular/cdk/collections';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { Router } from '@angular/router';
import { Org } from 'src/app/proto/generated/auth_pb';
import { ProjectState, ProjectType, ProjectView } from 'src/app/proto/generated/management_pb';
import { AuthService } from 'src/app/services/auth.service';
import { StorageKey, StorageService } from 'src/app/services/storage.service';
@Component({
selector: 'app-owned-project-grid',
@@ -47,7 +49,7 @@ export class OwnedProjectGridComponent implements OnChanges {
public ProjectState: any = ProjectState;
public ProjectType: any = ProjectType;
constructor(private router: Router, private authService: AuthService) {
constructor(private router: Router, private authService: AuthService, private storage: StorageService) {
this.selection.changed.subscribe(selection => {
this.setPrefixedItem('pinned-projects', JSON.stringify(
this.selection.selected.map(item => item.projectId),
@@ -87,7 +89,6 @@ export class OwnedProjectGridComponent implements OnChanges {
const array: string[] = JSON.parse(storageEntry);
const toSelect: ProjectView.AsObject[] = this.items.filter((item, index) => {
if (array.includes(item.projectId)) {
// this.notPinned.splice(index, 1);
return true;
}
});
@@ -104,13 +105,13 @@ export class OwnedProjectGridComponent implements OnChanges {
}
private async getPrefixedItem(key: string): Promise<string | null> {
const prefix = (await this.authService.GetActiveOrg()).id;
return localStorage.getItem(`${prefix}:${key}`);
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization) as Org.AsObject;
return localStorage.getItem(`${org.id}:${key}`);
}
private async setPrefixedItem(key: string, value: any): Promise<void> {
const prefix = (await this.authService.GetActiveOrg()).id;
return localStorage.setItem(`${prefix}:${key}`, value);
const org = this.storage.getItem<Org.AsObject>(StorageKey.organization) as Org.AsObject;
return localStorage.setItem(`${org.id}:${key}`, value);
}
public navigateToProject(id: string, event: any): void {