mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
1 line
24 KiB
JSON
1 line
24 KiB
JSON
{"ast":null,"code":"import _asyncToGenerator from \"C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { __decorate } from \"tslib\";\nimport __NG_CLI_RESOURCE__0 from \"./view-publications.page.html?ngResource\";\nimport __NG_CLI_RESOURCE__1 from \"./view-publications.page.scss?ngResource\";\nimport { Component } from '@angular/core';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { ModalController } from '@ionic/angular';\nimport { PublicationFolder } from 'src/app/models/publicationfolder';\nimport { PublicationPipe } from 'src/app/pipes/publication.pipe';\nimport { PublicationsService } from 'src/app/services/publications.service';\nimport { NewPublicationPage } from '../new-publication/new-publication.page';\nimport { PublicationDetailPage } from './publication-detail/publication-detail.page';\nimport { SqliteService } from 'src/app/services/sqlite.service';\nimport { BackgroundService } from 'src/app/services/background.service';\nimport { ThemeService } from 'src/app/services/theme.service';\nimport { ToastService } from 'src/app/services/toast.service';\nimport { PermissionService } from 'src/app/services/permission.service';\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\nimport { Storage } from '@ionic/storage';\nlet ViewPublicationsPage = class ViewPublicationsPage {\n constructor(modalController, publications, activatedRoute, router, sqliteservice, backgroundservice, ThemeService, toastService, p, httpErroHandle, storage) {\n this.modalController = modalController;\n this.publications = publications;\n this.activatedRoute = activatedRoute;\n this.router = router;\n this.sqliteservice = sqliteservice;\n this.backgroundservice = backgroundservice;\n this.ThemeService = ThemeService;\n this.toastService = toastService;\n this.p = p;\n this.httpErroHandle = httpErroHandle;\n this.storage = storage;\n this.showLoader = true;\n this.publicationList = {};\n this.publicationItem = {};\n this.defaultImage = \"/assets/icon/icon-no-image.svg\";\n this.publicationPipe = new PublicationPipe();\n this.getpublication = [];\n this.doRefresh = event => {\n //setTimeout(() => {\n //this.testForkJoin()\n this.getPublicationDetail();\n this.getPublicationsIds();\n try {\n event?.target?.complete();\n } catch (error) {}\n //}, 3000);\n };\n\n this.createPublicationList();\n this.getFromDB();\n this.activatedRoute.paramMap.subscribe(params => {\n if (params[\"params\"]) {\n this.folderId = params[\"params\"].folderId;\n // \n }\n\n window['app-view-publications-page-doRefresh'] = this.doRefresh;\n });\n }\n ngOnInit() {\n if (typeof this.folderId == 'object') {\n this.folderId = this.folderId['ProcessId'];\n }\n this.createPublicationList();\n this.getFromDB();\n //this.testForkJoin()\n this.getPublicationDetail();\n this.getPublicationsIds();\n /* setTimeout(() => {\r\n this.getPublications();\r\n }, 1000); */\n this.backgroundservice.registerBackService('Online', () => {\n this.getPublicationDetail();\n //this.testForkJoin()\n });\n }\n\n ngOnChanges() {\n if (typeof this.folderId == 'object') {\n this.folderId = this.folderId['ProcessId'];\n }\n this.createPublicationList();\n this.getFromDB();\n }\n createPublicationList(folderId = this.folderId) {\n if (!this.publicationList[folderId]) {\n this.publicationList[folderId] = [];\n }\n if (!this.publicationItem[folderId]) {\n this.publicationItem[folderId] = new PublicationFolder();\n }\n }\n close() {\n this.modalController.dismiss();\n this.router.navigate(['/home/publications']);\n }\n goBack() {\n this.router.navigate(['/home/publications']);\n }\n getPublicationDetail() {\n const folderId = this.folderId;\n this.publications.GetPresidentialAction(folderId).subscribe(res => {\n this.publicationItem[folderId] = res;\n this.storage.set(folderId + \"name\", res);\n }, error => {\n this.showLoader = false;\n // this.httpErroHandle.httpStatusHandle(error)\n });\n }\n\n getFromDB() {\n const folderId = this.folderId;\n this.storage.get(folderId).then(viewPublications => {\n this.publicationList[folderId] = viewPublications;\n });\n this.storage.get(folderId + \"name\").then(viewPublications => {\n this.publicationItem[folderId] = viewPublications;\n });\n }\n getPublicationsIds() {\n var _this = this;\n return _asyncToGenerator(function* () {\n _this.showLoader = true;\n const folderId = _this.folderId;\n try {\n const publicationIds = yield _this.publications.GetPublicationsList(folderId).toPromise();\n _this.createPublicationList(folderId);\n let loadLater = [];\n for (let publicationId of publicationIds) {\n if (!_this.publicationIsPresent(publicationId, folderId)) {\n yield _this.loadPublication(publicationId, folderId);\n } else {\n loadLater.push(publicationId);\n }\n }\n for (let publicationId of loadLater) {\n yield _this.loadPublication(publicationId, folderId);\n }\n _this.showLoader = false;\n _this.storage.set(folderId, _this.publicationList[folderId]);\n _this.getpublication = _this.publicationList[folderId];\n } catch (error) {\n _this.showLoader = false;\n }\n })();\n }\n publicationIsPresent(publicationId, folderId) {\n return this.publicationList[folderId].find(e => e.DocumentId == publicationId);\n }\n publicationFind(publicationId, folderId) {\n return this.publicationList[folderId].find(e => e.DocumentId == publicationId);\n }\n publicationFindIndex(publicationId, folderId) {\n return this.publicationList[folderId].findIndex(e => e.DocumentId == publicationId);\n }\n loadPublication(publicationId, folderId) {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n let Publication = yield _this2.publications.GetPublicationById(publicationId).toPromise();\n let publicationDetails = _this2.publicationPipe.itemList(Publication);\n const findIndex = _this2.publicationFindIndex(publicationId, folderId);\n const found = _this2.publicationIsPresent(publicationId, folderId);\n if (!found) {\n _this2.publicationList[folderId].push(publicationDetails);\n } else {\n _this2.publicationList[folderId][findIndex] = publicationDetails;\n }\n })();\n }\n AddPublication(publicationType, folderId) {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n const modal = yield _this3.modalController.create({\n component: NewPublicationPage,\n componentProps: {\n publicationType: publicationType,\n folderId: _this3.folderId\n },\n cssClass: 'new-publication modal modal-desktop',\n backdropDismiss: false\n });\n yield modal.present();\n modal.onDidDismiss().then(() => {\n _this3.doRefresh(event);\n });\n })();\n }\n goToPublicationDetail(publicationId) {\n this.router.navigate(['/home/publications/view-publications', this.folderId, publicationId]);\n }\n viewPublicationDetail(publicationId) {\n var _this4 = this;\n return _asyncToGenerator(function* () {\n const modal = yield _this4.modalController.create({\n component: PublicationDetailPage,\n componentProps: {\n publicationId: publicationId,\n folderId: _this4.folderId,\n isModal: true\n },\n cssClass: 'publication-detail modal modal-desktop'\n // backdropDismiss: false\n });\n\n yield modal.present();\n modal.onDidDismiss().then(() => {\n _this4.getPublicationsIds();\n });\n })();\n }\n};\nViewPublicationsPage.ctorParameters = () => [{\n type: ModalController\n}, {\n type: PublicationsService\n}, {\n type: ActivatedRoute\n}, {\n type: Router\n}, {\n type: SqliteService\n}, {\n type: BackgroundService\n}, {\n type: ThemeService\n}, {\n type: ToastService\n}, {\n type: PermissionService\n}, {\n type: HttpErrorHandle\n}, {\n type: Storage\n}];\nViewPublicationsPage = __decorate([Component({\n selector: 'app-view-publications',\n template: __NG_CLI_RESOURCE__0,\n styles: [__NG_CLI_RESOURCE__1]\n})], ViewPublicationsPage);\nexport { ViewPublicationsPage };","map":{"version":3,"mappings":";;;;AAAA,SAASA,SAAS,QAAgB,eAAe;AACjD,SAASC,cAAc,EAAEC,MAAM,QAAQ,iBAAiB;AACxD,SAASC,eAAe,QAAQ,gBAAgB;AAEhD,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,kBAAkB,QAAQ,yCAAyC;AAC5E,SAASC,qBAAqB,QAAQ,8CAA8C;AACpF,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SAASC,YAAY,QAAQ,gCAAgC;AAE7D,SAASC,YAAY,QAAQ,gCAAgC;AAC7D,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SAASC,eAAe,QAAQ,4CAA4C;AAC5E,SAASC,OAAO,QAAQ,gBAAgB;AAQjC,IAAMC,oBAAoB,GAA1B,MAAMA,oBAAoB;EAiB/BC,YACUC,eAAgC,EAChCC,YAAiC,EACjCC,cAA8B,EAC9BC,MAAc,EACdC,aAA4B,EAC5BC,iBAAoC,EACrCZ,YAA0B,EACzBa,YAA0B,EAC3BC,CAAoB,EACnBC,cAA+B,EAC/BC,OAAgB;IAVhB,oBAA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B,EAAE;MAC3B,CAAC,CAAC;IAAC;EACL;;;;;;;;;;;;;;;;;;;;;;;;;AAjOWd,oBAAoB,eALhChB,SAAS,CAAC;EACTgG,QAAQ,EAAE,uBAAuB;EACjCC,8BAA4C;;CAE7C,CAAC,GACWjF,oBAAoB;SAApBA,oBAAoB","names":["Component","ActivatedRoute","Router","ModalController","PublicationFolder","PublicationPipe","PublicationsService","NewPublicationPage","PublicationDetailPage","SqliteService","BackgroundService","ThemeService","ToastService","PermissionService","HttpErrorHandle","Storage","ViewPublicationsPage","constructor","modalController","publications","activatedRoute","router","sqliteservice","backgroundservice","toastService","p","httpErroHandle","storage","event","getPublicationDetail","getPublicationsIds","target","complete","error","createPublicationList","getFromDB","paramMap","subscribe","params","folderId","window","doRefresh","ngOnInit","registerBackService","ngOnChanges","publicationList","publicationItem","close","dismiss","navigate","goBack","GetPresidentialAction","res","set","showLoader","get","then","viewPublications","_this","publicationIds","GetPublicationsList","toPromise","loadLater","publicationId","publicationIsPresent","loadPublication","push","getpublication","find","e","DocumentId","publicationFind","publicationFindIndex","findIndex","Publication","_this2","GetPublicationById","publicationDetails","publicationPipe","itemList","found","AddPublication","publicationType","modal","_this3","create","component","componentProps","cssClass","backdropDismiss","present","onDidDismiss","goToPublicationDetail","viewPublicationDetail","_this4","isModal","selector","template"],"sourceRoot":"","sources":["C:\\Users\\eudes.inacio\\GabineteDigital\\gabinete-digital-fo\\src\\app\\pages\\publications\\view-publications\\view-publications.page.ts"],"sourcesContent":["import { Component, OnInit } from '@angular/core';\r\nimport { ActivatedRoute, Router } from '@angular/router';\r\nimport { ModalController } from '@ionic/angular';\r\nimport { Publication } from 'src/app/models/publication';\r\nimport { PublicationFolder } from 'src/app/models/publicationfolder';\r\nimport { PublicationPipe } from 'src/app/pipes/publication.pipe';\r\nimport { PublicationsService } from 'src/app/services/publications.service';\r\nimport { NewPublicationPage } from '../new-publication/new-publication.page';\r\nimport { PublicationDetailPage } from './publication-detail/publication-detail.page';\r\nimport { SqliteService } from 'src/app/services/sqlite.service';\r\nimport { BackgroundService } from 'src/app/services/background.service';\r\nimport { ThemeService } from 'src/app/services/theme.service'\r\nimport { forkJoin } from 'rxjs';\r\nimport { ToastService } from 'src/app/services/toast.service';\r\nimport { PermissionService } from 'src/app/services/permission.service';\r\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\r\nimport { Storage } from '@ionic/storage';\r\nimport { PublicationModel } from 'src/app/models/beast-orm';\r\n\r\n@Component({\r\n selector: 'app-view-publications',\r\n templateUrl: './view-publications.page.html',\r\n styleUrls: ['./view-publications.page.scss'],\r\n})\r\nexport class ViewPublicationsPage implements OnInit {\r\n showLoader = true;\r\n loading: any;\r\n\r\n publicationList: {[key: string]: Publication[] } = {};\r\n publicationItem: {[key: string]: PublicationFolder } = {};\r\n\r\n defaultImage = \"/assets/icon/icon-no-image.svg\";\r\n folderId: string;\r\n id: string;\r\n error: any;\r\n\r\n publicationPipe = new PublicationPipe()\r\n publicationDitails: any;\r\n getpublication = [];\r\n\r\n\r\n constructor(\r\n private modalController: ModalController,\r\n private publications: PublicationsService,\r\n private activatedRoute: ActivatedRoute,\r\n private router: Router,\r\n private sqliteservice: SqliteService,\r\n private backgroundservice: BackgroundService,\r\n public ThemeService: ThemeService,\r\n private toastService: ToastService,\r\n public p: PermissionService,\r\n private httpErroHandle: HttpErrorHandle,\r\n private storage: Storage,) {\r\n\r\n this.createPublicationList()\r\n\r\n this.getFromDB();\r\n\r\n this.activatedRoute.paramMap.subscribe(params => {\r\n \r\n if (params[\"params\"]) {\r\n this.folderId = params[\"params\"].folderId;\r\n // \r\n }\r\n\r\n window['app-view-publications-page-doRefresh'] = this.doRefresh\r\n });\r\n }\r\n\r\n ngOnInit() {\r\n\r\n if (typeof (this.folderId) == 'object') {\r\n this.folderId = this.folderId['ProcessId']\r\n }\r\n\r\n this.createPublicationList()\r\n\r\n this.getFromDB();\r\n //this.testForkJoin()\r\n this.getPublicationDetail();\r\n this.getPublicationsIds();\r\n /* setTimeout(() => {\r\n this.getPublications();\r\n }, 1000); */\r\n\r\n this.backgroundservice.registerBackService('Online', () => {\r\n this.getPublicationDetail();\r\n //this.testForkJoin()\r\n\r\n })\r\n }\r\n\r\n ngOnChanges() {\r\n\r\n if (typeof (this.folderId) == 'object') {\r\n this.folderId = this.folderId['ProcessId']\r\n }\r\n\r\n this.createPublicationList()\r\n\r\n this.getFromDB();\r\n }\r\n\r\n\r\n createPublicationList(folderId = this.folderId) {\r\n if(!this.publicationList[folderId]) {\r\n this.publicationList[folderId] = []\r\n }\r\n if(!this.publicationItem[folderId]) {\r\n this.publicationItem[folderId] = new PublicationFolder();\r\n }\r\n }\r\n\r\n doRefresh = (event) => {\r\n //setTimeout(() => {\r\n //this.testForkJoin()\r\n this.getPublicationDetail();\r\n this.getPublicationsIds();\r\n try {\r\n event?.target?.complete();\r\n } catch(error) {}\r\n //}, 3000);\r\n\r\n }\r\n\r\n close() {\r\n this.modalController.dismiss();\r\n this.router.navigate(['/home/publications']);\r\n }\r\n\r\n goBack() {\r\n this.router.navigate(['/home/publications']);\r\n }\r\n\r\n getPublicationDetail() {\r\n const folderId = this.folderId\r\n this.publications.GetPresidentialAction(folderId).subscribe(res =>{ \r\n \r\n this.publicationItem[folderId] = res\r\n this.storage.set(folderId+\"name\", res)\r\n }, (error) => {\r\n this.showLoader = false;\r\n // this.httpErroHandle.httpStatusHandle(error)\r\n });\r\n }\r\n\r\n getFromDB() {\r\n const folderId = this.folderId\r\n this.storage.get(folderId).then((viewPublications) => {\r\n this.publicationList[folderId] = viewPublications\r\n })\r\n this.storage.get(folderId+\"name\").then((viewPublications) => {\r\n this.publicationItem[folderId] = viewPublications\r\n })\r\n }\r\n\r\n async getPublicationsIds() {\r\n\r\n this.showLoader = true;\r\n const folderId = this.folderId\r\n\r\n try {\r\n const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();\r\n \r\n this.createPublicationList(folderId)\r\n let loadLater = []\r\n for (let publicationId of publicationIds) {\r\n\r\n if(!this.publicationIsPresent(publicationId, folderId)) {\r\n await this.loadPublication(publicationId, folderId)\r\n\r\n } else {\r\n loadLater.push(publicationId)\r\n }\r\n }\r\n\r\n for( let publicationId of loadLater) {\r\n await this.loadPublication(publicationId, folderId)\r\n }\r\n \r\n this.showLoader = false;\r\n \r\n this.storage.set(folderId, this.publicationList[folderId]);\r\n this.getpublication = this.publicationList[folderId];\r\n } catch(error) {\r\n this.showLoader = false;\r\n }\r\n\r\n }\r\n\r\n publicationIsPresent(publicationId, folderId) {\r\n return this.publicationList[folderId].find( e => e.DocumentId == publicationId )\r\n }\r\n publicationFind(publicationId, folderId) {\r\n return this.publicationList[folderId].find( e => e.DocumentId == publicationId )\r\n }\r\n publicationFindIndex(publicationId, folderId) {\r\n return this.publicationList[folderId].findIndex( e => e.DocumentId == publicationId )\r\n }\r\n\r\n async loadPublication(publicationId, folderId) {\r\n let Publication = await this.publications.GetPublicationById(publicationId).toPromise();\r\n let publicationDetails: Publication = this.publicationPipe.itemList(Publication)\r\n \r\n const findIndex = this.publicationFindIndex(publicationId, folderId)\r\n const found = this.publicationIsPresent(publicationId, folderId)\r\n if(!found) {\r\n this.publicationList[folderId].push(publicationDetails)\r\n } else {\r\n this.publicationList[folderId][findIndex] = publicationDetails\r\n }\r\n \r\n }\r\n\r\n async AddPublication(publicationType: any, folderId: any) {\r\n const modal = await this.modalController.create({\r\n component: NewPublicationPage,\r\n componentProps: {\r\n publicationType: publicationType,\r\n folderId: this.folderId,\r\n },\r\n cssClass: 'new-publication modal modal-desktop',\r\n backdropDismiss: false\r\n });\r\n await modal.present();\r\n modal.onDidDismiss().then(() => {\r\n this.doRefresh(event);\r\n });\r\n }\r\n\r\n goToPublicationDetail(publicationId: string) {\r\n this.router.navigate(['/home/publications/view-publications', this.folderId, publicationId]);\r\n }\r\n\r\n async viewPublicationDetail(publicationId: string) {\r\n const modal = await this.modalController.create({\r\n component: PublicationDetailPage,\r\n componentProps: {\r\n publicationId: publicationId,\r\n folderId: this.folderId,\r\n isModal: true\r\n },\r\n cssClass: 'publication-detail modal modal-desktop',\r\n // backdropDismiss: false\r\n });\r\n await modal.present();\r\n modal.onDidDismiss().then(() => {\r\n this.getPublicationsIds();\r\n });\r\n }\r\n\r\n}\r\n"]},"metadata":{},"sourceType":"module"} |