mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	configure websocket endpoint for production
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { Subject } from 'rxjs'; | import { Subject } from 'rxjs'; | ||||||
|  | import { environment } from 'src/environments/environment'; | ||||||
| import { WebsocketConsumerStatusMessage } from '../data/websocket-consumer-status-message'; | import { WebsocketConsumerStatusMessage } from '../data/websocket-consumer-status-message'; | ||||||
|  |  | ||||||
| export enum FileStatusPhase { | export enum FileStatusPhase { | ||||||
| @@ -77,7 +78,7 @@ export class ConsumerStatusService { | |||||||
|  |  | ||||||
|   constructor() { } |   constructor() { } | ||||||
|  |  | ||||||
|   private statusWebSocked: WebSocket |   private statusWebSocket: WebSocket | ||||||
|  |  | ||||||
|   private consumerStatus: FileStatus[] = [] |   private consumerStatus: FileStatus[] = [] | ||||||
|  |  | ||||||
| @@ -123,8 +124,9 @@ export class ConsumerStatusService { | |||||||
|  |  | ||||||
|   connect() { |   connect() { | ||||||
|     this.disconnect() |     this.disconnect() | ||||||
|     this.statusWebSocked = new WebSocket("ws://localhost:8000/ws/status/"); |  | ||||||
|     this.statusWebSocked.onmessage = (ev) => { |     this.statusWebSocket = new WebSocket(`${environment.webSocketProtocol}//${environment.webSocketHost}/ws/status/`); | ||||||
|  |     this.statusWebSocket.onmessage = (ev) => { | ||||||
|       let statusMessage: WebsocketConsumerStatusMessage = JSON.parse(ev['data']) |       let statusMessage: WebsocketConsumerStatusMessage = JSON.parse(ev['data']) | ||||||
|  |  | ||||||
|       let statusMessageGet = this.get(statusMessage.task_id, statusMessage.filename) |       let statusMessageGet = this.get(statusMessage.task_id, statusMessage.filename) | ||||||
| @@ -160,9 +162,9 @@ export class ConsumerStatusService { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   disconnect() { |   disconnect() { | ||||||
|     if (this.statusWebSocked) { |     if (this.statusWebSocket) { | ||||||
|       this.statusWebSocked.close() |       this.statusWebSocket.close() | ||||||
|       this.statusWebSocked = null |       this.statusWebSocket = null | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,5 +2,7 @@ export const environment = { | |||||||
|   production: true, |   production: true, | ||||||
|   apiBaseUrl: "/api/", |   apiBaseUrl: "/api/", | ||||||
|   appTitle: "Paperless-ng", |   appTitle: "Paperless-ng", | ||||||
|   version: "1.1.0" |   version: "1.1.0", | ||||||
|  |   webSocketHost: window.location.host, | ||||||
|  |   webSocketProtocol: (window.location.protocol == "https:" ? "wss:" : "ws:") | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -7,7 +7,8 @@ export const environment = { | |||||||
|   apiBaseUrl: "http://localhost:8000/api/", |   apiBaseUrl: "http://localhost:8000/api/", | ||||||
|   appTitle: "Paperless-ng", |   appTitle: "Paperless-ng", | ||||||
|   version: "DEVELOPMENT", |   version: "DEVELOPMENT", | ||||||
|   wsBaseUrl: "ws://localhost:8000/ws/" |   webSocketHost: "localhost:8000", | ||||||
|  |   webSocketProtocol: "ws:" | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler