change publication like instagram and add time zone to agenda

This commit is contained in:
Peter Maquiran
2023-09-26 10:29:29 +01:00
parent c0eee0e2b3
commit f042168e2e
22 changed files with 305 additions and 113 deletions
@@ -53,7 +53,7 @@
<div class="content-details">
<ion-label>
<p>{{customDate}}</p>
<p>{{customDate}}, {{ TimeZoneString }}</p>
<p *ngIf="toDateString(loadedEvent.StartDate) == toDateString(loadedEvent.EndDate)">das {{loadedEvent.StartDate | date: 'HH:mm'}} às {{loadedEvent.EndDate | date: 'HH:mm'}}</p>
<p *ngIf="toDateString(loadedEvent.StartDate) != toDateString(loadedEvent.EndDate)">{{loadedEvent.StartDate | date: 'd/M/yy' }} - {{ loadedEvent.EndDate | date: 'dd/M/yy'}} </p>
<p *ngIf="loadedEvent.EventRecurrence">
@@ -53,6 +53,8 @@ export class ViewEventPage implements OnInit {
LoadedDocument: any = null;
sesseionStora = SessionStore
TimeZoneString = ''
constructor(
private modalController: ModalController,
/* private navParams: NavParams, */
@@ -70,7 +72,7 @@ export class ViewEventPage implements OnInit {
private attachmentsService: AttachmentsService,
) {
this.isEventEdited = false;
this.loadedEvent = new Event();
this.eventBody = { BodyType: "1", Text: "" };
@@ -107,7 +109,7 @@ export class ViewEventPage implements OnInit {
JSON.parse(req).forEach(element => {
this.eventsService.editEvent(element, 2, 3).subscribe((res) => {
this.storage.remove('eventEdit')
})
});
})
@@ -115,7 +117,7 @@ export class ViewEventPage implements OnInit {
JSON.parse(req).forEach(element => {
this.eventsService.editEvent(element, 2, 3).subscribe((res) => {
this.storage.remove('eventDelete')
})
});
})
@@ -141,7 +143,7 @@ export class ViewEventPage implements OnInit {
// } else {
// this.sqliteservice.getAllEvents().then((events: any[] = []) => {
// resolve(events)
// })
// }
// }).catch ((error) => {
@@ -167,7 +169,7 @@ export class ViewEventPage implements OnInit {
else {
// this.router.navigate(['/home', params["params"].caller]);
this.RouteService.goBack();
}
});
}
@@ -179,19 +181,24 @@ export class ViewEventPage implements OnInit {
ev.target.complete();
}
setTimeZone() {
this.TimeZoneString = this.loadedEvent.TimeZone.split(')')[1]
}
loadEvent() {
const loader = this.toastService.loading();
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.getEvent(this.eventId).subscribe(res => {
this.loadedEvent = res;
this.setTimeZone()
// this.addEventToDb(res);
loader.remove()
}, (error) => {
if (error.status === 0) {
this.getFromDb();
} else {
@@ -204,20 +211,21 @@ export class ViewEventPage implements OnInit {
});
} else {
if(this.CalendarId) {
this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => {
const div = document.createElement("div")
div.innerHTML = res.Body.Text
res.Body.Text = div.innerText
this.loadedEvent = res;
this.setTimeZone()
// this.addEventToDb(res);
loader.remove()
}, (error) => {
if (error.status === 0) {
this.getFromDb();
} else {
@@ -261,14 +269,14 @@ export class ViewEventPage implements OnInit {
const loader = this.toastService.loading()
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Evento removido',
buttons: ['OK']
});
setTimeout(() => {
alert.dismiss();
}, 1500);
@@ -278,29 +286,29 @@ export class ViewEventPage implements OnInit {
() => {
loader.remove();
});
} else {
this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.loadedEvent.CalendarId).subscribe(async () => {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Evento removido',
buttons: ['OK']
});
setTimeout(() => {
alert.dismiss();
}, 1500);
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('delete event')
}, (error) => {
}, (error) => {
this.httpErrorHandle.httpStatusHandle(error)
},
() => {
loader.remove();
});
}
}
@@ -318,7 +326,7 @@ export class ViewEventPage implements OnInit {
});
modal.onDidDismiss().then((res) => {
if (res) {
setTimeout(() => {
@@ -350,7 +358,7 @@ export class ViewEventPage implements OnInit {
});
await modal.present();
modal.onDidDismiss().then((res) => {
if (res) {
setTimeout(() => {
@@ -365,7 +373,7 @@ export class ViewEventPage implements OnInit {
}
async editEvent() {
let classs;
if (window.innerWidth <= 800) {
@@ -384,19 +392,19 @@ export class ViewEventPage implements OnInit {
});
modal.onDidDismiss().then((res) => {
if (res) {
setTimeout(() => {
/* this.loadEvent(); */
this.loadEvent()
}, 250);
this.isEventEdited = true;
if(res.data.Attendees?.length >= 1) {
this.loadedEvent.HasAttachments = true
this.getAttachments()
this.getAttachments()
}
console.log('res', res)
}
@@ -416,10 +424,10 @@ export class ViewEventPage implements OnInit {
if(this.loadedEvent.HasAttachments) {
this.attachmentsService.getAttachmentsById(this.loadedEvent.EventId).subscribe(res=>{
this.loadedEvent.Attachments = res;
},((erro) => {
console.error('editgetAttchament', erro)
}));
}));
}
}
@@ -429,7 +437,7 @@ export class ViewEventPage implements OnInit {
const applicationId: any = this.loadedEvent.Attachments[this.dicIndex].ApplicationId
const selectedDoc = this.loadedEvent.Attachments[this.dicIndex]
this.task = {
serialNumber: '',
@@ -515,37 +523,6 @@ export class ViewEventPage implements OnInit {
}
// addEventToDb(data) {
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
// this.ionicStorage.set('eventDetails', data).then(() => {
// })
// } else {
// let event = {
// Attendees: JSON.stringify(data.Attendees) || JSON.stringify(''),
// Body: JSON.stringify(data.Body) || JSON.stringify(''),
// CalendarId: data.CalendarId,
// CalendarName: data.CalendarName,
// Category: data.Category,
// EndDate: data.EndDate,
// EventId: data.EventId,
// EventRecurrence: JSON.stringify(data.EventRecurrence) || JSON.stringify(''),
// EventType: data.EventType,
// HasAttachments: data.HasAttachments,
// IsAllDayEvent: data.IsAllDayEvent,
// IsMeeting: data.IsMeeting,
// IsRecurring: data.IsRecurring,
// Location: data.Location,
// Organizer: JSON.stringify(data.Organizer) || JSON.stringify(''),
// StartDate: data.StartDate,
// Subject: data.Subject,
// TimeZone: data.TimeZone
// }
// this.sqliteservice.updateEvent(event);
// }
// }
getFromDb() {
+1 -1
View File
@@ -75,7 +75,7 @@
</div>
<div *ngIf="room.lastMessage" class="item-description" [class.item-description-active]="room.id == idSelected">
<p class="font-13-em mb-0 add-ellipsis white-space-nowrap" *ngIf="room.lastMessage && room.otherUserType == false">{{room.lastMessage.msg}}</p>
<p class="font-13-em mb-0 white-space-nowrap" *ngIf="room.lastMessage && room.otherUserType == false">{{room.lastMessage.msg}}</p>
<p class="font-13-em" *ngIf="room.otherUserType == true">está escrever...</p>
<!-- <ion-label *ngIf="room.lastMessage.file">
<fa-icon *ngIf="room.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
@@ -529,6 +529,8 @@ export class ChatSystemService {
}
}
this.getUser()
})
}
@@ -76,7 +76,7 @@
</div>
<div class="content-details">
<ion-label>
<p>{{customDate}}</p>
<p>{{customDate}}, {{ TimeZoneString }}</p>
<p *ngIf="toDateString(loadedEvent.StartDate) == toDateString(loadedEvent.EndDate)">das
{{loadedEvent.StartDate | date: 'HH:mm'}} às {{loadedEvent.EndDate | date: 'HH:mm'}}</p>
<p *ngIf="toDateString(loadedEvent.StartDate) != toDateString(loadedEvent.EndDate)">{{loadedEvent.StartDate |
@@ -114,12 +114,18 @@ export class ViewEventPage implements OnInit {
})
}
TimeZoneString = ''
setTimeZone() {
this.TimeZoneString = this.loadedEvent.TimeZone.split(')')[1]
}
loadEvent() {
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.getEvent(this.eventId).subscribe(res => {
this.loadedEvent = res;
this.setTimeZone()
this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
@@ -142,6 +148,7 @@ export class ViewEventPage implements OnInit {
div.innerHTML = res.Body.Text
res.Body.Text = div.innerText
this.loadedEvent = res;
this.setTimeZone()
this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PublicationCardPage } from './publication-card.page';
const routes: Routes = [
{
path: '',
component: PublicationCardPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PublicationCardPageRoutingModule {}
@@ -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 { PublicationCardPageRoutingModule } from './publication-card-routing.module';
import { PublicationCardPage } from './publication-card.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
PublicationCardPageRoutingModule
],
declarations: [PublicationCardPage],
exports: [PublicationCardPage]
})
export class PublicationCardPageModule {}
@@ -0,0 +1,9 @@
<ion-header>
<ion-toolbar>
<ion-title>publicationCard</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
</ion-content>
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { PublicationCardPage } from './publication-card.page';
describe('PublicationCardPage', () => {
let component: PublicationCardPage;
let fixture: ComponentFixture<PublicationCardPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ PublicationCardPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(PublicationCardPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-publication-card',
templateUrl: './publication-card.page.html',
styleUrls: ['./publication-card.page.scss'],
})
export class PublicationCardPage implements OnInit {
constructor() { }
ngOnInit() {
}
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ShowMorePage } from './show-more.page';
const routes: Routes = [
{
path: '',
component: ShowMorePage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ShowMorePageRoutingModule {}
@@ -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 { ShowMorePageRoutingModule } from './show-more-routing.module';
import { ShowMorePage } from './show-more.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ShowMorePageRoutingModule
],
declarations: [ShowMorePage],
exports: [ShowMorePage]
})
export class ShowMorePageModule {}
@@ -0,0 +1,9 @@
<div>
<pre #text class="text ma-0 add-ellipsis white-space-nowrap" *ngIf="showShortText">{{shortText}}</pre>
<pre class="text ma-0" *ngIf="!showShortText">{{text}}</pre>
<div class="cursor-pointer" *ngIf="showMoreButton" (click)="showShortText=false;showMoreButton=false">
<span>...</span>
<span>Mais</span>
</div>
</div>
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ShowMorePage } from './show-more.page';
describe('ShowMorePage', () => {
let component: ShowMorePage;
let fixture: ComponentFixture<ShowMorePage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ShowMorePage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(ShowMorePage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,55 @@
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
@Component({
selector: 'app-show-more',
templateUrl: './show-more.page.html',
styleUrls: ['./show-more.page.scss'],
})
export class ShowMorePage implements OnInit {
@ViewChild('text') HTMLElement: any;
@Input() text = ''
shortText = ''
showShortText = true
showMoreButton = false
constructor() { }
ngOnInit() {
this.run()
}
run() {
let split = this.text.split(/\r?\n|\r|\n/g)
let text = split[0]
this.shortText = text.slice(0, 100)
if(split.length >= 2) {
this.showShortText = true
this.showMoreButton = true
return
}
setTimeout(()=> {
if (this.isEllipsisActive(this.HTMLElement.nativeElement)) {
this.showShortText = true
this.showMoreButton = true
} else {
this.showShortText = false
}
}, 500)
}
isEllipsisActive(element) {
if (element.clientWidth < element.scrollWidth) {
var style = element.currentStyle || window.getComputedStyle(element);
console.log('add ellopsiss')
return style.textOverflow === 'ellipsis'
}
return false;
}
ngOnChanges(changes: any): void {}
}
@@ -7,7 +7,8 @@ import { IonicModule } from '@ionic/angular';
import { ViewPublicationsPageRoutingModule } from './view-publications-routing.module';
import { ViewPublicationsPage } from './view-publications.page';
import { Attributes, IntersectionObserverHooks, LazyLoadImageModule, LAZYLOAD_IMAGE_HOOKS } from 'ng-lazyload-image';
import { PublicationCardPageModule } from './publication-card/publication-card.module'
import { ShowMorePageModule } from './show-more/show-more.module';
export class LazyLoadImageHooks extends IntersectionObserverHooks {
setup(attributes: Attributes) {
attributes.offset = 10;
@@ -23,7 +24,10 @@ setup(attributes: Attributes) {
FormsModule,
IonicModule,
ViewPublicationsPageRoutingModule,
LazyLoadImageModule
LazyLoadImageModule,
// page
ShowMorePageModule,
PublicationCardPageModule
],
exports: [ViewPublicationsPage],
declarations: [ViewPublicationsPage],
@@ -37,10 +37,9 @@
<div class="main-container px-20" *ngIf="publicationFolderService.FolderDetails[folderId]">
<p class="item-content-detail">{{publicationFolderService.FolderDetails[folderId].Detail}}</p>
<ion-card *ngFor="let publication of publicationFolderService.publicationList[folderId] let i = index"
(click)="viewPublicationDetail(publication.DocumentId, publication.ProcessId)">
<ion-card *ngFor="let publication of publicationFolderService.publicationList[folderId] let i = index">
<ion-card-content>
<div class="post-img">
<div class="post-img cursor-pointer" (click)="viewPublicationDetail(publication.DocumentId, publication.ProcessId)">
<img [lazyLoad]="publication.FileBase64">
</div>
<div class="post-content">
@@ -51,38 +50,13 @@
<div class="post-data">{{publication.DatePublication | date: 'dd-MM-yyyy HH:mm'}}</div>
</div>
<div class="post-description">
<pre class="text">{{publication.Message}}</pre>
<app-show-more
[text]=publication.Message
></app-show-more>
</div>
</div>
</ion-card-content>
</ion-card>
<!-- <ion-list>
<div class="post-item d-md-block mb-10 cursor-pointer"
*ngFor="let publication of publicationFolderService.publicationList"
(click)="viewPublicationDetail(publication.DocumentId)">
<div *ngIf="publication.FileBase64.length > 30" class="mb-10 post-img width-md-100">
<img src="{{publication.FileBase64}}" alt="image">
</div>
<div *ngIf="publication.FileBase64.length < 30" class="mb-10 post-img">
<img src="/assets/icon/icon-no-image.svg" alt="image">
</div>
<div class="post-content px-20 width-md-100 ">
<div class="post-title-time">
<div class="post-title">
<ion-label>{{publication.Title}}</ion-label>
</div>
<div class="post-data">{{publication.DatePublication | date: 'dd-MM-yyyy HH:mm'}}</div>
</div>
<div class="post-description">
<p>{{publication.Message}}</p>
</div>
</div>
</div>
<div class="center height-100" *ngIf="!publicationFolderService.publicationList">
<p>{{error}}</p>
</div>
</ion-list> -->
</ion-card>
</div>
<!-- fab placed to the bottom end -->
<ion-fab *ngIf="p.userPermission([p.permissionList.Actions.create]) && publicationFolderService.FolderDetails[folderId]" vertical="bottom" horizontal="end">
@@ -135,12 +135,23 @@
}
.post-img{
width: 100%;
height: 56.25vh !important;
border-radius: 0px!important;
height: 100%;
max-height: 500px;
max-width: 468px;
min-height: 350px;
min-width: 468px;
margin: 5px auto;
border-radius: 0px !important;
overflow: hidden;
background-color: white;
display: flex;
justify-content: center;
align-items: center;
background: black;
}
.post-img img{
@@ -191,4 +202,11 @@ ion-fab-button:hover{
ion-card{
width: fit-content;
max-width: calc(468px + 16px + 16px);
margin: 0px auto;
margin-top: 10px;
margin-bottom: 20px;
}
@@ -125,10 +125,10 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = true;
const folderId = this.folderId
try {
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
this.createPublicationList(folderId)
let loadLater = []
for (let publicationId of publicationIds) {
@@ -147,17 +147,17 @@ export class ViewPublicationsPage implements OnInit {
for(let localPublication of this.publicationFolderService.publicationList[folderId]) {
const apiPublication = publicationIds.includes(localPublication.DocumentId)
if(!apiPublication) {
this.publicationFolderService.deletePost(folderId, localPublication.DocumentId)
}
}
this.showLoader = false;
this.storage.set(folderId, this.publicationFolderService.publicationList[folderId]);
this.oldpublicationIds = publicationIds
} catch(error) {
this.showLoader = false;
@@ -166,10 +166,8 @@ export class ViewPublicationsPage implements OnInit {
}
_deletePublication = (folderId, publicationId) => {
this.publicationFolderService.publicationList[folderId] = this.publicationFolderService.publicationList[folderId].filter( e => e.DocumentId != publicationId)
console.log('this.publicationFolderService.publicationList[folderId]', this.publicationFolderService.publicationList[folderId].length)
}
@@ -186,7 +184,7 @@ export class ViewPublicationsPage implements OnInit {
async loadPublication(publicationId, folderId) {
let Publication = await this.publications.GetPublicationById(publicationId).toPromise();
let publicationDetails: Publication = this.publicationPipe.itemList(Publication)
const findIndex = this.publicationFindIndex(publicationId, folderId)
const found = this.publicationIsPresent(publicationId, folderId)
if(!found) {
@@ -194,7 +192,7 @@ export class ViewPublicationsPage implements OnInit {
} else {
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
}
}
getFromDB() {
@@ -242,7 +240,7 @@ export class ViewPublicationsPage implements OnInit {
cssClass: 'new-action modal modal-desktop',
backdropDismiss: true
});
modal.onDidDismiss().then(() => {
// Do nothing
});