mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
WIP
This commit is contained in:
@@ -55,7 +55,11 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
|||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot
|
||||||
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
): 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();
|
return this.redirectSSOSuccessURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -100,6 +100,7 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee
|
|||||||
}
|
}
|
||||||
|
|
||||||
getToken(): string {
|
getToken(): string {
|
||||||
|
debugger;
|
||||||
if (this.isOauth()) {
|
if (this.isOauth()) {
|
||||||
return this.oidcAuthenticationService.getToken();
|
return this.oidcAuthenticationService.getToken();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -15,7 +15,13 @@
|
|||||||
* limitations under the License.
|
* 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({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -24,6 +30,7 @@ export class StorageService {
|
|||||||
private memoryStore: { [key: string]: any } = {};
|
private memoryStore: { [key: string]: any } = {};
|
||||||
private readonly useLocalStorage: boolean = false;
|
private readonly useLocalStorage: boolean = false;
|
||||||
private _prefix: string = '';
|
private _prefix: string = '';
|
||||||
|
private storage?: Storage;
|
||||||
|
|
||||||
get prefix() {
|
get prefix() {
|
||||||
return this._prefix;
|
return this._prefix;
|
||||||
@@ -33,8 +40,28 @@ export class StorageService {
|
|||||||
this._prefix = prefix ? prefix + '_' : '';
|
this._prefix = prefix ? prefix + '_' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
this.useLocalStorage = this.storageAvailable('localStorage');
|
@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 {
|
getItem(key: string): string | null {
|
||||||
if (this.useLocalStorage) {
|
if (this.useLocalStorage) {
|
||||||
return localStorage.getItem(this.prefix + key);
|
return this.storage.getItem(this.prefix + key);
|
||||||
} else {
|
} else {
|
||||||
return Object.prototype.hasOwnProperty.call(this.memoryStore, this.prefix + key) ? this.memoryStore[this.prefix + key] : null;
|
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) {
|
setItem(key: string, data: string) {
|
||||||
if (this.useLocalStorage) {
|
if (this.useLocalStorage) {
|
||||||
localStorage.setItem(this.prefix + key, data);
|
this.storage.setItem(this.prefix + key, data);
|
||||||
} else {
|
} else {
|
||||||
this.memoryStore[this.prefix + key] = data.toString();
|
this.memoryStore[this.prefix + key] = data.toString();
|
||||||
}
|
}
|
||||||
@@ -68,7 +95,7 @@ export class StorageService {
|
|||||||
/** Removes all currently stored items. */
|
/** Removes all currently stored items. */
|
||||||
clear() {
|
clear() {
|
||||||
if (this.useLocalStorage) {
|
if (this.useLocalStorage) {
|
||||||
localStorage.clear();
|
this.storage.clear();
|
||||||
} else {
|
} else {
|
||||||
this.memoryStore = {};
|
this.memoryStore = {};
|
||||||
}
|
}
|
||||||
@@ -81,7 +108,7 @@ export class StorageService {
|
|||||||
*/
|
*/
|
||||||
removeItem(key: string) {
|
removeItem(key: string) {
|
||||||
if (this.useLocalStorage) {
|
if (this.useLocalStorage) {
|
||||||
localStorage.removeItem(`${this.prefix}` + key);
|
this.storage.removeItem(`${this.prefix}` + key);
|
||||||
} else {
|
} else {
|
||||||
delete this.memoryStore[this.prefix + key];
|
delete this.memoryStore[this.prefix + key];
|
||||||
}
|
}
|
||||||
@@ -95,7 +122,7 @@ export class StorageService {
|
|||||||
*/
|
*/
|
||||||
hasItem(key: string): boolean {
|
hasItem(key: string): boolean {
|
||||||
if (this.useLocalStorage) {
|
if (this.useLocalStorage) {
|
||||||
return !!localStorage.getItem(this.prefix + key);
|
return !!this.storage.getItem(this.prefix + key);
|
||||||
} else {
|
} else {
|
||||||
return Object.prototype.hasOwnProperty.call(this.memoryStore, key);
|
return Object.prototype.hasOwnProperty.call(this.memoryStore, key);
|
||||||
}
|
}
|
||||||
|
@@ -114,6 +114,7 @@ export class UserPreferencesService {
|
|||||||
* @param value New value for the property
|
* @param value New value for the property
|
||||||
*/
|
*/
|
||||||
set(property: string, value: any) {
|
set(property: string, value: any) {
|
||||||
|
console.trace();
|
||||||
if (!property) {
|
if (!property) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -132,6 +133,7 @@ export class UserPreferencesService {
|
|||||||
* @param value New value for the property
|
* @param value New value for the property
|
||||||
*/
|
*/
|
||||||
setWithoutStore(property: string, value: any) {
|
setWithoutStore(property: string, value: any) {
|
||||||
|
// debugger;
|
||||||
if (!property) {
|
if (!property) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -38,8 +38,10 @@ export class TimeAgoPipe implements PipeTransform, OnDestroy {
|
|||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(public userPreferenceService: UserPreferencesService,
|
constructor(
|
||||||
public appConfig: AppConfigService) {
|
public userPreferenceService: UserPreferencesService,
|
||||||
|
public appConfig: AppConfigService
|
||||||
|
) {
|
||||||
this.userPreferenceService
|
this.userPreferenceService
|
||||||
.select(UserPreferenceValues.Locale)
|
.select(UserPreferenceValues.Locale)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
|
@@ -375,6 +375,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
}
|
}
|
||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,8 +397,10 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
|
|
||||||
private refreshFormData() {
|
private refreshFormData() {
|
||||||
this.form = this.parseForm(this.formCloudRepresentationJSON);
|
this.form = this.parseForm(this.formCloudRepresentationJSON);
|
||||||
this.onFormLoaded(this.form);
|
if (this.form) {
|
||||||
this.onFormDataRefreshed(this.form);
|
this.onFormLoaded(this.form);
|
||||||
|
this.onFormDataRefreshed(this.form);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onFormLoaded(form: FormModel) {
|
protected onFormLoaded(form: FormModel) {
|
||||||
|
Reference in New Issue
Block a user