mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
Add integration of publication
This commit is contained in:
@@ -17,6 +17,10 @@ const routes: Routes = [
|
||||
{
|
||||
path: 'publications',
|
||||
loadChildren: () => import('./pages/publications/publications.module').then( m => m.PublicationsPageModule)
|
||||
},
|
||||
{
|
||||
path: 'header',
|
||||
loadChildren: () => import('./shared/header/header.module').then( m => m.HeaderPageModule)
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { title } from "process"
|
||||
|
||||
export class Image {
|
||||
title: string;
|
||||
url: string;
|
||||
format: string;
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
/* import { Image } from './image'; */
|
||||
|
||||
export class Publication{
|
||||
publicationId:string;
|
||||
processId:string;
|
||||
title: string;
|
||||
description: string;
|
||||
imageUrl:string;
|
||||
date: Date;
|
||||
/* image: Image; */
|
||||
imageTitle: string;
|
||||
imageUrl:string;
|
||||
imageFormat: string;
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="publicationType!='1'" class="ion-item-container">
|
||||
<ion-input [(ngModel)]="pub.title" placeholder="Título" ></ion-input>
|
||||
<ion-input [(ngModel)]="pub.title" name="title" ngDefaultControl placeholder="Título" ></ion-input>
|
||||
</div>
|
||||
|
||||
<div *ngIf="publicationType!='1'" class="container-div">
|
||||
@@ -32,7 +32,7 @@
|
||||
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
|
||||
</div>
|
||||
<div class="ion-textarea-class">
|
||||
<ion-textarea [(ngModel)]="pub.description" rows="6" cols="20" placeholder="Corpo de texto..."></ion-textarea>
|
||||
<ion-textarea [(ngModel)]="pub.description" name="description" ngDefaultControl rows="6" cols="20" placeholder="Corpo de texto..."></ion-textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -40,7 +40,7 @@
|
||||
<ion-label class="attached-title">Fotografia Anexada</ion-label>
|
||||
<ion-item lines="none">
|
||||
<ion-thumbnail slot="start">
|
||||
<ion-img [(ngModel)]="pub.imageUrl" [src]="pub.imageUrl"></ion-img>
|
||||
<ion-img [(ngModel)]="pub.imageUrl" name="image" ngDefaultControl [src]="pub.imageUrl"></ion-img>
|
||||
</ion-thumbnail>
|
||||
<!-- <ion-thumbnail *ngIf="!publication" slot="start">
|
||||
<ion-img [(ngModel)]="publication.imageUrl" [src]="guestPicture"></ion-img>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {Plugins, CameraResultType, CameraSource} from '@capacitor/core';
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { Publication } from 'src/app/models/publication';
|
||||
import { Image } from 'src/app/models/image';
|
||||
/* import { Camera } from '@ionic-native/camera/ngx'; */
|
||||
|
||||
/* const { Camera } = Plugins; */
|
||||
@@ -19,11 +20,16 @@ import { Publication } from 'src/app/models/publication';
|
||||
export class NewPublicationPage implements OnInit {
|
||||
publication: Publication;
|
||||
pub: Publication = new Publication();
|
||||
folderId: string;
|
||||
image: Image = new Image();
|
||||
|
||||
publicationType:string;
|
||||
publicationTitle:string;
|
||||
imgUrl:any;
|
||||
|
||||
Defaultimage:any = '';
|
||||
|
||||
|
||||
photo: SafeResourceUrl;
|
||||
|
||||
guestPicture:any;
|
||||
@@ -36,6 +42,7 @@ export class NewPublicationPage implements OnInit {
|
||||
private publications: PublicationsService,
|
||||
) {
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
this.folderId = this.navParams.get('folderId');
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
}
|
||||
|
||||
@@ -66,20 +73,48 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
|
||||
save(){
|
||||
if(this.publication.processId){
|
||||
if(this.publicationType == '3'){
|
||||
this.image = {
|
||||
title: this.image.title,
|
||||
url: this.image.url,
|
||||
format: 'png'
|
||||
}
|
||||
this.publication = {
|
||||
publicationId:this.publication.publicationId,
|
||||
processId:this.publication.processId,
|
||||
title: this.publication.title,
|
||||
description: this.publication.description,
|
||||
imageUrl:this.publication.imageUrl,
|
||||
date: this.publication.date,
|
||||
/* image: this.image, */
|
||||
imageTitle: '',
|
||||
imageUrl: this.publication.imageUrl,
|
||||
imageFormat: 'png',
|
||||
}
|
||||
console.log('Edit');
|
||||
console.log('Edit');
|
||||
console.log(this.publication);
|
||||
this.publications.UpdatePublication(this.publication.processId, this.publication);
|
||||
}
|
||||
else{
|
||||
console.log('Create');
|
||||
this.image = {
|
||||
title: this.image.title,
|
||||
url: this.image.url,
|
||||
format: 'png'
|
||||
}
|
||||
this.publication = {
|
||||
publicationId:null,
|
||||
processId:this.folderId,
|
||||
title: this.pub.title,
|
||||
description: this.pub.description,
|
||||
date: new Date(),
|
||||
/* image: this.image, */
|
||||
imageTitle: '',
|
||||
imageUrl: '',
|
||||
imageFormat: 'jpg',
|
||||
}
|
||||
|
||||
console.log('Create');
|
||||
console.log(this.publication);
|
||||
this.publications.CreatePublication(this.folderId, this.publication);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,16 +124,14 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
setTitle(){
|
||||
if(this.publicationType == '1'){
|
||||
this.publicationTitle = 'Nova Publicação Rápida'
|
||||
this.publicationTitle = 'Nova Publicação Rápida';
|
||||
}
|
||||
else if(this.publicationType == '2'){
|
||||
this.publicationTitle = 'Nova Publicação'
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
}
|
||||
else if(this.publicationType == '3'){
|
||||
this.publicationTitle = 'Editar Publicação';
|
||||
this.pub = this.navParams.get('publication');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
|
||||
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
|
||||
<ion-refresher-content>
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="title-content">
|
||||
<div class="div-title">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
@@ -12,18 +13,41 @@ import { ViewPublicationsPage } from './view-publications/view-publications.page
|
||||
styleUrls: ['./publications.page.scss'],
|
||||
})
|
||||
export class PublicationsPage implements OnInit {
|
||||
showLoader: boolean;
|
||||
|
||||
publicationFolderList: PublicationFolder[];
|
||||
publicationsEventFolderList: PublicationFolder[];
|
||||
publicationsTravelFolderList: PublicationFolder[];
|
||||
|
||||
theDate:any;
|
||||
customDate:any;
|
||||
months: string[];
|
||||
days:string[];
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private modalController: ModalController,
|
||||
private publications: PublicationsService,
|
||||
) { }
|
||||
) {
|
||||
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
||||
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.router.events.forEach((event) => {
|
||||
if(event instanceof NavigationEnd && event.url == this.router.url) {
|
||||
this.getActions();
|
||||
}
|
||||
});
|
||||
}
|
||||
doRefresh(event) {
|
||||
this.getActions();
|
||||
|
||||
setTimeout(() => {
|
||||
event.target.complete();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
getActions(){
|
||||
|
||||
+13
-2
@@ -28,8 +28,11 @@ export class PublicationDetailPage implements OnInit {
|
||||
processId:'',
|
||||
title:'',
|
||||
description: '',
|
||||
imageUrl: '',
|
||||
/* image: null, */
|
||||
date: null,
|
||||
imageUrl: '',
|
||||
imageTitle: '',
|
||||
imageFormat: '',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,13 +44,21 @@ export class PublicationDetailPage implements OnInit {
|
||||
|
||||
getPublicationDetail(){
|
||||
this.publications.GetPublicationById(this.folderId,this.publicationId).subscribe(res=>{
|
||||
let itemImage = {
|
||||
title: 'Title',
|
||||
url: "data:image/jpg;base64," + res.FileBase64,
|
||||
format: 'png'
|
||||
}
|
||||
this.publication = {
|
||||
publicationId: res.DocumentId,
|
||||
processId:res.ProcessId,
|
||||
title:res.Title,
|
||||
description: res.Message,
|
||||
imageUrl: "data:image/jpg;base64," + res.FileBase64,
|
||||
date: res.DatePublication,
|
||||
/* image: itemImage, */
|
||||
imageUrl: "data:image/jpg;base64," + res.FileBase64,
|
||||
imageTitle: '',
|
||||
imageFormat: '',
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
<p class="item-content-date">{{item.DateBegin}}</p>
|
||||
</div>
|
||||
<div class="actions-icon">
|
||||
<ion-icon (click)="AddPublication('1')" slot="end" src='assets/images/icons-add-photo.svg'></ion-icon>
|
||||
<ion-icon (click)="AddPublication('2')" slot="end" src='assets/images/icons-add.svg'></ion-icon>
|
||||
<ion-icon (click)="AddPublication('1',item.ProcessId)" slot="end" src='assets/images/icons-add-photo.svg'></ion-icon>
|
||||
<ion-icon (click)="AddPublication('2',item.ProcessId)" slot="end" src='assets/images/icons-add.svg'></ion-icon>
|
||||
</div>
|
||||
</div>
|
||||
<ion-list>
|
||||
|
||||
@@ -37,13 +37,21 @@ export class ViewPublicationsPage implements OnInit {
|
||||
this.publicationList = new Array();
|
||||
console.log(res);
|
||||
res.forEach(element => {
|
||||
let itemImage = {
|
||||
title: 'Title',
|
||||
url: "data:image/jpg;base64," + element.FileBase64,
|
||||
format: 'png'
|
||||
}
|
||||
let item: Publication = {
|
||||
"publicationId":element.DocumentId,
|
||||
"processId":element.ProcessId,
|
||||
"title":element.Title,
|
||||
"description": element.Message,
|
||||
"imageUrl": "data:image/jpg;base64," + element.FileBase64,
|
||||
"date": element.DatePublication,
|
||||
/* image:itemImage, */
|
||||
"imageUrl": "data:image/jpg;base64," + element.FileBase64,
|
||||
"imageTitle": '',
|
||||
"imageFormat": '',
|
||||
}
|
||||
this.publicationList.push(item);
|
||||
});
|
||||
@@ -51,11 +59,12 @@ export class ViewPublicationsPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
async AddPublication(publicationType:any) {
|
||||
async AddPublication(publicationType:any, folderId:string) {
|
||||
const modal = await this.modalController.create({
|
||||
component: NewPublicationPage,
|
||||
componentProps:{
|
||||
publicationType: publicationType,
|
||||
folderId: folderId,
|
||||
},
|
||||
cssClass: 'new-publication',
|
||||
backdropDismiss: false
|
||||
|
||||
@@ -104,6 +104,31 @@ export class PublicationsService {
|
||||
};
|
||||
return this.http.get<any>(`${geturl}`, options);
|
||||
}
|
||||
CreatePublication(folderId:any,body:any){
|
||||
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/posts';
|
||||
let params = new HttpParams();
|
||||
params = params.set("folderId", folderId);
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
|
||||
UpdatePublication(folderId:any,body:any){
|
||||
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/posts';
|
||||
let params = new HttpParams();
|
||||
params = params.set("folderId", folderId);
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
return this.http.put<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { HeaderPage } from './header.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: HeaderPage
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class HeaderPageRoutingModule {}
|
||||
@@ -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 { HeaderPageRoutingModule } from './header-routing.module';
|
||||
|
||||
import { HeaderPage } from './header.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
HeaderPageRoutingModule
|
||||
],
|
||||
declarations: [HeaderPage]
|
||||
})
|
||||
export class HeaderPageModule {}
|
||||
@@ -0,0 +1,14 @@
|
||||
<ion-header class="ion-no-border">
|
||||
<ion-toolbar class="ion-no-border">
|
||||
<div class="div-top-header">
|
||||
<div class="div-search">
|
||||
<ion-icon src='assets/images/icons-search.svg'></ion-icon>
|
||||
</div>
|
||||
<div class="div-logo">
|
||||
<img src='assets/images/logo-no-bg.png' alt='logo'>
|
||||
</div>
|
||||
<div class="div-profile">
|
||||
<ion-icon src='assets/images/icons-profile.svg'></ion-icon>
|
||||
</div>
|
||||
</div>
|
||||
</ion-toolbar>
|
||||
@@ -0,0 +1,41 @@
|
||||
:host{
|
||||
background: #0782c9;
|
||||
}
|
||||
ion-content{
|
||||
--background: transparent;
|
||||
}
|
||||
ion-toolbar{
|
||||
background: transparent;
|
||||
border-width: 0 !important;
|
||||
}
|
||||
.div-top-header{
|
||||
width: 400px;
|
||||
margin: 0 auto;
|
||||
background-color: #0782c9;
|
||||
overflow: auto;
|
||||
padding-top: 15px;
|
||||
border: 0!important;
|
||||
}
|
||||
.div-search{
|
||||
font-size: 45px;
|
||||
float: left;
|
||||
margin: 0 0 0 10px
|
||||
}
|
||||
.div-logo{
|
||||
background: transparent;
|
||||
width: 140px;
|
||||
margin: 5px 0 0px 71px;
|
||||
float: left;
|
||||
}
|
||||
.div-logo img{
|
||||
width: 100%;
|
||||
}
|
||||
.div-profile{
|
||||
font-size: 45px;
|
||||
float: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
ion-content{
|
||||
--background:#0782c9;
|
||||
--border: none;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
|
||||
import { HeaderPage } from './header.page';
|
||||
|
||||
describe('HeaderPage', () => {
|
||||
let component: HeaderPage;
|
||||
let fixture: ComponentFixture<HeaderPage>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ HeaderPage ],
|
||||
imports: [IonicModule.forRoot()]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HeaderPage);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
templateUrl: './header.page.html',
|
||||
styleUrls: ['./header.page.scss'],
|
||||
})
|
||||
export class HeaderPage implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user