feat(console): seo metatags, fix policy bugs, project options (#844)

* add seo service, index meta info

* fix policy buttons, refresh

* refresh after timeout

* loading spinner for login policy, complexity

* fix user form, add project role options

* authtoken options

* seo service lint

* style lint

* remove duplicate authmethod

* en i18n

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

Co-authored-by: Fabi <[email protected]>

Co-authored-by: Fabi <[email protected]>
This commit is contained in:
Max Peintner
2020-10-16 13:51:52 +02:00
committed by GitHub
co-authored by Fabi
parent c3b4c3f264
commit b1d61afc8f
30 changed files with 310 additions and 80 deletions
@@ -97,19 +97,9 @@ export class IdpTableComponent implements OnInit {
private async getData(limit: number, offset: number): Promise<void> {
this.loadingSubject.next(true);
// let query: AdminIdpSearchQuery | MgmtIdpSearchQuery;
// if (this.service instanceof AdminService) {
// query = new AdminIdpSearchQuery();
// query.setKey(AdminIdpSearchKey.IDPSEARCHKEY_IDP_CONFIG_ID);
// } else if (this.service instanceof ManagementService) {
// query = new MgmtIdpSearchQuery();
// query.setKey(MgmtIdpSearchKey.IDPSEARCHKEY_PROVIDER_TYPE);
// }
this.service.SearchIdps(limit, offset).then(resp => {
this.idpResult = resp.toObject();
this.dataSource.data = this.idpResult.resultList;
console.log(this.idpResult.resultList);
this.loadingSubject.next(false);
}).catch(error => {
this.toast.showError(error);
@@ -2,10 +2,14 @@
[title]="'ORG.POLICY.LOGIN_POLICY.TITLECREATE' | translate"
[description]="(serviceType==PolicyComponentServiceType.MGMT ? 'ORG.POLICY.LOGIN_POLICY.DESCRIPTIONCREATEMGMT' : PolicyComponentServiceType.ADMIN ? 'ORG.POLICY.LOGIN_POLICY.DESCRIPTIONCREATEADMIN' : '') | translate">
<ng-template appHasRole
[appHasRole]="[serviceType === PolicyComponentServiceType.ADMIN ? 'iam.policy.delete' : 'org.policy.delete']">
<button matTooltip="{{'ORG.POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()"
mat-stroked-button>
<p class="default" *ngIf="isDefault"> {{'ORG.POLICY.DEFAULTLABEL' | translate}}</p>
<div class="spinner-wr">
<mat-spinner diameter="30" *ngIf="loading" color="primary"></mat-spinner>
</div>
<ng-template appHasRole [appHasRole]="['policy.delete']">
<button *ngIf="serviceType === PolicyComponentServiceType.MGMT && !isDefault"
matTooltip="{{'ORG.POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()" mat-stroked-button>
{{'ORG.POLICY.RESET' | translate}}
</button>
</ng-template>
@@ -3,6 +3,10 @@
margin-top: 0;
}
.spinner-wr {
margin: .5rem 0;
}
.content {
padding-top: 1rem;
display: flex;
@@ -33,9 +33,11 @@ export class LoginPolicyComponent implements OnDestroy {
private sub: Subscription = new Subscription();
public service!: ManagementService | AdminService;
PolicyComponentServiceType: any = PolicyComponentServiceType;
public PolicyComponentServiceType: any = PolicyComponentServiceType;
public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
public idps: MgmtIdpProviderView.AsObject[] | AdminIdpProviderView.AsObject[] = [];
public loading: boolean = false;
constructor(
private route: ActivatedRoute,
private toast: ToastService,
@@ -43,7 +45,6 @@ export class LoginPolicyComponent implements OnDestroy {
private injector: Injector,
) {
this.sub = this.route.data.pipe(switchMap(data => {
console.log(data.serviceType);
this.serviceType = data.serviceType;
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
@@ -56,15 +57,19 @@ export class LoginPolicyComponent implements OnDestroy {
return this.route.params;
})).subscribe(() => {
this.getData().then(data => {
if (data) {
this.loginData = data.toObject();
}
});
this.getIdps().then(idps => {
console.log(idps);
this.idps = idps;
});
this.fetchData();
});
}
private fetchData(): void {
this.getData().then(data => {
if (data) {
this.loginData = data.toObject();
this.loading = false;
}
});
this.getIdps().then(idps => {
this.idps = idps;
});
}
@@ -122,6 +127,10 @@ export class LoginPolicyComponent implements OnDestroy {
public savePolicy(): void {
this.updateData().then(() => {
this.toast.showInfo('ORG.POLICY.LOGIN_POLICY.SAVED', true);
this.loading = true;
setTimeout(() => {
this.fetchData();
}, 2000);
}).catch(error => {
this.toast.showError(error);
});
@@ -131,9 +140,10 @@ export class LoginPolicyComponent implements OnDestroy {
if (this.serviceType === PolicyComponentServiceType.MGMT) {
(this.service as ManagementService).RemoveLoginPolicy().then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.RESETSUCCESS', true);
this.loading = true;
setTimeout(() => {
this.getData();
}, 1000);
this.fetchData();
}, 2000);
}).catch(error => {
this.toast.showError(error);
});
@@ -151,7 +161,10 @@ export class LoginPolicyComponent implements OnDestroy {
dialogRef.afterClosed().subscribe(resp => {
if (resp && resp.idp && resp.type) {
this.addIdp(resp.idp, resp.type).then(() => {
this.getData();
this.loading = true;
setTimeout(() => {
this.fetchData();
}, 2000);
});
}
});
@@ -5,6 +5,7 @@ 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 { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TranslateModule } from '@ngx-translate/core';
@@ -37,6 +38,7 @@ import { LoginPolicyComponent } from './login-policy.component';
DetailLayoutModule,
AddIdpDialogModule,
IdpTableModule,
MatProgressSpinnerModule,
],
})
export class LoginPolicyModule { }
@@ -20,7 +20,7 @@ import { PolicyComponentServiceType } from '../policy-component-types.enum';
export class OrgIamPolicyComponent implements OnDestroy {
@Input() service!: AdminService;
private managementService!: ManagementService;
public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
public serviceType!: PolicyComponentServiceType;
public iamData!: AdminOrgIamPolicyView.AsObject | MgmtOrgIamPolicyView.AsObject;
@@ -47,11 +47,7 @@ export class OrgIamPolicyComponent implements OnDestroy {
}
return this.route.params;
})).subscribe(_ => {
this.getData().then(data => {
if (data) {
this.iamData = data.toObject();
}
});
this.fetchData();
});
}
@@ -59,6 +55,14 @@ export class OrgIamPolicyComponent implements OnDestroy {
this.sub.unsubscribe();
}
public fetchData(): void {
this.getData().then(data => {
if (data) {
this.iamData = data.toObject();
}
});
}
private async getData(): Promise<AdminOrgIamPolicyView | MgmtOrgIamPolicyView | undefined> {
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
@@ -114,7 +118,7 @@ export class OrgIamPolicyComponent implements OnDestroy {
this.adminService.RemoveOrgIamPolicy(this.org.id).then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.RESETSUCCESS', true);
setTimeout(() => {
this.getData();
this.fetchData();
}, 1000);
}).catch(error => {
this.toast.showError(error);
@@ -1,9 +1,8 @@
<app-detail-layout [backRouterLink]="[ serviceType === PolicyComponentServiceType.ADMIN ? '/iam' : '/org']"
[title]="'ORG.POLICY.PWD_AGE.TITLE' | translate" [description]="'ORG.POLICY.PWD_AGE.DESCRIPTION' | translate">
<ng-template appHasRole
[appHasRole]="[serviceType === PolicyComponentServiceType.ADMIN ? 'iam.policy.delete' : 'org.policy.delete']">
<button matTooltip="{{'ORG.POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()"
mat-stroked-button>
<ng-template appHasRole [appHasRole]="['policy.delete']">
<button *ngIf="serviceType === PolicyComponentServiceType.MGMT" matTooltip="{{'ORG.POLICY.RESET' | translate}}"
color="warn" (click)="removePolicy()" mat-stroked-button>
{{'ORG.POLICY.RESET' | translate}}
</button>
</ng-template>
@@ -110,14 +110,20 @@ export class PasswordAgePolicyComponent implements OnDestroy {
(this.service as ManagementService).CreatePasswordAgePolicy(
this.ageData.maxAgeDays,
this.ageData.expireWarnDays,
).catch(error => {
).then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
this.getData();
}).catch(error => {
this.toast.showError(error);
});
} else {
(this.service as ManagementService).UpdatePasswordAgePolicy(
this.ageData.maxAgeDays,
this.ageData.expireWarnDays,
).catch(error => {
).then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
this.getData();
}).catch(error => {
this.toast.showError(error);
});
}
@@ -126,7 +132,10 @@ export class PasswordAgePolicyComponent implements OnDestroy {
(this.service as AdminService).UpdateDefaultPasswordAgePolicy(
this.ageData.maxAgeDays,
this.ageData.expireWarnDays,
).catch(error => {
).then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
this.getData();
}).catch(error => {
this.toast.showError(error);
});
break;
@@ -1,12 +1,16 @@
<app-detail-layout [backRouterLink]="[ serviceType === PolicyComponentServiceType.ADMIN ? '/iam' : '/org']"
[title]="'ORG.POLICY.PWD_COMPLEXITY.TITLE' | translate"
[description]="'ORG.POLICY.PWD_COMPLEXITY.DESCRIPTION' | translate">
<p class="default" *ngIf="isDefault"> {{'ORG.POLICY.DEFAULTLABEL' | translate}}</p>
<ng-template appHasRole
[appHasRole]="[serviceType === PolicyComponentServiceType.ADMIN ? 'iam.policy.delete' : 'org.policy.delete']">
<button matTooltip="{{'ORG.POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()"
mat-stroked-button>
<div class="spinner-wr">
<mat-spinner diameter="30" *ngIf="loading" color="primary"></mat-spinner>
</div>
<ng-template appHasRole [appHasRole]="['policy.delete']">
<button *ngIf="serviceType === PolicyComponentServiceType.MGMT && !isDefault"
matTooltip="{{'ORG.POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()" mat-stroked-button>
{{'ORG.POLICY.RESET' | translate}}
</button>
</ng-template>
@@ -3,6 +3,10 @@
margin-top: 0;
}
.spinner-wr {
margin: .5rem 0;
}
.content {
padding-top: 1rem;
display: flex;
@@ -23,6 +23,8 @@ export class PasswordComplexityPolicyComponent implements OnDestroy {
private sub: Subscription = new Subscription();
public PolicyComponentServiceType: any = PolicyComponentServiceType;
public loading: boolean = false;
constructor(
private route: ActivatedRoute,
private toast: ToastService,
@@ -42,11 +44,18 @@ export class PasswordComplexityPolicyComponent implements OnDestroy {
return this.route.params;
})).subscribe(() => {
this.getData().then(data => {
if (data) {
this.complexityData = data.toObject();
}
});
this.fetchData();
});
}
public fetchData(): void {
this.loading = true;
this.getData().then(data => {
if (data) {
this.complexityData = data.toObject();
this.loading = false;
}
});
}
@@ -69,7 +78,7 @@ export class PasswordComplexityPolicyComponent implements OnDestroy {
this.service.removePasswordComplexityPolicy().then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.RESETSUCCESS', true);
setTimeout(() => {
this.getData();
this.fetchData();
}, 1000);
}).catch(error => {
this.toast.showError(error);
@@ -5,6 +5,7 @@ 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 { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TranslateModule } from '@ngx-translate/core';
@@ -29,6 +30,7 @@ import { PasswordComplexityPolicyComponent } from './password-complexity-policy.
MatTooltipModule,
TranslateModule,
DetailLayoutModule,
MatProgressSpinnerModule,
],
})
export class PasswordComplexityPolicyModule { }
@@ -2,10 +2,10 @@
[title]="'ORG.POLICY.PWD_LOCKOUT.TITLE' | translate"
[description]="'ORG.POLICY.PWD_LOCKOUT.DESCRIPTION' | translate">
<p class="default" *ngIf="isDefault"> {{'ORG.POLICY.DEFAULTLABEL' | translate}}</p>
<ng-template appHasRole
[appHasRole]="[serviceType === PolicyComponentServiceType.ADMIN ? 'iam.policy.delete' : 'org.policy.delete']">
<button matTooltip="{{'ORG.POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()"
mat-stroked-button>
<ng-template appHasRole [appHasRole]="['policy.delete']">
<button *ngIf="serviceType === PolicyComponentServiceType.MGMT" matTooltip="{{'ORG.POLICY.RESET' | translate}}"
color="warn" (click)="removePolicy()" mat-stroked-button>
{{'ORG.POLICY.RESET' | translate}}
</button>
</ng-template>
@@ -58,7 +58,6 @@ export class PasswordLockoutPolicyComponent implements OnDestroy {
}
private getData(): Promise<PasswordLockoutPolicyView | DefaultPasswordLockoutPolicyView> {
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
return (this.service as ManagementService).GetPasswordLockoutPolicy();
@@ -100,6 +99,7 @@ export class PasswordLockoutPolicyComponent implements OnDestroy {
this.lockoutData.showLockoutFailure,
).then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
this.getData();
}).catch(error => {
this.toast.showError(error);
});
@@ -110,6 +110,7 @@ export class PasswordLockoutPolicyComponent implements OnDestroy {
this.lockoutData.showLockoutFailure,
).then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
this.getData();
}).catch(error => {
this.toast.showError(error);
});
@@ -119,6 +120,7 @@ export class PasswordLockoutPolicyComponent implements OnDestroy {
this.lockoutData.showLockoutFailure,
).then(() => {
this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
this.getData();
}).catch(error => {
this.toast.showError(error);
});