Correction docker

version_2
VANNEAU 1 year ago
parent 3d3b9a7a45
commit a33f1ab1e2
  1. 30
      Dockerfile
  2. 22
      nginx.conf
  3. 7
      proxy.conf.json
  4. 34
      src/app/service/employee.service.ts
  5. 19
      src/app/service/info-column.service.ts
  6. 16
      src/app/service/info-table.service.ts
  7. 9
      src/app/service/reset_data.service.ts
  8. 27
      src/app/service/script.service.ts
  9. 14
      src/app/service/tags.service.ts
  10. 1
      src/environments/environment.development.ts
  11. 2
      src/environments/environment.ts

@ -1,7 +1,27 @@
FROM node:18-alpine ## STEP 1 BUILD ##
FROM node:18-alpine AS build
RUN mkdir -p /app
WORKDIR /app WORKDIR /app
COPY . .
RUN npm cache clean --force
COPY package*.json /app
RUN npm install RUN npm install
EXPOSE 9002
RUN npm run build COPY . /app
CMD ["npm", "start"]
RUN npm run build --prod
## STEP 2 DEPLOY ##
FROM nginx:1.21.3 AS ngi
COPY --from=build /app/dist/* /usr/share/nginx/html
COPY /nginx.conf /etc/nginx/conf.d/default.conf
# COPY /nginx.conf /etc/nginx/nginx.conf
# EXPOSE 9002
CMD ["nginx", "-g", "daemon off;"]

@ -0,0 +1,22 @@
upstream docker-web {
server 178.18.0.5:9001;
}
server {
include /etc/nginx/extra-conf.d/*.conf;
listen 80;
include /etc/nginx/mime.types;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://docker-web;
}
}

@ -0,0 +1,7 @@
{
"/api/*": {
"target": "http://localhost:9002",
"secure": false,
"timeout": 600000
}
}

@ -1,34 +0,0 @@
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { Employee } from '../model/employee';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class EmployeeService {
private apiServerUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) {}
public getAllEmployees(): Observable<Employee[]> {
return this.http.get<Employee[]>(`${this.apiServerUrl}/api/employees/all`);
}
public getEmployee(employeeId: number): Observable<Employee> {
return this.http.get<Employee>(`${this.apiServerUrl}/api/employee/${employeeId}`);
}
public addEmployee(employee: Employee): Observable<Employee> {
return this.http.post<Employee>(`${this.apiServerUrl}/api/employee/add`, employee);
}
public updateEmployee(employee: Employee, employeeId: number): Observable<Employee> {
return this.http.put<Employee>(`${this.apiServerUrl}/api/employee/update/${employeeId}`, employee);
}
public deleteEmployee(employeeId: number): Observable<void> {
return this.http.delete<void>(`${this.apiServerUrl}/api/employee/delete/${employeeId}`);
}
}

@ -1,5 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment.development';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
import { InfoColumn } from '../model/info-column'; import { InfoColumn } from '../model/info-column';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@ -9,30 +8,28 @@ import { Observable } from 'rxjs';
}) })
export class InfoColumnService { export class InfoColumnService {
private apiServerUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
public getAllColumns(): Observable<InfoColumn[]>{ public getAllColumns(): Observable<InfoColumn[]>{
return this.http.get<InfoColumn[]>(`${this.apiServerUrl}/api/columns/all`); return this.http.get<InfoColumn[]>(`/api/columns/all`);
} }
public getColumn(columnId: Number): Observable<InfoColumn>{ public getColumn(columnId: Number): Observable<InfoColumn>{
return this.http.get<InfoColumn>(`${this.apiServerUrl}/api/column/${columnId}`); return this.http.get<InfoColumn>(`/api/column/${columnId}`);
} }
public getSelectedColumns(schema: String, table: String): Observable<InfoColumn[]>{ public getSelectedColumns(schema: String, table: String): Observable<InfoColumn[]>{
return this.http.get<InfoColumn[]>(`${this.apiServerUrl}/api/columns/${schema}/${table}`); return this.http.get<InfoColumn[]>(`/api/columns/${schema}/${table}`);
} }
public getColumnsForJoin(firstSchema: String, secondSchema: String, firstTable: String, secondTable: String): Observable<InfoColumn[]>{ public getColumnsForJoin(firstSchema: String, secondSchema: String, firstTable: String, secondTable: String): Observable<InfoColumn[]>{
return this.http.get<InfoColumn[]>(`${this.apiServerUrl}/api/columns/${firstSchema}/${secondSchema}/${firstTable}/${secondTable}`); return this.http.get<InfoColumn[]>(`/api/columns/${firstSchema}/${secondSchema}/${firstTable}/${secondTable}`);
} }
public getColumnsForJoinTwo(tables: string[], schemas: string[]): Observable<InfoColumn[]>{ public getColumnsForJoinTwo(tables: string[], schemas: string[]): Observable<InfoColumn[]>{
const paramsGetJoins = new HttpParams().set('tables', tables.toString()).set('schemas', schemas.toString()); const paramsGetJoins = new HttpParams()
return this.http.get<InfoColumn[]>(`${this.apiServerUrl}/api/columns/joins`, {params: paramsGetJoins}); .set('tables', tables.toString())
.set('schemas', schemas.toString());
return this.http.get<InfoColumn[]>(`/api/columns/joins`, {params: paramsGetJoins});
} }
} }

@ -2,42 +2,40 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { InfoTable } from '../model/info-table'; import { InfoTable } from '../model/info-table';
import { environment } from 'src/environments/environment';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class InfoTableService { export class InfoTableService {
private apiServerUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
public getAllTables(): Observable<InfoTable[]>{ public getAllTables(): Observable<InfoTable[]>{
return this.http.get<InfoTable[]>(`${this.apiServerUrl}/api/tables/all`); return this.http.get<InfoTable[]>(`/api/tables/all`);
} }
public getTable(tableId: Number): Observable<InfoTable>{ public getTable(tableId: Number): Observable<InfoTable>{
return this.http.get<InfoTable>(`${this.apiServerUrl}/api/table/${tableId}`); return this.http.get<InfoTable>(`/api/table/${tableId}`);
} }
public getSchemas(): Observable<String[]>{ public getSchemas(): Observable<String[]>{
return this.http.get<String[]>(`${this.apiServerUrl}/api/schemas/all`); return this.http.get<String[]>(`/api/schemas/all`);
} }
public getTablesBySchema(nameSchema : String): Observable<InfoTable[]>{ public getTablesBySchema(nameSchema : String): Observable<InfoTable[]>{
return this.http.get<InfoTable[]>(`${this.apiServerUrl}/api/tables/${nameSchema}`); return this.http.get<InfoTable[]>(`/api/tables/${nameSchema}`);
} }
public getSchemasByTable(nameTable : String): Observable<InfoTable[]>{ public getSchemasByTable(nameTable : String): Observable<InfoTable[]>{
return this.http.get<InfoTable[]>(`${this.apiServerUrl}/api/schemas/${nameTable}`); return this.http.get<InfoTable[]>(`/api/schemas/${nameTable}`);
} }
public getTablesWithFilter(filter : String): Observable<InfoTable[]>{ public getTablesWithFilter(filter : String): Observable<InfoTable[]>{
return this.http.get<InfoTable[]>(`${this.apiServerUrl}/api/tables/filter/${filter}`); return this.http.get<InfoTable[]>(`/api/tables/filter/${filter}`);
} }
public getTablesWithFilterAndSchema(filter : String, schema: String): Observable<InfoTable[]>{ public getTablesWithFilterAndSchema(filter : String, schema: String): Observable<InfoTable[]>{
return this.http.get<InfoTable[]>(`${this.apiServerUrl}/api/tables/filter/${schema}/${filter}`); return this.http.get<InfoTable[]>(`/api/tables/filter/${schema}/${filter}`);
} }
} }

@ -1,22 +1,19 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment.development'; import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class ResetDataService { export class ResetDataService {
private apiServerUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
public resetDatabase(){ public resetDatabase(){
return this.http.post<void>(`${this.apiServerUrl}/api/reset`, null); return this.http.post<void>(`/api/reset`, null);
} }
public testres(){ public testres(){
return this.http.post<void>(`${this.apiServerUrl}/api/testres`, null); return this.http.post<void>(`/api/testres`, null);
} }
} }

@ -1,7 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment.development';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, from } from 'rxjs'; import { Observable } from 'rxjs';
import { Script } from '../model/script'; import { Script } from '../model/script';
import { LinkScriptTag } from '../model/link-script-tag'; import { LinkScriptTag } from '../model/link-script-tag';
@ -9,29 +8,37 @@ import { LinkScriptTag } from '../model/link-script-tag';
providedIn: 'root' providedIn: 'root'
}) })
export class ScriptService { export class ScriptService {
private apiServerUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
public retreiveScripts(): Observable<Script[]>{ public retreiveScripts(): Observable<Script[]>{
return this.http.get<Script[]>(`${this.apiServerUrl}/api/scripts`); return this.http.get<Script[]>(`/api/scripts`);
} }
public getAllScriptsWithTags(): Observable<LinkScriptTag[]>{ public getAllScriptsWithTags(): Observable<LinkScriptTag[]>{
return this.http.get<LinkScriptTag[]>(`${this.apiServerUrl}/api/scripts/link`); return this.http.get<LinkScriptTag[]>(`/api/scripts/link`);
} }
public deleteScript(name: String){ public deleteScript(name: String){
return this.http.delete<void>(`${this.apiServerUrl}/api/script/delete/${name}`); return this.http.delete<void>(`/api/script/delete/${name}`);
} }
public addOneScript(script: Script, description: String, tagList: String[], id: number){ public addOneScript(script: Script, description: String, tagList: String[], id: number){
const paramsAddScript = new HttpParams().set('name', script.name.toString()).set('desc', description.toString()).set('tagList', tagList.join(', ')).set('linkid', id); const paramsAddScript = new HttpParams()
return this.http.post<void>(`${this.apiServerUrl}/api/script/add`, script.data, {params: paramsAddScript}); .set('name', script.name.toString())
.set('desc', description.toString())
.set('tagList', tagList.join(', '))
.set('linkid', id);
return this.http.post<void>(`/api/script/add`, script.data, {params: paramsAddScript});
} }
public editScript(content: String, defaultName: String, newName: String, description: String, tagList: String[], id: number){ public editScript(content: String, defaultName: String, newName: String, description: String, tagList: String[], id: number){
const paramsAddScript = new HttpParams().set('defaultname', defaultName.toString()).set('newname', newName.toString()).set('desc', description.toString()).set('tagList', tagList.join(', ')).set('linkid', id); const paramsAddScript = new HttpParams()
return this.http.post<void>(`${this.apiServerUrl}/api/script/edit`, content, {params: paramsAddScript}); .set('defaultname', defaultName.toString())
.set('newname', newName.toString())
.set('desc', description.toString())
.set('tagList', tagList.join(', '))
.set('linkid', id);
return this.http.post<void>(`/api/script/edit`, content, {params: paramsAddScript});
} }
} }

@ -1,5 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment.development';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Tag } from '../model/tag'; import { Tag } from '../model/tag';
@ -8,31 +7,30 @@ import { Tag } from '../model/tag';
providedIn: 'root' providedIn: 'root'
}) })
export class TagsService { export class TagsService {
private apiServerUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
public addTag(tag: Tag){ public addTag(tag: Tag){
return this.http.post<void>(`${this.apiServerUrl}/api/tag/add`, tag); return this.http.post<void>(`/api/tag/add`, tag);
} }
public updateTag(prevName: string, tag: Tag){ public updateTag(prevName: string, tag: Tag){
return this.http.put<void>(`${this.apiServerUrl}/api/tag/update/${prevName}`, tag); return this.http.put<void>(`/api/tag/update/${prevName}`, tag);
} }
public getTag(tagId: Number): Observable<Tag>{ public getTag(tagId: Number): Observable<Tag>{
return this.http.get<Tag>(`${this.apiServerUrl}/api/tag/${tagId}`); return this.http.get<Tag>(`/api/tag/${tagId}`);
} }
public getAllTags(): Observable<Tag[]>{ public getAllTags(): Observable<Tag[]>{
return this.http.get<Tag[]>(`${this.apiServerUrl}/api/tags/all`); return this.http.get<Tag[]>(`/api/tags/all`);
} }
public deleteTag(tagName: String){ public deleteTag(tagName: String){
return this.http.delete<void>(`${this.apiServerUrl}/api/tag/delete/${tagName}`); return this.http.delete<void>(`/api/tag/delete/${tagName}`);
} }
public deleteAllTags(){ public deleteAllTags(){
return this.http.delete<void>(`${this.apiServerUrl}/api/tags/deleteAll`); return this.http.delete<void>(`/api/tags/deleteAll`);
} }
} }

@ -1,4 +1,3 @@
export const environment = { export const environment = {
production: false, production: false,
apiBaseUrl: 'http://178.18.0.5:9001'
}; };

@ -1,5 +1,3 @@
export const environment = { export const environment = {
production: false, production: false,
apiBaseUrl: 'http://178.18.0.5:9001'
}; };

Loading…
Cancel
Save