chage file path

This commit is contained in:
Peter Maquiran
2024-08-16 17:45:45 +01:00
parent 9d441a3e5b
commit f18239a021
47 changed files with 137 additions and 79 deletions
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ChatPopoverPage } from './chat-popover.page';
const routes: Routes = [
{
path: '',
component: ChatPopoverPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ChatPopoverPageRoutingModule {}
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { ChatPopoverPageRoutingModule } from './chat-popover-routing.module';
import { ChatPopoverPage } from './chat-popover.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ChatPopoverPageRoutingModule
],
exports: [ChatPopoverPage],
declarations: [ChatPopoverPage]
})
export class ChatPopoverPageModule {}
@@ -0,0 +1,31 @@
<ion-content class="options-container">
<div class="arrow-right header-fix">
<button class="btn-no-color" (click)="close('cancel')">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" class="arrow-right-icon"
src='assets/images/icons-arrow-arrow-right.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" class="arrow-right-icon"
src='assets/images/theme/gov/icons-calendar-arrow-right.svg'></ion-icon>
</button>
</div>
<div class="buttons">
<!-- <button *ngIf="isAdmin" (click)="addUser()" class="btn-cancel" shape="round">Adicionar</button>
<button (click)="leaveGroup()" class="btn-cancel" shape="round">Sair do Grupo</button>
<button *ngIf="isAdmin" (click)="openChangeGroupName()" class="btn-cancel btn-cancel mt-10" shape="round" style="min-width: 192px;">Alterar
nome do grupo</button>
<div class="solid"></div>
<button (click)="close('cancel')" full class="btn-cancel mobile-only" shape="round">Cancelar</button>
<button *ngIf="isAdmin" (click)="deleteGroup()" class="btn-delete" shape="round">Apagar grupo</button>
-->
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<br *ngIf="showLoader">
<button (click)="addUser()" class="btn-cancel" shape="round">Adicionar</button>
<button (click)="leaveGroup()" class="btn-cancel" shape="round">Sair do Grupo</button>
<button (click)="openChangeGroupName()" class="btn-cancel btn-cancel mt-10" shape="round" style="min-width: 192px;">Alterar
nome do grupo</button>
<button (click)="setRoomOwner()" class="btn-cancel" shape="round">Adicionar admin</button>
<div class="solid"></div>
<button (click)="close('cancel')" full class="btn-cancel mobile-only" shape="round">Cancelar</button>
<button (click)="deleteGroup()" class="btn-delete" shape="round">Apagar grupo</button>
</div>
</ion-content>
@@ -0,0 +1,58 @@
.options-container{
--padding-top:20px !important;
--padding-bottom:20px !important;
--padding-start:20px !important;
--padding-end:20px !important;
}
.arrow-right{
display: none;
margin-bottom: 20px;
.arrow-right-icon{
width: 37px;
float: right;
font-size: rem(35);
overflow: hidden;
}
}
.buttons{
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.solid {
display: block;
width: 90%;
border-top: 1px solid #bbb;
margin: 10px auto !important;
}
@media only screen and (min-width: 701px) {
.arrow-right{
display: flex;
justify-content: flex-end;
}
.btn-cancel{
//display: none;
width: 100% !important;
margin-bottom: 10px !important;
}
.btn-cancel:hover, .btn-delete:hover{
background-color: var(--button-hover);
color: #fff !important;
}
.btn-ok{
width: 100% !important;
}
.btn-delete{
width: 100% !important;
margin-bottom: 10px !important;
}
.solid{
display: block;
}
.mobile-only{
display: none !important;
}
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ChatPopoverPage } from './chat-popover.page';
describe('ChatPopoverPage', () => {
let component: ChatPopoverPage;
let fixture: ComponentFixture<ChatPopoverPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChatPopoverPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(ChatPopoverPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,147 @@
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
import { ChatService } from 'src/app/services/chat.service';
import { ToastService } from 'src/app/services/toast.service';
import { ThemeService } from 'src/app/services/theme.service'
import { SetRoomOwnerPage } from 'src/app/modals/set-room-owner/set-room-owner.page';
import { SessionStore } from 'src/app/store/session.service';
import { ZodError } from 'zod';
import { isHttpResponse } from 'src/app/services/http.service';
import { MessageRepositoryService } from 'src/app/module/chat/data/repository/message-respository.service'
import { RoomRepositoryService } from 'src/app/module/chat/data/repository/room-repository.service'
@Component({
selector: 'app-chat-popover',
templateUrl: './chat-popover.page.html',
styleUrls: ['./chat-popover.page.scss'],
})
export class ChatPopoverPage implements OnInit {
roomId:string;
room: any;
isAdmin = false;
isGroupCreated: boolean;
showLoader = false
constructor(
private popoverController: PopoverController,
private modalController: ModalController,
private navParams: NavParams,
private toastService: ToastService,
public ThemeService: ThemeService,
private RoomRepositoryService: RoomRepositoryService
) {
this.roomId = this.navParams.get('roomId');
this.isAdmin = this.navParams.get('isAdmin');
}
ngOnInit() {
// this.chatService.refreshtoken();
}
close(action:any){
if( window.innerWidth < 701){
this.popoverController.dismiss(action);
}
else{
this.modalController.dismiss(action)
}
}
//Top menu options
//Close
async setRoomOwner() {
let classs;
if (window.innerWidth < 701) {
classs = 'modal modal-desktop'
} else {
classs = 'centered-rounded-modal'
}
const modal = await this.modalController.create({
component: SetRoomOwnerPage,
cssClass: classs,
backdropDismiss: true,
componentProps: {
roomId: this.roomId,
isAdmin: this.isAdmin
}
});
await modal.present();
modal.onDidDismiss().then((res)=>{
if(res.data == 'success'){
this.leaveGroup();
//this.ChatSystemService.hidingRoom(this.roomId);
}
});
}
setAdmin() {
this.setRoomOwner();
}
async leaveGroup() {
//this.setRoomOwner();
this.showLoader = true
const result = await this.RoomRepositoryService.leaveRoom({
id: this.roomId,
members: [SessionStore.user.UserId]
})
if(result.isOk()) {
this.close('leave');
// this.openGroupMessage.emit(this.roomId);
} else if (isHttpResponse(result.error)) {
if(result.error.status == 404) {
this.close('leave');
}
// this.httpErrorHandle.httpStatusHandle(result.error)
} else if (result.error instanceof ZodError) {
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
console.log(result.error.errors)
} else {
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
console.log(result.error)
}
this.showLoader = false
}
//Delete
async deleteGroup() {
this.showLoader = true
const result = await this.RoomRepositoryService.deleteRoomById(this.roomId)
if(result.isOk()) {
this.close('delete');
// this.openGroupMessage.emit(this.roomId);
} else if (isHttpResponse(result.error)) {
if(result.error.status == 404) {
this.close('close');
}
} else if (result.error instanceof ZodError) {
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
console.log(result.error.errors)
} else {
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
console.log(result.error)
}
this.showLoader = false
}
async openChangeGroupName(){
this.close('edit');
}
async addUser() {
this.close('addUser');
}
}