mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add models
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { models } from 'beast-orm'
|
||||
// import { models } from 'beast-orm'
|
||||
import { models } from 'src/plugin/src'
|
||||
import { environment } from 'src/environments/environment'
|
||||
const { ArrayField, JsonField} = models.indexedDB.fields
|
||||
|
||||
@@ -47,4 +48,37 @@ models.register({
|
||||
})
|
||||
|
||||
|
||||
window['MessageModel'] = MessageModel
|
||||
window['MessageModel'] = MessageModel
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class ActionModel extends models.Model{
|
||||
ProcessId = models.IntegerField({unique: true})
|
||||
Description = models.CharField()
|
||||
Detail = models.CharField()
|
||||
DateBegin = models.CharField()
|
||||
DateEnd = models.CharField()
|
||||
ActionType = models.CharField()
|
||||
}
|
||||
|
||||
export class PublicationModel extends models.Model{
|
||||
DateIndex = models.CharField()
|
||||
DocumentId = models.IntegerField({unique: true})
|
||||
ProcessId = models.CharField()
|
||||
Title = models.CharField()
|
||||
Message = models.CharField()
|
||||
DatePublication = models.CharField()
|
||||
OriginalFileName = models.CharField()
|
||||
FileBase64 = models.CharField()
|
||||
FileExtension = models.CharField()
|
||||
OrganicEntityId = models.IntegerField()
|
||||
}
|
||||
|
||||
models.register({
|
||||
databaseName: 'actions'+environment.version.lastCommitNumber + environment.id,
|
||||
type: 'indexedDB',
|
||||
version: 14,
|
||||
models: [PublicationModel, ActionModel]
|
||||
})
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
export class Publication{
|
||||
DateIndex: Date | string;
|
||||
DocumentId:string;
|
||||
DocumentId: number;
|
||||
ProcessId:string;
|
||||
Title: string;
|
||||
Message: string;
|
||||
|
||||
@@ -11,7 +11,7 @@ import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { momentG } from 'src/plugin/momentG';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||
@@ -130,8 +130,8 @@ export class EventsPage implements OnInit {
|
||||
if (event) {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
event?.target?.complete();
|
||||
} catch(error) {}
|
||||
event?.target?.complete();
|
||||
} catch(error) {}
|
||||
}, 2000);
|
||||
}
|
||||
this.RefreshEvents();
|
||||
@@ -166,7 +166,7 @@ export class EventsPage implements OnInit {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.showLoader = false;
|
||||
this.showAgendaLoader = false;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class PublicationDetailPage implements OnInit {
|
||||
/* this.folderId = this.navParams.get('folderIdId'); */
|
||||
this.publication = {
|
||||
DateIndex: null,
|
||||
DocumentId: '',
|
||||
DocumentId: null,
|
||||
ProcessId:'',
|
||||
Title:'',
|
||||
Message: '',
|
||||
|
||||
@@ -16,6 +16,7 @@ import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { ActionModel } from 'src/app/models/beast-orm';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -146,7 +147,11 @@ export class PublicationsPage implements OnInit {
|
||||
this.publications.GetPublicationFolderList().subscribe(async res => {
|
||||
this.showLoader = false;
|
||||
const folders: PublicationFolder[] = this.getPublicationFolderMap(res)
|
||||
|
||||
let publications = await ActionModel.create(folders)
|
||||
|
||||
console.log('publications', publications)
|
||||
|
||||
this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento')
|
||||
this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento')
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ export class PublicationDetailPage implements OnInit {
|
||||
|
||||
this.publication = {
|
||||
DateIndex: null,
|
||||
DocumentId: '',
|
||||
DocumentId: null,
|
||||
ProcessId:'',
|
||||
Title:'',
|
||||
Message: '',
|
||||
|
||||
@@ -15,6 +15,7 @@ import { ToastService } from 'src/app/services/toast.service';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { PublicationModel } from 'src/app/models/beast-orm';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-publications',
|
||||
@@ -162,20 +163,24 @@ export class ViewPublicationsPage implements OnInit {
|
||||
const folderId = this.folderId
|
||||
|
||||
try {
|
||||
const res = await this.publications.GetPublicationsImages(folderId).toPromise();
|
||||
let publicationList = []
|
||||
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
|
||||
|
||||
for (let element of res) {
|
||||
let ress = await this.publications.GetPublicationById(element).toPromise();
|
||||
let item: Publication = this.publicationPipe.itemList(ress)
|
||||
publicationList.push(item);
|
||||
for (let publicationId of publicationIds) {
|
||||
let Publication = await this.publications.GetPublicationById(publicationId).toPromise();
|
||||
let publicationDetails: Publication = this.publicationPipe.itemList(Publication)
|
||||
|
||||
const found = this.publicationList[folderId].find( e => e.DocumentId == publicationId )
|
||||
|
||||
if(!found) {
|
||||
PublicationModel.create(publicationDetails)
|
||||
this.publicationList[folderId].push(publicationDetails)
|
||||
}
|
||||
}
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
this.publicationList[folderId] = publicationList
|
||||
this.storage.set(folderId, publicationList);
|
||||
this.getpublication = publicationList;
|
||||
this.storage.set(folderId, this.publicationList[folderId]);
|
||||
this.getpublication = this.publicationList[folderId];
|
||||
} catch(error) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ export class PublicationsService {
|
||||
return this.http.delete<any>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
GetPublicationsImages(folder:any) {
|
||||
GetPublicationsList(folder:any) {
|
||||
const geturl = environment.apiURL + 'presidentialActions/'+ folder +'/posts/ids';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -105,7 +105,7 @@ export class PublicationsService {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
return this.http.get<Publication[]>(`${geturl}`, options)
|
||||
return this.http.get<number[]>(`${geturl}`, options)
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ export class PublicationDetailPage implements OnInit {
|
||||
/* this.folderId = this.navParams.get('folderIdId'); */
|
||||
this.publication = {
|
||||
DateIndex: null,
|
||||
DocumentId: '',
|
||||
DocumentId: null,
|
||||
ProcessId:'',
|
||||
Title:'',
|
||||
Message: '',
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</button >
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-body width-100">
|
||||
<div class="div-body width-100" *ngIf="publicationItem[folderId].DateBegin">
|
||||
<p class="item-content-detail">{{publicationItem[folderId].Detail}}</p>
|
||||
<p class="item-content-date">{{ publicationItem[folderId].DateBegin | date: 'dd-MM-yy HH:mm'}}</p>
|
||||
</div>
|
||||
|
||||
@@ -12,6 +12,7 @@ import { EditActionPage } from 'src/app/pages/publications/edit-action/edit-acti
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { PublicationModel } from 'src/app/models/beast-orm';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-publications',
|
||||
@@ -116,20 +117,24 @@ export class ViewPublicationsPage implements OnInit {
|
||||
const folderId = this.folderId
|
||||
|
||||
try {
|
||||
const res = await this.publications.GetPublicationsImages(folderId).toPromise();
|
||||
let publicationList = []
|
||||
|
||||
for (let element of res) {
|
||||
let ress = await this.publications.GetPublicationById(element).toPromise();
|
||||
let item: Publication = this.publicationPipe.itemList(ress)
|
||||
publicationList.push(item);
|
||||
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
|
||||
|
||||
for (let publicationId of publicationIds) {
|
||||
let Publication = await this.publications.GetPublicationById(publicationId).toPromise();
|
||||
let publicationDetails: Publication = this.publicationPipe.itemList(Publication)
|
||||
|
||||
const found = this.publicationList[folderId].find( e => e.DocumentId == publicationId )
|
||||
|
||||
if(!found) {
|
||||
PublicationModel.create(publicationDetails)
|
||||
this.publicationList[folderId].push(publicationDetails)
|
||||
}
|
||||
}
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
this.publicationList[folderId] = publicationList
|
||||
this.storage.set(folderId, publicationList);
|
||||
this.getpublication = publicationList;
|
||||
this.storage.set(folderId, this.publicationList[folderId]);
|
||||
this.getpublication = this.publicationList[folderId];
|
||||
} catch(error) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user