Fetch config from the build environment config (#13)
continuous-integration/drone/push Build is passing Details

Add two environment files for production and development

Co-authored-by: cofrizot <colin.frizot@etu.uca.fr>
Reviewed-on: #13
Reviewed-by: Clément FRÉVILLE <clement.freville2@etu.uca.fr>
Co-authored-by: Colin FRIZOT <colin.frizot@etu.uca.fr>
Co-committed-by: Colin FRIZOT <colin.frizot@etu.uca.fr>
chore/angular18
Colin FRIZOT 11 months ago committed by Clément FRÉVILLE
parent 6a6fc064ef
commit f295bd5e91

@ -16,14 +16,27 @@
"outputPath": "dist/sandkasten", "outputPath": "dist/sandkasten",
"index": "src/index.html", "index": "src/index.html",
"browser": "src/main.ts", "browser": "src/main.ts",
"polyfills": ["zone.js"], "polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json", "tsConfig": "tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"], "assets": [
"styles": ["src/styles.scss"], "src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [] "scripts": []
}, },
"configurations": { "configurations": {
"production": { "production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"budgets": [ "budgets": [
{ {
"type": "initial", "type": "initial",
@ -39,6 +52,7 @@
"outputHashing": "all" "outputHashing": "all"
}, },
"development": { "development": {
"fileReplacements": [],
"optimization": false, "optimization": false,
"extractLicenses": false, "extractLicenses": false,
"sourceMap": true "sourceMap": true
@ -67,10 +81,18 @@
"test": { "test": {
"builder": "@angular-devkit/build-angular:karma", "builder": "@angular-devkit/build-angular:karma",
"options": { "options": {
"polyfills": ["zone.js", "zone.js/testing"], "polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json", "tsConfig": "tsconfig.spec.json",
"assets": ["src/favicon.ico", "src/assets"], "assets": [
"styles": ["src/styles.scss"], "src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [], "scripts": [],
"karmaConfig": "karma.conf.js" "karmaConfig": "karma.conf.js"
} }
@ -78,7 +100,10 @@
"lint": { "lint": {
"builder": "@angular-eslint/builder:lint", "builder": "@angular-eslint/builder:lint",
"options": { "options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] "lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
} }
} }
} }
@ -86,6 +111,8 @@
}, },
"cli": { "cli": {
"analytics": false, "analytics": false,
"schematicCollections": ["@angular-eslint/schematics"] "schematicCollections": [
"@angular-eslint/schematics"
]
} }
} }

@ -42,6 +42,7 @@ import {
getDocument, getDocument,
peerExtension, peerExtension,
} from '../../services/connection.service'; } from '../../services/connection.service';
import { environment } from '../../../environments/environment';
const basicSetup: Extension = (() => [ const basicSetup: Extension = (() => [
highlightActiveLineGutter(), highlightActiveLineGutter(),
@ -94,6 +95,7 @@ export class EditorComponent {
get selectedLanguage(): LanguageDescription { get selectedLanguage(): LanguageDescription {
return this._selectedLanguage; return this._selectedLanguage;
} }
set selectedLanguage(value: LanguageDescription) { set selectedLanguage(value: LanguageDescription) {
this._selectedLanguage = value; this._selectedLanguage = value;
if (value.name in CODE_DEFAULTS) { if (value.name in CODE_DEFAULTS) {
@ -106,10 +108,12 @@ export class EditorComponent {
}); });
}); });
} }
private _linesNumbers: boolean = true; private _linesNumbers: boolean = true;
get linesNumbers() { get linesNumbers() {
return this._linesNumbers; return this._linesNumbers;
} }
set linesNumbers(lines: boolean) { set linesNumbers(lines: boolean) {
this._linesNumbers = lines; this._linesNumbers = lines;
this.codemirror.editor?.dispatch({ this.codemirror.editor?.dispatch({
@ -138,13 +142,14 @@ export class EditorComponent {
]; ];
private client: WebSocket | undefined; private client: WebSocket | undefined;
@Input() @Input()
set idRoom(idRoom: string) { set idRoom(idRoom: string) {
if (idRoom === undefined) { if (idRoom === undefined) {
return; return;
} }
this.client = new WebSocket(`ws://127.0.0.1:3000/live/${idRoom}`); this.client = new WebSocket(`${environment.webSocketUrl}/live/${idRoom}`);
this.client.addEventListener('open', async () => { this.client.addEventListener('open', async () => {
let conn = new Connection(this.client!); let conn = new Connection(this.client!);
let { version, doc } = await getDocument(conn); let { version, doc } = await getDocument(conn);

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { SSE } from 'sse.js'; import { SSE } from 'sse.js';
import { Observable, Subject } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { environment } from '../../environments/environment';
export type ExecutionMessage = { export type ExecutionMessage = {
type: 'stdout' | 'stderr' | 'exit'; type: 'stdout' | 'stderr' | 'exit';
@ -11,7 +12,8 @@ export type ExecutionMessage = {
providedIn: 'root', providedIn: 'root',
}) })
export class BackendService { export class BackendService {
private apiUrl = 'http://localhost:3000'; private apiUrl = environment.apiUrl;
private resultSubject = new Subject<ExecutionMessage>(); private resultSubject = new Subject<ExecutionMessage>();
constructor() {} constructor() {}

@ -0,0 +1,5 @@
export const environment = {
production: true,
apiUrl: 'https://tododomain.com',
webSocketUrl: 'ws://tododomain.com',
};

@ -0,0 +1,5 @@
export const environment = {
production: false,
apiUrl: 'http://localhost:3000',
webSocketUrl: 'ws://localhost:3000',
};
Loading…
Cancel
Save