feat(console): organization overview table, table, org context filtering, fix grpc error log, cleanup pipes (#796)

* chore(deps-dev): bump @angular/cli from 10.0.8 to 10.1.3 in /console (#785)

Bumps [@angular/cli](https://github.com/angular/angular-cli) from 10.0.8 to 10.1.3.
- [Release notes](https://github.com/angular/angular-cli/releases)
- [Commits](https://github.com/angular/angular-cli/compare/v10.0.8...v10.1.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @angular-devkit/build-angular in /console (#784)

Bumps [@angular-devkit/build-angular](https://github.com/angular/angular-cli) from 0.1000.8 to 0.1001.3.
- [Release notes](https://github.com/angular/angular-cli/releases)
- [Commits](https://github.com/angular/angular-cli/commits)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Peintner <[email protected]>

* chore(deps-dev): bump @angular/language-service in /console (#783)

Bumps [@angular/language-service](https://github.com/angular/angular/tree/HEAD/packages/language-service) from 10.1.0 to 10.1.3.
- [Release notes](https://github.com/angular/angular/releases)
- [Changelog](https://github.com/angular/angular/blob/master/CHANGELOG.md)
- [Commits](https://github.com/angular/angular/commits/10.1.3/packages/language-service)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump stylelint from 13.7.1 to 13.7.2 in /console (#782)

Bumps [stylelint](https://github.com/stylelint/stylelint) from 13.7.1 to 13.7.2.
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint/compare/13.7.1...13.7.2)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump karma from 5.2.1 to 5.2.3 in /console (#781)

Bumps [karma](https://github.com/karma-runner/karma) from 5.2.1 to 5.2.3.
- [Release notes](https://github.com/karma-runner/karma/releases)
- [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma/compare/v5.2.1...v5.2.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump moment from 2.27.0 to 2.29.0 in /console (#780)

Bumps [moment](https://github.com/moment/moment) from 2.27.0 to 2.29.0.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.27.0...2.29.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @types/node from 14.6.4 to 14.11.2 in /console (#778)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.6.4 to 14.11.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump prettier from 2.1.1 to 2.1.2 in /console (#757)

Bumps [prettier](https://github.com/prettier/prettier) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.1.1...2.1.2)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump ts-protoc-gen from 0.12.0 to 0.13.0 in /console (#737)

Bumps [ts-protoc-gen](https://github.com/improbable-eng/ts-protoc-gen) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/improbable-eng/ts-protoc-gen/releases)
- [Changelog](https://github.com/improbable-eng/ts-protoc-gen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/improbable-eng/ts-protoc-gen/compare/0.12.0...0.13.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump jasmine-spec-reporter in /console (#762)

Bumps [jasmine-spec-reporter](https://github.com/bcaudan/jasmine-spec-reporter) from 5.0.2 to 6.0.0.
- [Release notes](https://github.com/bcaudan/jasmine-spec-reporter/releases)
- [Changelog](https://github.com/bcaudan/jasmine-spec-reporter/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bcaudan/jasmine-spec-reporter/compare/v5.0.2...v6.0.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Peintner <[email protected]>

* fix: package

* change html lang to translation lang

* disable detail view org idp

* catch errorcode 16 in auth response interceptor

* new icons

* refactor pipes, idp table config

* fix router guard

* lint

* allowed commonjs deps

* Update console/src/assets/i18n/en.json

Co-authored-by: Florian Forster <[email protected]>

* Update console/src/assets/i18n/de.json

Co-authored-by: Florian Forster <[email protected]>

* clear table warning

* org overview table, header filter

* toolbar filter

* user table filter

* fix org filter themed color, reject error

* org context filter

* button cleanup

* commonjs deps, remove a11y module

* replace progressbar with spinner

* dynamic user, org filter

* ts lint, scss lint

* cleanup table, row highlighting

* lint

* fix i18n description, refresh idp list in login p

* remove async from grpc services, fix external idp

* remove external idp

* fix theme toggle

* change iam policy header i18n

* sticky action columns

* lint

* add i18n filter to user, remove unused org code

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Florian Forster <[email protected]>
This commit is contained in:
Max Peintner
2020-10-01 15:53:43 +02:00
committed by GitHub
co-authored by dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Florian Forster dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
parent bdcf9fcc5c
commit 124988e2d2
119 changed files with 1361 additions and 1451 deletions
@@ -85,7 +85,6 @@ h1 {
margin-top: 3rem;
display: block;
padding: .5rem 4rem;
border-radius: .5rem;
}
}
@@ -138,7 +137,6 @@ h1 {
.small-button {
display: block;
border-radius: .5rem;
}
.fill-space {
@@ -148,7 +146,6 @@ h1 {
.big-button {
display: block;
padding: .5rem 4rem;
border-radius: .5rem;
}
}
@@ -19,8 +19,4 @@
.ok-button {
margin-left: .5rem;
}
button {
border-radius: .5rem;
}
}
@@ -4,7 +4,6 @@
button {
margin: 1rem .5rem;
border-radius: .5rem;
display: block;
}
}
@@ -34,8 +33,4 @@
.ok-button {
margin-left: .5rem;
}
button {
border-radius: .5rem;
}
}
@@ -21,8 +21,8 @@
mat-icon-button (click)="removeDomain(domain.domain)"><i class="las la-trash"></i></button>
</div>
<p class="new-desc">{{'ORG.PAGES.ORGDOMAIN_VERIFICATION' | translate}}</p>
<button [disabled]="(canwrite$ | async) == false" class="add-button" matTooltip="Add domain"
mat-raised-button color="primary" (click)="addNewDomain()">{{'ORG.DOMAINS.NEW' | translate}}
<button [disabled]="(canwrite$ | async) == false" matTooltip="Add domain" mat-raised-button
color="primary" (click)="addNewDomain()">{{'ORG.DOMAINS.NEW' | translate}}
</button>
</app-card>
</ng-container>
@@ -58,4 +58,4 @@
</mat-tab>
</mat-tab-group>
</div>
</app-meta-layout>
</app-meta-layout>
@@ -41,7 +41,6 @@
}
.verify-btn {
border-radius: .5rem;
font-size: 13px;
}
@@ -50,10 +49,6 @@
}
}
.add-button {
border-radius: .5rem;
}
.new-desc {
font-size: 14px;
color: #818a8a;
@@ -1,62 +0,0 @@
<div class="max-width-container">
<h1>{{ 'ORG.PAGES.LIST' | translate }}</h1>
<p class="top-desc">{{'ORG.PAGES.LISTDESCRIPTION' | translate}}</p>
<div class="view-toggle">
<div class="anim-list" *ngIf="selection.selected.length > 0">
</div>
<button disabled mat-icon-button>
<mat-icon></mat-icon>
</button>
</div>
<div class="container">
<p class="n-items" *ngIf="!loading && selection.selected.length > 0">{{'PROJECT.PAGES.PINNED' | translate}}</p>
<div matTooltip="{{'ORG.PAGES.SELECTORGTOOLTIP' | translate}}" class="item card"
*ngFor="let org of selection.selected; index as i" (click)="selectOrg(org, $event)"
[ngClass]="{ active: activeOrg?.id === org?.id }">
<div class="text-part">
<span class="description">{{org.id}}</span>
<span class="name" *ngIf="org.name">{{ org.name }}</span>
<span class="name" *ngIf="!org.name">No Name</span>
<span class="fill-space"></span>
<div class="icons">
</div>
</div>
<button [ngClass]="{ selected: selection.isSelected(org)}" (click)="selection.toggle(org)"
class="edit-button" mat-icon-button>
<mat-icon>push_pin_outline</mat-icon>
</button>
</div>
</div>
<div class="container">
<p class="n-items" *ngIf="!loading && notPinned.length > 0">{{'PROJECT.PAGES.ALL' | translate}}</p>
<div matTooltip="{{'ORG.PAGES.SELECTORGTOOLTIP' | translate}}" class="item card"
*ngFor="let org of notPinned; index as i" (click)="selectOrg(org, $event)"
[ngClass]="{ active: activeOrg?.id === org?.id }">
<div class="text-part">
<span class="description">{{org.id}}</span>
<span class="name" *ngIf="org.name">{{ org.name }}</span>
<span class="name" *ngIf="!org.name">No Name</span>
<span class="fill-space"></span>
<div class="icons">
</div>
</div>
<button [ngClass]="{ selected: selection.isSelected(org)}" (click)="selection.toggle(org)"
class="edit-button" mat-icon-button>
<mat-icon>push_pin_outline</mat-icon>
</button>
</div>
<ng-template appHasRole [appHasRole]="['iam.write']">
<div class="card add-org-button" [routerLink]="[ '/org/create' ]">
<mat-icon class="icon">add</mat-icon>
<span>Add new organization</span>
</div>
</ng-template>
</div>
</div>
@@ -1,251 +0,0 @@
h1 {
margin-top: 0;
}
.top-desc {
color: #8795a1;
}
.view-toggle {
width: 100%;
display: flex;
justify-content: flex-end;
padding-bottom: .5rem;
border-bottom: 1px solid #2d2e30;
.anim-list {
display: flex;
justify-content: flex-end;
align-items: center;
}
button {
&.left-button {
margin-right: 1rem;
}
}
}
.container {
display: flex;
flex-wrap: wrap;
margin: 0 -1rem;
box-sizing: border-box;
.item {
position: relative;
z-index: 100;
margin: 1rem;
flex-basis: 230px;
display: flex;
text-decoration: none;
overflow: hidden;
cursor: pointer;
padding-top: 0;
padding-right: 0;
padding-bottom: 0;
padding-left: 1rem;
border-radius: .5rem;
box-sizing: border-box;
min-height: 130px;
* {
box-sizing: border-box;
}
&.active {
border: 2px solid #38649d;
}
.selection-icon {
opacity: 0;
position: absolute;
top: -12px;
left: -12px;
}
img {
height: 50px;
width: 50px;
margin: 1rem;
}
.text-part {
position: relative;
flex: 1;
display: flex;
flex-direction: column;
// justify-content: center;
min-height: 70px;
padding: .5rem 0;
.top {
font-size: .8rem;
margin-bottom: 0;
margin-top: .5rem;
}
.name {
margin-top: 1rem;
font-size: 1.2rem;
margin-bottom: .5rem;
}
.description {
font-size: .8rem;
margin-top: .5rem;
}
.created {
font-size: .8rem;
}
.organization {
display: flex;
align-items: center;
margin-top: 1rem;
.org_avatar {
height: 25px;
width: 25px;
border-radius: 50%;
margin: 0;
margin-right: 1rem;
}
}
.fill-space {
flex: 1;
}
.icons {
margin-top: 1rem;
transition: all .3s;
display: flex;
align-items: center;
.current {
height: 10px;
font-size: 14px;
width: 10px;
border-radius: 50%;
background-color: rgb(144, 212, 210);
display: flex;
margin: .5rem 0;
align-items: center;
box-sizing: border-box;
span {
margin-left: 1.5rem;
text-transform: uppercase;
color: rgb(144, 212, 210);
}
}
.icon {
opacity: 0;
margin-right: 3px;
font-size: 1.3rem;
height: 1.4rem;
color: #8795a1;
}
}
}
.edit-button {
opacity: 0;
user-select: none;
position: absolute;
bottom: 0;
right: 0;
margin: 0;
margin-bottom: .25rem;
color: #8795a1;
&:hover {
opacity: 1;
color: white;
}
&.selected {
opacity: 1;
}
}
&:hover {
.edit-button {
opacity: 1;
}
.text-part {
.icons {
.icon {
opacity: 1;
}
}
}
}
&.selected {
.text-part {
.icons {
opacity: 1;
}
}
.edit-button {
opacity: 1;
}
}
@media only screen and (max-width: 450px) {
flex-basis: 100%;
}
}
.add-org-button {
z-index: 100;
flex-basis: 230px;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
min-height: 130px;
border-radius: .5rem;
margin: 1rem;
box-sizing: border-box;
.icon {
display: flex;
justify-content: center;
align-self: center;
margin-bottom: 1rem;
height: 2.5rem;
line-height: 2.5rem;
font-size: 2.5rem;
}
&:hover {
background-color: #ffffff25;
.icon,
span {
&.disabled {
color: gray;
}
}
}
@media only screen and (max-width: 450px) {
flex-basis: 100%;
}
}
}
.n-items {
padding: 0 1rem;
font-size: .8rem;
color: #8795a1;
flex-basis: 100%;
}
@@ -1,112 +0,0 @@
import { SelectionModel } from '@angular/cdk/collections';
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { Observable, of } from 'rxjs';
import { switchMap, take } from 'rxjs/operators';
import { Org } from 'src/app/proto/generated/auth_pb';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { ToastService } from 'src/app/services/toast.service';
@Component({
selector: 'app-org-grid',
templateUrl: './org-grid.component.html',
styleUrls: ['./org-grid.component.scss'],
})
export class OrgGridComponent {
public activeOrg!: Org.AsObject;
public orgList: Org.AsObject[] = [];
public selection: SelectionModel<Org.AsObject> = new SelectionModel<Org.AsObject>(true, []);
public selectedIndex: number = -1;
public loading: boolean = false;
public notPinned: Array<Org.AsObject> = [];
constructor(
private userService: GrpcAuthService,
private toast: ToastService,
private router: Router,
) {
this.loading = true;
this.getData(10, 0);
this.userService.GetActiveOrg().then(org => this.activeOrg = org);
this.selection.changed.subscribe(selection => {
this.setPrefixedItem('pinned-orgs', JSON.stringify(
this.selection.selected.map(item => item.id),
)).pipe(take(1)).subscribe(() => {
selection.added.forEach(element => {
const index = this.notPinned.findIndex(item => item.id === element.id);
this.notPinned.splice(index, 1);
});
this.notPinned.push(...selection.removed);
});
});
}
public reorganizeItems(): void {
this.getPrefixedItem('pinned-orgs').pipe(take(1)).subscribe(storageEntry => {
if (storageEntry) {
const array: string[] = JSON.parse(storageEntry);
const toSelect: Org.AsObject[] = this.orgList.filter((item, index) => {
if (array.includes(item.id)) {
// this.notPinned.splice(index, 1);
return true;
}
});
this.selection.select(...toSelect);
const toNotPinned: Org.AsObject[] = this.orgList.filter((item, index) => {
if (!array.includes(item.id)) {
return true;
}
});
this.notPinned = toNotPinned;
}
});
}
private getPrefixedItem(key: string): Observable<string | null> {
return this.userService.user.pipe(
take(1),
switchMap(user => {
return of(localStorage.getItem(`${user.id}:${key}`));
}),
);
}
private setPrefixedItem(key: string, value: any): Observable<void> {
return this.userService.user.pipe(
take(1),
switchMap(user => {
return of(localStorage.setItem(`${user.id}:${key}`, value));
}),
);
}
private getData(limit: number, offset: number): void {
this.userService.SearchMyProjectOrgs(limit, offset).then(res => {
this.orgList = res.toObject().resultList;
this.notPinned = Object.assign([], this.orgList);
this.reorganizeItems();
this.loading = false;
}).catch(error => {
this.toast.showError(error);
this.loading = false;
});
}
public selectOrg(item: Org.AsObject, event?: any): void {
if (event && !event.target.classList.contains('mat-icon')) {
this.userService.setActiveOrg(item);
this.routeToOrg(item);
}
}
public routeToOrg(item: Org.AsObject): void {
this.router.navigate(['/orgs', item.id]);
}
}
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { OrgListComponent } from './org-list.component';
const routes: Routes = [
{
path: '',
component: OrgListComponent,
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class OrgListRoutingModule { }
@@ -0,0 +1,56 @@
<div class="max-width-container">
<h1>{{ 'ORG.PAGES.LIST' | translate }}</h1>
<p class="top-desc">{{'ORG.PAGES.LISTDESCRIPTION' | translate}}</p>
<app-refresh-table *ngIf="dataSource" (refreshed)="refresh()" [dataSize]="dataSource.data.length"
[loading]="loading$ | async">
<mat-form-field @appearfade *ngIf="orgSearchKey != undefined" actions class="filter">
<mat-label>{{'ORG.PAGES.FILTER' | translate}}</mat-label>
<input matInput (keyup)="applyFilter($event)" placeholder="{{'ORG.PAGES.FILTERPLACEHOLDER' | translate}}"
#input>
</mat-form-field>
<table [dataSource]="dataSource" mat-table class="table" matSort aria-label="Elements">
<ng-container matColumnDef="select">
<th class="selection" mat-header-cell *matHeaderCellDef>
{{'ORG.PAGES.ACTIVE' | translate}}
</th>
<td class="selection" mat-cell *matCellDef="let row">
<mat-radio-button (change)="selectOrg(row)" color="primary" (click)="$event.stopPropagation()"
[checked]="row.id == activeOrg.id">
</mat-radio-button>
</td>
</ng-container>
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef mat-sort-header> {{ 'ORG.PAGES.ID' | translate }} </th>
<td mat-cell *matCellDef="let org"> {{org.id}} </td>
</ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header
[ngClass]="{'search-active': this.orgSearchKey == MyProjectOrgSearchKey.MYPROJECTORGSEARCHKEY_ORG_NAME}">
{{ 'ORG.PAGES.NAME' | translate }}
<template [ngTemplateOutlet]="templateRef"
[ngTemplateOutletContext]="{key: MyProjectOrgSearchKey.MYPROJECTORGSEARCHKEY_ORG_NAME}"></template>
</th>
<td mat-cell *matCellDef="let org"> {{org.name}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator class="paginator" [pageSize]="10" #paginator [pageSizeOptions]="[10, 20, 100, 250]">
</mat-paginator>
</app-refresh-table>
</div>
<ng-template #templateRef let-key="key">
<button class="search-button" mat-icon-button
(click)="this.orgSearchKey != key ? this.orgSearchKey = key : this.orgSearchKey = undefined">
<mat-icon *ngIf="this.orgSearchKey != key">search</mat-icon>
<mat-icon *ngIf="this.orgSearchKey == key">search_off</mat-icon>
</button>
</ng-template>
@@ -0,0 +1,53 @@
h1 {
margin-top: 0;
}
.top-desc {
color: #8795a1;
}
.table,
.paginator {
width: 100%;
td,
th {
padding: 0 1rem;
&:first-child {
padding-left: 0;
padding-right: 1rem;
}
&:last-child {
padding-right: 0;
}
}
.selection {
width: 50px;
max-width: 50px;
}
}
.pointer {
outline: none;
cursor: pointer;
}
.filter {
margin-left: 1rem;
}
th {
.search-button {
visibility: hidden;
}
&:hover,
&.search-active {
.search-button {
visibility: visible;
}
}
}
@@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { OrgGridComponent } from './org-grid.component';
import { OrgListComponent } from './org-list.component';
describe('OrgGridComponent', () => {
let component: OrgGridComponent;
let fixture: ComponentFixture<OrgGridComponent>;
describe('OrgListComponent', () => {
let component: OrgListComponent;
let fixture: ComponentFixture<OrgListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [OrgGridComponent],
declarations: [OrgListComponent],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(OrgGridComponent);
fixture = TestBed.createComponent(OrgListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
@@ -0,0 +1,83 @@
import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { BehaviorSubject, from, Observable, of } from 'rxjs';
import { catchError, finalize, map } from 'rxjs/operators';
import { enterAnimations } from 'src/app/animations';
import { MyProjectOrgSearchKey, MyProjectOrgSearchQuery, Org, SearchMethod } from 'src/app/proto/generated/auth_pb';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
@Component({
selector: 'app-org-list',
templateUrl: './org-list.component.html',
styleUrls: ['./org-list.component.scss'],
animations: [
enterAnimations,
],
})
export class OrgListComponent implements AfterViewInit {
public orgSearchKey: MyProjectOrgSearchKey | undefined = undefined;
@ViewChild(MatPaginator) public paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
public dataSource!: MatTableDataSource<Org.AsObject>;
public displayedColumns: string[] = ['select', 'id', 'name'];
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
public activeOrg!: Org.AsObject;
public MyProjectOrgSearchKey: any = MyProjectOrgSearchKey;
constructor(
private authService: GrpcAuthService,
) {
this.loadOrgs(10, 0);
this.authService.GetActiveOrg().then(org => this.activeOrg = org);
}
public ngAfterViewInit(): void {
this.loadOrgs(10, 0);
}
public loadOrgs(limit: number, offset: number, filter?: string): void {
this.loadingSubject.next(true);
let query;
if (filter) {
query = new MyProjectOrgSearchQuery();
query.setMethod(SearchMethod.SEARCHMETHOD_CONTAINS_IGNORE_CASE);
query.setKey(MyProjectOrgSearchKey.MYPROJECTORGSEARCHKEY_ORG_NAME);
query.setValue(filter);
}
from(this.authService.SearchMyProjectOrgs(limit, offset, query ? [query] : undefined)).pipe(
map(resp => {
return resp.toObject().resultList;
}),
catchError(() => of([])),
finalize(() => this.loadingSubject.next(false)),
).subscribe(views => {
this.dataSource = new MatTableDataSource(views);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
});
}
public selectOrg(item: Org.AsObject, event?: any): void {
this.authService.setActiveOrg(item);
}
public refresh(): void {
this.loadOrgs(this.paginator.length, this.paginator.pageSize * this.paginator.pageIndex);
}
public applyFilter(event: Event): void {
const filterValue = (event.target as HTMLInputElement).value;
this.loadOrgs(
this.paginator.pageSize,
this.paginator.pageIndex * this.paginator.pageSize,
filterValue.trim().toLowerCase(),
);
}
}
@@ -0,0 +1,42 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatRadioModule } from '@angular/material/radio';
import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TranslateModule } from '@ngx-translate/core';
import { RefreshTableModule } from 'src/app/modules/refresh-table/refresh-table.module';
import { LocalizedDatePipeModule } from 'src/app/pipes/localized-date-pipe/localized-date-pipe.module';
import { TimestampToDatePipeModule } from 'src/app/pipes/timestamp-to-date-pipe/timestamp-to-date-pipe.module';
import { OrgListRoutingModule } from './org-list-routing.module';
import { OrgListComponent } from './org-list.component';
@NgModule({
declarations: [OrgListComponent],
imports: [
CommonModule,
OrgListRoutingModule,
MatTableModule,
TranslateModule,
RefreshTableModule,
TimestampToDatePipeModule,
LocalizedDatePipeModule,
MatPaginatorModule,
MatSortModule,
MatIconModule,
MatButtonModule,
MatTooltipModule,
MatRadioModule,
MatFormFieldModule,
MatInputModule,
FormsModule,
],
})
export class OrgListModule { }
@@ -9,8 +9,7 @@
</button>
</ng-template>
<ng-template appHasRole actions [appHasRole]="['org.member.write:'+org?.id,'org.member.write']">
<a color="primary" [disabled]="disabled" class="add-button" (click)="openAddMember()" color="primary"
mat-raised-button>
<a color="primary" [disabled]="disabled" (click)="openAddMember()" color="primary" mat-raised-button>
<mat-icon class="icon">add</mat-icon>{{ 'ACTIONS.NEW' | translate }}
</a>
</ng-template>
@@ -73,7 +72,7 @@
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr class="data-row" mat-row *matRowDef="let row; columns: displayedColumns;">
<tr class="highlight" mat-row *matRowDef="let row; columns: displayedColumns;">
</tr>
</table>
@@ -24,12 +24,6 @@
width: 40px;
}
.data-row {
&:hover {
background-color: #ffffff05;
}
}
.selection {
width: 50px;
max-width: 50px;
@@ -37,10 +31,6 @@
}
}
.add-button {
border-radius: .5rem;
}
.pointer {
outline: none;
cursor: pointer;
@@ -5,7 +5,6 @@ import { PolicyComponentServiceType, PolicyComponentType } from 'src/app/modules
import { OrgCreateComponent } from './org-create/org-create.component';
import { OrgDetailComponent } from './org-detail/org-detail.component';
import { OrgGridComponent } from './org-grid/org-grid.component';
const routes: Routes = [
{
@@ -82,7 +81,7 @@ const routes: Routes = [
},
{
path: 'overview',
component: OrgGridComponent,
loadChildren: () => import('./org-list/org-list.module').then(m => m.OrgListModule),
},
];
+1 -2
View File
@@ -25,12 +25,11 @@ import { ChangesModule } from '../../modules/changes/changes.module';
import { AddDomainDialogModule } from './org-detail/add-domain-dialog/add-domain-dialog.module';
import { DomainVerificationComponent } from './org-detail/domain-verification/domain-verification.component';
import { OrgDetailComponent } from './org-detail/org-detail.component';
import { OrgGridComponent } from './org-grid/org-grid.component';
import { OrgsRoutingModule } from './orgs-routing.module';
import { PolicyGridComponent } from './policy-grid/policy-grid.component';
@NgModule({
declarations: [OrgDetailComponent, OrgGridComponent, PolicyGridComponent, DomainVerificationComponent],
declarations: [OrgDetailComponent, PolicyGridComponent, DomainVerificationComponent],
imports: [
CommonModule,
HasRolePipeModule,
@@ -70,7 +70,6 @@ h1 {
button {
margin-right: 1rem;
border-radius: .5rem;
}
}
}