diff --git a/angular.json b/angular.json index fe3047c..c35f991 100644 --- a/angular.json +++ b/angular.json @@ -16,14 +16,27 @@ "outputPath": "dist/sandkasten", "index": "src/index.html", "browser": "src/main.ts", - "polyfills": ["zone.js"], + "polyfills": [ + "zone.js" + ], "tsConfig": "tsconfig.app.json", - "assets": ["src/favicon.ico", "src/assets"], - "styles": ["src/styles.scss"], + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.scss" + ], "scripts": [] }, "configurations": { "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], "budgets": [ { "type": "initial", @@ -39,6 +52,7 @@ "outputHashing": "all" }, "development": { + "fileReplacements": [], "optimization": false, "extractLicenses": false, "sourceMap": true @@ -67,10 +81,18 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "polyfills": ["zone.js", "zone.js/testing"], + "polyfills": [ + "zone.js", + "zone.js/testing" + ], "tsConfig": "tsconfig.spec.json", - "assets": ["src/favicon.ico", "src/assets"], - "styles": ["src/styles.scss"], + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.scss" + ], "scripts": [], "karmaConfig": "karma.conf.js" } @@ -78,7 +100,10 @@ "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html" + ] } } } @@ -86,6 +111,8 @@ }, "cli": { "analytics": false, - "schematicCollections": ["@angular-eslint/schematics"] + "schematicCollections": [ + "@angular-eslint/schematics" + ] } } diff --git a/src/app/components/editor/editor.component.ts b/src/app/components/editor/editor.component.ts index cd27853..dcf76b1 100644 --- a/src/app/components/editor/editor.component.ts +++ b/src/app/components/editor/editor.component.ts @@ -42,6 +42,7 @@ import { getDocument, peerExtension, } from '../../services/connection.service'; +import { environment } from '../../../environments/environment'; const basicSetup: Extension = (() => [ highlightActiveLineGutter(), @@ -94,6 +95,7 @@ export class EditorComponent { get selectedLanguage(): LanguageDescription { return this._selectedLanguage; } + set selectedLanguage(value: LanguageDescription) { this._selectedLanguage = value; if (value.name in CODE_DEFAULTS) { @@ -106,10 +108,12 @@ export class EditorComponent { }); }); } + private _linesNumbers: boolean = true; get linesNumbers() { return this._linesNumbers; } + set linesNumbers(lines: boolean) { this._linesNumbers = lines; this.codemirror.editor?.dispatch({ @@ -138,13 +142,14 @@ export class EditorComponent { ]; private client: WebSocket | undefined; + @Input() set idRoom(idRoom: string) { if (idRoom === undefined) { 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 () => { let conn = new Connection(this.client!); let { version, doc } = await getDocument(conn); diff --git a/src/app/services/backendService.service.ts b/src/app/services/backendService.service.ts index 90b64ed..d6808f4 100644 --- a/src/app/services/backendService.service.ts +++ b/src/app/services/backendService.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { SSE } from 'sse.js'; import { Observable, Subject } from 'rxjs'; +import { environment } from '../../environments/environment'; export type ExecutionMessage = { type: 'stdout' | 'stderr' | 'exit'; @@ -11,7 +12,8 @@ export type ExecutionMessage = { providedIn: 'root', }) export class BackendService { - private apiUrl = 'http://localhost:3000'; + private apiUrl = environment.apiUrl; + private resultSubject = new Subject(); constructor() {} diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts new file mode 100644 index 0000000..0900c39 --- /dev/null +++ b/src/environments/environment.prod.ts @@ -0,0 +1,5 @@ +export const environment = { + production: true, + apiUrl: 'https://tododomain.com', + webSocketUrl: 'ws://tododomain.com', +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..0411da0 --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,5 @@ +export const environment = { + production: false, + apiUrl: 'http://localhost:3000', + webSocketUrl: 'ws://localhost:3000', +};