mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3910] Expose the identityHost as part of the setting component (#4161)
This commit is contained in:
committed by
Eugenio Romano
parent
a49cd76fcb
commit
28da31c550
@@ -29,6 +29,7 @@ export enum AppConfigValues {
|
|||||||
ECMHOST = 'ecmHost',
|
ECMHOST = 'ecmHost',
|
||||||
BASESHAREURL = 'baseShareUrl',
|
BASESHAREURL = 'baseShareUrl',
|
||||||
BPMHOST = 'bpmHost',
|
BPMHOST = 'bpmHost',
|
||||||
|
IDENTITY_HOST = 'identityHost',
|
||||||
AUTHTYPE = 'authType',
|
AUTHTYPE = 'authType',
|
||||||
CONTEXTROOTECM = 'contextRootEcm',
|
CONTEXTROOTECM = 'contextRootEcm',
|
||||||
CONTEXTROOTBPM = 'contextRootBpm',
|
CONTEXTROOTBPM = 'contextRootBpm',
|
||||||
|
@@ -53,6 +53,17 @@
|
|||||||
{{ 'CORE.HOST_SETTINGS.REQUIRED'| translate }}
|
{{ 'CORE.HOST_SETTINGS.REQUIRED'| translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<mat-form-field *ngIf="hasIdentity" class="adf-full-width" floatLabel="Identity Host">
|
||||||
|
<mat-label>Identity Host</mat-label>
|
||||||
|
<input matInput name="identityHost" id="identityHost" formControlName="identityHost"
|
||||||
|
placeholder="http(s)://host|ip:port(/path)">
|
||||||
|
<mat-error *ngIf="identityHost.hasError('pattern')">
|
||||||
|
{{ 'CORE.HOST_SETTINGS.NOT_VALID'| translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="identityHost.hasError('required')">
|
||||||
|
{{ 'CORE.HOST_SETTINGS.REQUIRED'| translate }}
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
@@ -99,6 +99,7 @@ describe('HostSettingsComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appConfigService.config.providers = 'BPM';
|
appConfigService.config.providers = 'BPM';
|
||||||
|
appConfigService.config.authType = 'BASIC';
|
||||||
appConfigService.load();
|
appConfigService.load();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
bpmUrlInput = element.querySelector('#bpmHost');
|
bpmUrlInput = element.querySelector('#bpmHost');
|
||||||
@@ -152,6 +153,7 @@ describe('HostSettingsComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appConfigService.config.providers = 'ECM';
|
appConfigService.config.providers = 'ECM';
|
||||||
|
appConfigService.config.authType = 'BASIC';
|
||||||
appConfigService.load();
|
appConfigService.load();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
bpmUrlInput = element.querySelector('#bpmHost');
|
bpmUrlInput = element.querySelector('#bpmHost');
|
||||||
@@ -200,6 +202,7 @@ describe('HostSettingsComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appConfigService.config.providers = 'ALL';
|
appConfigService.config.providers = 'ALL';
|
||||||
|
appConfigService.config.authType = 'BASIC';
|
||||||
appConfigService.load();
|
appConfigService.load();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
bpmUrlInput = element.querySelector('#bpmHost');
|
bpmUrlInput = element.querySelector('#bpmHost');
|
||||||
@@ -270,10 +273,12 @@ describe('HostSettingsComponent', () => {
|
|||||||
|
|
||||||
let bpmUrlInput;
|
let bpmUrlInput;
|
||||||
let ecmUrlInput;
|
let ecmUrlInput;
|
||||||
|
let identityUrlInput;
|
||||||
let oauthHostUrlInput;
|
let oauthHostUrlInput;
|
||||||
let clientIdInput;
|
let clientIdInput;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
appConfigService.config.identityHost = 'http://localhost:123';
|
||||||
appConfigService.config.providers = 'ALL';
|
appConfigService.config.providers = 'ALL';
|
||||||
appConfigService.config.authType = 'OAUTH';
|
appConfigService.config.authType = 'OAUTH';
|
||||||
appConfigService.config.oauth2 = {
|
appConfigService.config.oauth2 = {
|
||||||
@@ -289,6 +294,7 @@ describe('HostSettingsComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
bpmUrlInput = element.querySelector('#bpmHost');
|
bpmUrlInput = element.querySelector('#bpmHost');
|
||||||
ecmUrlInput = element.querySelector('#ecmHost');
|
ecmUrlInput = element.querySelector('#ecmHost');
|
||||||
|
identityUrlInput = element.querySelector('#identityHost');
|
||||||
oauthHostUrlInput = element.querySelector('#oauthHost');
|
oauthHostUrlInput = element.querySelector('#oauthHost');
|
||||||
clientIdInput = element.querySelector('#clientId');
|
clientIdInput = element.querySelector('#clientId');
|
||||||
});
|
});
|
||||||
@@ -300,6 +306,7 @@ describe('HostSettingsComponent', () => {
|
|||||||
it('should have a valid form when the urls are correct', (done) => {
|
it('should have a valid form when the urls are correct', (done) => {
|
||||||
const urlBpm = 'http://localhost:9999/bpm';
|
const urlBpm = 'http://localhost:9999/bpm';
|
||||||
const urlEcm = 'http://localhost:9999/bpm';
|
const urlEcm = 'http://localhost:9999/bpm';
|
||||||
|
const urlIdentity = 'http://localhost:9999/identity';
|
||||||
|
|
||||||
component.form.statusChanges.subscribe((status: string) => {
|
component.form.statusChanges.subscribe((status: string) => {
|
||||||
expect(status).toEqual('VALID');
|
expect(status).toEqual('VALID');
|
||||||
@@ -311,6 +318,9 @@ describe('HostSettingsComponent', () => {
|
|||||||
|
|
||||||
bpmUrlInput.value = urlBpm;
|
bpmUrlInput.value = urlBpm;
|
||||||
bpmUrlInput.dispatchEvent(new Event('input'));
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
||||||
|
|
||||||
|
identityUrlInput.value = urlIdentity;
|
||||||
|
identityUrlInput.dispatchEvent(new Event('input'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an invalid form when the url inserted is wrong', (done) => {
|
it('should have an invalid form when the url inserted is wrong', (done) => {
|
||||||
@@ -326,6 +336,19 @@ describe('HostSettingsComponent', () => {
|
|||||||
bpmUrlInput.dispatchEvent(new Event('input'));
|
bpmUrlInput.dispatchEvent(new Event('input'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should have an invalid form when the identity url inserted is wrong', (done) => {
|
||||||
|
const url = 'wrong';
|
||||||
|
|
||||||
|
component.form.statusChanges.subscribe((status: string) => {
|
||||||
|
expect(status).toEqual('INVALID');
|
||||||
|
expect(component.identityHost.hasError('pattern')).toBeTruthy();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
identityUrlInput.value = url;
|
||||||
|
identityUrlInput.dispatchEvent(new Event('input'));
|
||||||
|
});
|
||||||
|
|
||||||
it('should have an invalid form when the host is wrong', (done) => {
|
it('should have an invalid form when the host is wrong', (done) => {
|
||||||
const hostUrl = 'wrong';
|
const hostUrl = 'wrong';
|
||||||
|
|
||||||
|
@@ -43,6 +43,7 @@ export class HostSettingsComponent implements OnInit {
|
|||||||
providers: string[] = ['BPM', 'ECM', 'ALL'];
|
providers: string[] = ['BPM', 'ECM', 'ALL'];
|
||||||
|
|
||||||
showSelectProviders = true;
|
showSelectProviders = true;
|
||||||
|
hasIdentity = false;
|
||||||
|
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
|
|
||||||
@@ -101,11 +102,14 @@ export class HostSettingsComponent implements OnInit {
|
|||||||
private removeFormGroups() {
|
private removeFormGroups() {
|
||||||
this.form.removeControl('bpmHost');
|
this.form.removeControl('bpmHost');
|
||||||
this.form.removeControl('ecmHost');
|
this.form.removeControl('ecmHost');
|
||||||
|
this.form.removeControl('identityHost');
|
||||||
|
this.hasIdentity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private addFormGroups() {
|
private addFormGroups() {
|
||||||
this.addBPMFormControl();
|
this.addBPMFormControl();
|
||||||
this.addECMFormControl();
|
this.addECMFormControl();
|
||||||
|
this.addIdentityHostFormControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private addOAuthFormGroup() {
|
private addOAuthFormGroup() {
|
||||||
@@ -120,6 +124,14 @@ export class HostSettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private addIdentityHostFormControl() {
|
||||||
|
if ((this.isOAUTH()) && !this.identityHost) {
|
||||||
|
const identityHostFormControl = this.createIdentityFormControl();
|
||||||
|
this.form.addControl('identityHost', identityHostFormControl);
|
||||||
|
this.hasIdentity = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private addECMFormControl() {
|
private addECMFormControl() {
|
||||||
if ((this.isECM() || this.isALL()) && !this.ecmHost) {
|
if ((this.isECM() || this.isALL()) && !this.ecmHost) {
|
||||||
const ecmFormControl = this.createECMFormControl();
|
const ecmFormControl = this.createECMFormControl();
|
||||||
@@ -146,6 +158,10 @@ export class HostSettingsComponent implements OnInit {
|
|||||||
return new FormControl(this.appConfig.get<string>(AppConfigValues.BPMHOST), [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
return new FormControl(this.appConfig.get<string>(AppConfigValues.BPMHOST), [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private createIdentityFormControl(): AbstractControl {
|
||||||
|
return new FormControl(this.appConfig.get<string>(AppConfigValues.IDENTITY_HOST), [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
||||||
|
}
|
||||||
|
|
||||||
private createECMFormControl(): AbstractControl {
|
private createECMFormControl(): AbstractControl {
|
||||||
return new FormControl(this.appConfig.get<string>(AppConfigValues.ECMHOST), [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
return new FormControl(this.appConfig.get<string>(AppConfigValues.ECMHOST), [Validators.required, Validators.pattern(this.HOST_REGEX)]);
|
||||||
}
|
}
|
||||||
@@ -179,6 +195,7 @@ export class HostSettingsComponent implements OnInit {
|
|||||||
|
|
||||||
private saveOAuthValues(values: any) {
|
private saveOAuthValues(values: any) {
|
||||||
this.storageService.setItem(AppConfigValues.OAUTHCONFIG, JSON.stringify(values.oauthConfig));
|
this.storageService.setItem(AppConfigValues.OAUTHCONFIG, JSON.stringify(values.oauthConfig));
|
||||||
|
this.storageService.setItem(AppConfigValues.IDENTITY_HOST, values.identityHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
private saveBPMValues(values: any) {
|
private saveBPMValues(values: any) {
|
||||||
@@ -221,6 +238,10 @@ export class HostSettingsComponent implements OnInit {
|
|||||||
return this.oauthConfig.get('host');
|
return this.oauthConfig.get('host');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identityHost(): AbstractControl {
|
||||||
|
return this.form.get('identityHost');
|
||||||
|
}
|
||||||
|
|
||||||
get clientId(): AbstractControl {
|
get clientId(): AbstractControl {
|
||||||
return this.oauthConfig.get('clientId');
|
return this.oauthConfig.get('clientId');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user