improve setup meeting from task

This commit is contained in:
Peter Maquiran
2024-10-18 16:22:45 +01:00
parent 3f41e9e9c0
commit 661b449fb4
48 changed files with 253 additions and 995 deletions
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { ListBoxService } from './list-box.service';
describe('ListBoxService', () => {
let service: ListBoxService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ListBoxService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
-477
View File
@@ -1,477 +0,0 @@
import { Injectable } from '@angular/core';
import { CustomCalendarEvent, EventListStore } from 'src/app/models/agenda/AgendaEventList';
import { DateService } from '../date.service';
import { momentG } from 'src/plugin/momentG';
import { NativeNotificationService } from 'src/app/services/native-notification.service';
@Injectable({
providedIn: 'root'
})
export class ListBoxService {
height = "unset"
constructor(
private dateService: DateService,
){}
filterProfile(eventSource: EventListStore[] = [], profile: 'md' | 'pr' | 'all') {
return eventSource.filter((e) => e.profile == profile)
}
getEventInsideRange(eventSource: EventListStore[], rangeStartDate, randEndDate) {
return eventSource.filter((e)=> {
if(new Date(rangeStartDate).getTime() <= new Date(e.startTime).getTime() &&
new Date(randEndDate).getTime() >= new Date(e.endTime).getTime()) {
return true
}
return false
})
}
filterSegment(eventSource: EventListStore[], segment): EventListStore[] {
return eventSource.filter( data => data.calendarName == segment)
}
daysBetween(){ }
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'Combinado', selectedDate= null}): Year[] {
// // filter range
// if(selectedDate) {
// eventSource = eventSource.filter(data =>
// data.startTime.toLocaleDateString('pt') >= new Date(rangeStartDate).toLocaleDateString('pt') &&
// data.startTime.toLocaleDateString('pt') <= new Date(rangeStartDate).toLocaleDateString('pt')
// )
// }
if(segment!='Combinado') {
eventSource = this.filterSegment(eventSource, segment)
}
// if(profile != 'all') {
// eventSource = this.filterProfile(eventSource, profile)
// }
let newStracture:CustomCalendarEvent[];
newStracture = this.encapsulation(eventSource);
// const object = {}
// for (const e of newStracture.reverse()) {
// if(!object[momentG(new Date(e.start), 'MMMM yyyy')]) {
// object[momentG(new Date(e.start), 'MMMM yyyy')] = []
// }
// object[momentG(new Date(e.start), 'MMMM yyyy')].push(e)
// }
// const daysStringNum = Object.keys(object).reverse()
// const daysObject = {}
// for(const day of daysStringNum) {
// daysObject[day] = object[day]
// }
// console.log('newStracture', newStracture)
const data = this.display(newStracture, selectedDate)
return data.year
// const daysStringNum = Object.keys(daysObject)
// for(const day of daysStringNum) {
// daysObject[day] = daysObject[day].reverse()
// }
// daysObject = this.transformObjectKeyOrder(daysObject, daysStringNum)
// return daysObject
}
sortArrayISODate(myArray: any): any[] {
return myArray.sort((a,b) =>
Date.parse(b.start )
-
Date.parse(a.start))
}
display(list: CustomCalendarEvent[], selectedDate) {
let days = {};
const year: Year[] = []
this.sortArrayISODate(list).reverse().forEach( (event:CustomCalendarEvent, index) => {
var startDate: any = new Date(event.start);
var endDate: any = this.dateService.EventEndDateTreatment({
startTime: startDate,
endTime: event.end
})
const day = this.dateService.getDay(event.start)
event['manyDays'] = !this.dateService.isSameDate(event.start, event.end)
event['todayOnly'] = this.dateService.isSameDate(event.start, event.end)
if(!days.hasOwnProperty(day)) {
days[day] = []
}
const diffDays = this.dateService.deferenceBetweenDays(endDate, startDate)
if (this.dateService.notSameDate(startDate, endDate)) {
const cloneSelectedDate = new Date(selectedDate)
cloneSelectedDate.setHours(0)
cloneSelectedDate.setMinutes(0)
cloneSelectedDate.setSeconds(0)
if (diffDays >= 1) {
const StartEvent = this.transForm(event, {startMany: true, endMany: false, middle: false, hasMany: true})
if(this.CanPush(event, selectedDate) && (new Date(event.start)).getTime() >= cloneSelectedDate.getTime()) {
days[day].push(StartEvent); this.push(StartEvent, year)
}
let i = 1;
//create event between date
while (startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate()) {
const newDate = startDate.setDate(startDate.getDate()+ i)
let otherDays = this.dateService.getDay(newDate)
const cloneEvent = {...event}
cloneEvent['other'] = true
cloneEvent.start = new Date(startDate)
if(!days.hasOwnProperty(otherDays)) {
days[otherDays] = []
}
if (!(startDate.getFullYear() != endDate.getFullYear() ||
startDate.getMonth() != endDate.getMonth() ||
startDate.getDate() != endDate.getDate())) {
// last push
const EndEvent = this.transForm(cloneEvent, {startMany: false, endMany: true, middle: false, hasMany: true})
if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) {
days[otherDays].push(EndEvent) ; this.push(EndEvent, year)
}
} else {
const EndEvent = this.transForm(cloneEvent, {startMany: false,endMany: false, middle: true, hasMany: true})
if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) {
days[otherDays].push(EndEvent) ; this.push(EndEvent, year)
} else {
if( cloneEvent.start.getFullYear() == cloneSelectedDate.getFullYear() && cloneEvent.start.getDate() == cloneSelectedDate.getDate() && cloneEvent.start.getMonth() == cloneSelectedDate.getMonth()) {
// console.log("00_00")
days[otherDays].push(EndEvent) ; this.push(EndEvent, year)
} else {
// console.log('0000000000000000000000000',cloneEvent.start.getTime(), cloneSelectedDate.getTime())
// console.log('0000000000000000000000000',cloneEvent.start, cloneSelectedDate)
}
}
}
days[otherDays] = days[otherDays].reverse()
}
} else {
if(this.CanPush(event, selectedDate)) { days[day].push(event) ; this.push(event, year) }
}
} else {
event['sameDay'] = true
if(this.CanPush(event, selectedDate) && diffDays != 2) { days[day].push(event) ; this.push(event, year) }
}
})
// remove days that haven't event
Object.entries(days).forEach(([index, value]) => {
const _value: any = value
if(_value.length == 0) {
delete days[index]
}
})
return {days, year}
}
push(event: any, year: Year[]) {
const date = new Date(event.start)
const yearName = momentG(new Date(date), 'yyyy')
const monthName = momentG(new Date(date), 'MMMM')
const dayName = momentG(new Date(date), 'dd')
let YearIndex = year.findIndex( x => x.yearInfo.yearName == yearName)
if(YearIndex == -1) {
YearIndex = year.push({
yearInfo: {
yearName: yearName
},
months: []
})
YearIndex--
}
let MonthNameIndex = year[YearIndex].months.findIndex( x => x.monthInfo.monthName == monthName)
if(MonthNameIndex == -1) {
MonthNameIndex = year[YearIndex].months.push({
monthInfo: {
monthName: monthName
},
days: []
})
MonthNameIndex --
}
let DayNameIndex = year[YearIndex].months[MonthNameIndex].days.findIndex( x => x.daysInfo.dayName == dayName)
if(DayNameIndex == -1) {
year[YearIndex].months[MonthNameIndex].days.push({
daysInfo: {
dayName: dayName
},
events: [event]
})
} else {
year[YearIndex].months[MonthNameIndex].days[DayNameIndex].events.push(event)
}
}
CanPush(event: any, selectedDate: Date) {
const cloneSelectedDate = new Date(selectedDate);
cloneSelectedDate.setHours(0)
cloneSelectedDate.setMinutes(0)
cloneSelectedDate.setSeconds(0)
const limite = this.endOfMonth(selectedDate)
limite.setDate(limite.getDate() + 10)
limite.setHours(0)
selectedDate.setHours(0);
selectedDate.setMinutes(0);
selectedDate.setSeconds(0);
return (selectedDate.getTime() <= new Date(event.start).getTime() || selectedDate.getTime() <= new Date(event.end).getTime()) &&
(limite.getTime() >= new Date(event.start).getTime() || limite.getTime() >= new Date(event.end).getTime())
}
encapsulation(eventsList:EventListStore[]): CustomCalendarEvent[] {
// remove all event
let events: CustomCalendarEvent[] = [];
eventsList.forEach((element, eventIndex) => {
events.push({
start: new Date(element.startTime),
end: new Date(element.endTime),
id: element.id,
event: element.event,
profile: element.profile
});
});
return events;
}
transForm(event: CustomCalendarEvent, {startMany, endMany, middle, hasMany = false}) {
let daysLeft = this.daysToEndWithJS(event.start, event.end);
let eventTotalDuration = this.daysToEndWithJS(event.event.StartDate, event.event.EndDate);
return Object.assign({}, {
start: event.start,
end: event.end,
id: event.id,
profile: event.profile,
event: {
Subject: event.event.Subject,
StartDate: event.event.StartDate,
EndDate: event.event.EndDate,
Location: event.event.Location,
EventId: event.event.EventId,
CalendarName: event.event.CalendarName,
CalendarId: event.event.CalendarId,
daysLeft
},
eventTotalDuration,
hasMany,
duration: this.duration(event.start, event.event.EndDate),
daysLeft,
Subject: event.event.Subject,
startMany: startMany,
endMany: endMany,
middle: middle
})
}
daysToEndWithJS(startDateStr: any, endDateStr: any) {
// Define the start and end dates
const startDate: any = new Date(startDateStr);
const endDate: any = new Date(endDateStr);
startDate.setHours(0, 0, 0, 0); // Set hours, minutes, seconds, and milliseconds to 0
endDate.setHours(0, 0, 0, 0); // Set hours, minutes, seconds, and milliseconds to 0
// 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
}
duration(date1Str, date2Str) {
// Convert string dates to Date objects
const date1: any = new Date(date1Str);
const date2: any = new Date(date2Str);
// Calculate the difference in milliseconds
const timeDifferenceMs = date2 - date1;
// Convert difference to days, hours, and minutes
const totalMinutes = Math.floor(timeDifferenceMs / (1000 * 60));
const days = Math.floor(totalMinutes / (60 * 24));
const hours = Math.floor((totalMinutes % (60 * 24)) / 60);
const minutes = totalMinutes % 60;
return `${days}d`
}
transformObjectKeyOrder(originalObject, keyOrder) {
const transformedObject = {};
for (const key of keyOrder) {
if (originalObject.hasOwnProperty(key)) {
transformedObject[key] = originalObject[key];
}
}
// Include any remaining keys not in the specified order
for (const key in originalObject) {
if (!keyOrder.includes(key) && originalObject.hasOwnProperty(key)) {
transformedObject[key] = originalObject[key];
}
}
return transformedObject;
}
endOfMonth(myDate){
let date = new Date(myDate);
date.setDate(1); // Avoids edge cases on the 31st day of some months
date.setMonth(date.getMonth() +1);
date.setDate(0);
date.setHours(23);
date.setMinutes(59);
date.setSeconds(59);
return date;
}
}
interface DayInfo {
// Define properties for dayInfo here
dayName: string
}
interface Day {
// Define properties for day here
}
interface Month {
monthInfo: {
monthName: string
// Define properties for yearInfo inside months here
}
days: {
daysInfo: DayInfo;
events: Day[];
}[]
}
interface Year {
yearInfo: {
yearName: string
// Define properties for yearInfo here
};
months: Month[];
}
const years: Year[] = [
{
yearInfo: {
yearName: ""
// Define properties for yearInfo inside the first year here
},
months: [
{
monthInfo: {
monthName: "",
// Define properties for yearInfo inside the first month here
},
days: [
{
daysInfo: {
dayName: "",
// Define properties for dayInfo inside the first day here
},
events: [
{
// Define properties for the first day here
},
],
}
],
},
// Add more months here as needed
],
},
// Add more years here as needed
];
-39
View File
@@ -1,39 +0,0 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class CacheService {
// A HashMap to store the cache. The key is the page and the value is the data.
private cache = new Map<string, any[]>();
// BehaviorSubject that will contain the updated cache data.
public cache$ = new BehaviorSubject<any[]>(null);
// The 'set' method for storing data in the cache.
set(key: string, data: any[]): void {
// We check if data already exists for this key.
if (this.cache.has(key)) {
// If it already exists, we throw an exception to prevent overwriting the data.
throw new Error(`Data already exists for key '${key}'. Use a different key or delete the existing one first.`);
}
// If there is no data for this key, we store it in the cache and update the BehaviorSubject.
this.cache.set(key, data);
this.cache$.next(this.cache.get(key));
}
// The 'get' method for retrieving data from the cache.
get(key: string): any[] {
// We retrieve the data from the cache and update the BehaviorSubject.
const data = this.cache.get(key);
this.cache$.next(data);
return data;
}
// The 'clear' method to clear data from the cache.
clear(key: string): void {
// We remove the data from the cache and update the BehaviorSubject.
this.cache.delete(key);
this.cache$.next(null);
}
}
-53
View File
@@ -1,53 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ChunksService {
chunkSize: number
private file: File
constructor() {
}
get totalChunks () {
return Math.ceil(this.file.size / this.chunkSize);
}
// Function to read a chunk of the file
readChunk(start: number, end: number): Promise<ArrayBuffer> {
const file = this.file
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
if (reader.result instanceof ArrayBuffer) {
resolve(reader.result);
} else {
reject(new Error("Failed to read chunk"));
}
};
reader.readAsArrayBuffer(file.slice(start, end));
});
}
setFile(file) {
this.file = file
}
async getChunks(i: number,chunkSize: number) {
i--
if(i < this.totalChunks) {
const start = i * chunkSize;
const end = Math.min(start + chunkSize, this.file.size);
const chunk = await this.readChunk(start, end);
return chunk
}
}
}
-16
View File
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { ContactsService } from './contacts.service';
describe('ContactsService', () => {
let service: ContactsService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ContactsService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
-61
View File
@@ -1,61 +0,0 @@
import { Injectable } from '@angular/core';
import { EventPerson } from '../models/eventperson.model';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { LoginUserRespose } from '../models/user.model';
import { SessionStore } from '../store/session.service';
import { ChangeProfileService } from './change-profile.service';
@Injectable({
providedIn: 'root'
})
export class ContactsService {
authheader = {};
loggeduser: LoginUserRespose;
headers: HttpHeaders;
constacts: EventPerson[] = []
constructor(
private http: HttpClient,
user: AuthService,
private changeProfileService: ChangeProfileService) {
this.setHeader()
this.changeProfileService.registerCallback(() => {
this.setHeader()
})
this.getContacts("").subscribe( result => {
this.constacts = result
})
}
setHeader() {
this.loggeduser = SessionStore.user;
this.headers = new HttpHeaders();;
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
}
getContacts(namefilter:string): Observable<EventPerson[]>{
/* const geturl = environment.apiURL + 'contacts/get' */;
const geturl = environment.apiURL + 'userauthentication/list'
let params = new HttpParams();
/* params = params.set("namefilter", namefilter);
params = params.set("domain", environment.domain); */
params = params.set("namefilter", namefilter);
params = params.set("domain", "");
let options = {
headers: this.headers,
params: params
};
return this.http.get<EventPerson[]>(`${geturl}`, options);
}
}
-16
View File
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { DataService } from './data.service';
describe('DataService', () => {
let service: DataService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DataService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { ChatServiceService } from './chat-service.service';
describe('ChatServiceService', () => {
let service: ChatServiceService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ChatServiceService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,9 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ChatServiceService {
constructor() { }
}
+84 -84
View File
@@ -16,58 +16,58 @@ import { Subscribe } from './subcribe';
})
export class EventsService {
authheader = {};
headers: HttpHeaders;
// authheader = {};
// headers: HttpHeaders;
headersPrOficial: HttpHeaders;
headersPrPessoal: HttpHeaders;
// headersPrOficial: HttpHeaders;
// headersPrPessoal: HttpHeaders;
headersMdOficial: HttpHeaders;
headersMdPessoal: HttpHeaders;
// headersMdOficial: HttpHeaders;
// headersMdPessoal: HttpHeaders;
headerOwnOficial: HttpHeaders;
headerOwnPessoal: HttpHeaders;
// headerOwnOficial: HttpHeaders;
// headerOwnPessoal: HttpHeaders;
headerSharedOficial: HttpHeaders;
headerSharedPessoal: HttpHeaders;
// headerSharedOficial: HttpHeaders;
// headerSharedPessoal: HttpHeaders;
headersSharedOficial: HttpHeaders;
headersSharedPessoal: HttpHeaders;
// headersSharedOficial: HttpHeaders;
// headersSharedPessoal: HttpHeaders;
calendarIds = []
usersCalendarIds = []
// calendarIds = []
// usersCalendarIds = []
hasSharedCalendar = false;
hasSharedOficial: boolean = false;
hasSharedPessoal: boolean = false;
// hasSharedCalendar = false;
// hasSharedOficial: boolean = false;
// hasSharedPessoal: boolean = false;
hasOwnOficial: boolean = false;
hasOwnPessoal: boolean = false;
hasOwnCalendar = false
// hasOwnOficial: boolean = false;
// hasOwnPessoal: boolean = false;
// hasOwnCalendar = false
calendarNames = {}
// calendarNames = {}
// calendarNamesAry = []
// calendarNamesAryNoPr = []
// calendarNamesAryNoPrNMD = []
// calendarNamesAryOnlyMD = []
// calendarNamesAryReverse = []
// calendarNamesAryPR = []
// // calendarNamesAry = []
// // calendarNamesAryNoPr = []
// // calendarNamesAryNoPrNMD = []
// // calendarNamesAryOnlyMD = []
// // calendarNamesAryReverse = []
// // calendarNamesAryPR = []
calendarNamesType = {}
calendarRole = []
calendrFullName = []
// calendarNamesType = {}
// calendarRole = []
// calendrFullName = []
myCalendarNames = {}
hasAnyCalendar = false
// myCalendarNames = {}
// hasAnyCalendar = false
HasMdGPR = false
// HasMdGPR = false
onLoadCalendars: Function[] =[]
loadCalendars = false
// onLoadCalendars: Function[] =[]
// loadCalendars = false
onCalendarFinishLoad = new Subscribe({execute : false, deleteOnExecute: true})
// onCalendarFinishLoad = new Subscribe({execute : false, deleteOnExecute: true})
constructor(
private http: HttpClient,
@@ -75,35 +75,35 @@ export class EventsService {
private changeProfileService: ChangeProfileService,
private offlinemanager: OfflineManagerService) {
try {
//this.setHeader()
} catch (e) {
console.log(e)
}
// try {
// //this.setHeader()
// } catch (e) {
// console.log(e)
// }
this.changeProfileService.registerCallback(() => {
try {
//this.setHeader()
} catch (e) {
console.log(e)
}
})
// this.changeProfileService.registerCallback(() => {
// try {
// //this.setHeader()
// } catch (e) {
// console.log(e)
// }
// })
}
async setHeader () {
// async setHeader () {
}
// }
registerOnLoadCalendars(e: Function) {
if( this.loadCalendars) {
e()
} else {
this.onLoadCalendars.push(e)
}
// registerOnLoadCalendars(e: Function) {
// if( this.loadCalendars) {
// e()
// } else {
// this.onLoadCalendars.push(e)
// }
}
// }
// DetectCalendars(CalendarId) {
@@ -232,21 +232,21 @@ export class EventsService {
// }
GetCalendarName(userid:string) {
// GetCalendarName(userid:string) {
let geturl = environment.apiURL + 'userauthentication/single';
// let geturl = environment.apiURL + 'userauthentication/single';
let params = new HttpParams();
// let params = new HttpParams();
params = params.set("id", userid);
// params = params.set("id", userid);
let options = {
headers: this.headers,
params: params
}
// let options = {
// headers: this.headers,
// params: params
// }
return this.http.get<any>(`${geturl}`, options)
}
// return this.http.get<any>(`${geturl}`, options)
// }
// async getAllMdEvents(startdate: string, enddate: string) {
@@ -515,13 +515,13 @@ export class EventsService {
// }
getRecurrenceTypes(): any {
const geturl = environment.apiURL + 'Calendar/RecurrenceTypes';
let options = {
headers: this.headers,
};
return this.http.get<any>(`${geturl}`, options);
}
// getRecurrenceTypes(): any {
// const geturl = environment.apiURL + 'Calendar/RecurrenceTypes';
// // let options = {
// // headers: this.headers,
// // };
// return this.http.get<any>(`${geturl}`, options);
// }
// getEvents(calendarname: string, startdate: string, enddate: string): Observable<Event[]> {
@@ -539,19 +539,19 @@ export class EventsService {
// return this.http.get<Event[]>(`${geturl}`, options);
// }
getEvent(eventid: string): Observable<Event> {
let geturl = environment.apiURL + 'calendar/GetEvent';
let params = new HttpParams();
// getEvent(eventid: string): Observable<Event> {
// let geturl = environment.apiURL + 'calendar/GetEvent';
// let params = new HttpParams();
params = params.set("EventId", eventid);
// params = params.set("EventId", eventid);
let options = {
headers: this.headers,
params: params
};
// let options = {
// headers: this.headers,
// params: params
// };
return this.http.get<Event>(`${geturl}`, options);
}
// return this.http.get<Event>(`${geturl}`, options);
// }
// genericGetEvent(eventid: string, calendarId: string) {
// let geturl = environment.apiURL + 'calendar/GetEvent';
-16
View File
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { FcmService } from './fcm.service';
describe('FcmService', () => {
let service: FcmService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(FcmService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
-23
View File
@@ -1,23 +0,0 @@
import { Injectable } from '@angular/core';
/* import {
Plugins,
PushNotification,
PushNotificationToken,
PushNotificationActionPerformed,
Capacitor
} from '@capacitor/core'; */
import { Router } from '@angular/router';
/* const { PushNotifications } = Plugins; */
@Injectable({
providedIn: 'root'
})
export class FcmService {
constructor(private router: Router) { }
}
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { FileExprorerService } from './file-exprorer.service';
describe('FileExprorerService', () => {
let service: FileExprorerService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(FileExprorerService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,9 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class FileExprorerService {
constructor() { }
}
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { NetworkConnectionService } from './network-connection.service';
describe('NetworkConnectionService', () => {
let service: NetworkConnectionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NetworkConnectionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,28 +0,0 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs'
import { Platform } from '@ionic/angular'
import { Network } from '@capacitor/network';
@Injectable({
providedIn: 'root'
})
export class NetworkConnectionService {
online: boolean = true;
constructor(){
Network.addListener('networkStatusChange', status => {
});
}
logCurrentNetworkStatus = async () => {
const status = await Network.getStatus();
return status;
};
}
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { NotificationMessageService } from './notification-message.service';
describe('NotificationMessageService', () => {
let service: NotificationMessageService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NotificationMessageService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,13 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class NotificationMessageService {
constructor() { }
/*** @description Sem acesso à internet. Por favor verifique sua conexão */
noInternetConnection = 'Sem acesso à internet. Por favor verifique sua conexão'
}
-16
View File
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { PhotoService } from './photo.service';
describe('PhotoService', () => {
let service: PhotoService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PhotoService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
-69
View File
@@ -1,69 +0,0 @@
import { Injectable } from '@angular/core';
/* import { Plugins, CameraResultType, Capacitor, FilesystemDirectory, CameraPhoto, CameraSource } from '@capacitor/core'; */
import { Photo } from '../models/photo';
import { Platform } from '@ionic/angular';
/* import { Camera, CameraOptions } from '@ionic-native/camera/ngx'; */
/* const { Camera, Filesystem, Storage } = Plugins; */
@Injectable({
providedIn: 'root'
})
export class PhotoService {
public photos: Photo[] = [];
private PHOTO_STORAGE: string = "photos";
private platform: Platform;
constructor(platform: Platform,
/* private camera:Camera */
) {
this.platform = platform;
}
async takePicture(){
/* const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
let base64Image = 'data:image/jpeg;base64,' + imageData;
return base64Image;
}, (err) => {
// Handle error
}); */
}
/* async addNewToGallery() {
// Take a photo using Capacitor
const capturedPhoto = await Camera.getPhoto({
resultType: CameraResultType.Base64,
source: CameraSource.Camera,
quality: 90,
width: 1080,
height: 720,
});
this.photos.unshift({
fileName: new Date().getTime() + '.png',
webviewPath: capturedPhoto.base64String,
fileFormat: capturedPhoto.format,
});
} */
}
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { SocketConnectionMCRService } from './socket-connection-mcr.service';
describe('SocketConnectionMCRService', () => {
let service: SocketConnectionMCRService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SocketConnectionMCRService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
-16
View File
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { SqliteService } from './sqlite.service';
describe('SqliteService', () => {
let service: SqliteService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SqliteService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
-11
View File
@@ -1,11 +0,0 @@
import { Injectable } from '@angular/core';
//import { Platform } from '@ionic/angular';
//import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';
@Injectable({
providedIn: 'root'
})
export class SqliteService {
// y
}
@@ -1,124 +0,0 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Filesystem, FilesystemDirectory } from '@capacitor/filesystem';
import { Platform } from '@ionic/angular';
declare var FFmpeg: any;
@Injectable({
providedIn: 'root'
})
export class VideoCompressionService {
constructor(
private http: HttpClient,
private platform: Platform
) { }
async compressVideo(inputFile: string, outputFileName: string, quality: string = 'medium'): Promise<void> {
// Load FFmpeg
await this.loadFFmpeg();
// Input file
const inputBuffer = await this.fetchVideo(inputFile);
// Output file path
const outputPath = await this.getOutputFilePath(outputFileName);
// Run FFmpeg command
await this.runFFmpegCommand(inputBuffer, outputPath, quality);
console.log('Video compression complete!');
}
private async loadFFmpeg(): Promise<void> {
if (!FFmpeg.isLoaded()) {
await FFmpeg.load();
}
}
private async fetchVideo(url: string): Promise<ArrayBuffer> {
const response = await this.http.get(url, { responseType: 'arraybuffer' }).toPromise();
return response;
}
private async getOutputFilePath(outputFileName: string): Promise<string> {
const dataDirectory = await Filesystem.getUri({
directory: FilesystemDirectory.Data,
path: ''
});
return `${dataDirectory.uri}/${outputFileName}`;
}
private async runFFmpegCommand(inputBuffer: ArrayBuffer, outputPath: string, quality: string): Promise<void> {
await FFmpeg.run('-i', inputBuffer, '-c:v', 'libx264', '-preset', quality, outputPath);
}
}
//Mobile
/* import { Injectable } from '@angular/core';
import { HTTP } from '@ionic-native/http/ngx';
import { Filesystem, FilesystemDirectory, FilesystemEncoding } from '@capacitor/filesystem';
import { Platform } from '@ionic/angular';
declare var FFmpeg: any;
@Injectable({
providedIn: 'root'
})
export class VideoCompressionService {
constructor(
private http: HTTP,
private platform: Platform
) { }
async compressVideo(inputFile: string, outputFileName: string, quality: string = 'medium'): Promise<void> {
// Load FFmpeg
await this.loadFFmpeg();
// Input file
const inputBuffer = await this.fetchVideo(inputFile);
// Output file path
const outputPath = await this.getOutputFilePath(outputFileName);
// Run FFmpeg command
await this.runFFmpegCommand(inputBuffer, outputPath, quality);
console.log('Video compression complete!');
}
private async loadFFmpeg(): Promise<void> {
if (!FFmpeg.isLoaded()) {
await FFmpeg.load();
}
}
private async fetchVideo(url: string): Promise<ArrayBuffer> {
const response = await this.http.sendRequest(url, {
method: 'get',
responseType: 'arraybuffer'
});
return response.data;
}
private async getOutputFilePath(outputFileName: string): Promise<string> {
const dataDirectory = await Filesystem.getUri({
directory: FilesystemDirectory.Data,
path: ''
});
return `${dataDirectory.uri}/${outputFileName}`;
}
private async runFFmpegCommand(inputBuffer: ArrayBuffer, outputPath: string, quality: string): Promise<void> {
await FFmpeg.run('-i', inputBuffer, '-c:v', 'libx264', '-preset', quality, outputPath);
}
}
*/
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { VideoconvertService } from './videoconvert.service';
describe('VideoconvertService', () => {
let service: VideoconvertService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(VideoconvertService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { WebsocketService } from './websocket.service';
describe('WebsocketService', () => {
let service: WebsocketService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(WebsocketService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
-49
View File
@@ -1,49 +0,0 @@
import { Injectable } from '@angular/core';
import * as Rx from "rxjs/Rx";
import { Observable, Subject } from "rxjs/Rx";
@Injectable({
providedIn: 'root'
})
export class WebsocketService {
message = '';
public messages: Subject<any>;
currentUser = '';
private subject: Rx.Subject<MessageEvent>;
constructor() {
}
public connect(url): Rx.Subject<MessageEvent> {
if (!this.subject) {
this.subject = this.create(url);
}
return this.subject;
}
private create(url): Rx.Subject<MessageEvent> {
let ws = new WebSocket(url);
let observable = Rx.Observable.create((obs: Rx.Observer<MessageEvent>) => {
ws.onmessage = obs.next.bind(obs);
ws.onerror = obs.error.bind(obs);
ws.onclose = obs.complete.bind(obs);
return ws.close.bind(ws);
});
let observer = {
next: (data: Object) => {
if (ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(data));
}
}
};
return Rx.Subject.create(observer, observable);
}
}