mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
ITOTEAM-530 Inform the user how many days are left until the end of the wind for each selected day
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Device } from '@capacitor/device';
|
||||
import { SocketLog } from './worker.worker';
|
||||
// import { SocketLog } from './worker.worker';
|
||||
import { FCM } from '@capacitor-community/fcm';
|
||||
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
import { AlertController, Platform } from '@ionic/angular';
|
||||
@@ -14,7 +14,7 @@ export class CaptureLogService {
|
||||
deviceName = ''
|
||||
|
||||
constructor(
|
||||
public socket: SocketLog,
|
||||
// public socket: SocketLog,
|
||||
private platform: Platform,
|
||||
private afMessaging: AngularFireMessaging,
|
||||
) {
|
||||
@@ -25,6 +25,13 @@ export class CaptureLogService {
|
||||
this.deviceName = e.name
|
||||
});
|
||||
|
||||
// Create a new
|
||||
const worker = new Worker(new URL('./worker.worker', import.meta.url));
|
||||
worker.onmessage = ({ data }) => {
|
||||
console.log(`page got message: ${data}`);
|
||||
};
|
||||
worker.postMessage('hello');
|
||||
|
||||
}
|
||||
|
||||
setToken() {
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
// src/app/worker.worker.ts
|
||||
// addEventListener('message', ({ data }) => {
|
||||
// const response = `Worker response to ${data}`;
|
||||
// postMessage(response);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
/// <reference lib="webworker" />
|
||||
import { Observable, Subject, BehaviorSubject } from 'rxjs';
|
||||
import { webSocket, WebSocketSubject } from 'rxjs/webSocket';
|
||||
import { catchError, retryWhen, tap, delay } from 'rxjs/operators';
|
||||
@@ -17,15 +8,7 @@ interface WebSocketMessage {
|
||||
payload: any;
|
||||
}
|
||||
|
||||
interface WebSocketError {
|
||||
type: string;
|
||||
error: any;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SocketLog {
|
||||
class SocketLog {
|
||||
private socket$: WebSocketSubject<WebSocketMessage>;
|
||||
private messageSubject$: Subject<WebSocketMessage>;
|
||||
private connectionStatus$: BehaviorSubject<boolean>;
|
||||
@@ -36,6 +19,8 @@ export class SocketLog {
|
||||
this.messageSubject$ = new Subject<WebSocketMessage>();
|
||||
this.connectionStatus$ = new BehaviorSubject<boolean>(false);
|
||||
this.setupVisibilityChangeHandler();
|
||||
// this.connect('https://5-180-182-151.cloud-xip.com:85/ws/')
|
||||
//console.log('connect1')
|
||||
}
|
||||
|
||||
public connect(url: string) {
|
||||
@@ -61,12 +46,14 @@ export class SocketLog {
|
||||
this.messageSubject$.next(message);
|
||||
this.connectionStatus$.next(true);
|
||||
this.reconnectAttempts = 0;
|
||||
|
||||
// console.log({message})
|
||||
},
|
||||
(err) => {
|
||||
console.error('WebSocket connection error:', err);
|
||||
// console.error('WebSocket connection error:', err);
|
||||
},
|
||||
() => {
|
||||
console.log('WebSocket connection closed');
|
||||
// console.log('WebSocket connection closed');
|
||||
this.connectionStatus$.next(false);
|
||||
}
|
||||
);
|
||||
@@ -150,3 +137,6 @@ export class SocketLog {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let _ = new SocketLog()
|
||||
|
||||
@@ -7,7 +7,7 @@ import { environment } from 'src/environments/environment';
|
||||
const meterProvider = new MeterProvider();
|
||||
metrics.setGlobalMeterProvider(meterProvider);
|
||||
|
||||
if (window.location.protocol !== 'https:' && environment.presidential == false) {
|
||||
if (window.location.protocol !== 'https:' && environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
|
||||
const metricReader = new PeriodicExportingMetricReader({
|
||||
exporter: new OTLPMetricExporter({
|
||||
url: 'http://5-180-182-151.cloud-xip.com:4318/v1/metrics',
|
||||
@@ -20,7 +20,6 @@ if (window.location.protocol !== 'https:' && environment.presidential == false)
|
||||
|
||||
meterProvider.addMetricReader(metricReader);
|
||||
}
|
||||
|
||||
export const meter = meterProvider.getMeter('example-exporter-collector');
|
||||
export const RequestCounter = meter.createCounter('post_requests', {
|
||||
description: 'Example of a Counter',
|
||||
|
||||
@@ -64,7 +64,7 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
|
||||
return data.tags[key]
|
||||
},
|
||||
finish: () => {
|
||||
if(environment.presidential == false) {
|
||||
if(environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
|
||||
span.end();
|
||||
UseCaseCounter.add(1, {user: SessionStore?.user?.FullName, outcome:data.tags['outcome'], usecase: name})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user