Skip to content
Snippets Groups Projects
Commit 99785af8 authored by Lukasz Lopatowski's avatar Lukasz Lopatowski
Browse files

Merge remote-tracking branch 'origin/develop' into develop

parents e54db251 ddb43f42
No related branches found
No related tags found
3 merge requests!184Develop,!119Develop,!116Develop
Showing
with 76 additions and 72 deletions
......@@ -186,6 +186,7 @@ describe('Component: AppInstance', () => {
createdAt: new Date(),
descriptiveDeploymentId: 'test-oxidized-48',
domainId: 4,
domainName: "Test Domain",
id: 1,
internalId: 'eccbaf70-7fdd-401a-bb3e-b8659bcfbdff',
name: 'oxi-virt-1',
......
......@@ -78,7 +78,7 @@
<td class="col-lg-1 col-md-1">{{appInstance?.applicationVersion}}</td>
<td class="col-lg-2 col-md-2"
*ngIf="domainId === undefined || domainId === domainService.getGlobalDomainId()">
{{getDomainNameById(appInstance?.domainId)}}
{{appInstance?.domainName}}
</td>
<td class="col-lg-1 col-md-1">{{appInstance?.owner?.username}}</td>
<td class="col-lg-2 col-md-2">{{appInstance?.createdAt | localDate:'dd-MM-yyyy HH:mm'}}</td>
......@@ -128,7 +128,7 @@
<td class="col-lg-2 col-md-2">{{appInstance?.applicationName}}</td>
<td class="col-lg-1 col-md-1"
*ngIf="domainId === undefined || domainId === domainService.getGlobalDomainId()">
{{getDomainNameById(appInstance?.domainId)}}</td>
{{appInstance?.domainName}}</td>
<td class="col-lg-1 col-md-1">{{appInstance?.owner?.username}}</td>
<td class="col-lg-2 col-md-2">{{appInstance?.createdAt | localDate:'dd-MM-yyyy HH:mm'}}</td>
<td class="col-lg-3 col-md-3">{{ translateState(appInstance?.state) }}</td>
......
......@@ -52,8 +52,6 @@ export class AppInstanceListComponent implements OnInit {
public selectedUsername: string;
public domainId = 0;
public domains: Domain[] = [];
public searchValue = '';
public selectionOptions = [
{ label: this.translateEnum(AppInstanceListSelection.ALL), value: AppInstanceListSelection.ALL },
......@@ -73,9 +71,6 @@ export class AppInstanceListComponent implements OnInit {
ngOnInit() {
this.sessionService.registerCulture(this.translateService.currentLang);
this.domainService.getAll().subscribe(result => {
this.domains.push(...result);
});
const i = sessionStorage.getItem(this.item_number_key);
if (i) {
this.maxItemsOnPage = +i;
......@@ -110,12 +105,6 @@ export class AppInstanceListComponent implements OnInit {
}
public getDomainNameById(id: number): string {
if (this.domains === undefined) {
return 'none';
}
return this.domains.find(value => value.id === id).name;
}
public translateEnum(value: AppInstanceListSelection): string {
let outValue = '';
......
......@@ -32,6 +32,7 @@ describe('AddMembersModalComponent', () => {
createdAt: new Date(),
descriptiveDeploymentId: 'test-oxidized-48',
domainId: 4,
domainName: "Test Domain",
id: 1,
internalId: 'eccbaf70-7fdd-401a-bb3e-b8659bcfbdff',
name: 'oxi-virt-1',
......
......@@ -260,6 +260,11 @@
<div class="flex justify-content-end">
<button *ngIf="!isInMode(ComponentMode.VIEW)" type="submit" class="btn btn-primary" [disabled]="!domainForm.form.valid">{{ 'DOMAIN_DETAILS.SUBMIT_BUTTON' | translate }}</button>
</div>
<br *ngIf="errorMessage">
<div class="alert alert-danger text-left" *ngIf="errorMessage">
{{errorMessage}}
</div>
</form>
</div>
......
......@@ -9,7 +9,7 @@ import {User} from '../../../model';
import {Observable, of} from 'rxjs';
import {UserRole} from '../../../model/userrole';
import {AuthService} from '../../../auth/auth.service';
import {ModalComponent} from '../../../shared';
import {ModalComponent} from '../../../shared';
import {map, shareReplay, take} from 'rxjs/operators';
import {DcnDeploymentType} from '../../../model/dcndeploymenttype';
import {CustomerNetwork} from '../../../model/customernetwork';
......@@ -48,6 +48,8 @@ export class DomainComponent extends BaseComponent implements OnInit {
public annotations : Observable<DomainAnnotation[]> = of([]);
public errorMessage = "";
constructor(public domainService: DomainService,
protected userService: UserService,
private router: Router,
......@@ -103,7 +105,14 @@ export class DomainComponent extends BaseComponent implements OnInit {
if (this.domainId !== undefined) {
this.updateExistingDomain();
} else {
this.domainService.add(this.domain).subscribe(() => this.router.navigate(['admin/domains/']));
this.domainService.add(this.domain).subscribe(() => {
this.router.navigate(['admin/domains/'])
}, err => {
console.error(err);
if(err.statusCode !== 409 && err?.message !== undefined) this.errorMessage = err.message;
else this.errorMessage = err;
});
}
this.domainService.setUpdateRequiredFlag(true);
}
......
......@@ -25,6 +25,7 @@ export class LoginSuccessComponent implements OnInit {
if (refreshToken) {
this.authService.storeOidcToken(oidcToken);
}
this.authService.loadUser();
this.router.navigate(['/'])
})
......
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
import { AuthService } from '../auth/auth.service';
@Directive({
selector: '[rolesExcluded]'
})
export class RolesExcludedDirective {
private _excluded: Array<string> = [];
constructor(
private _templateRef: TemplateRef<any>,
private _viewContainer: ViewContainerRef,
private authService: AuthService
) {}
@Input() set rolesExcluded(excludedRoles: Array<string>) {
this._excluded = excludedRoles;
this.updateState();
}
private updateState() {
this._viewContainer.clear();
const hasExcludedRole = this._excluded.some(role => this.authService.hasRole(role));
if (!hasExcludedRole) {
// If user has exluded role hide the element
this._viewContainer.createEmbeddedView(this._templateRef);
}
}
}
\ No newline at end of file
......@@ -3,10 +3,7 @@ import {Directive, Input, TemplateRef, ViewContainerRef} from '@angular/core';
class RoleState {
public allowed: Array<string> = new Array<string>();
public excluded: Array<string> = new Array<string>()
}
@Directive({
selector: '[roles]',
inputs: ['roles']
......@@ -15,8 +12,6 @@ export class RolesDirective {
private _allowed: Array<string> = new Array<string>();
private _excluded: Array<string> = new Array<string>();
constructor(private _templateRef: TemplateRef<any>,
private _viewContainer: ViewContainerRef,
private authService: AuthService) {
......@@ -26,53 +21,18 @@ export class RolesDirective {
@Input() set roles(allowedRoles: Array<string>) {
this._allowed = allowedRoles;
this.updateState({
allowed: this._allowed,
excluded: this._excluded
})
}
// Excluded roles have priority than allowed roles
// If user have excluded role template would not be shown
@Input() set rolesExcluded(excluded: Array<string>) {
this._excluded = excluded;
this.updateState({
allowed: this._allowed,
excluded: this._excluded
allowed: this._allowed
})
}
updateState(state: RoleState) {
this._viewContainer.clear();
let show: boolean = false;
let notAllowed: boolean = false;
const allowedRoles = state.allowed;
for (let exclude of state.excluded) {
if (this.authService.hasRole(exclude)) {
notAllowed = true;
break;
}
const hasAllowedRole = state.allowed.some(role => this.authService.hasRole(role));
if (hasAllowedRole) {
this._viewContainer.createEmbeddedView(this._templateRef);
}
if (notAllowed) {
this._viewContainer.clear();
} else {
for (let allowedRole of allowedRoles) {
if (this.authService.hasRole(allowedRole)) {
show = true;
break;
}
}
if (show) {
this._viewContainer.createEmbeddedView(this._templateRef);
} else {
this._viewContainer.clear();
}
}
}
}
......@@ -28,6 +28,7 @@ export class AppInstance {
public id: number = undefined;
public domainId: number = undefined;
public domainName: string = undefined;
public applicationId: number = undefined;
public applicationName: string = undefined;
public applicationVersion: string = undefined;
......
......@@ -77,9 +77,13 @@
<li *roles="['ROLE_SYSTEM_ADMIN']"><a
[routerLink]="['/admin/users']">{{ 'NAVBAR.USERS' | translate }}</a>
</li>
<li *roles="['ROLE_DOMAIN_ADMIN', 'ROLE_GROUP_DOMAIN_ADMIN']"><a
[routerLink]="['/domain/users']">{{ 'NAVBAR.DOMAIN_USERS' | translate }}</a>
<li *roles="['ROLE_DOMAIN_ADMIN', 'ROLE_GROUP_DOMAIN_ADMIN']">
<a *rolesExcluded="['ROLE_SYSTEM_ADMIN']"
[routerLink]="['/domain/users']">{{ 'NAVBAR.DOMAIN_USERS' | translate }}</a>
</li>
<li *roles="['ROLE_SYSTEM_ADMIN']"><a
[routerLink]="['/admin/languages']">{{ 'NAVBAR.LANGUAGES' | translate }}</a>
</li>
......
import {DefaultLogo} from '../directive/defaultlogo.directive';
import {RolesDirective} from '../directive/roles.directive';
import {NgModule} from '@angular/core';
import {NgModule, NO_ERRORS_SCHEMA} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {CommonModule, DatePipe} from '@angular/common';
......@@ -65,6 +65,7 @@ import { InputGroupModule } from 'primeng/inputgroup';
import { InputGroupAddonModule } from 'primeng/inputgroupaddon';
import { ButtonModule } from 'primeng/button';
import { BrowserModule } from '@angular/platform-browser';
import { RolesExcludedDirective } from '../directive/roles-exluded.directive';
@NgModule({
......@@ -103,6 +104,7 @@ import { BrowserModule } from '@angular/platform-browser';
NavbarComponent,
DefaultLogo,
RolesDirective,
RolesExcludedDirective,
MinLengthDirective,
MaxLengthDirective,
SearchComponent,
......@@ -179,13 +181,16 @@ import { BrowserModule } from '@angular/platform-browser';
ModalTestInstanceComponent,
ModalNotificationSendComponent,
DomainRolesDirective,
RolesExcludedDirective,
SshKeysComponent,
ModalProvideSshKeyComponent,
PreferencesComponent,
SortableHeaderDirective,
DomainNamespaceAnnotationsComponent,
AccessTokensComponent
]
],
schemas: [NO_ERRORS_SCHEMA], // Dodanie schematu
})
export class SharedModule {
}
......@@ -6,22 +6,20 @@
<tr>
<th scope="col">{{'TOKENS.TABLE.ID' | translate}}</th>
<th scope="col">{{'TOKENS.TABLE.NAME' | translate}}</th>
<th scope="col">{{'TOKENS.TABLE.VALUE' | translate}}</th>
<th scope="col">{{'TOKENS.TABLE.VALID' | translate}}</th>
<th scope="col">{{'TOKENS.TABLE.ACTIONS' | translate}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let token of tokensList">
<td>{{token.id}}</td>
<td>{{token.name}}</td>
<td>{{token.tokenValue}}</td>
<td>{{token.valid}}</td>
<td *ngIf="token.valid">
<td style="width: 25%;">{{token.id}}</td>
<td style="width: 25%;">{{token.name}}</td>
<td style="width: 25%;">{{token.valid}}</td>
<td style="width: 25%;" *ngIf="token.valid">
<button type="button" class="btn btn-danger"
(click)="invalidate(token.id)">{{'TOKENS.BUTTON_INVALIDATE' | translate}}</button>
</td>
<td *ngIf="!token.valid">
<td style="width: 25%;" *ngIf="!token.valid">
<button type="button" class="btn btn-danger"
(click)="deleteToken(token.id)">{{'TOKENS.BUTTON_DELETE' | translate}}</button>
</td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment