feat: rehauled console (#3525)

* new console

* move npm ci to angular build

* rel path for assets

* local grpc copy

* login policy, rm clear views, features rel path

* lock

Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
Max Peintner
2022-04-28 10:35:02 +00:00
committed by GitHub
co-authored by Livio Amstutz
parent 00f7dbe875
commit 08ae39ae19
668 changed files with 47746 additions and 19117 deletions
@@ -1,21 +1,33 @@
import { DatePipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import * as moment from 'moment';
@Pipe({
name: 'localizedDate',
name: 'localizedDate',
})
export class LocalizedDatePipe implements PipeTransform {
constructor(private translateService: TranslateService) {}
constructor(private translateService: TranslateService) { }
public transform(value: any, pattern?: string): any {
if (pattern && pattern === 'fromNow') {
moment.locale(this.translateService.currentLang ?? 'en');
public transform(value: any, pattern: string = 'mediumDate'): any {
if (this.translateService.currentLang && this.translateService.currentLang === ('de' || 'it' || 'fr' || 'eng')) {
const datePipe: DatePipe = new DatePipe(this.translateService.currentLang);
return datePipe.transform(value, pattern);
} else {
const datePipe: DatePipe = new DatePipe('de');
return datePipe.transform(value, pattern);
}
let date = moment(value);
if (moment().diff(date, 'days') <= 2) {
return date.fromNow(); // '2 days ago' etc.
} else {
const localeData = moment(value).localeData();
const format = localeData.longDateFormat('L');
return moment(value).format(`${format}, HH:mm`);
}
} else {
const lang = this.translateService.currentLang === ('de' || 'it' || 'en') ? this.translateService.currentLang : 'en';
const datePipe: DatePipe = new DatePipe(
lang,
// ['de', 'it', 'en'].includes(this.translateService.currentLang) ? this.translateService.currentLang : 'en',
);
return datePipe.transform(value, pattern ?? 'mediumDate');
}
}
}
@@ -0,0 +1,11 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RoleTransformPipe } from './role-transform.pipe';
@NgModule({
declarations: [RoleTransformPipe],
imports: [CommonModule],
exports: [RoleTransformPipe],
})
export class RoleTransformPipeModule {}
@@ -0,0 +1,27 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'roletransform',
})
export class RoleTransformPipe implements PipeTransform {
public transform(value: string | string[]): string {
if (typeof value === 'string') {
return getNewString(value);
} else if (typeof value === 'object' && value.length) {
return (
value
.map((s) => getNewString(s))
// .slice(0, -1)
.join(', ')
);
} else {
return '';
}
}
}
function getNewString(value: string): string {
const splitted = value.toLowerCase().split('_');
const uppercased = splitted.map((s) => `${s.substring(0, 1).toUpperCase()}${s.substring(1, s.length)}`);
return uppercased.join(' ');
}