diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index f08d68e49..eaeb56b01 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,170 +1,174 @@ -import { NgModule } from '@angular/core'; -import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; -import { ChatPage } from './pages/chat/chat.page'; -import { MessagesPage } from './pages/chat/messages/messages.page'; - -const routes = [ - { - path: '', - loadChildren: () => import('./index/index.module').then(m => m.IndexPageModule) - }, - { - path: '', - loadChildren: () => import('./home/home.module').then( m => m.HomePageModule) - }, - { - path: 'empty-chat', - loadChildren: () => import('./shared/chat/empty-chat/empty-chat.module').then( m => m.EmptyChatPageModule) - }, - { - path: 'empty-container', - loadChildren: () => import('./shared/empty-container/empty-container.module').then( m => m.EmptyContainerPageModule) - }, - { - path: 'events-to-approve', - loadChildren: () => import('./shared/gabinete-digital/events-to-approve/events-to-approve.module').then( m => m.EventsToApprovePageModule) - }, - { - path: 'expedients', - loadChildren: () => import('./shared/gabinete-digital/expedients/expedients.module').then( m => m.ExpedientsPageModule) - }, - { - path: 'document-detail', - loadChildren: () => import('./modals/document-detail/document-detail.module').then( m => m.DocumentDetailPageModule) - }, - { - path: 'edit-group', - loadChildren: () => import('./shared/chat/edit-group/edit-group.module').then( m => m.EditGroupPageModule) - }, - { - path: 'pedidos', - loadChildren: () => import('./shared/gabinete-digital/pedidos/pedidos.module').then( m => m.PedidosPageModule) - }, - { - path: 'event-list', - loadChildren: () => import('./pages/gabinete-digital/event-list/event-list.module').then(m =>m.EventListPageModule) - }, - { - path: 'despachos', - loadChildren: () => import('./shared/gabinete-digital/despachos/despachos.module').then( m => m.DespachosPageModule) - }, - { - path: 'create-process', - loadChildren: () => import('./modals/create-process/create-process.module').then( m => m.CreateProcessPageModule) - }, - { - path: 'pendentes', - loadChildren: () => import('./shared/gabinete-digital/pendentes/pendentes.module').then( m => m.PendentesPageModule) - }, - { - path: 'delegar', - loadChildren: () => import('./modals/delegar/delegar.module').then( m => m.DelegarPageModule) - }, - { - path: 'add-note', - loadChildren: () => import('./modals/add-note/add-note.module').then( m => m.AddNotePageModule) - }, - { - path: 'dar-parecer', - loadChildren: () => import('./modals/dar-parecer/dar-parecer.module').then( m => m.DarParecerPageModule) - }, - { - path: 'opts-expediente', - loadChildren: () => import('./shared/popover/opts-expediente/opts-expediente.module').then( m => m.OptsExpedientePageModule) - }, - { - path: 'despachos-pr', - loadChildren: () => import('./shared/gabinete-digital/despachos-pr/despachos-pr.module').then( m => m.DespachosPrPageModule) - }, - { - path: 'diplomas', - loadChildren: () => import('./shared/gabinete-digital/diplomas/diplomas.module').then( m => m.DiplomasPageModule) - }, - { - path: 'expedientes-pr', - loadChildren: () => import('./shared/gabinete-digital/expedientes-pr/expedientes-pr.module').then( m => m.ExpedientesPrPageModule) - }, - { - path: 'diplomas-assinar', - loadChildren: () => import('./shared/gabinete-digital/diplomas-assinar/diplomas-assinar.module').then( m => m.DiplomasAssinarPageModule) - }, - { - path: 'opts-expediente-pr', - loadChildren: () => import('./shared/popover/opts-expediente-pr/opts-expediente-pr.module').then( m => m.OptsExpedientePrPageModule) - }, - { - path: 'despachos-options', - loadChildren: () => import('./shared/popover/despachos-options/despachos-options.module').then( m => m.DespachosOptionsPageModule) - }, - { - path: 'despachos-pr-options', - loadChildren: () => import('./shared/popover/despachos-pr-options/despachos-pr-options.module').then( m => m.DespachosPrOptionsPageModule) - }, - { - path: 'deploma-options', - loadChildren: () => import('./shared/popover/deploma-options/deploma-options.module').then( m => m.DeplomaOptionsPageModule) - }, - { - path: 'pin', - loadChildren: () => import('./shared/pin/pin.module').then( m => m.PinPageModule) - }, - { - path: 'fingerprint', - loadChildren: () => import('./shared/fingerprint/fingerprint.module').then( m => m.FingerprintPageModule) - }, - { - path: 'new-event', - loadChildren: () => import('./shared/agenda/new-event/new-event.module').then( m => m.NewEventPageModule) - }, - { - path: 'event-list', - loadChildren: () => import('./shared/agenda/event-list/event-list.module').then( m => m.EventListPageModule) - }, - { - path: 'approve-event', - loadChildren: () => import('./shared/agenda/approve-event/approve-event.module').then( m => m.ApproveEventPageModule) - }, - { - path: 'bad-request', - loadChildren: () => import('./shared/popover/bad-request/bad-request.module').then( m => m.BadRequestPageModule) - }, - { - path: 'success-message', - loadChildren: () => import('./shared/popover/success-message/success-message.module').then( m => m.SuccessMessagePageModule) - }, - { - path: 'forward', - loadChildren: () => import('./modals/forward/forward.module').then( m => m.ForwardPageModule) - }, - { - path: 'edit-event-to-approve', - loadChildren: () => import('./shared/agenda/edit-event-to-approve/edit-event-to-approve.module').then( m => m.EditEventToApprovePageModule) - }, - { - path: 'actions-options', - loadChildren: () => import('./shared/popover/actions-options/actions-options.module').then( m => m.ActionsOptionsPageModule) - }, - { - path: 'edit-action', - loadChildren: () => import('./shared/publication/edit-action/edit-action.module').then( m => m.EditActionPageModule) - }, - { - path: 'eliminate-event', - loadChildren: () => import('./modals/eliminate-event/eliminate-event.module').then( m => m.EliminateEventPageModule) +import { NgModule } from '@angular/core'; +import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; +import { ChatPage } from './pages/chat/chat.page'; +import { MessagesPage } from './pages/chat/messages/messages.page'; + +const routes = [ + { + path: '', + loadChildren: () => import('./index/index.module').then(m => m.IndexPageModule) + }, + { + path: '', + loadChildren: () => import('./home/home.module').then( m => m.HomePageModule) + }, + { + path: 'empty-chat', + loadChildren: () => import('./shared/chat/empty-chat/empty-chat.module').then( m => m.EmptyChatPageModule) + }, + { + path: 'empty-container', + loadChildren: () => import('./shared/empty-container/empty-container.module').then( m => m.EmptyContainerPageModule) + }, + { + path: 'events-to-approve', + loadChildren: () => import('./shared/gabinete-digital/events-to-approve/events-to-approve.module').then( m => m.EventsToApprovePageModule) + }, + { + path: 'expedients', + loadChildren: () => import('./shared/gabinete-digital/expedients/expedients.module').then( m => m.ExpedientsPageModule) + }, + { + path: 'document-detail', + loadChildren: () => import('./modals/document-detail/document-detail.module').then( m => m.DocumentDetailPageModule) + }, + { + path: 'edit-group', + loadChildren: () => import('./shared/chat/edit-group/edit-group.module').then( m => m.EditGroupPageModule) + }, + { + path: 'pedidos', + loadChildren: () => import('./shared/gabinete-digital/pedidos/pedidos.module').then( m => m.PedidosPageModule) + }, + { + path: 'event-list', + loadChildren: () => import('./pages/gabinete-digital/event-list/event-list.module').then(m =>m.EventListPageModule) + }, + { + path: 'despachos', + loadChildren: () => import('./shared/gabinete-digital/despachos/despachos.module').then( m => m.DespachosPageModule) + }, + { + path: 'create-process', + loadChildren: () => import('./modals/create-process/create-process.module').then( m => m.CreateProcessPageModule) + }, + { + path: 'pendentes', + loadChildren: () => import('./shared/gabinete-digital/pendentes/pendentes.module').then( m => m.PendentesPageModule) + }, + { + path: 'delegar', + loadChildren: () => import('./modals/delegar/delegar.module').then( m => m.DelegarPageModule) + }, + { + path: 'add-note', + loadChildren: () => import('./modals/add-note/add-note.module').then( m => m.AddNotePageModule) + }, + { + path: 'dar-parecer', + loadChildren: () => import('./modals/dar-parecer/dar-parecer.module').then( m => m.DarParecerPageModule) + }, + { + path: 'opts-expediente', + loadChildren: () => import('./shared/popover/opts-expediente/opts-expediente.module').then( m => m.OptsExpedientePageModule) + }, + { + path: 'despachos-pr', + loadChildren: () => import('./shared/gabinete-digital/despachos-pr/despachos-pr.module').then( m => m.DespachosPrPageModule) + }, + { + path: 'diplomas', + loadChildren: () => import('./shared/gabinete-digital/diplomas/diplomas.module').then( m => m.DiplomasPageModule) + }, + { + path: 'expedientes-pr', + loadChildren: () => import('./shared/gabinete-digital/expedientes-pr/expedientes-pr.module').then( m => m.ExpedientesPrPageModule) + }, + { + path: 'diplomas-assinar', + loadChildren: () => import('./shared/gabinete-digital/diplomas-assinar/diplomas-assinar.module').then( m => m.DiplomasAssinarPageModule) + }, + { + path: 'opts-expediente-pr', + loadChildren: () => import('./shared/popover/opts-expediente-pr/opts-expediente-pr.module').then( m => m.OptsExpedientePrPageModule) + }, + { + path: 'despachos-options', + loadChildren: () => import('./shared/popover/despachos-options/despachos-options.module').then( m => m.DespachosOptionsPageModule) + }, + { + path: 'despachos-pr-options', + loadChildren: () => import('./shared/popover/despachos-pr-options/despachos-pr-options.module').then( m => m.DespachosPrOptionsPageModule) + }, + { + path: 'deploma-options', + loadChildren: () => import('./shared/popover/deploma-options/deploma-options.module').then( m => m.DeplomaOptionsPageModule) + }, + { + path: 'pin', + loadChildren: () => import('./shared/pin/pin.module').then( m => m.PinPageModule) + }, + { + path: 'fingerprint', + loadChildren: () => import('./shared/fingerprint/fingerprint.module').then( m => m.FingerprintPageModule) + }, + { + path: 'new-event', + loadChildren: () => import('./shared/agenda/new-event/new-event.module').then( m => m.NewEventPageModule) + }, + { + path: 'event-list', + loadChildren: () => import('./shared/agenda/event-list/event-list.module').then( m => m.EventListPageModule) + }, + { + path: 'approve-event', + loadChildren: () => import('./shared/agenda/approve-event/approve-event.module').then( m => m.ApproveEventPageModule) + }, + { + path: 'bad-request', + loadChildren: () => import('./shared/popover/bad-request/bad-request.module').then( m => m.BadRequestPageModule) + }, + { + path: 'success-message', + loadChildren: () => import('./shared/popover/success-message/success-message.module').then( m => m.SuccessMessagePageModule) + }, + { + path: 'forward', + loadChildren: () => import('./modals/forward/forward.module').then( m => m.ForwardPageModule) + }, + { + path: 'edit-event-to-approve', + loadChildren: () => import('./shared/agenda/edit-event-to-approve/edit-event-to-approve.module').then( m => m.EditEventToApprovePageModule) + }, + { + path: 'actions-options', + loadChildren: () => import('./shared/popover/actions-options/actions-options.module').then( m => m.ActionsOptionsPageModule) + }, + { + path: 'edit-action', + loadChildren: () => import('./shared/publication/edit-action/edit-action.module').then( m => m.EditActionPageModule) + }, + { + path: 'eliminate-event', + loadChildren: () => import('./modals/eliminate-event/eliminate-event.module').then( m => m.EliminateEventPageModule) + }, { + path: 'inactivity', + loadChildren: () => import('./pages/inactivity/inactivity.module').then( m => m.InactivityPageModule) }, - - /* - path: 'chat', - component: ChatPage - } */ - -]; -@NgModule({ - imports: [ - RouterModule.forRoot(routes, - { preloadingStrategy: PreloadAllModules }) - ], - exports: [RouterModule] -}) -export class AppRoutingModule {} + + + /* + path: 'chat', + component: ChatPage + } */ + +]; +@NgModule({ + imports: [ + RouterModule.forRoot(routes, + { preloadingStrategy: PreloadAllModules }) + ], + exports: [RouterModule] +}) +export class AppRoutingModule {} diff --git a/src/app/home/home-routing.module.ts b/src/app/home/home-routing.module.ts index 338ccf71b..83fdd6ad4 100644 --- a/src/app/home/home-routing.module.ts +++ b/src/app/home/home-routing.module.ts @@ -356,6 +356,16 @@ const routes: Routes = [ ], }, + { + path: 'inactivity', + children: [ + { + path:'', + loadChildren: ()=> import('../pages/inactivity/inactivity.module').then(m => m.InactivityPageModule) + }, + ], + + }, ], canActivate: [AuthGuard] diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html index c8d9ad52d..d1ba2aeaa 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -376,15 +376,18 @@ - + + + + + + + + + + + + + + + + + + Inicie a sessão + + Email + + + + Palavra-passe + + + + + Iniciar + + + + Uma iniciativa do Gabinete do Presidente da República + + + + + + + + + + + + + Digite o PIN + Digite o novo PIN + + + = 1"> + = 2"> + = 3"> + = 4"> + + + + + 1 2 3 + + + + 4 5 6 + + + + 7 8 9 + + + + 0 + + + + + + Entrar com senha + + + + Limpar + + + + + + + + + diff --git a/src/app/pages/inactivity/inactivity.page.scss b/src/app/pages/inactivity/inactivity.page.scss new file mode 100644 index 000000000..88f9eae74 --- /dev/null +++ b/src/app/pages/inactivity/inactivity.page.scss @@ -0,0 +1,219 @@ +@import '~src/function.scss'; +:host, app-login { + ion-content { + background: linear-gradient(180deg, #42B9FE 0%, #0782C9 100%) !important; + } +} +ion-content{ + background-color: white !important; +} + +.main-wrapper{ + background: linear-gradient(180deg, #42B9FE 0%, #0782C9 100%) !important; + display: flex; + width: 100vw; + height: 100vh; + overflow: auto; + +} +.wrapper{ + width: 400px; + height: auto; + padding: 0 !important; + margin: auto !important; + overflow: auto; +} +.logo{ + width: 400px; + height: 400px; + background-image: url("/assets/background/auth.svg"); + background-position: center; + background-repeat: no-repeat; +} +.bg-1{ + width: 250px; + height: 250px; + overflow: auto; + border-radius: 50%; + background: #4cb9f825; + margin: auto; + .bg-2{ + width: 225px; + height: 225px; + overflow: auto; + border-radius: 50%; + background: #61bdf2b4; + margin: auto; + .bg-3{ + width: 200px; + height: 200px; + overflow: auto; + border-radius: 50%; + background: #96d3f8be; + margin: auto; + .bg-4{ + width: 175px; + height: 175px; + overflow: auto; + border-radius: 50%; + background: rgba(255, 255, 255, 0.918); + padding: 15px; + margin: auto; + + .bg-4 img{ + width: 100%; + } + } + } + } +} +.div-logo{ + width: 200px !important; + margin: 0 auto; + padding-bottom: 15px; + +} +.div-logo img{ + width: 100%; +} +.wrapper ion-input{ + font-size: 16px; +} +.wrapper ion-button{ + font-size: medium; + margin-top: 16px; +} +ion-item{ + --background: transparent; +} +.form{ + width: 300px; + margin: auto; + overflow: auto; +} +.form-label{ + margin: 15px 0 5px 0; + font-size: 15px; +} +.form-input{ + --background: #fff; + --color:#000; + border-radius: 22.5px; + margin: 10px 0 10px 0; +} +.btn-login{ + font-size: 16px; + } + + + + + + +.div-top-header{ + margin: 0 em(20px); + padding-top: em(15px); + border: 0!important; +} + +.div-logo { + background: transparent; + width: em(140px); + justify-content: center; + display: flex; +} +.div-logo img{ + width: 100%; + margin: 0px auto; +} + + + +.circle{ + color: white; + width: 70px; + height: 70px; + display: flex; + align-items: center; + justify-content: center; + font-size: 19pt; + background: #44b5ea; + border-radius: 56px; + margin-left: 30px; + margin-bottom: 15px; + user-select: none; +} + +.title{ + padding-top: 32px; +} + +.terminal { + padding-top: 112px; + margin-left: -30px; + justify-content: center; + display: flex; + flex-direction: column; + align-items: center; +} + +.clear{ + color: #44b5ea; + font-size: 12pt; +} +.dot-active{ + background: #44b5ea; +} + +.dot{ + width: 25px; + height: 25px; + margin: 0 10px 0 0; + border: 3px solid #44b5ea; + box-sizing: border-box; + border-radius: 50px; + -webkit-border-radius: 50px; + -moz-border-radius: 50px; + -ms-border-radius: 50px; + -o-border-radius: 50px; +} + +.main-content { + width: 100vw; + height: 100vh; + background-color: white; + text-align: center; + align-items: center; + justify-content: center; + background-image: url("/assets/background/auth.svg"); + background-size: 686px 674px; + background-position: center; + background-position-y: 110px; + background-repeat: no-repeat; + margin: auto; +} + +.voltar{ + user-select: none; +} + +.msg-bottom{ + width: 100%; + color: #fff; + align-items: center; + justify-content: center; + + .msg-bottom-p{ + width: 220px; + position: absolute; + bottom: 0 !important; + text-align: center; + } +} + +@media only screen and (max-height: 746px){ + .msg-bottom-p { + padding-top: 20px; + position: unset !important; + } +} \ No newline at end of file diff --git a/src/app/pages/inactivity/inactivity.page.spec.ts b/src/app/pages/inactivity/inactivity.page.spec.ts new file mode 100644 index 000000000..f993dacaa --- /dev/null +++ b/src/app/pages/inactivity/inactivity.page.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; + +import { InactivityPage } from './inactivity.page'; + +describe('InactivityPage', () => { + let component: InactivityPage; + let fixture: ComponentFixture; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ InactivityPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(InactivityPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts new file mode 100644 index 000000000..92db2288d --- /dev/null +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -0,0 +1,194 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { AuthService } from 'src/app/services/auth.service'; +import { UserForm } from 'src/app/models/user.model'; +import { ToastService } from 'src/app/services/toast.service'; +import { environment } from 'src/environments/environment'; +import { AlertController } from '@ionic/angular'; +import { NotificationsService } from 'src/app/services/notifications.service'; +import crypto from 'crypto-js' +import { LocalstoreService } from 'src/app/store/localstore.service'; + +@Component({ + selector: 'app-inactivity', + templateUrl: './inactivity.page.html', + styleUrls: ['./inactivity.page.scss'], +}) +export class InactivityPage implements OnInit { + + logstatus: boolean; + username: string = environment.defaultuser; + password: string = environment.defaultuserpwd; + userattempt: UserForm; + code = [] + + hasPin: boolean + loginPreference: string + hasSession = false + setPin = false + + constructor( + private notificatinsservice: NotificationsService, + private router: Router, + private authService: AuthService, + private toastService: ToastService, + public alertController: AlertController, + private localstoreService: LocalstoreService + ) { + } + + ngOnInit() { + // clear local storage + window.localStorage.clear(); + + let userData = this.localstoreService.get('UserData', {}) + + const loginPreference = userData?.loginPreference + const pin = userData?.PIN + + } + + //Function to validade the login inputs + validateUsername() { + return ( + this.username.trim().length > 0 + ); + } + + validatePassword() { + return ( + this.password.trim().length > 0 + ); + } + + async presentAlert(message: string) { + const alert = await this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Mensagem do sistema', + message: message, + buttons: ['OK'] + }); + + await alert.present(); + } + + /* loginRocketChat() { + + let postData = { + "user": this.username, + "password": this.password, + } + + this.authService.loginChat(postData).subscribe((res: any) => { + console.log(res.data); + this.storageService.store(AuthConnstants.AUTH, res.data); + console.log('Login to Rocket chat OK'); + }, (error: any) => { + console.log('Network error'); + this.presentAlert('Network error ' + error); + }); + } */ + + getToken() { + this.notificatinsservice.getAndpostToken(this.username); + } + + async Login() { + + if (this.validateUsername()) { + if(this.validatePassword()){ + + this.userattempt = { + username: this.username, + password: this.password, + domainName: environment.domain, + BasicAuthKey: "" + } + let attempt = await this.authService.login(this.userattempt) + + if (attempt) { + this.authService.loginChat(this.userattempt); + this.getToken(); + this.hasSession = true + this.hasPin = false + this.setPin = true + + if(!this.hasPin || this.hasPin) { + } else { + this.router.navigate(['/home/events']); + } + } + } + else { + this.toastService.badRequest('Por favor, insira a sua palavra-passe'); + } + } + else { + this.toastService.badRequest('Por favor, insira o seu nome de utilizador'); + } + } + + setCode(code: string) { + + if(this.code.length < 4) { + this.code.push(code) + } + + if(this.code.length == 4) { + + const code = this.code.join('') + const encrypted = crypto.SHA1(code) + + if(!this.hasPin) { + // alert('storePin') + this.storePin() + } else { + // alert('pinLogin') + this.pinLogin() + } + } + } + + clearCode() { + this.code =[] + } + + pinLogin() { + + const code = this.code.join('') + const encrypted = crypto.SHA1(code) + + let userData = this.localstoreService.get('UserData', {}) + const pin = userData?.PIN + + //if( encrypted == pin) { + + if( encrypted == this.localstoreService.get('UserData', false)) { + + //this.toastService.successMessage() + this.router.navigate(['/home/events']); + } else { + this.toastService.badRequest('Pin incorreto') + this.code = [] + } + + } + + storePin() { + + const code = this.code.join('') + const encrypted = crypto.SHA1(code).toString() + let userData: Object = this.localstoreService.get('UserData', {}) + + userData['PIN'] = encrypted + userData['loginPreference'] = 'none' + + this.localstoreService.set('UserData', userData) + + this.localstoreService.set('PIN', encrypted) + + this.router.navigate(['/home/events']); + + } + +} diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index ad25f1dfc..14a4b624a 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -130,7 +130,7 @@ export class NewPublicationPage implements OnInit { this.Form = new FormGroup({ Subject: new FormControl(this.pub.Title, [ - Validators.required, + //Validators.required, // Validators.minLength(4) ]), capturedImage: new FormControl(this.capturedImage, [ @@ -215,6 +215,34 @@ export class NewPublicationPage implements OnInit { loader.remove() } + } else { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId:this.publication.DocumentId, + ProcessId:this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.capturedImageTitle, + FileBase64: this.capturedImage, + FileExtension: 'jpeg', + } + + console.log('Edit change image'); + console.log(this.publication); + const loader = this.toastService.loading() + + try { + await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() + this.toastService.successMessage("Publicação criado") + + this.close(); + } catch (error) { + this.toastService.badRequest("Publicação não criado") + } finally { + loader.remove() + } + } } else { diff --git a/src/app/shared/agenda/approve-event/approve-event.page.html b/src/app/shared/agenda/approve-event/approve-event.page.html index cfd4ab74c..dd0adcb95 100644 --- a/src/app/shared/agenda/approve-event/approve-event.page.html +++ b/src/app/shared/agenda/approve-event/approve-event.page.html @@ -102,6 +102,6 @@ Adicionar Nota Aprovar - Rejeitar + Rejeitar diff --git a/src/app/shared/agenda/approve-event/approve-event.page.ts b/src/app/shared/agenda/approve-event/approve-event.page.ts index 4c7e8a407..c55044ef5 100644 --- a/src/app/shared/agenda/approve-event/approve-event.page.ts +++ b/src/app/shared/agenda/approve-event/approve-event.page.ts @@ -18,7 +18,7 @@ import { ToastService } from 'src/app/services/toast.service'; export class ApproveEventPage implements OnInit { event: Event; - loadedEvent:any; + @Input() loadedEvent:any; loadedAttachments:any; customDate:any; today:any; @@ -28,6 +28,8 @@ export class ApproveEventPage implements OnInit { days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; @Input() serialNumber:string; + @Input() showComponent:string; + @Input() componentTransparent: any @Input() InstanceId:string; @Input() showAside:boolean; @@ -58,7 +60,11 @@ export class ApproveEventPage implements OnInit { ngOnInit() { this.getTask(); this.getAttachments(); - + } + + ngOnChanges() { + this.getTask(); + this.getAttachments(); } notImplemented() { @@ -94,6 +100,7 @@ export class ApproveEventPage implements OnInit { } catch (error) { this.toastService.badRequest() } finally { + this.close() loader.remove() } @@ -121,8 +128,9 @@ export class ApproveEventPage implements OnInit { this.toastService.successMessage('Evento rejeitado') } catch (error) { this.toastService.badRequest('Processo não efectuado') - } finally { + } finally { loader.remove() + this.close() } } diff --git a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts index 7c5cb35a6..d5ffcf0dd 100644 --- a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts +++ b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts @@ -247,14 +247,14 @@ export class EditEventToApprovePage implements OnInit { // Validators.required // ]), participantes: new FormControl(this.taskParticipants, [ - Validators.required + // Validators.required ]), }) } - save() { - + async save() { + this.injectValidation() this.runValidation() @@ -263,6 +263,8 @@ export class EditEventToApprovePage implements OnInit { // set dates to eventProcess object this.getDatepickerData() + + this.taskParticipantsCc.forEach( e => { e.IsRequired = false }) @@ -300,24 +302,28 @@ export class EditEventToApprovePage implements OnInit { console.log(event); - this.eventsService.postEventToApproveEdit(event).subscribe(()=>{ + try { + await this.eventsService.postEventToApproveEdit(event).toPromise() + this.close() this.toastService.successMessage('Evento editado'); - }, error =>{ - this.toastService.badRequest('Evento não editado'); - }) + + } catch(e) { + this.toastService.badRequest('Evento não editado'); + } + this.loadedAttachments.forEach((document:any)=>{ if(document['action'] == 'add') { delete document.action this.attachmentsService.setEventAttachmentById(document).subscribe(()=>{ - this.toastService.successMessage(); + // this.toastService.successMessage(); }, error =>{ this.toastService.badRequest(); }); } else if(document['action'] == 'delete') { delete document.action this.attachmentsService.deleteEventAttachmentById(document.Id).subscribe( res=>{ - this.toastService.successMessage() + // this.toastService.successMessage() }, error =>{ this.toastService.badRequest() }) @@ -325,8 +331,6 @@ export class EditEventToApprovePage implements OnInit { }) - this.modalController.dismiss(); - } // setIntervenient(data){ diff --git a/src/app/shared/agenda/event-list/event-list.page.ts b/src/app/shared/agenda/event-list/event-list.page.ts index 8109cdc85..b3e8a5433 100644 --- a/src/app/shared/agenda/event-list/event-list.page.ts +++ b/src/app/shared/agenda/event-list/event-list.page.ts @@ -27,6 +27,7 @@ export class EventListPage implements OnInit { segment:string; @Input() profile:string; + @Input() showComponent:string; @Output() cloneAllmobileComponent = new EventEmitter(); @Output() approveEventDismiss = new EventEmitter(); @@ -55,6 +56,10 @@ export class EventListPage implements OnInit { }); } + ngOnChanges() { + this.LoadToApproveEvents(); + } + segmentChanged(ev: any) { this.LoadToApproveEvents(); } diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index 9e28fc764..bada805a2 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -140,7 +140,7 @@ export class NewPublicationPage implements OnInit { this.Form = new FormGroup({ Subject: new FormControl(this.pub.Title, [ - Validators.required, + // Validators.required, // Validators.minLength(4) ]), Message: new FormControl(this.pub.Message, [ @@ -158,11 +158,10 @@ export class NewPublicationPage implements OnInit { if(this.Form.invalid) return false - - if(this.publicationType == '3') { - + alert('3') if(this.capturedImage != '') { + alert('2') this.publication = { DateIndex: this.publication.DateIndex, DocumentId:this.publication.DocumentId, @@ -180,7 +179,6 @@ export class NewPublicationPage implements OnInit { const loader = this.toastService.loading() try { - await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() this.toastService.successMessage("Publicação criado") @@ -193,7 +191,7 @@ export class NewPublicationPage implements OnInit { } else if (!this.publication.OriginalFileName) { - + alert('1') this.publication = { DateIndex: this.publication.DateIndex, DocumentId:this.publication.DocumentId, @@ -219,15 +217,42 @@ export class NewPublicationPage implements OnInit { loader.remove() } + } else { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId:this.publication.DocumentId, + ProcessId:this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.capturedImageTitle, + FileBase64: this.capturedImage, + FileExtension: 'jpeg', + } + + console.log('Edit change image'); + console.log(this.publication); + const loader = this.toastService.loading() + + try { + await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() + this.toastService.successMessage("Publicação criado") + + this.goBack(); + } catch (error) { + this.toastService.badRequest("Publicação não criado") + } finally { + loader.remove() + } + } } else { - let time = new Date() this.publication = { DateIndex: time, - DocumentId:null, + DocumentId: null, ProcessId:this.folderId, Title: this.pub.Title, Message: this.pub.Message,
Email
Palavra-passe
Uma iniciativa do Gabinete do Presidente da República