Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/olt-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@outerlimitstech/ngx-app-core",
"version": "15.1.2",
"version": "15.1.6",
"description": "Common Angular components, models, etc. for OuterLimits Technologies applications",
"bugs": "https://github.com/OuterlimitsTech/olt-angular-libraries/issues",
"homepage": "https://github.com/OuterlimitsTech/olt-angular-libraries#readme",
Expand Down
30 changes: 27 additions & 3 deletions projects/olt-core/src/lib/directives/int-entry.directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
import { ElementRef, forwardRef, Directive, HostListener } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { OltUtility } from '../utilities/utility';
import { ElementRef, Directive, HostListener, EventEmitter, Output } from '@angular/core';

// https://dev.to/dilika/restrict-angular-input-to-number-only-4o4k

@Directive({
selector: 'input[oltIntEntry]'
})
export class IntEntryDirective {

@Output() valueChange = new EventEmitter()

constructor(private elementRef: ElementRef) {
}

@HostListener('input', ['$event']) onInputChange(event: any) {
const initalValue = this.elementRef.nativeElement.value;
const newValue = initalValue.replace(/[^0-9]*/g, '');
this.elementRef.nativeElement.value = newValue;
this.valueChange.emit(newValue);
if (initalValue !== this.elementRef.nativeElement.value) {
event.stopPropagation();
}
}

}

/* Old Directive
const noop = () => { };

const clean = (value: string | null) => {
Expand Down Expand Up @@ -78,3 +101,4 @@ export class IntEntryDirective {
this.disabled = isDisabled;
}
}
*/
18 changes: 18 additions & 0 deletions projects/olt-core/src/lib/interfaces/app-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface IOltAppSettings {
hosts: IOltAppSettingHost[];
}

export interface IOltAppSettingHost {
host: string;
apiEndpoint: string;
environment: string;
production: boolean;
}

export interface IOltAppSettingResult<T> {
served: boolean;
withError: boolean | null
settings: T | null;
}


1 change: 1 addition & 0 deletions projects/olt-core/src/lib/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './address.interface';
export * from './api-param.interface';
export * from './app-settings';
export * from './auth-service.interface';
export * from './broadcast-message.interface';
export * from './cache-content.interface';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import { PersonName } from './person-name.model';
export class AuthenticatedUser {
userPrincipalName!: string;
name!: PersonName;

tokenType!: string;
/**
* @deprecated Move to tokenType
*/
authenticationType!: string;

token!: string;
issued!: string;
expires!: string;
expiresIn!: string;
roles!: string[];
permissions!: string[];
/**
* @deprecated No longer used
*/
otherClaims?: any;
username!: string;
email!: string;
Expand Down Expand Up @@ -46,7 +55,8 @@ export class AuthenticatedUser {

constructor(data?: any) {
this.userPrincipalName = data?.userPrincipalName;
this.authenticationType = data?.authenticationType || data?.token_type || 'Bearer';
this.authenticationType = data?.authenticationType || data?.tokenType || data?.token_type || 'Bearer';
this.tokenType = data?.tokenType || data?.token_type || data?.authenticationType || 'Bearer';
this.token = data?.token || data?.access_token;
this.issued = data?.issued;
this.expires = data?.expires;
Expand Down
50 changes: 50 additions & 0 deletions projects/olt-core/src/lib/services/app-setting.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { HttpClient } from "@angular/common/http";
import { BehaviorSubject, Observable, catchError, map, of } from "rxjs";
import { IOltAppSettingResult } from "../interfaces/app-settings";
import { OltHelperService } from "./helper.service";


export abstract class OltAppSettingsServiceBase<T> {
private config = new BehaviorSubject<IOltAppSettingResult<T> | null>(null); //this.FALL_BACK_SETTINGS
protected static _appSettings: IOltAppSettingResult<any>;

constructor(
protected helperService: OltHelperService,
protected http: HttpClient
) { }

get settings(): T {
return OltAppSettingsServiceBase._appSettings?.settings;
}
abstract get FALL_BACK_SETTINGS(): IOltAppSettingResult<T>;
abstract get settingsURL(): string;

appSetting$: Observable<IOltAppSettingResult<T> | null> = this.config.asObservable();

private _createConfig(appSettings: IOltAppSettingResult<T>, withError: boolean): void {
const _config = { ...this.FALL_BACK_SETTINGS, ...appSettings };
_config.served = appSettings.served;
_config.withError = withError;
OltAppSettingsServiceBase._appSettings = _config;
console.log('_createConfig', _config);
this.config.next(appSettings);
}

loadAppConfig(): Observable<boolean> {
const url = this.helperService.resolveUrl(this.settingsURL);
return this.http.get<IOltAppSettingResult<T>>(url).pipe(
map((response) => {
this._createConfig(response, false);
return true;
}),
catchError((error) => {
// if in error, return set fall back from environment
this._createConfig(this.FALL_BACK_SETTINGS, true);
console.error(error);
return of(false);
})
);
}


}
2 changes: 1 addition & 1 deletion projects/olt-core/src/lib/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './api.service';
export * from './app-setting.service';
export * from './auth.service';
export * from './cache.service';
export * from './config.service';
export * from './error.service';
export * from './helper.service';
// export * from './modal.service';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, forwardRef } from '@angular/core';
import { AbstractControl, ControlValueAccessor, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
import { OltUtility } from '@outerlimitstech/ngx-app-core';

@Component({
Expand All @@ -11,7 +11,12 @@ import { OltUtility } from '@outerlimitstech/ngx-app-core';
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => DateTimePickerComponent),
multi: true
}
},
{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => DateTimePickerComponent),
multi: true,
}
]
})
export class DateTimePickerComponent implements ControlValueAccessor, Validator {
Expand Down
2 changes: 1 addition & 1 deletion projects/olt-ngx-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@outerlimitstech/ngx-bootstrap",
"version": "15.1.2",
"version": "15.1.6",
"description": "Components that utilize ngx-bootstrap for OuterLimits Technologies applications",
"bugs": "https://github.com/OuterlimitsTech/olt-angular-libraries/issues",
"homepage": "https://github.com/OuterlimitsTech/olt-angular-libraries#readme",
Expand Down