fix: Merge master (#1373)

* feat(console): app infos, api apps, fix redirects on create, fix role update, redesign idps, policy, prettier history  (#1310)

* idp fixes

* idp cleanup and rehaul, complexity policy preview

* policy fixes, orthodox redirect

* link component, add links to policies

* redirect pipe, state labels

* Cnsl map changes (#1315)

* map changes to different format

* fix changes layout, cursor

* set asc values

* fix user appearance in changes, index

* changes

* app create with api

* api app create

* auth method for api config

* authmethods, app card for api, authmethod in dev create

* move machine keys to own module

* jwt method for oidc

* fix app edit

* save toast

* fix changes, change det in app detail

* regenerate secret

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

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

Signed-off-by: dependabot[bot] <support@github.com>

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

* fix policy backlink

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit 40a7e958d7)

* fix: i18n refs, unnecessary logs (#1343)

(cherry picked from commit 2e04c977eb)

* fix: tos link (#1345)

(cherry picked from commit 5333ef10c1)

* fix: reactivate/deactivate idp, remove idp provider (#1348)

* fix: reactivate/deactivate idp, remove idp provider

* fix build

* fix(console): add jwt to selection, idp deactivate reactivate (#1347)

* fix: log error on idp change

* add jwt to method selection

Co-authored-by: Max Peintner <max@caos.ch>

(cherry picked from commit c8b9888427)

* fix: reactivate/deactivate idp (#1351)

(cherry picked from commit 54f395e2e0)

Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
Fabi
2021-03-01 09:01:34 +01:00
committed by GitHub
parent 3c07a186fc
commit 9f417f3957
113 changed files with 2976 additions and 1327 deletions

View File

@@ -4,6 +4,8 @@ import { catchError, debounceTime, scan, take, takeUntil, tap } from 'rxjs/opera
import { Change, Changes } from 'src/app/proto/generated/management_pb';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { ManagementService } from 'src/app/services/mgmt.service';
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
import { KeyValue } from '@angular/common';
export enum ChangeType {
MYUSER = 'myuser',
@@ -13,6 +15,18 @@ export enum ChangeType {
APP = 'app',
}
export interface MappedChange {
key: string,
values: Array<{
data: any[];
dates: Timestamp.AsObject[];
editorId: string;
editorName: string;
eventTypes: Array<{ key: string; localizedMessage: string; }>;
sequences: number[];
}>;
}
@Component({
selector: 'app-changes',
templateUrl: './changes.component.html',
@@ -31,7 +45,7 @@ export class ChangesComponent implements OnInit, OnDestroy {
private _data: BehaviorSubject<any> = new BehaviorSubject([]);
loading: Observable<boolean> = this._loading.asObservable();
public data!: Observable<Change.AsObject[]>;
public data!: Observable<MappedChange[]>;
public changes!: Changes.AsObject;
private destroyed$: Subject<void> = new Subject();
constructor(private mgmtUserService: ManagementService, private authUserService: GrpcAuthService) {
@@ -52,6 +66,7 @@ export class ChangesComponent implements OnInit, OnDestroy {
}
public scrollHandler(e: any): void {
console.log('bottom');
if (e === 'bottom') {
this.more();
}
@@ -83,6 +98,7 @@ export class ChangesComponent implements OnInit, OnDestroy {
private more(): void {
const cursor = this.getCursor();
console.log('cursor' + cursor);
let more: Promise<Changes>;
@@ -105,9 +121,11 @@ export class ChangesComponent implements OnInit, OnDestroy {
// Determines the snapshot to paginate query
private getCursor(): number {
const current = this._data.value;
if (current.length) {
return !this.sortDirectionAsc ? current[0].sequence :
current[current.length - 1].sequence;
const lastElementValues = current[current.length - 1].values;
const seq = lastElementValues[lastElementValues.length - 1].sequences;
return seq[seq.length - 1];
}
return 0;
}
@@ -125,8 +143,10 @@ export class ChangesComponent implements OnInit, OnDestroy {
take(1),
tap((res: Changes) => {
const values = res.toObject().changesList;
const mapped = this.mapChanges(values);
// update source with new values, done loading
this._data.next(values);
// this._data.next(values);
this._data.next(mapped);
this._loading.next(false);
@@ -143,4 +163,85 @@ export class ChangesComponent implements OnInit, OnDestroy {
).subscribe();
}
}
mapChanges(changes: Change.AsObject[]) {
const splitted: { [editorId: string]: any[]; } = {};
changes.forEach((change) => {
if (change.changeDate) {
const index = `${this.getDateString(change.changeDate)}`;//`${this.getDateString(change.changeDate)}:${change.editorId}`;
if (index) {
if (splitted[index]) {
const userData: any = {
editor: change.editor,
editorId: change.editorId,
editorName: change.editor,
dates: [change.changeDate],
data: [change.data],
eventTypes: [change.eventType],
sequences: [change.sequence],
};
const lastIndex = splitted[index].length - 1;
if (lastIndex > -1 && splitted[index][lastIndex].editor === change.editor) {
splitted[index][lastIndex].dates.push(change.changeDate);
splitted[index][lastIndex].data.push(change.data);
splitted[index][lastIndex].eventTypes.push(change.eventType);
splitted[index][lastIndex].sequences.push(change.sequence);
} else {
splitted[index].push(userData);
}
} else {
splitted[index] = [
{
editor: change.editor,
editorId: change.editorId,
editorName: change.editor,
dates: [change.changeDate],
data: [change.data],
eventTypes: [change.eventType],
sequences: [change.sequence],
}
];
}
}
}
});
const arr = Object.keys(splitted).map(key => {
return { key: key, values: splitted[key] };
});
arr.sort((a, b) => {
return parseFloat(b.key) - parseFloat(a.key);
});
// console.log(arr);
return arr;
}
getDateString(ts: Timestamp.AsObject) {
const date = new Date(ts.seconds * 1000 + ts.nanos / 1000 / 1000);
return date.getUTCFullYear() + this.pad(date.getUTCMonth() + 1) + this.pad(date.getUTCDate());
}
getTimestampIndex(date: any): number {
const ts: Date = new Date(date.seconds * 1000 + date.nanos / 1000 / 1000);
console.log(ts);
return ts.getTime();
}
pad(n: number): string {
return n < 10 ? '0' + n : n.toString();
}
// Order by ascending property value
valueAscOrder = (a: KeyValue<number, string>, b: KeyValue<number, string>): number => {
return a.value.localeCompare(b.value);
};
// Order by descending property key
keyDescOrder = (a: KeyValue<number, string>, b: KeyValue<number, string>): number => {
return a.key > b.key ? -1 : (b.key > a.key ? 1 : 0);
};
}