diff --git a/package-lock.json b/package-lock.json
index ee75b4756..2b94937bc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -94,6 +94,7 @@
"@logisticinfotech/ionic4-datepicker": "^1.4.4",
"@microsoft/signalr": "^8.0.0",
"@ng-bootstrap/ng-bootstrap": "^9.1.2",
+ "@ngrx/store": "^10.1.2",
"@ngx-translate/core": "^13.0.0",
"@ngxs/store": "^3.8.2",
"@pdftron/pdfjs-express": "^8.0.1",
@@ -164,6 +165,7 @@
"ngx-extended-pdf-viewer": "^13.0.0-alpha.2",
"ngx-image-compress": "^11.0.3",
"ngx-image-cropper": "^5.0.1",
+ "ngx-indexed-db": "^18.0.0",
"ngx-letters-avatar": "^1.0.2",
"ngx-socket-io": "^3.2.0",
"pdfjs": "^2.4.6",
@@ -7567,6 +7569,18 @@
"rxjs": "^6.5.5"
}
},
+ "node_modules/@ngrx/store": {
+ "version": "10.1.2",
+ "resolved": "https://registry.npmjs.org/@ngrx/store/-/store-10.1.2.tgz",
+ "integrity": "sha512-FUjN786ch4Qt9WgJ78ef7Yquq3mPCekgcWgZrs4ycZw1f+KdfTHLTk1bGDtO8A8CzOya5yTT7KhxbdVjbOS5ng==",
+ "dependencies": {
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "@angular/core": "^10.0.0",
+ "rxjs": "^6.5.3"
+ }
+ },
"node_modules/@ngtools/webpack": {
"version": "12.2.18",
"resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-12.2.18.tgz",
@@ -27816,6 +27830,18 @@
"@angular/platform-browser": ">=10.0.0"
}
},
+ "node_modules/ngx-indexed-db": {
+ "version": "18.0.0",
+ "resolved": "https://registry.npmjs.org/ngx-indexed-db/-/ngx-indexed-db-18.0.0.tgz",
+ "integrity": "sha512-G2fUZZOHdFn8+g4fNtTQPX0Hf5huEBsGNvbjhXX8gbeoetVI8i7mPPVxnLwHsG/9WtXlW2690U5JQCptUJQMlA==",
+ "dependencies": {
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "@angular/common": ">=10.0.6",
+ "@angular/core": ">=10.0.6"
+ }
+ },
"node_modules/ngx-letters-avatar": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ngx-letters-avatar/-/ngx-letters-avatar-1.0.2.tgz",
@@ -49374,6 +49400,14 @@
"tslib": "^2.0.0"
}
},
+ "@ngrx/store": {
+ "version": "10.1.2",
+ "resolved": "https://registry.npmjs.org/@ngrx/store/-/store-10.1.2.tgz",
+ "integrity": "sha512-FUjN786ch4Qt9WgJ78ef7Yquq3mPCekgcWgZrs4ycZw1f+KdfTHLTk1bGDtO8A8CzOya5yTT7KhxbdVjbOS5ng==",
+ "requires": {
+ "tslib": "^2.0.0"
+ }
+ },
"@ngtools/webpack": {
"version": "12.2.18",
"resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-12.2.18.tgz",
@@ -65149,6 +65183,14 @@
"tslib": "^2.0.0"
}
},
+ "ngx-indexed-db": {
+ "version": "18.0.0",
+ "resolved": "https://registry.npmjs.org/ngx-indexed-db/-/ngx-indexed-db-18.0.0.tgz",
+ "integrity": "sha512-G2fUZZOHdFn8+g4fNtTQPX0Hf5huEBsGNvbjhXX8gbeoetVI8i7mPPVxnLwHsG/9WtXlW2690U5JQCptUJQMlA==",
+ "requires": {
+ "tslib": "^2.0.0"
+ }
+ },
"ngx-letters-avatar": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ngx-letters-avatar/-/ngx-letters-avatar-1.0.2.tgz",
diff --git a/package.json b/package.json
index c06f607aa..fd3289c9f 100644
--- a/package.json
+++ b/package.json
@@ -110,6 +110,7 @@
"@logisticinfotech/ionic4-datepicker": "^1.4.4",
"@microsoft/signalr": "^8.0.0",
"@ng-bootstrap/ng-bootstrap": "^9.1.2",
+ "@ngrx/store": "^10.1.2",
"@ngx-translate/core": "^13.0.0",
"@ngxs/store": "^3.8.2",
"@pdftron/pdfjs-express": "^8.0.1",
@@ -180,6 +181,7 @@
"ngx-extended-pdf-viewer": "^13.0.0-alpha.2",
"ngx-image-compress": "^11.0.3",
"ngx-image-cropper": "^5.0.1",
+ "ngx-indexed-db": "^18.0.0",
"ngx-letters-avatar": "^1.0.2",
"ngx-socket-io": "^3.2.0",
"pdfjs": "^2.4.6",
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 4699fdb51..e323446a4 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -95,6 +95,8 @@ import { VisibilityDirective } from './services/directives/visibility.directive'
import { DeplomaOptionsPageModule } from './shared/popover/deploma-options/deploma-options.module';
import { DiplomaOptionsPage } from './shared/popover/deploma-options/deploma-options.page';
import { ImageCropperModule } from 'ngx-image-cropper';
+import { createAction, createReducer, on, StoreModule } from '@ngrx/store';
+import { chatReducer } from './services/Repositorys/chat/data-source/room-memory-data-source';
// import { ServiceWorkerModule } from '@angular/service-worker';
// import { AngularFireModule } from '@angular/fire';
// import { AngularFireMessagingModule } from '@angular/fire/messaging';
@@ -122,9 +124,28 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
// Forward the init method to the sibling Framework.
SentrySibling.init
);
+
+export const increment = createAction('[Counter Component] Increment');
+export const decrement = createAction('[Counter Component] Decrement');
+export const reset = createAction('[Counter Component] Reset');
+
+export const initialState = 0;
+
+const _counterReducer = createReducer(
+ initialState,
+ on(increment, (state) => state + 1),
+ on(decrement, (state) => state - 1),
+ on(reset, (state) => 0)
+);
+
+export function counterReducer(state, action) {
+ return _counterReducer(state, action);
+}
+
@NgModule({
declarations: [AppComponent, PopupQuestionPipe, InputFilterDirective],
imports: [BrowserModule,
+ StoreModule.forRoot({ count: counterReducer, chat: chatReducer }),
CommonModule,
FormsModule,
CalendarModule.forRoot({
@@ -223,7 +244,7 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
{ provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptorService, multi: true },
chatTokenInterceptor,
tokenInterceptor,
-
+
],
bootstrap: [AppComponent],
diff --git a/src/app/pages/chat/chat.page.html b/src/app/pages/chat/chat.page.html
index d058c8ae2..01bb8d57a 100644
--- a/src/app/pages/chat/chat.page.html
+++ b/src/app/pages/chat/chat.page.html
@@ -31,160 +31,21 @@
-
-
-
- Conversas
-
-
- Grupos
-
-
-
+
Current Count Object: {{ count$ | async | json }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{room.lastMessage.msg}}
-
está escrever ...
+
+
{{ item.key }}: {{ item.value | json }}
+
+
+
-
-
-
- audio
-
- {{ room.lastMessage.attachments[0].title }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{group.name.split('-').join(' ')}}
-
-
{{group.duration }}
-
{{group.countDownTime }}
-
-
-
{{group.lastMessage.u.name}} : {{group.lastMessage.msg}}
-
{{group.userThatIsTyping}} está escrever ...
-
-
-
-
- audio
-
- {{ group.lastMessage.attachments[0].title }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Current Count: {{ count$ | async }}
+
+
;
+
+
constructor(
private chatService: ChatService,
private modalController: ModalController,
@@ -128,9 +133,12 @@ export class ChatPage implements OnInit {
private eventTriger: EventTrigger,
private RochetChatConnectorService: RochetChatConnectorService,
private zone: NgZone,
- public RouteService: RouteService
+ public RouteService: RouteService,
+ private store: Store<{ chat: RoomRemoteDataSourceState }>
) {
+ this.count$ = store.select('chat');
+
this.headers = new HttpHeaders();;
window.onresize = (event) => {
if (window.innerWidth > 701) {
diff --git a/src/app/pages/events/events.page.html b/src/app/pages/events/events.page.html
index b8356548b..1e09b1f79 100644
--- a/src/app/pages/events/events.page.html
+++ b/src/app/pages/events/events.page.html
@@ -16,6 +16,9 @@
+ Current Count: {{ count$ | async }}
+
+
diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts
index 847a69cda..4f55b4ee9 100644
--- a/src/app/pages/events/events.page.ts
+++ b/src/app/pages/events/events.page.ts
@@ -16,6 +16,10 @@ import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { SessionStore } from 'src/app/store/session.service';
import { TaskService } from 'src/app/services/task.service';
+import { Store } from '@ngrx/store';
+import { Observable } from 'rxjs';
+import { increment } from 'src/app/app.module';
+
@Component({
selector: 'app-events',
templateUrl: './events.page.html',
@@ -78,6 +82,8 @@ export class EventsPage implements OnInit {
}
+ count$: Observable;
+
constructor(
private eventService: EventsService,
private router: Router,
@@ -90,9 +96,17 @@ export class EventsPage implements OnInit {
private storage: Storage,
public p: PermissionService,
private changeProfileService: ChangeProfileService,
- public TaskService: TaskService
+ public TaskService: TaskService,
+ private store: Store<{ count: number }>
) {
+ this.count$ = store.select('count');
+
+ setInterval(() => {
+ this.store.dispatch(increment());
+ }, 5000)
+
+
window['zipPhoneCallback'] = function (zipphone) {
var frame = document.getElementById('home-iframe');
if(frame) {
@@ -157,6 +171,7 @@ export class EventsPage implements OnInit {
}
+
async dynamicSearch() {
const ordinance = this.ordinance
diff --git a/src/app/services/Repositorys/chat/data-source/room-memory-data-source.ts b/src/app/services/Repositorys/chat/data-source/room-memory-data-source.ts
new file mode 100644
index 000000000..b2f13164a
--- /dev/null
+++ b/src/app/services/Repositorys/chat/data-source/room-memory-data-source.ts
@@ -0,0 +1,68 @@
+import { createAction, createFeatureSelector, createReducer, createSelector, on, props } from "@ngrx/store";
+
+export interface Room {
+ roomName: string;
+ text: string;
+ timestamp: number;
+}
+
+export interface ChatRoom {
+ [roomId: string]: Room[];
+}
+
+export interface RoomRemoteDataSourceState {
+ chatRooms: ChatRoom;
+}
+
+export const initialState: RoomRemoteDataSourceState = {
+ chatRooms: {
+ // add more rooms as needed
+ }
+};
+
+export const addMessage = createAction(
+ '[Chat] Add Message',
+ props<{ roomId: string; message: any }>()
+);
+
+export const addRoom = createAction(
+ '[Chat] Add Room',
+ props()
+);
+
+const _chatReducer = createReducer(
+ initialState,
+ on(addMessage, (state, { roomId, message }) => ({
+ ...state,
+ chatRooms: {
+ ...state.chatRooms,
+ [roomId]: [...(state.chatRooms[roomId] || []), message]
+ }
+ })),
+ on(addRoom, (state, roomData: Room) => ({
+ ...state,
+ chatRooms: {
+ ...state.chatRooms,
+ [roomData.roomName]: roomData
+ }
+ }))
+);
+
+export function chatReducer(state, action) {
+ return _chatReducer(state, action);
+}
+
+// Create a feature selector
+export const selectChatState = createFeatureSelector('chat');
+
+// Create a selector for a specific room's messages
+export const selectMessagesByRoom = (roomId: string) => createSelector(
+ selectChatState,
+ (state: RoomRemoteDataSourceState) => state.chatRooms[roomId] || []
+);
+
+// Create a selector for the list of rooms
+export const selectAllRooms = createSelector(
+ selectChatState,
+ (state: RoomRemoteDataSourceState) => Object.keys(state.chatRooms)
+);
diff --git a/src/app/services/Repositorys/chat/data-source/room-remote-data-source.service.spec.ts b/src/app/services/Repositorys/chat/data-source/room-remote-data-source.service.spec.ts
deleted file mode 100644
index 085e70b61..000000000
--- a/src/app/services/Repositorys/chat/data-source/room-remote-data-source.service.spec.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-
-import { RoomRemoteDataSourceService } from './room-remote-data-source.service';
-
-describe('RoomRemoteDataSourceService', () => {
- let service: RoomRemoteDataSourceService;
-
- beforeEach(() => {
- TestBed.configureTestingModule({});
- service = TestBed.inject(RoomRemoteDataSourceService);
- });
-
- it('should be created', () => {
- expect(service).toBeTruthy();
- });
-});
diff --git a/src/app/services/Repositorys/chat/data-source/room-remote-data-source.service.ts b/src/app/services/Repositorys/chat/data-source/room-remote-data-source.service.ts
index 1a84ae853..7c2981dec 100644
--- a/src/app/services/Repositorys/chat/data-source/room-remote-data-source.service.ts
+++ b/src/app/services/Repositorys/chat/data-source/room-remote-data-source.service.ts
@@ -1,15 +1,16 @@
import { Injectable } from '@angular/core';
import { ok, err, Result } from 'neverthrow';
import { HttpService } from 'src/app/services/http.service';
-import { RoomListOutPutDTO } from '../dto/roomOutputDTO';
-
+import { RoomListOutPutDTO } from '../dto/roomListOutputDTO';
+import { RoomListInputDTO } from '../dto/roomInputDTO';
+import { RoomOutPutDTO } from '../dto/roomOutputDTO';
@Injectable({
providedIn: 'root'
})
export class RoomRemoteDataSourceService {
- private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
+ private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
constructor(private httpService: HttpService) {}
@@ -21,11 +22,10 @@ export class RoomRemoteDataSourceService {
return await this.httpService.post(`${this.baseUrl}/Messages/${id}/React`, reaction);
}
- async createRoom(room: any): Promise> {
- return await this.httpService.post(`${this.baseUrl}/Room`, room);
+ async createRoom(data: RoomListInputDTO): Promise> {
+ return await this.httpService.post(`${this.baseUrl}/Room`, data);
}
-
async getRoomList(): Promise> {
return await this.httpService.get(`${this.baseUrl}/Room`);
}
diff --git a/src/app/services/Repositorys/chat/data-source/rooom-local-data-srource.ts b/src/app/services/Repositorys/chat/data-source/rooom-local-data-srource.ts
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/app/services/Repositorys/chat/dto/outPut.ts b/src/app/services/Repositorys/chat/dto/outPut.ts
new file mode 100644
index 000000000..5de5f8d24
--- /dev/null
+++ b/src/app/services/Repositorys/chat/dto/outPut.ts
@@ -0,0 +1,9 @@
+import { z } from "zod";
+
+const OutPutDTOSchema = z.object({
+ success: z.string(),
+ message: z.string(),
+ data: z.any()
+});
+
+export type OutPutDTO = z.infer
diff --git a/src/app/services/Repositorys/chat/dto/roomInputDTO.ts b/src/app/services/Repositorys/chat/dto/roomInputDTO.ts
new file mode 100644
index 000000000..25f5ffcb8
--- /dev/null
+++ b/src/app/services/Repositorys/chat/dto/roomInputDTO.ts
@@ -0,0 +1,11 @@
+import { z } from "zod";
+
+export const RoomListInputDTOSchema = z.object({
+ roomName: z.string(),
+ createdBy: z.number(),
+ roomType: z.number(),
+ expirationDate: z.string().datetime().nullable()
+});
+
+
+export type RoomListInputDTO = z.infer
diff --git a/src/app/services/Repositorys/chat/dto/roomListOutputDTO.ts b/src/app/services/Repositorys/chat/dto/roomListOutputDTO.ts
new file mode 100644
index 000000000..4a9447c44
--- /dev/null
+++ b/src/app/services/Repositorys/chat/dto/roomListOutputDTO.ts
@@ -0,0 +1,21 @@
+import { z } from "zod";
+
+const CreatedBySchema = z.object({
+ wxUserId: z.number(),
+ wxFullName: z.string(),
+ wxeMail: z.string().email(),
+ userPhoto: z.string()
+});
+
+const RoomListOutPutDTOSchema = z.object({
+ id: z.string(),
+ roomName: z.string(),
+ createdBy: CreatedBySchema,
+ createdAt: z.string().datetime(),
+ expirationDate: z.string().datetime(),
+ roomType: z.number()
+});
+
+
+
+export type RoomListOutPutDTO = z.infer
diff --git a/src/app/services/Repositorys/chat/dto/roomOutputDTO.ts b/src/app/services/Repositorys/chat/dto/roomOutputDTO.ts
index 4a9447c44..da74f600d 100644
--- a/src/app/services/Repositorys/chat/dto/roomOutputDTO.ts
+++ b/src/app/services/Repositorys/chat/dto/roomOutputDTO.ts
@@ -1,21 +1,9 @@
import { z } from "zod";
-const CreatedBySchema = z.object({
- wxUserId: z.number(),
- wxFullName: z.string(),
- wxeMail: z.string().email(),
- userPhoto: z.string()
+const RoomOutPutDTOSchema = z.object({
+ success: z.string(),
+ message: z.string(),
+ data: z.any()
});
-const RoomListOutPutDTOSchema = z.object({
- id: z.string(),
- roomName: z.string(),
- createdBy: CreatedBySchema,
- createdAt: z.string().datetime(),
- expirationDate: z.string().datetime(),
- roomType: z.number()
-});
-
-
-
-export type RoomListOutPutDTO = z.infer
+export type RoomOutPutDTO = z.infer
diff --git a/src/app/services/Repositorys/chat/repository/room-repository.service.ts b/src/app/services/Repositorys/chat/repository/room-repository.service.ts
new file mode 100644
index 000000000..5df5dbaef
--- /dev/null
+++ b/src/app/services/Repositorys/chat/repository/room-repository.service.ts
@@ -0,0 +1,37 @@
+import { Injectable } from '@angular/core';
+import { RoomRemoteDataSourceService } from '../data-source/room-remote-data-source.service'
+import { RoomListInputDTO, RoomListInputDTOSchema } from '../dto/roomInputDTO';
+import { IRepositoryReturn } from '../../type';
+import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
+import { addRoom, RoomRemoteDataSourceState } from '../data-source/room-memory-data-source';
+import { Store } from '@ngrx/store';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class RoomRepositoryService {
+
+ constructor(
+ private roomRemoteDataSourceService: RoomRemoteDataSourceService,
+ private roomMemoryDataSourceService: Store
+ ) { }
+
+ list() {
+ this.roomRemoteDataSourceService.getRoomList()
+ }
+
+ @ValidateSchema(RoomListInputDTOSchema)
+ async create(data: RoomListInputDTO): IRepositoryReturn {
+ const result = await this.roomRemoteDataSourceService.createRoom(data)
+
+ if(result.isOk()) {
+ this.roomMemoryDataSourceService.dispatch(addRoom({
+ text: '',
+ timestamp: 0,
+ roomName: data.roomName
+ }))
+ }
+
+ return result
+ }
+}
diff --git a/src/app/services/Repositorys/chat/repository/room-respository.service.ts b/src/app/services/Repositorys/chat/repository/room-respository.service.ts
deleted file mode 100644
index 85910caf9..000000000
--- a/src/app/services/Repositorys/chat/repository/room-respository.service.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Injectable } from '@angular/core';
-import { RoomRemoteDataSourceService } from '../data-source/room-remote-data-source.service'
-@Injectable({
- providedIn: 'root'
-})
-export class RoomRepositoryService {
-
- constructor(
- private roomRemoteDataSourceService: RoomRemoteDataSourceService
- ) { }
-
- list() {
- this.roomRemoteDataSourceService.getRoomList()
- }
-}
diff --git a/src/app/services/Repositorys/type.ts b/src/app/services/Repositorys/type.ts
new file mode 100644
index 000000000..f849abdba
--- /dev/null
+++ b/src/app/services/Repositorys/type.ts
@@ -0,0 +1,5 @@
+import { HttpErrorResponse } from "@angular/common/http";
+import { Result } from "neverthrow";
+import { ZodError } from "zod";
+
+export type IRepositoryReturn = Promise>
diff --git a/src/app/services/decorators/validate-schema.decorator.ts b/src/app/services/decorators/validate-schema.decorator.ts
new file mode 100644
index 000000000..bf6a8ae84
--- /dev/null
+++ b/src/app/services/decorators/validate-schema.decorator.ts
@@ -0,0 +1,21 @@
+import { err } from 'neverthrow';
+import { Schema } from 'zod';
+
+export function ValidateSchema(schema: Schema) {
+ return (
+ target: unknown,
+ propertyKey: string,
+ descriptor: PropertyDescriptor,
+ ) => {
+ const originalMethod = descriptor.value;
+ descriptor.value = function (...args: unknown[]) {
+ try {
+ const model = schema.parse(args[0]);
+ args[0] = model;
+ return originalMethod.apply(this, args);
+ } catch (e) {
+ return err(e)
+ }
+ };
+ };
+}
diff --git a/src/app/services/http.service.ts b/src/app/services/http.service.ts
index 70da0d27c..fd5f35a4a 100644
--- a/src/app/services/http.service.ts
+++ b/src/app/services/http.service.ts
@@ -1,6 +1,6 @@
-import { HttpClient, HttpHeaderResponse, HttpHeaders } from '@angular/common/http';
+import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
-import { environment } from 'src/environments/environment';
+import { ok, err, Result } from 'neverthrow';
@Injectable({
providedIn: 'root'
@@ -9,18 +9,43 @@ export class HttpService {
constructor(private http:HttpClient) { }
- post(serviceName:string, data:any){
- const headers = new HttpHeaders();;
- const options = {header: headers, withCredentials: false};
- const url = environment.apiChatUrl+serviceName;
- const body = {"user": "admin","password": "tabteste@006"};
+ async post(url: string, body: any): Promise> {
- return this.http.post(url, /* JSON.stringify( */data/* ), options */)
+ try {
+ const result = await this.http.post(url, body).toPromise()
+ return ok (result as T)
+ } catch (e) {
+ return err(e as HttpErrorResponse)
+ }
}
- get(serviceName:string, options:any){
- const url = environment.apiChatUrl+serviceName;
- return this.http.get(url, options);
+ async get(url: string): Promise> {
+ try {
+ const result = await this.http.get(url).toPromise()
+ return ok (result as T)
+ } catch (e) {
+ return err(e as HttpErrorResponse)
+ }
+ }
+
+ async put(url: string, body: any): Promise> {
+
+ try {
+ const result = await this.http.put(url, body).toPromise()
+ return ok (result as T)
+ } catch (e) {
+ return err(e as HttpErrorResponse)
+ }
+
+ }
+
+ async delete(url: string): Promise> {
+
+ try {
+ const result = await this.http.delete(url).toPromise()
+ return ok (result as T)
+ } catch (e) {
+ return err(e as HttpErrorResponse)
+ }
}
}
-
diff --git a/src/app/services/new-chat/new-chat-system.service.spec.ts b/src/app/services/new-chat/new-chat-system.service.spec.ts
new file mode 100644
index 000000000..867114338
--- /dev/null
+++ b/src/app/services/new-chat/new-chat-system.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { NewChatSystemService } from './new-chat-system.service';
+
+describe('NewChatSystemService', () => {
+ let service: NewChatSystemService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(NewChatSystemService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/services/new-chat/new-chat-system.service.ts b/src/app/services/new-chat/new-chat-system.service.ts
new file mode 100644
index 000000000..03dbcfdad
--- /dev/null
+++ b/src/app/services/new-chat/new-chat-system.service.ts
@@ -0,0 +1,12 @@
+import { Injectable } from '@angular/core';
+import { RoomRepositoryService } from '../Repositorys/chat/repository/room-repository.service';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class NewChatSystemService {
+
+ constructor(
+ private roomRepositoryService: RoomRepositoryService
+ ) { }
+}
diff --git a/src/app/shared/chat/new-group/new-group.page.html b/src/app/shared/chat/new-group/new-group.page.html
index 7535a5970..b312c6fc9 100644
--- a/src/app/shared/chat/new-group/new-group.page.html
+++ b/src/app/shared/chat/new-group/new-group.page.html
@@ -28,7 +28,7 @@
-
+
Grupo Ultra-secreto
diff --git a/src/app/shared/chat/new-group/new-group.page.ts b/src/app/shared/chat/new-group/new-group.page.ts
index ff091b870..be1e89a5a 100644
--- a/src/app/shared/chat/new-group/new-group.page.ts
+++ b/src/app/shared/chat/new-group/new-group.page.ts
@@ -8,6 +8,8 @@ import { GroupContactsPage } from '../group-messages/group-contacts/group-contac
import { ToastService } from 'src/app/services/toast.service';
import { ThemeService } from 'src/app/services/theme.service';
import { RouteService } from 'src/app/services/route.service';
+import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service';
+import { HttpErrorResponse } from '@angular/common/http';
@Component({
selector: 'app-new-group',
templateUrl: './new-group.page.html',
@@ -18,7 +20,7 @@ export class NewGroupPage implements OnInit{
showLoader: boolean;
displayDuration: any;
showDuration: boolean;
- thedate:any;
+ expirationDate:any;
_day:any;
selectedDuration = ['','',''];
countDownTime:any;
@@ -49,7 +51,8 @@ export class NewGroupPage implements OnInit{
private toastService: ToastService,
public ThemeService: ThemeService,
private RouteService: RouteService,
- private viewContainerRef: ViewContainerRef
+ private viewContainerRef: ViewContainerRef,
+ private roomRepositoryService: RoomRepositoryService
)
{
this.loggedUserChat = SessionStore.user.ChatData['data'];
@@ -83,15 +86,15 @@ export class NewGroupPage implements OnInit{
}
- _ionChange(event) {
+ onDateExpirationChange(event) {
this.showDuration = event.detail.checked;
if(event.detail.checked) {
- this.thedate = new Date();
+ this.expirationDate = new Date();
}
else {
- this.thedate = '';
+ this.expirationDate = '';
}
}
@@ -113,61 +116,83 @@ export class NewGroupPage implements OnInit{
}
async createGroup() {
+ this.createGroup1()
- let name = this.groupName.split(' ').join('-');
- //Take out all special characters in string
- name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
+ // let name = this.groupName.split(' ').join('-');
+ // //Take out all special characters in string
+ // name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
- let customFields = {}
- let res:any;
+ // let customFields = {}
+ // let res:any;
- const loader = this.toastService.loading();
+ // const loader = this.toastService.loading();
- if(this.thedate) {
- let customFields = {
- "countDownDate":this.thedate
- }
- res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
- }
- else {
- res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
- }
+ // if(this.expirationDate) {
+ // let customFields = {
+ // "countDownDate":this.expirationDate
+ // }
+ // res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
+ // }
+ // else {
+ // res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
+ // }
- loader.remove();
+ // loader.remove();
- // FsId
- // DocId
+ // // FsId
+ // // DocId
- if(res?.result?.rid) {
- this.addGroupMessage.emit(res.result.rid);
+ // if(res?.result?.rid) {
+ // this.addGroupMessage.emit(res.result.rid);
- this.ChatSystemService.getAllRooms(() => {
- if(!this.ChatSystemService.getGroupRoom(res.result.rid)) {
- this.createGroupWithAttachmentsCath(res)
- } else {
- setTimeout(()=> {
+ // this.ChatSystemService.getAllRooms(() => {
+ // if(!this.ChatSystemService.getGroupRoom(res.result.rid)) {
+ // this.createGroupWithAttachmentsCath(res)
+ // } else {
+ // setTimeout(()=> {
- this.createGroupWithAttachments(res)
+ // this.createGroupWithAttachments(res)
- }, 500)
- }
- }, res.result.rid);
+ // }, 500)
+ // }
+ // }, res.result.rid);
- } else {
+ // } else {
- this.toastService._badRequest('Existe um grupo com este nome!');
+ // this.toastService._badRequest('Existe um grupo com este nome!');
+
+ // }
+
+ }
+
+
+ async createGroup1() {
+ const result = await this.roomRepositoryService.create({
+ roomName: this.groupName,
+ createdBy: 0,
+ roomType: 0,
+ expirationDate: null
+ })
+
+
+ console.log(result)
+
+ if(result.isOk()) {
+
+ } else if(result.error instanceof HttpErrorResponse) {
}
}
+
createGroupWithAttachmentsCath(res: any) {
if(!this.ChatSystemService.getGroupRoom(res.result.rid)) {
- setTimeout(()=>{
+ setTimeout(() => {
this.createGroupWithAttachmentsCath(res)
}, 1500)
} else {
@@ -261,7 +286,7 @@ export class NewGroupPage implements OnInit{
handler:(value:any)=>{
let now = new Date();
- this.thedate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + value.days.value, now.getHours() + value.hours.value, now.getMinutes() + value.minutes.value, now.getSeconds(), now.getMilliseconds());
+ this.expirationDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + value.days.value, now.getHours() + value.hours.value, now.getMinutes() + value.minutes.value, now.getSeconds(), now.getMilliseconds());
this.selectedDuration = [
value.days.value,