fixed URL for JHipster REST API

This commit is contained in:
Maria Teresa Paratore 2023-12-11 15:48:15 +01:00
parent a64bfc97dc
commit 90c432b18f
5 changed files with 20 additions and 24 deletions

View File

@ -1,5 +0,0 @@
export class appProperties {
public static BASEURL_API = "http://localhost:8081/api/";
//public static BASEURL_API = "http://localhost:8080/api/";
}

View File

@ -2,8 +2,7 @@
<div [ngSwitch]="account !== null"> <div [ngSwitch]="account !== null">
<div *ngSwitchCase="true"> <div *ngSwitchCase="true">
<div class="alert alert-success"> <div class="alert alert-success">
<h3 id="home-logged-message" *ngIf="account" jhiTranslate="home.logged.message" <h3 id="home-logged-message" *ngIf="account">You are logged in as user "{{account.login}}"</h3>
[translateValues]="{ username: account.login }">You are logged in as user "{{account.login}}"</h3>
</div> </div>
<div *ngIf="isLoading" class="loader-container"> <div *ngIf="isLoading" class="loader-container">

View File

@ -3,8 +3,8 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { appProperties } from 'app/config/app-properties';
import { IContextNode } from './i-context-node'; import { IContextNode } from './i-context-node';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -15,11 +15,13 @@ export class ContextsLoaderService {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }), headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
}; };
constructor(private http: HttpClient) {} constructor(private http: HttpClient, private applicationConfigService: ApplicationConfigService) {}
fetchAll(): Observable<IContextNode[]> { fetchAll(): Observable<IContextNode[]> {
return this.http.get<IContextNode[]>(appProperties.BASEURL_API + 'is/allcontexts'); //return this.http.get<IContextNode[]>(appProperties.BASEURL_API + 'is/allcontexts');
const resourceUrl = this.applicationConfigService.getEndpointFor('api/is/allcontexts');
return this.http.get<IContextNode[]>(resourceUrl);
} }

View File

@ -1,10 +1,10 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { appProperties } from 'app/config/app-properties';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { IHostingNode } from './i-hosting-node'; import { IHostingNode } from './i-hosting-node';
import { IEService } from './i-e-service'; import { IEService } from './i-e-service';
import { ApplicationConfigService } from 'app/core/config/application-config.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -12,33 +12,30 @@ import { IEService } from './i-e-service';
export class ResourcesImplService { export class ResourcesImplService {
//public isLoading: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false); //public isLoading: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
httpOptions = { httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }), headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
}; };
private loading: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false); private loading: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
constructor(private http: HttpClient) { } constructor(private http: HttpClient, private applicationConfigService: ApplicationConfigService) { }
public isLoading():Observable<any>{ public isLoading():Observable<any>{
return this.loading; return this.loading;
} }
//TODO: qui va messo parametro per paginazione //TODO: paginate when APIs are ready
fetchResourceImpls(ctx:string, type:string): Observable<any[]> { fetchResourceImpls(ctx:string, type:string): Observable<any[]> {
const SERVICE_URL = appProperties.BASEURL_API+'is/resourceinstances'; const resourceUrl = this.applicationConfigService.getEndpointFor('api/is/resourceinstances');
//console.debug("******SIAMO NEL SERVIZIO:");
//console.debug(SERVICE_URL);
let queryParams = new HttpParams(); let queryParams = new HttpParams();
queryParams = queryParams.append("currentContext",ctx).append("resourceType",type); queryParams = queryParams.append("currentContext",ctx).append("resourceType",type);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return // eslint-disable-next-line @typescript-eslint/no-unsafe-return
if(type==='HostingNode'){ if(type==='HostingNode'){
//console.debug("******GETTING HOSTING NODE*****"); //console.debug("******GETTING HOSTING NODE*****");
return this.http.get<IHostingNode[]>(SERVICE_URL,{params:queryParams}); return this.http.get<IHostingNode[]>(resourceUrl,{params:queryParams});
} }
if(type==='EService'){ if(type==='EService'){
return this.http.get<IEService[]>(SERVICE_URL,{params:queryParams}); return this.http.get<IEService[]>(resourceUrl,{params:queryParams});
} }
return new Observable<any[]>(); return new Observable<any[]>();
} }
@ -46,10 +43,11 @@ export class ResourcesImplService {
getJsonDetails(ctx:string, type:string, uid: string): Observable<string> { getJsonDetails(ctx:string, type:string, uid: string): Observable<string> {
const SERVICE_URL = appProperties.BASEURL_API+'is/resourcejson'; const resourceUrl = this.applicationConfigService.getEndpointFor('api/is/resourcejson');
// const SERVICE_URL = appProperties.BASEURL_API+'is/resourcejson';
let queryParams = new HttpParams(); let queryParams = new HttpParams();
queryParams = queryParams.append("currentContext",ctx).append("resourceType",type).append("uid",uid); queryParams = queryParams.append("currentContext",ctx).append("resourceType",type).append("uid",uid);
return this.http.get<string>(SERVICE_URL,{params:queryParams}); return this.http.get<string>(resourceUrl,{params:queryParams});
} }
} }

View File

@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { IResource} from './i-resource'; import { IResource} from './i-resource';
import { appProperties } from 'app/config/app-properties'; import { ApplicationConfigService } from 'app/core/config/application-config.service';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -13,12 +13,14 @@ export class RestypesService {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }), headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
}; };
constructor(private http: HttpClient) {} constructor(private http: HttpClient, private applicationConfigService: ApplicationConfigService){}
//TODO: pipe per gestione errori //TODO: pipe per gestione errori
fetchAll(): Observable<IResource[]> { fetchAll(): Observable<IResource[]> {
return this.http.get<IResource[]>(appProperties.BASEURL_API+'is/resourcetypes'); //return this.http.get<IResource[]>(appProperties.BASEURL_API+'is/resourcetypes');
const resourceUrl = this.applicationConfigService.getEndpointFor('api/is/resourcetypes');
return this.http.get<IResource[]>(resourceUrl);
} }