mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Bug fix offline actions
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<name>gabinete digital</name>
|
<name>gabinete digital</name>
|
||||||
<description>An awesome Ionic/Cordova app.</description>
|
<description>An awesome Ionic/Cordova app.</description>
|
||||||
<author email="hi@ionicframework.com" href="http://ionicframework.com/">Ionic Framework Team</author>
|
<author email="hi@ionicframework.com" href="http://ionicframework.com/">Ionic Framework Team</author>
|
||||||
<content src="index.html" />
|
<content original-src="index.html" src="http://localhost:8100" />
|
||||||
<access origin="*" />
|
<access origin="*" />
|
||||||
<allow-navigation href="*" />
|
<allow-navigation href="*" />
|
||||||
<allow-navigation href="*" />
|
<allow-navigation href="*" />
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { ToastService } from 'src/app/services/toast.service';
|
|||||||
import { ImageModalPage } from '../gallery/image-modal/image-modal.page';
|
import { ImageModalPage } from '../gallery/image-modal/image-modal.page';
|
||||||
import { NewPublicationPage } from '../new-publication/new-publication.page';
|
import { NewPublicationPage } from '../new-publication/new-publication.page';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||||
|
import { synchro } from 'src/app/services/socket/synchro.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -25,7 +27,8 @@ export class PublicationDetailPage implements OnInit {
|
|||||||
private publications:PublicationsService,
|
private publications:PublicationsService,
|
||||||
private animationController: AnimationController,
|
private animationController: AnimationController,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private location: Location ) {
|
private location: Location,
|
||||||
|
private sqliteservice: SqliteService ) {
|
||||||
|
|
||||||
this.publicationId = this.navParams.get('publicationId');
|
this.publicationId = this.navParams.get('publicationId');
|
||||||
/* this.folderId = this.navParams.get('folderIdId'); */
|
/* this.folderId = this.navParams.get('folderIdId'); */
|
||||||
@@ -77,6 +80,14 @@ export class PublicationDetailPage implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFromDB() {
|
||||||
|
if(synchro.connected === true) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.location.back()
|
this.location.back()
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ export class PublicationsPage implements OnInit {
|
|||||||
this.publications.GetPublicationFolderList().subscribe(res => {
|
this.publications.GetPublicationFolderList().subscribe(res => {
|
||||||
|
|
||||||
console.log('accoes', res)
|
console.log('accoes', res)
|
||||||
this.sqliteservice.addactions(res);
|
|
||||||
|
|
||||||
this.publicationsEventFolderList = new Array();
|
this.publicationsEventFolderList = new Array();
|
||||||
this.publicationsTravelFolderList = new Array();
|
this.publicationsTravelFolderList = new Array();
|
||||||
@@ -137,10 +136,14 @@ export class PublicationsPage implements OnInit {
|
|||||||
ActionType: data.ActionType,
|
ActionType: data.ActionType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sqliteservice.addactions(folder);
|
||||||
|
|
||||||
if (data.ActionType == "Evento") {
|
if (data.ActionType == "Evento") {
|
||||||
|
console.log('Evento', folder)
|
||||||
this.publicationsEventFolderList.push(folder);
|
this.publicationsEventFolderList.push(folder);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
console.log('Viagem', folder)
|
||||||
this.publicationsTravelFolderList.push(folder);
|
this.publicationsTravelFolderList.push(folder);
|
||||||
}
|
}
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
@@ -168,6 +171,8 @@ export class PublicationsPage implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
this.sqliteservice.getAllActions().then((actions: any[]) => {
|
this.sqliteservice.getAllActions().then((actions: any[]) => {
|
||||||
|
|
||||||
|
console.log('offline publi', actions)
|
||||||
|
|
||||||
this.publicationsEventFolderList = new Array();
|
this.publicationsEventFolderList = new Array();
|
||||||
this.publicationsTravelFolderList = new Array();
|
this.publicationsTravelFolderList = new Array();
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<ion-list>
|
<ion-list>
|
||||||
<!-- [routerLink]="['/home/publications/view-publications/publication-detail', publication.publicationId]" -->
|
<!-- [routerLink]="['/home/publications/view-publications/publication-detail', publication.publicationId]" -->
|
||||||
<div class="post-item"
|
<div class="post-item"
|
||||||
*ngFor="let publication of publicationListStorage.documents[folderId]"
|
*ngFor="let publication of getpublication"
|
||||||
(click)="goToPublicationDetail(publication.DocumentId)"
|
(click)="goToPublicationDetail(publication.DocumentId)"
|
||||||
>
|
>
|
||||||
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
|
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
|
|
||||||
publicationList: Publication[] = new Array();
|
publicationList: Publication[] = new Array();
|
||||||
item: PublicationFolder;
|
item: PublicationFolder;
|
||||||
folderId:string;
|
folderId: string;
|
||||||
error: any;
|
error: any;
|
||||||
|
|
||||||
publicationListStorage = PublicationListStorage
|
publicationListStorage = PublicationListStorage
|
||||||
@@ -33,6 +33,9 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
publicationTravelFolderService = PublicationTravelFolderStore
|
publicationTravelFolderService = PublicationTravelFolderStore
|
||||||
|
|
||||||
publicationPipe = new PublicationPipe()
|
publicationPipe = new PublicationPipe()
|
||||||
|
publicationDitails: any;
|
||||||
|
getpublication = [];
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
@@ -45,7 +48,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
this.activatedRoute.paramMap.subscribe(params => {
|
this.activatedRoute.paramMap.subscribe(params => {
|
||||||
console.log(params);
|
console.log(params);
|
||||||
|
|
||||||
if(params["params"]) {
|
if (params["params"]) {
|
||||||
this.folderId = params["params"].folderId;
|
this.folderId = params["params"].folderId;
|
||||||
// console.log(params["params"]);
|
// console.log(params["params"]);
|
||||||
}
|
}
|
||||||
@@ -56,20 +59,17 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
if(typeof(this.folderId) == 'object') {
|
if (typeof (this.folderId) == 'object') {
|
||||||
this.folderId = this.folderId['ProcessId']
|
this.folderId = this.folderId['ProcessId']
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getPublicationDetail();
|
this.getFromDB();
|
||||||
setTimeout(() => {
|
|
||||||
this.getPublications();
|
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
|
|
||||||
if(typeof(this.folderId) == 'object') {
|
if (typeof (this.folderId) == 'object') {
|
||||||
this.folderId = this.folderId['ProcessId']
|
this.folderId = this.folderId['ProcessId']
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
this.getPublications();
|
this.getPublications();
|
||||||
}
|
}
|
||||||
|
|
||||||
doRefresh =(event) => {
|
doRefresh = (event) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getPublicationDetail();
|
this.getPublicationDetail();
|
||||||
this.getPublications();
|
this.getPublications();
|
||||||
@@ -99,7 +99,8 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let allActions = this.publicationEventFolderStorage.list.concat(this.publicationTravelFolderService.list)
|
let allActions = this.publicationEventFolderStorage.list.concat(this.publicationTravelFolderService.list)
|
||||||
this.item = allActions.find((e)=> e.ProcessId == this.folderId);
|
this.item = allActions.find((e) => e.ProcessId == this.folderId);
|
||||||
|
this.publicationDitails = this.item
|
||||||
console.log('item', this.item)
|
console.log('item', this.item)
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
@@ -108,47 +109,86 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
getPublications() {
|
getPublications() {
|
||||||
this.showLoader = true;
|
this.showLoader = true;
|
||||||
const folderId = this.folderId
|
const folderId = this.folderId
|
||||||
this.publications.GetPublications(this.folderId).subscribe(res=>{
|
this.publications.GetPublications(this.folderId).subscribe(res => {
|
||||||
console.log(this.folderId)
|
console.log(this.folderId)
|
||||||
console.log('getPublications',res)
|
|
||||||
this.sqliteservice.updateactions(this.folderId, res);
|
|
||||||
|
|
||||||
this.publicationList = new Array();
|
this.publicationList = new Array();
|
||||||
|
|
||||||
|
|
||||||
res.forEach(element => {
|
res.forEach(element => {
|
||||||
|
console.log('getPublications', element)
|
||||||
let item: Publication = this.publicationPipe.itemList(element)
|
let item: Publication = this.publicationPipe.itemList(element)
|
||||||
this.publicationList.push(item);
|
this.publicationList.push(item);
|
||||||
});
|
});
|
||||||
|
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
|
||||||
|
|
||||||
|
|
||||||
this.publicationListStorage.add(folderId, this.publicationList)
|
this.publicationListStorage.add(folderId, this.publicationList)
|
||||||
|
this.getpublication = this.publicationList;
|
||||||
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
},
|
},
|
||||||
(error)=>{
|
(error) => {
|
||||||
if(error.status == '404'){
|
if (error.status == '404') {
|
||||||
this.error = 'Sem publicações disponíveis!';
|
this.error = 'Sem publicações disponíveis!';
|
||||||
this.publicationList= [];
|
this.publicationList = [];
|
||||||
this.publicationListStorage.add(folderId, this.publicationList)
|
this.publicationListStorage.add(folderId, this.publicationList)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getFromDB() {
|
getFromDB() {
|
||||||
if(synchro.connected === true) {
|
if (synchro.connected === true) {
|
||||||
|
this.getPublicationDetail();
|
||||||
|
setTimeout(() => {
|
||||||
|
this.getPublications();
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
this.sqliteservice.getActionById(this.folderId).then((publications) => {
|
||||||
|
console.log('publications', publications)
|
||||||
|
let item = {
|
||||||
|
ActionType: publications[0].ActionType,
|
||||||
|
DateBegin: publications[0].DateBegin,
|
||||||
|
DateEnd: publications[0].DateEnd,
|
||||||
|
Description: publications[0].Description,
|
||||||
|
Detail: publications[0].Detail,
|
||||||
|
ProcessId: publications[0].ProcessId
|
||||||
|
}
|
||||||
|
this.publicationDitails = item;
|
||||||
|
|
||||||
|
let publicationArray = [];
|
||||||
|
JSON.parse(publications[0].publications).forEach(element => {
|
||||||
|
let publicationlis = {
|
||||||
|
DateIndex: element.DateIndex,
|
||||||
|
DatePublication: element.DatePublication,
|
||||||
|
DocumentId: element.DocumentId,
|
||||||
|
FileBase64: element.FileBase64,
|
||||||
|
FileExtension: element.FileExtension,
|
||||||
|
Message: element.Message,
|
||||||
|
OrganicEntityId: element.OrganicEntityId,
|
||||||
|
OriginalFileName: element.OriginalFileName,
|
||||||
|
ProcessId: element.ProcessId
|
||||||
|
}
|
||||||
|
publicationArray.push(publicationlis);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
this.getpublication = publicationArray;
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async AddPublication(publicationType:any, folderId:any) {
|
async AddPublication(publicationType: any, folderId: any) {
|
||||||
const modal = await this.modalController.create({
|
const modal = await this.modalController.create({
|
||||||
component: NewPublicationPage,
|
component: NewPublicationPage,
|
||||||
componentProps:{
|
componentProps: {
|
||||||
publicationType: publicationType,
|
publicationType: publicationType,
|
||||||
folderId: folderId,
|
folderId: folderId,
|
||||||
},
|
},
|
||||||
@@ -156,19 +196,19 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
backdropDismiss: false
|
backdropDismiss: false
|
||||||
});
|
});
|
||||||
await modal.present();
|
await modal.present();
|
||||||
modal.onDidDismiss().then(()=>{
|
modal.onDidDismiss().then(() => {
|
||||||
this.doRefresh(event);
|
this.doRefresh(event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
goToPublicationDetail(publicationId:string){
|
goToPublicationDetail(publicationId: string) {
|
||||||
this.router.navigate(['/home/publications/view-publications', this.folderId, publicationId]);
|
this.router.navigate(['/home/publications/view-publications', this.folderId, publicationId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async viewPublicationDetail(publicationId:string) {
|
async viewPublicationDetail(publicationId: string) {
|
||||||
const modal = await this.modalController.create({
|
const modal = await this.modalController.create({
|
||||||
component: PublicationDetailPage,
|
component: PublicationDetailPage,
|
||||||
componentProps:{
|
componentProps: {
|
||||||
publicationId: publicationId,
|
publicationId: publicationId,
|
||||||
folderId: this.folderId,
|
folderId: this.folderId,
|
||||||
},
|
},
|
||||||
@@ -176,7 +216,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
// backdropDismiss: false
|
// backdropDismiss: false
|
||||||
});
|
});
|
||||||
await modal.present();
|
await modal.present();
|
||||||
modal.onDidDismiss().then(()=>{
|
modal.onDidDismiss().then(() => {
|
||||||
this.getPublications();
|
this.getPublications();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,15 +115,7 @@ export class SqliteService {
|
|||||||
DateEnd varchar(255),
|
DateEnd varchar(255),
|
||||||
Detail varchar(255),
|
Detail varchar(255),
|
||||||
Description varchar(255),
|
Description varchar(255),
|
||||||
DateIndex varchar(255),
|
publications Text
|
||||||
DatePublication varchar(255),
|
|
||||||
DocumentId INTERGER,
|
|
||||||
FileBase64 Text,
|
|
||||||
FileExtension varchar(255),
|
|
||||||
Message varchar(255),
|
|
||||||
OrganicEntityId INTERGER,
|
|
||||||
OriginalFileName varchar(255),
|
|
||||||
Title varchar(255)
|
|
||||||
)`, [])
|
)`, [])
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log("Sucess action Table created: ", res)
|
console.log("Sucess action Table created: ", res)
|
||||||
@@ -136,10 +128,10 @@ export class SqliteService {
|
|||||||
|
|
||||||
//addactions
|
//addactions
|
||||||
public addactions(data) {
|
public addactions(data) {
|
||||||
|
console.log('Action insert', data)
|
||||||
this.dbInstance.executeSql(`
|
this.dbInstance.executeSql(`
|
||||||
INSERT OR IGNORE INTO ${this.actions} (ActionType,DateBegin,DateEnd,Description,Detail,ProcessId,DateIndex,DatePublication,DocumentId,FileBase64,FileExtension,Message,OrganicEntityId,OriginalFileName,Title)
|
INSERT OR IGNORE INTO ${this.actions} (ActionType,DateBegin,DateEnd,Description,Detail,ProcessId,publications)
|
||||||
VALUES ('${data.ActionType}','${data.DateBegin}', '${data.DateEnd}','${data.Description}','${data.Detail}','${data.ProcessId}','${data.DateIndex}','${data.DatePublication},'${data.DocumentId}',
|
VALUES ('${data.ActionType}','${data.DateBegin}', '${data.DateEnd}','${data.Description}','${data.Detail}','${data.ProcessId}','${data.publications}')`, [])
|
||||||
'${data.FileBase64}','${data.FileExtension}','${data.Message}','${data.OrganicEntityId}','${data.OriginalFileName}','${data.Title}')`, [])
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("action add with Success");
|
console.log("action add with Success");
|
||||||
|
|
||||||
@@ -192,8 +184,9 @@ export class SqliteService {
|
|||||||
|
|
||||||
//updateActions
|
//updateActions
|
||||||
public updateactions(id,data) {
|
public updateactions(id,data) {
|
||||||
|
console.log("update action data", data )
|
||||||
this.dbInstance.executeSql(`
|
this.dbInstance.executeSql(`
|
||||||
UPDATE ${this.actions} SET DateIndex = ?, DatePublication = ?,DocumentId = ?,FileBase64 = ?,FileExtension = ?,Message = ?,OrganicEntityId = ?,OriginalFileName = ?,Title = ? WHERE ProcessId = ${id}`,data)
|
UPDATE ${this.actions} SET publications = ? WHERE ProcessId = ${id}`,[data])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("action update with Success");
|
console.log("action update with Success");
|
||||||
|
|
||||||
@@ -403,6 +396,21 @@ export class SqliteService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//getActionById
|
||||||
|
getActionById(id) {
|
||||||
|
return this.dbInstance.executeSql(`SELECT * FROM ${this.actions} WHERE ProcessId = ? `, [id]).then((res) => {
|
||||||
|
this.ALLACTIONS = [];
|
||||||
|
if (res.rows.length > 0) {
|
||||||
|
for (var i = 0; i < res.rows.length; i++) {
|
||||||
|
this.ALLACTIONS.push(res.rows.item(i))
|
||||||
|
}
|
||||||
|
return this.ALLACTIONS;
|
||||||
|
}
|
||||||
|
}, (e) => {
|
||||||
|
console.log(" Get actions by processId error", JSON.stringify(e));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//getEventBy id
|
//getEventBy id
|
||||||
getEventById(id) {
|
getEventById(id) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user