first commit

This commit is contained in:
2024-04-19 12:53:45 +07:00
commit 71a3a661dc
1943 changed files with 246917 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { ChatService } from './chat.service';
describe('ChatService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: ChatService = TestBed.get(ChatService);
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,45 @@
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { Chats } from 'src/app/content/applications/chat/chats';
import { Observable } from 'rxjs';
import { Timestamp, FieldValue, arrayUnion } from "firebase/firestore";
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class ChatService {
constructor(private afs: AngularFirestore) { }
getChats() {
return this.afs.collection('chatroom').snapshotChanges();
}
createChatRoom(data) {
return this.afs.collection('chatroom').add(data);
}
showChat(id): Observable<Chats> {
const chat = this.afs.doc<Chats>('chatroom/' + id);
return chat.snapshotChanges()
.pipe(
map(changes => {
const data = changes.payload.data() as Chats;
const chatId = changes.payload.id;
return { chatId, ...data };
}));
}
sendMessage(chatId, data) {
return this.afs.collection('chatroom').doc(chatId).update({
chatHistory: arrayUnion(data)
});
}
updateChatStatus (chatId, history) {
return this.afs.collection('chatroom').doc(chatId).update({
chatHistory: history
});
}
}

View File

@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { TodoService } from './todo.service';
describe('TodoService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: TodoService = TestBed.get(TodoService);
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,53 @@
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import firebase from 'firebase/compat/app';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class TodoService {
formData;
loggedInUser = JSON.parse(localStorage.getItem('currentUser'));
ref = firebase.firestore().collection('todo');
constructor(private firestore: AngularFirestore) {
}
getTODOS(userId) {
return this.firestore.collection('todo', ref => ref.orderBy('createdDate', 'desc')
.where('uid', '==', userId)).snapshotChanges();
}
getAssignedTODOS(userId) {
return this.firestore.collection('todo', ref => ref.orderBy('createdDate', 'desc')
.where('assignedTo.uid', '==', userId)).snapshotChanges();
}
createTodo(todo): Observable<any> {
return new Observable((observer) => {
this.ref.add(todo).then((doc) => {
observer.next({
data: doc
});
});
});
}
sendMessage(todoId, data) {
return this.firestore.collection('todo').doc(todoId).update({
todoComments: data
});
}
updateTODO(id: string, data): Observable<any> {
return new Observable((observer) => {
this.ref.doc(id).set(data).then(() => {
observer.next();
});
});
}
deleteTodo(id: string): Promise<void> {
return this.ref.doc(id).delete();
}
}

View File

@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { UserService } from './user.service';
describe('UserService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: UserService = TestBed.get(UserService);
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import firebase from 'firebase/compat/app';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class UserService {
ref = firebase.firestore().collection('users');
constructor(private firestore: AngularFirestore) {
}
getUsers() {
return this.firestore.collection('users').snapshotChanges();
}
getCurrentUser(userId): Observable<any> {
return this.firestore.collection('users', ref => ref.where('uid', '==', userId)).snapshotChanges();
}
createUser(user) {
return this.ref.add(user);
}
}