Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ddcbc5bc authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Small UI fixes - ResourceType/logout clearing

parent 5538fdf4
Branches EDELIVERY-11518-adoptiumopenjdk-for-dockers
No related tags found
No related merge requests found
Pipeline #174227 failed
......@@ -22,6 +22,7 @@ export class HttpSessionInterceptor implements HttpInterceptor {
private readonly TIME_BEFORE_EXPIRATION_IN_SECONDS = 60;
private timerId: number;
private timerToLogoutId: number;
constructor(public securityService: SecurityService,
public alertMessageService: AlertMessageService,
......@@ -30,6 +31,7 @@ export class HttpSessionInterceptor implements HttpInterceptor {
public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
clearTimeout(this.timerId);
clearTimeout(this.timerToLogoutId);
let user = this.securityService.getCurrentUser();
if (user && user.sessionMaxIntervalTimeoutInSeconds && user.sessionMaxIntervalTimeoutInSeconds > this.TIME_BEFORE_EXPIRATION_IN_SECONDS) {
let timeout = (user.sessionMaxIntervalTimeoutInSeconds - this.TIME_BEFORE_EXPIRATION_IN_SECONDS) * 1000;
......@@ -39,6 +41,11 @@ export class HttpSessionInterceptor implements HttpInterceptor {
}
private sessionExpiringSoon(timeout) {
// Logout the user after the session expires
this.timerToLogoutId = setTimeout(() => {
this.securityService.logout();
}, this.TIME_BEFORE_EXPIRATION_IN_SECONDS * 1000);
this.dialog.open(SessionExpirationDialogComponent, {
data: {
timeLeft: this.TIME_BEFORE_EXPIRATION_IN_SECONDS,
......
......@@ -2,7 +2,7 @@
import {Observable, ReplaySubject} from 'rxjs';
import {User} from './user.model';
import {SecurityEventService} from './security-event.service';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {HttpClient, HttpErrorResponse, HttpHeaders} from '@angular/common/http';
import {SmpConstants} from "../smp.constants";
import {Authority} from "./authority.model";
import {AlertMessageService} from "../common/alert-message/alert-message.service";
......@@ -104,8 +104,13 @@ export class SecurityService {
this.http.delete(SmpConstants.REST_PUBLIC_SECURITY_AUTHENTICATION).subscribe((res: Response) => {
this.finalizeLogout(res);
},
(error) => {
this.securityEventService.notifyLogoutErrorEvent(error);
(err) => {
if (err instanceof HttpErrorResponse && err.status === 401) {
this.finalizeLogout(err);
}
else {
this.securityEventService.notifyLogoutErrorEvent(err);
}
});
}
......@@ -203,5 +208,4 @@ export class SecurityService {
public clearLocalStorage() {
localStorage.removeItem(this.LOCAL_STORAGE_KEY_CURRENT_USER);
}
}
......@@ -40,6 +40,7 @@ import {MemberTypeEnum} from "../../common/enums/member-type.enum";
import {firstValueFrom, Subscription} from "rxjs";
import {VisibilityEnum} from "../../common/enums/visibility.enum";
import {CertificateRo} from "../../common/model/certificate-ro.model";
import {GlobalLookups} from "../../common/global-lookups";
@Component({
......@@ -75,6 +76,7 @@ export class AdminDomainComponent implements OnInit, OnDestroy, AfterViewInit, B
constructor(private domainService: AdminDomainService,
private keystoreService: AdminKeystoreService,
private extensionService: ExtensionService,
protected lookups: GlobalLookups,
private alertService: AlertMessageService,
private dialog: MatDialog) {
......@@ -331,8 +333,15 @@ export class AdminDomainComponent implements OnInit, OnDestroy, AfterViewInit, B
return false;
}
/**
* Method checks if domain entity is set and domainId does not exists.
* @return true if domain is set and domainId does not exists otherwise false
*/
isNewDomain(): boolean {
return this.selected != null && !this.selected.domainId
if (!this.selected) {
return false;
}
return !this.selected.domainId
}
......@@ -351,8 +360,25 @@ export class AdminDomainComponent implements OnInit, OnDestroy, AfterViewInit, B
}
}
/**
* The domain can not be deleted if it is not selected or it is registered in the SML
* or it is new domain
*/
get canNotDelete(): boolean {
return !this.selected || this.domainSmlIntegrationPanelComponent?.isDomainRegistered || this.isNewDomain()
return !this.selected || this.isNewDomain() || this.isSelectedSMPRegister ;
}
/**
* Method returns true if the SML integration is enabled and the domain is registered
*
*/
get isSelectedSMPRegister(): boolean {
return this.isSMLIntegrationEnabled && this.selected?.smlRegistered;
}
get isSMLIntegrationEnabled() {
return !!this.lookups.cachedApplicationConfig?.smlIntegrationOn
}
get editMode(): boolean {
......
......@@ -39,8 +39,17 @@ export class DomainResourceTypePanelComponent implements BeforeLeaveGuard {
});
}
/**
* If domain is not set, the event is ignored
* else it updates the resource definitions and emtis
* "onSave event"
*/
onSaveClicked() {
this.onSaveResourceTypesEvent.emit(this.domain);
if (!this._domain){
return
}
this._domain.resourceDefinitions = this.domainForm.controls['resourceDefinitions'].value;
this.onSaveResourceTypesEvent.emit(this._domain);
}
......
......@@ -175,12 +175,12 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
return false;
}
// entity must be first persisted in order to be enabled to registering to SML
// entity must be first persisted in order to be enabled to register to SML
return this.isDomainRegistered;
}
get isDomainRegistered():boolean {
return this._domain?.smlRegistered;
return !!this._domain?.smlRegistered;
}
......@@ -270,8 +270,5 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
this.alertService.exception('Error occurred while unregistering domain:' + domain.domainCode, err);
}
)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment