mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +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:
@@ -37,6 +37,7 @@ export class ListBoxService {
|
||||
|
||||
daysBetween(){ }
|
||||
|
||||
|
||||
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'Combinado', selectedDate= null}): Year[] {
|
||||
|
||||
// // filter range
|
||||
@@ -306,6 +307,9 @@ export class ListBoxService {
|
||||
}
|
||||
|
||||
transForm(event: CustomCalendarEvent, {startMany, endMany, middle}) {
|
||||
|
||||
let daysLeft = this.daysToEndWithJS(event.start, event.end);
|
||||
|
||||
return Object.assign({}, {
|
||||
start: event.start,
|
||||
end: event.end,
|
||||
@@ -318,8 +322,10 @@ export class ListBoxService {
|
||||
Location: event.event.Location,
|
||||
EventId: event.event.EventId,
|
||||
CalendarName: event.event.CalendarName,
|
||||
CalendarId: event.event.CalendarId
|
||||
CalendarId: event.event.CalendarId,
|
||||
daysLeft
|
||||
},
|
||||
daysLeft,
|
||||
Subject: event.event.Subject,
|
||||
startMany: startMany,
|
||||
endMany: endMany,
|
||||
@@ -329,6 +335,26 @@ export class ListBoxService {
|
||||
|
||||
|
||||
|
||||
|
||||
daysToEndWithJS(startDateStr: any, endDateStr: any) {
|
||||
// Define the start and end dates
|
||||
const startDate: any = new Date(startDateStr);
|
||||
const endDate: any = new Date(endDateStr);
|
||||
|
||||
// Calculate the difference in milliseconds between the two dates
|
||||
const differenceMs = Math.abs(endDate - startDate);
|
||||
|
||||
// Convert milliseconds to days
|
||||
const millisecondsPerDay = 1000 * 60 * 60 * 24;
|
||||
const differenceDays = Math.ceil(differenceMs / millisecondsPerDay);
|
||||
|
||||
// console.log(`Number of days between the dates: ${differenceDays}`);
|
||||
|
||||
return differenceDays
|
||||
|
||||
}
|
||||
|
||||
|
||||
transformObjectKeyOrder(originalObject, keyOrder) {
|
||||
const transformedObject = {};
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// import { Injectable } from '@angular/core';
|
||||
// import * as log4js from 'log4js';
|
||||
|
||||
// @Injectable({
|
||||
// providedIn: 'root'
|
||||
// })
|
||||
// export class LoggingService {
|
||||
// private logger;
|
||||
|
||||
// constructor() {
|
||||
// log4js.configure({
|
||||
// appenders: {
|
||||
// graylog: {
|
||||
// type: '@log4js-node/gelf',
|
||||
// host: 'localhost', // Replace with your Graylog server hostname or IP
|
||||
// port: 1514, // GELF TCP port configured in Graylog Docker Compose
|
||||
// hostname: 'angular-app', // Optional: Name of your application or hostname
|
||||
// facility: 'angular-app', // Optional: Facility for categorizing logs
|
||||
// customFields: { // Optional: Additional fields you want to include
|
||||
// app: 'AngularApp',
|
||||
// env: 'development'
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// categories: {
|
||||
// default: { appenders: ['graylog'], level: 'debug' }
|
||||
// }
|
||||
// });
|
||||
|
||||
// this.logger = log4js.getLogger();
|
||||
|
||||
// this.log("teste-123s")
|
||||
// }
|
||||
|
||||
// log(message: string) {
|
||||
// this.logger.info(message);
|
||||
// }
|
||||
|
||||
// error(message: string) {
|
||||
// this.logger.error(message);
|
||||
// }
|
||||
|
||||
// debug(message: string) {
|
||||
// this.logger.debug(message);
|
||||
// }
|
||||
// }
|
||||
@@ -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