Remove injection for environment variables
MODIFY
src/app/app.module.ts
src/app/app.module.ts
@@ -103,18 +103,6 @@ import {TokenService} from './services/token.service';
useFactory: initializer,
multi: true,
deps: [KeycloakService, TokenService]
- },
- {
- provide: 'API_MGMT_UI_REST_URL',
- useValue: environment.apiMgmtUiRestUrl
- },
- {
- provide: 'KEYCLOAK_AUTH_URL',
- useValue: environment.keycloakAuthUrl
- },
- {
- provide: 'API_MGTM_REALM',
- useValue: environment.apiMgmtRealm
}
],
bootstrap: [AppComponent]

MODIFY
src/app/components/admin/services/admin.service.ts
src/app/components/admin/services/admin.service.ts
* limitations under the License.
*/
-import {Inject, Injectable} from '@angular/core';
import {from, Observable, of} from 'rxjs';
import {mergeMap} from 'rxjs/operators';
import {ClientSearchResult, Developer} from '../../../services/api-data.service';
import {HttpClient} from '@angular/common/http';
import {KeycloakInteractionService} from './keycloak-interaction.service';
+import {environment} from '../../../../environments/environment';
-@Injectable({
- providedIn: 'root'
-})
export class AdminService {
+ private apiMgmtUiRestUrl: string = environment.apiMgmtUiRestUrl;
+
/**
* Constructor of Admin Service
* @param http Http Client
@@ -33,8 +32,7 @@ export class AdminService {
* @param apiMgmtUiRestUrl Api Management UI REST Url
*/
constructor(private http: HttpClient,
- private keycloak: KeycloakInteractionService, @Inject('API_MGMT_UI_REST_URL')
- private apiMgmtUiRestUrl: string) {
+ private keycloak: KeycloakInteractionService) {
}
/**

MODIFY
src/app/components/admin/services/keycloak-interaction.service.ts
src/app/components/admin/services/keycloak-interaction.service.ts
* limitations under the License.
*/
-import {Inject, Injectable} from '@angular/core';
import {KeycloakService} from 'keycloak-angular';
import KcAdminClient from 'keycloak-admin';
import {TokenService} from '../../../services/token.service';
import UserRepresentation from 'keycloak-admin/lib/defs/userRepresentation';
import GroupRepresentation from 'keycloak-admin/lib/defs/groupRepresentation';
+import {environment} from '../../../../environments/environment';
-@Injectable({
- providedIn: 'root'
-})
export class KeycloakInteractionService {
private kcAdminClient: KcAdminClient;
-
/**
* Constructor of Keycloak Interaction Service
* @param keycloak the keycloak service
* @param keycloakRestUrl the keycloak rest url
*/
constructor(private keycloak: KeycloakService,
- private tokenService: TokenService,
- @Inject('KEYCLOAK_AUTH_URL') private keycloakRestUrl: string,
- @Inject('API_MGTM_REALM') private apiMgmtRealm: string) {
+ private tokenService: TokenService) {
this.kcAdminClient = new KcAdminClient({
- baseUrl: this.keycloakRestUrl,
- realmName: this.apiMgmtRealm
+ baseUrl: environment.keycloakAuthUrl,
+ realmName: environment.apiMgmtRealm,
});
// set initial token
const token = keycloak.getKeycloakInstance().token;

MODIFY
src/app/components/developer/api-list/api-list.component.ts
src/app/components/developer/api-list/api-list.component.ts
* limitations under the License.
*/
-import {Component, Inject, OnInit} from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {forkJoin, from, Observable, Subject} from 'rxjs';
import {concatMap, map, mergeAll, mergeMap, switchMap, toArray} from 'rxjs/operators';
import {ApiDataService, ApiVersion, Client, Contract} from '../../../services/api-data.service';
@@ -25,6 +25,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations';
import {Sort} from '@angular/material/sort';
import {KeycloakService} from 'keycloak-angular';
import {formatDate} from '@angular/common';
+import {environment} from '../../../../environments/environment';
export interface ApiListElement {
id: string;
@@ -72,6 +73,8 @@ class GatewayEndpoint {
export class ApiListComponent implements OnInit {
+ private apiMgmtUiRestUrl: string = environment.apiMgmtUiRestUrl;
+
columnHeaders: string[] = ['api', 'publicAPI', 'apiVersion', 'tryApi', 'options'];
expandedElements: Array<ApiListElement> = [];
@@ -94,8 +97,7 @@ export class ApiListComponent implements OnInit {
private apiDataService: ApiDataService,
private toasterService: ToasterService,
private loadingSpinnerService: SpinnerService,
- private keycloak: KeycloakService,
- @Inject('API_MGMT_UI_REST_URL') private apiMgmtUiRestUrl: string) {
+ private keycloak: KeycloakService) {
}
/**

MODIFY
src/app/components/swagger/swagger.component.ts
src/app/components/swagger/swagger.component.ts
* limitations under the License.
*/
-import {Component, Inject, OnInit} from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
+import {environment} from '../../../environments/environment';
declare const SwaggerUIBundle: any;
@@ -26,7 +27,10 @@ declare const SwaggerUIBundle: any;
})
export class SwaggerComponent implements OnInit {
- constructor(@Inject('API_MGMT_UI_REST_URL') private apiMgmtUiRestUrl: string, private route: ActivatedRoute) { }
+ private apiMgmtUiRestUrl: string = environment.apiMgmtUiRestUrl;
+
+ constructor(private route: ActivatedRoute) {
+ }
/**
* Load the swagger definition and display it with the swagger ui bundle library on component initialization

MODIFY
src/app/services/api-data.service.spec.ts
src/app/services/api-data.service.spec.ts
@@ -26,7 +26,6 @@ describe('ApiDataService', () => {
beforeEach(() => TestBed.configureTestingModule({
providers: [
{ provide: HttpClient, useValue: httpClient},
- { provide: 'API_MGMT_UI_REST_URL', useValue: 'https://dummyURL.com/apiman' }
]
}));

MODIFY
src/app/services/api-data.service.ts
src/app/services/api-data.service.ts
* limitations under the License.
*/
-import {Inject, Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
+import {environment} from '../../environments/environment';
/**
* Api Version
@@ -174,21 +174,20 @@ export interface GatewayEndpoint {
endpoint: string;
}
-@Injectable({
- providedIn: 'root'
-})
/**
* A service which executes the REST calls to Api Mgmt UI REST Interface
*/
export class ApiDataService {
+ private apiMgmtUiRestUrl: string = environment.apiMgmtUiRestUrl;
+
/**
* Constructor
* @param http The http client
* @param apiMgmtUiRestUrl The Api Mgmt UI REST url
*/
- constructor(private http: HttpClient, @Inject('API_MGMT_UI_REST_URL') private apiMgmtUiRestUrl: string) {
+ constructor(private http: HttpClient) {
}
/**

Remove injection for environment variables