New Attachmentes Page with Skeleton. EventAttachments Model revised. Compatibility with v2. Get Attachments revised.

This commit is contained in:
Paulo Pinto
2020-08-24 23:41:15 +01:00
parent 91147ef6b9
commit 751b8dd7c5
23 changed files with 494 additions and 74 deletions
+5 -7
View File
@@ -11320,7 +11320,11 @@
"integrity": "sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==",
"dev": true
},
<<<<<<< HEAD
"preact": {
"version": "10.4.7",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.4.7.tgz",
"integrity": "sha512-DtnnPbOm7oxW7Sxf5Co+KSIOxo7bGm0vLfJN/wGey7G2sAGKnGP5+bFyE2YIgutMISQl6xFVTsOd6l/Au88VVw=="
},
"prebuild-install": {
"version": "5.3.5",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.5.tgz",
@@ -11354,12 +11358,6 @@
}
}
}
=======
"preact": {
"version": "10.4.7",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.4.7.tgz",
"integrity": "sha512-DtnnPbOm7oxW7Sxf5Co+KSIOxo7bGm0vLfJN/wGey7G2sAGKnGP5+bFyE2YIgutMISQl6xFVTsOd6l/Au88VVw=="
>>>>>>> d8f224a4e3cb066734ae0358efe8cc6198d0daa6
},
"prepend-http": {
"version": "1.0.4",
+1 -1
View File
@@ -90,4 +90,4 @@
"android"
]
}
}
}
+10
View File
@@ -23,6 +23,16 @@ const routes: Routes = [
]
},
{
path: 'attachments',
children: [
{
path:':eventId',
loadChildren: ()=> import('../pages/events/attachments/attachments.module').then(m => m.AttachmentsPageModule)
},
]
},
{
path: 'agenda',
children: [
+21
View File
@@ -0,0 +1,21 @@
export class Attachment {
Id: number;
ParentId: string;
Sources: Sources;
SourceId: string;
Description: string;
SourceName: string;
CreateDate: string;
Stakeholders: string;
Link: string;
//Data: any;
}
enum Sources
{
Undefined = 0,
webTRIX = 1,
K2 = 2,
Exchange = 3,
File = 4
}
+1 -3
View File
@@ -1,7 +1,5 @@
import { EventBody } from './eventbody.model';
import { EventPerson } from './eventperson.model';
import { EventAttachment } from './eventattachment.model';
import { EventOrganizer } from './organizer.model';
export class Event{
@@ -22,5 +20,5 @@ export class Event{
TimeZone: string;
Organizer: string;
Categories: string[];
Attachments: EventAttachment[];
HasAttachments: boolean;
}
-16
View File
@@ -1,16 +0,0 @@
export class EventAttachment{
Id: number;
ParentId: string;
Sources: Sources;
SourceId: string;
Data: any;
}
enum Sources
{
Unknow = 0,
webTRIX = 1,
K2 = 2,
Exchange = 3,
File = 4
}
+1 -4
View File
@@ -4,9 +4,8 @@ import { AlertController, ModalController } from '@ionic/angular';
import { formatDate } from '@angular/common';
import { CalModalPage } from '../cal-modal/cal-modal.page';
import { EventsService } from 'src/app/services/events.service';
import { Observable, ObjectUnsubscribedError } from 'rxjs';
import { Observable } from 'rxjs';
import { Event } from '../../models/event.model';
import { parse } from 'date-fns';
import { Router } from '@angular/router';
@Component({
@@ -39,8 +38,6 @@ export class AgendaPage implements OnInit {
eventItem: Observable<Event>;
constructor(
private alertCtrl: AlertController,
@Inject(LOCALE_ID) private locale: string,
private modalCtrl: ModalController,
private eventService: EventsService,
private router: Router
+3 -3
View File
@@ -41,7 +41,7 @@
</ion-radio-group>
</ion-list> -->
<ion-item>
<ion-label>Selecione o calendário</ion-label>
<ion-label>Selecione a Agenda</ion-label>
<ion-select [(ngModel)]="postEvent.CalendarName" interface="action-sheet" class="custom-options" Cancel-text="Cancelar">
<ion-select-option Pessoal="Reunião">Pessoal</ion-select-option>
<ion-select-option Oficial="Viagem">Oficial</ion-select-option>
@@ -58,13 +58,13 @@
</ion-item>
<ion-item>
<ion-label>Data Início</ion-label>
<ion-datetime [(ngModel)]="postEvent.StartDate" value="2005-06-17T11:06Z" min="1990" max="2020"
<ion-datetime [(ngModel)]="postEvent.StartDate" min="2020" max="2100"
displayFormat="D MMM YYYY H:mm"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"></ion-datetime>
</ion-item>
<ion-item>
<ion-label>Data Fim</ion-label>
<ion-datetime [(ngModel)]="postEvent.EndDate" value="2005-06-17T11:06Z" min="1990" max="2020"
<ion-datetime [(ngModel)]="postEvent.EndDate" min="2020" max="2100"
displayFormat="D MMM YYYY H:mm"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"></ion-datetime>
</ion-item>
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AttachmentsPage } from './attachments.page';
const routes: Routes = [
{
path: '',
component: AttachmentsPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AttachmentsPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { AttachmentsPageRoutingModule } from './attachments-routing.module';
import { AttachmentsPage } from './attachments.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
AttachmentsPageRoutingModule
],
declarations: [AttachmentsPage]
})
export class AttachmentsPageModule {}
@@ -0,0 +1,102 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button routerDirection="back">Voltar</ion-back-button>
</ion-buttons>
<ion-title>Anexos do evento</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div *ngIf="loadedEventAttachments">
<ion-list>
<ion-item-sliding>
<ion-item lines="none" *ngFor="let att of loadedEventAttachments" [routerLink]="['/home/viewer', att.SourceId]">
<div class="div-item">
<div class="div-up">
<div class="div-icon">
<ion-icon class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
</div>
<div class="div-content-attachment">
<h3>{{ att.SourceName }}</h3>
<p>{{ att.CreateDate }}</p>
<p>{{ att.Description }}</p>
</div>
</div>
<div class="div-botton">
<div class="div-botton-left">
<ion-icon class="ion-icon-location" slot="start" name="location"></ion-icon>
</div>
<div class="div-botton-middle">
<p class="item-list-small">{{ att.Stakeholders }}</p>
</div>
</div>
</div>
</ion-item>
</ion-item-sliding>
</ion-list>
</div>
<!-- Skeleton screen -->
<div *ngIf="!loadedEventAttachments">
<div class="ion-padding custom-skeleton">
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
<ion-skeleton-text animated></ion-skeleton-text>
<ion-skeleton-text animated style="width: 88%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 70%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</div>
<ion-list>
<ion-list-header>
<ion-label>
<ion-skeleton-text animated style="width: 20%"></ion-skeleton-text>
</ion-label>
</ion-list-header>
<ion-item>
<ion-avatar slot="start">
<ion-skeleton-text animated></ion-skeleton-text>
</ion-avatar>
<ion-label>
<h3>
<ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
</h3>
<p>
<ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
</p>
<p>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</p>
</ion-label>
</ion-item>
<ion-item>
<ion-thumbnail slot="start">
<ion-skeleton-text animated></ion-skeleton-text>
</ion-thumbnail>
<ion-label>
<h3>
<ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
</h3>
<p>
<ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
</p>
<p>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</p>
</ion-label>
</ion-item>
<ion-item>
<ion-skeleton-text animated style="width: 27px; height: 27px" slot="start"></ion-skeleton-text>
<ion-label>
<h3>
<ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
</h3>
<p>
<ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
</p>
<p>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</p>
</ion-label>
</ion-item>
</ion-list>
</div>
</ion-content>
@@ -0,0 +1,102 @@
/* CONTENT */
.item-list-small{
font-size: 14px;
overflow: auto;
}
.ion-item-class{
padding: 0;
}
.label-text{
width: 100%;
padding: 0;
margin: 0;
}
//DIV
.div-item{
width: 100%;
overflow: auto;
border-bottom: 1px solid #ccc;
margin: 10px 0 5px 0;
}
.div-up{
width: 100%;
overflow: auto;
}
.div-up h3{
margin: 0;
padding: 0;
font-size: 17px;
width: 100%;
}
.div-icon{
width: 10%;
font-size: 22px;
float: left;
color: #808080;
}
.div-icon ion-icon{
display: block;
margin: 0 auto;
}
.div-content-attachment{
width: 85%;
float: left;
padding: 0 0 0 12px;
}
.div-content-oficial h3, .div-content-pessoal h3{
font-size: 16pt;
/* border: 1px solid red; */
}
.div-content-oficial p, .div-content-pessoal p{
font-size: 14pt;
color: rgb(94, 92, 92);
padding: 0 !important;
margin: 0 !important;
}
.div-botton{
width: 100%;
overflow: auto;
margin: 10px 0 5px 0;
}
.div-botton-left{
width: 10%;
float: left;
}
.ion-icon-location{
text-align: center;
display: block;
color: #000;
font-size: 16px;
margin: 0 auto;
}
.div-botton-middle{
width: 75%;
float: left;
margin-top: 0.5px;
}
.div-botton-middle p{
padding: 0;
margin: 0;
}
.div-botton-right{
width: 10%;
float: left;
margin: 0;
padding: 0;
}
.ion-icon-attach{
color: #666666;
font-size: 20px;
}
/* Custom Skeleton Line Height and Margin */
.custom-skeleton ion-skeleton-text {
line-height: 13px;
}
.custom-skeleton ion-skeleton-text:last-child {
margin-bottom: 5px;
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { AttachmentsPage } from './attachments.page';
describe('AttachmentsPage', () => {
let component: AttachmentsPage;
let fixture: ComponentFixture<AttachmentsPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AttachmentsPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(AttachmentsPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,35 @@
import { Component, OnInit } from '@angular/core';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { Attachment } from 'src/app/models/attachment.model';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-attachments',
templateUrl: './attachments.page.html',
styleUrls: ['./attachments.page.scss'],
})
export class AttachmentsPage implements OnInit {
loadedEventAttachments: Attachment[];
constructor(private attachamentsService: AttachmentsService, private activatedRoute: ActivatedRoute) { }
ngOnInit() {
/* Emit new data when something changes */
this.activatedRoute.paramMap.subscribe(paramMap =>{
if(!paramMap.has('eventId')){
//Redirect
return;
}
this.loadAttachments(paramMap.get('eventId'));
});
}
loadAttachments(eventid:string)
{
this.attachamentsService.getEventAttachments(eventid).subscribe(attachments => {
this.loadedEventAttachments = attachments;
});
}
}
@@ -6,12 +6,11 @@
<ion-title>Visualizar Evento</ion-title>
</ion-toolbar>
</ion-header>
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<ion-content padding>
<ion-item-group>
<ion-item>
<ion-label position="stacked">Assunto</ion-label>
<!-- <ion-input value='{{event.Subject}}'></ion-input> -->
<ion-input [(ngModel)]="loadedEvent.Subject"></ion-input>
</ion-item>
<ion-item>
@@ -31,27 +30,48 @@
</ion-list>
</ion-item>
<ion-item>
<ion-label position="stacked">Calendário</ion-label>
<ion-input [(ngModel)]='loadedEvent.CalendarName'></ion-input>
<ion-label position="stacked">Agenda</ion-label>
<ion-select [(ngModel)]="loadedEvent.CalendarName" interface="action-sheet" class="custom-options" Cancel-text="Cancelar">
<ion-select-option Pessoal="Reunião">Pessoal</ion-select-option>
<ion-select-option Oficial="Viagem">Oficial</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="stacked">Tipo do evento</ion-label>
<ion-input [(ngModel)]='loadedEvent.EventType'></ion-input>
<ion-label position="stacked">Selecione o tipo de evento</ion-label>
<ion-select [(ngModel)]="loadedEvent.EventType" interface="action-sheet" class="custom-options" Cancel-text="Cancelar">
<ion-select-option value="Reunião">Reunião</ion-select-option>
<ion-select-option value="Viagem">Viagem</ion-select-option>
<ion-select-option value="Conferência">Conferência</ion-select-option>
<ion-select-option value="Encontro">Encontro</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="stacked">Data Início: </ion-label>
<ion-input [(ngModel)]='loadedEvent.StartDate'></ion-input>
<ion-label position="stacked">Data Início</ion-label>
<ion-datetime [(ngModel)]="loadedEvent.StartDate" min="2020" max="2100"
displayFormat="D MMM YYYY H:mm"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"></ion-datetime>
</ion-item>
<ion-item>
<ion-label position="stacked">Data Fim</ion-label>
<ion-input [(ngModel)]='loadedEvent.EndDate'></ion-input>
<ion-datetime [(ngModel)]="loadedEvent.EndDate" min="2020" max="2100"
displayFormat="D MMM YYYY H:mm"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"></ion-datetime>
</ion-item>
<ion-list>
<ion-list-header>Anexos</ion-list-header>
<ion-item>
<ion-icon name="attach" slot="start"></ion-icon>
<ion-label>Lei do orçamento geral do Estado</ion-label>
</ion-item>
<ion-item-sliding>
<ion-item lines="none" [routerLink]="['/home/attachments', loadedEvent.EventId]">
<div class="div-item">
<div class="div-up">
<div class="div-icon">
<ion-icon class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
</div>
<div class="div-content-attachment">
<h3>Ver anexos</h3>
</div>
</div>
</div>
</ion-item>
</ion-item-sliding>
</ion-list>
</ion-item-group>
<div class="event-detail-buttons">
@@ -11,4 +11,40 @@
}
.ion-button-right{
float: right;
}
}
.div-item{
width: 100%;
overflow: auto;
border-bottom: 1px solid #ccc;
margin: 10px 0 5px 0;
}
.div-up{
width: 100%;
overflow: auto;
}
.div-up h3{
margin: 0;
padding: 0;
font-size: 17px;
width: 100%;
}
.div-icon{
width: 10%;
font-size: 22px;
float: left;
color: #808080;
}
.div-icon ion-icon{
display: block;
margin: 0 auto;
}
.div-content-attachment{
width: 85%;
float: left;
padding: 0 0 0 12px;
}
.ion-icon-attach{
color: #666666;
font-size: 20px;
}
@@ -1,11 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { EventsService } from 'src/app/services/events.service';
import { Router } from '@angular/router';
import { Event } from '../../../models/event.model';
import { Observable } from 'rxjs';
import { EventBody } from 'src/app/models/eventbody.model';
import { AlertController } from '@ionic/angular';
import { Attachment } from 'src/app/models/attachment.model';
import { ActionSheetController } from '@ionic/angular';
@Component({
selector: 'app-event-detail',
@@ -15,9 +17,11 @@ import { AlertController } from '@ionic/angular';
export class EventDetailPage implements OnInit {
loadedEvent: Event;
eventItem: Observable<Event>;
loadedEventAttachments: Attachment[];
showLoader: boolean = true;
constructor(public alertController: AlertController, private router: Router, private activatedRoute: ActivatedRoute, private eventsService: EventsService) {
constructor(public actionSheetController: ActionSheetController, public alertController: AlertController, private router: Router, private activatedRoute: ActivatedRoute,
private eventsService: EventsService) {
this.loadedEvent = new Event();
this.loadedEvent.Body = new EventBody();
}
@@ -29,19 +33,17 @@ export class EventDetailPage implements OnInit {
//Redirect
return;
}
const eventId = paramMap.get('eventId');
this.loadEvent(paramMap.get('eventId'));
});
}
console.log(eventId);
/* Load my event detail */
/* this.loadedEvent = this.eventsService.getEvent(eventId); */
this.eventItem = this.eventsService.getEvent(eventId);
/* console.log(this.eventItem); */
this.eventsService.getEvent(eventId).subscribe(response =>
{
this.loadedEvent = response;
});
loadEvent(eventid:string)
{
this.showLoader = true;
this.eventsService.getEvent(eventid).subscribe(event => {
this.loadedEvent = event;
this.showLoader = false;
});
}
@@ -56,7 +58,7 @@ export class EventDetailPage implements OnInit {
text: 'Não',
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => { }
handler: () => { }
}, {
text: 'Sim',
handler: () => {
@@ -71,7 +73,7 @@ export class EventDetailPage implements OnInit {
Delete()
{
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async response =>
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async () =>
{
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
@@ -87,7 +89,7 @@ export class EventDetailPage implements OnInit {
Save()
{
this.eventsService.putEvent(this.loadedEvent, 2, 3).subscribe(async response =>
this.eventsService.putEvent(this.loadedEvent, 2, 3).subscribe(async () =>
{
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
@@ -100,5 +102,4 @@ export class EventDetailPage implements OnInit {
this.router.navigate(['/home/events']);
});
}
}
@@ -11,6 +11,10 @@ const routes: Routes = [
{
path: 'event-detail',
loadChildren: () => import('./event-detail/event-detail.module').then( m => m.EventDetailPageModule)
},
{
path: 'attachments',
loadChildren: () => import('./attachments/attachments.module').then( m => m.AttachmentsPageModule)
}
];
+1 -1
View File
@@ -106,7 +106,7 @@
<p class="item-list-small">{{event.Location}}</p>
</div>
<div class="div-botton-right">
<ion-icon class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
<ion-icon *ngIf="event.HasAttachments" class="ion-icon-attach" slot="end" name="attach-outline"></ion-icon>
</div>
</div>
</div>
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AttachmentsService } from './attachments.service';
describe('AttachmentsService', () => {
let service: AttachmentsService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AttachmentsService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+36
View File
@@ -0,0 +1,36 @@
import { Injectable } from '@angular/core';
import { Attachment } from '../models/attachment.model';
import { Observable } from 'rxjs';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { User } from '../models/user.model';
@Injectable({
providedIn: 'root'
})
export class AttachmentsService {
loggeduser: User;
headers: HttpHeaders;
constructor(private http: HttpClient, user: AuthService) {
this.loggeduser = user.ValidatedUser;
this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
}
getEventAttachments(eventid: string): Observable<Attachment[]>{
let geturl = environment.apiURL + 'attachments/GetAttachments';
let params = new HttpParams();
params = params.set("ParentId", eventid);
let options = {
headers: this.headers,
params: params
};
return this.http.get<Attachment[]>(`${geturl}`, options);
}
}
+3 -4
View File
@@ -1,13 +1,12 @@
import { Injectable } from '@angular/core';
import { Event } from '../models/event.model';
import axios from 'axios'
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 { User } from '../models/user.model';
@Injectable({
providedIn: 'root'
})
@@ -55,7 +54,7 @@ export class EventsService {
}
getEvent(eventid: string): Observable<Event>{
const geturl = environment.apiURL + 'calendar/GetEvent';
let geturl = environment.apiURL + 'calendar/GetEvent';
let params = new HttpParams();
params = params.set("EventId", eventid);
@@ -65,7 +64,7 @@ export class EventsService {
params: params
};
return this.http.get<Event>(`${geturl}`, options)
return this.http.get<Event>(`${geturl}`, options);
}
putEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number): Observable<Event>
+1 -1
View File
@@ -4,7 +4,7 @@
export const environment = {
production: false,
apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/v1/api/',
apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/v2/api/',
domain: 'gabinetedigital.local',
defaultuser: 'paulo.pinto',
defaultuserpwd: 'tabteste@006'