Compare commits

...
Author SHA1 Message Date
Bartosz Sekula 9832975a58 tmp 2024-04-09 16:09:34 +02:00
Bartosz Sekula 47a21b1787 WIP 2024-04-09 16:09:34 +02:00
8 changed files with 62 additions and 16 deletions
@@ -55,7 +55,11 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if (this.authenticationService.isLoggedIn() && this.authenticationService.isOauth() && this.isLoginFragmentPresent()) {
if (
this.authenticationService.isLoggedIn() &&
this.authenticationService.isOauth() &&
this.isLoginFragmentPresent()
) {
return this.redirectSSOSuccessURL();
}
@@ -100,6 +100,7 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee
}
getToken(): string {
debugger;
if (this.isOauth()) {
return this.oidcAuthenticationService.getToken();
} else {
@@ -15,7 +15,13 @@
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
export interface StorageServiceSettings {
storageType?: 'localStorage' | 'sessionStorage' | 'memoryStorage';
}
export const STORAGE_SERVICE_SETTINGS = new InjectionToken('STORAGE_SERVICE_SETTINGS');
@Injectable({
providedIn: 'root'
@@ -24,6 +30,7 @@ export class StorageService {
private memoryStore: { [key: string]: any } = {};
private readonly useLocalStorage: boolean = false;
private _prefix: string = '';
private storage?: Storage;
get prefix() {
return this._prefix;
@@ -33,8 +40,28 @@ export class StorageService {
this._prefix = prefix ? prefix + '_' : '';
}
constructor() {
this.useLocalStorage = this.storageAvailable('localStorage');
constructor(
@Optional()
@Inject(STORAGE_SERVICE_SETTINGS) private settings?: StorageServiceSettings
) {
if (this.settings) {
debugger;
switch (this.settings.storageType) {
case 'sessionStorage':
this.useLocalStorage = this.storageAvailable(this.settings.storageType);
this.storage = window['sessionStorage'];
break;
case 'memoryStorage':
this.useLocalStorage = false;
break;
default:
this.useLocalStorage = this.storageAvailable(this.settings.storageType);
this.storage = window['localStorage'];
}
} else {
this.useLocalStorage = this.storageAvailable('localStorage');
this.storage = window['localStorage'];
}
}
/**
@@ -45,7 +72,7 @@ export class StorageService {
*/
getItem(key: string): string | null {
if (this.useLocalStorage) {
return localStorage.getItem(this.prefix + key);
return this.storage.getItem(this.prefix + key);
} else {
return Object.prototype.hasOwnProperty.call(this.memoryStore, this.prefix + key) ? this.memoryStore[this.prefix + key] : null;
}
@@ -59,7 +86,7 @@ export class StorageService {
*/
setItem(key: string, data: string) {
if (this.useLocalStorage) {
localStorage.setItem(this.prefix + key, data);
this.storage.setItem(this.prefix + key, data);
} else {
this.memoryStore[this.prefix + key] = data.toString();
}
@@ -68,7 +95,7 @@ export class StorageService {
/** Removes all currently stored items. */
clear() {
if (this.useLocalStorage) {
localStorage.clear();
this.storage.clear();
} else {
this.memoryStore = {};
}
@@ -81,7 +108,7 @@ export class StorageService {
*/
removeItem(key: string) {
if (this.useLocalStorage) {
localStorage.removeItem(`${this.prefix}` + key);
this.storage.removeItem(`${this.prefix}` + key);
} else {
delete this.memoryStore[this.prefix + key];
}
@@ -95,7 +122,7 @@ export class StorageService {
*/
hasItem(key: string): boolean {
if (this.useLocalStorage) {
return !!localStorage.getItem(this.prefix + key);
return !!this.storage.getItem(this.prefix + key);
} else {
return Object.prototype.hasOwnProperty.call(this.memoryStore, key);
}
@@ -114,6 +114,7 @@ export class UserPreferencesService {
* @param value New value for the property
*/
set(property: string, value: any) {
console.trace();
if (!property) {
return;
}
@@ -132,6 +133,7 @@ export class UserPreferencesService {
* @param value New value for the property
*/
setWithoutStore(property: string, value: any) {
// debugger;
if (!property) {
return;
}
+4 -2
View File
@@ -38,8 +38,10 @@ export class TimeAgoPipe implements PipeTransform, OnDestroy {
private onDestroy$ = new Subject<boolean>();
constructor(public userPreferenceService: UserPreferencesService,
public appConfig: AppConfigService) {
constructor(
public userPreferenceService: UserPreferencesService,
public appConfig: AppConfigService
) {
this.userPreferenceService
.select(UserPreferenceValues.Locale)
.pipe(takeUntil(this.onDestroy$))
@@ -375,6 +375,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
}
return form;
}
return null;
}
@@ -396,8 +397,10 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
private refreshFormData() {
this.form = this.parseForm(this.formCloudRepresentationJSON);
this.onFormLoaded(this.form);
this.onFormDataRefreshed(this.form);
if (this.form) {
this.onFormLoaded(this.form);
this.onFormDataRefreshed(this.form);
}
}
protected onFormLoaded(form: FormModel) {
@@ -100,10 +100,12 @@
<ng-template #taskFormCloudButtons>
<div class="adf-start-process-cloud-actions">
<button
*ngIf="showCancelButton"
mat-button
(click)="cancelStartProcess()"
id="cancel_process">
{{ 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.ACTION.CANCEL' | translate | uppercase}}
id="cancel_process"
>
{{ 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.ACTION.CANCEL' | translate | uppercase}}
</button>
<button
color="primary"
@@ -112,7 +114,8 @@
(click)="startProcess()"
data-automation-id="btn-start"
id="button-start"
class="adf-btn-start">
class="adf-btn-start"
>
{{'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.ACTION.START' | translate | uppercase}}
</button>
</div>
@@ -86,6 +86,10 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
@Input()
showTitle: boolean = true;
/** Show/hide cancel button. */
@Input()
showCancelButton: boolean = true;
/** Emitted when the process is successfully started. */
@Output()
success = new EventEmitter<ProcessInstanceCloud>();