mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -219,6 +219,10 @@ const routes = [
|
||||
{
|
||||
path: 'preview-photo',
|
||||
loadChildren: () => import('./modals/preview-photo/preview-photo.module').then( m => m.PreviewPhotoPageModule)
|
||||
},
|
||||
{
|
||||
path: 'custom-image-cache',
|
||||
loadChildren: () => import('./services/file/custom-image-cache/custom-image-cache.module').then( m => m.CustomImageCachePageModule)
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -45,9 +45,17 @@ export class AppComponent {
|
||||
private backgroundservice: BackgroundService,
|
||||
private storageservice: StorageService
|
||||
) {
|
||||
// this.createCacheFolder()
|
||||
this.initializeApp();
|
||||
}
|
||||
|
||||
// async createCacheFolder(){
|
||||
// await Filesystem.mkdir({
|
||||
// directory: Directory.Cache,
|
||||
// path: `CACHED-IMG`
|
||||
// })
|
||||
// }
|
||||
|
||||
initializeApp() {
|
||||
this.platform.ready().then(() => {
|
||||
this.statusBar.styleDefault();
|
||||
|
||||
@@ -36,7 +36,7 @@ import {MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
|
||||
import { NgxMatDateFormats, NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
|
||||
import { Network } from '@ionic-native/network/ngx';
|
||||
import { File } from '@ionic-native/file/ngx';
|
||||
import { ImageCropperModule } from 'ngx-image-cropper';
|
||||
|
||||
|
||||
|
||||
import {
|
||||
@@ -66,6 +66,7 @@ import { Media } from '@ionic-native/media/ngx';
|
||||
import { StreamingMedia } from '@ionic-native/streaming-media/ngx';
|
||||
import { PhotoViewer } from '@ionic-native/photo-viewer/ngx';
|
||||
import {NgxImageCompressService} from 'ngx-image-compress';
|
||||
import { CustomImageCachePageRoutingModule } from './services/file/custom-image-cache/custom-image-cache-routing.module';
|
||||
|
||||
/* import { FCM } from '@ionic-native/fcm/ngx';
|
||||
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
@@ -82,7 +83,11 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
useFactory: adapterFactory
|
||||
}),
|
||||
IonicModule.forRoot({animated: false}),
|
||||
IonicStorageModule.forRoot(),
|
||||
IonicStorageModule.forRoot({
|
||||
name: '__mydb',
|
||||
driverOrder: ['indexeddb', 'sqlite', 'websql']
|
||||
}),
|
||||
|
||||
AppRoutingModule,
|
||||
FontAwesomeModule,
|
||||
HttpClientModule,
|
||||
@@ -104,6 +109,7 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
//
|
||||
PdfViewerModule,
|
||||
HammerModule,
|
||||
CustomImageCachePageRoutingModule
|
||||
|
||||
|
||||
],
|
||||
|
||||
@@ -4,10 +4,17 @@
|
||||
</ion-card-header>
|
||||
<ion-card-content >
|
||||
<ion-row>
|
||||
<ion-item>Iniciar Video Chamada?</ion-item>
|
||||
<ion-item>Tem certeza que apagar imagem?</ion-item>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-item>Iniciar Video Chamada?</ion-item>
|
||||
<ion-item ><ion-chip>
|
||||
<ion-label color="danger">Sim</ion-label>
|
||||
</ion-chip>
|
||||
|
||||
<ion-chip class="placed">
|
||||
<ion-label color="secondary" (click)= "dismiss()">Não</ion-label>
|
||||
</ion-chip >
|
||||
</ion-item>
|
||||
</ion-row>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
@@ -60,4 +60,8 @@
|
||||
|
||||
color: rgb(255, 38, 0);
|
||||
// background-color: rgb(255, 72, 0);
|
||||
}
|
||||
|
||||
.placed{
|
||||
float:right
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { IonSlides, ModalController, NavParams } from '@ionic/angular';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-icons',
|
||||
@@ -9,7 +10,8 @@ import { IonSlides, ModalController, NavParams } from '@ionic/angular';
|
||||
export class GroupIconsPage implements OnInit {
|
||||
|
||||
constructor( private modalController: ModalController,
|
||||
private navParams:NavParams) { }
|
||||
private navParams:NavParams,
|
||||
private publicService:PublicationsService ) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
@@ -26,6 +28,7 @@ export class GroupIconsPage implements OnInit {
|
||||
pesquizarWeb(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
dismiss() {
|
||||
// using the injected ModalController this page
|
||||
@@ -33,6 +36,11 @@ export class GroupIconsPage implements OnInit {
|
||||
this.modalController.dismiss({
|
||||
'dismissed': true
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
// delete(){
|
||||
// this.publicService.DeletePublication()
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<ion-card-header >
|
||||
|
||||
|
||||
<ion-text color="light" size="6">{{username}} <span>{{_updatedAt | date}}</span><div class="right" (click)="getIconGallery()"><ion-icon name="pencil-outline" ></ion-icon></div></ion-text>
|
||||
<ion-text color="dark" size="6">{{username}} <span>{{_updatedAt | date}}</span><div class="right" (click)="getIconGallery()"><ion-icon name="pencil-outline" ></ion-icon></div></ion-text>
|
||||
|
||||
|
||||
|
||||
@@ -27,23 +27,31 @@
|
||||
|
||||
<ion-footer color="light">
|
||||
<ion-row>
|
||||
<ion-col size="4" class="ion-text-center">
|
||||
<ion-col size="3" class="ion-text-center">
|
||||
<ion-button (click)="close()" fill="clear" color="light">
|
||||
<!-- <ion-icon name="remove" slot="start"></ion-icon> -->
|
||||
<ion-icon src="assets/icon/chat/circle-xmark-solid 1.svg" name="chatbox"></ion-icon>
|
||||
<ion-icon src="assets/icon/chat/circle-xmark-solid 1.svg" ></ion-icon>
|
||||
</ion-button>
|
||||
</ion-col>
|
||||
<ion-col size="4" class="ion-text-center">
|
||||
|
||||
<ion-button (click)="zoom(false)" fill="clear" color="light">
|
||||
<!-- <ion-icon name="remove" slot="start"></ion-icon> -->
|
||||
<ion-icon class="redla" name="flower-outline"></ion-icon>
|
||||
<ion-col size="3" class="ion-text-center">
|
||||
<ion-button (click)="deleteImage()" fill="clear" color="light">
|
||||
<ion-icon src="assets/icon/chat/Ellipse 8.svg" ></ion-icon>
|
||||
<!-- <ion-icon class="redla" name="flower-outline"></ion-icon> -->
|
||||
</ion-button>
|
||||
</ion-col>
|
||||
<ion-col size="4" class="ion-text-center">
|
||||
</ion-col>
|
||||
<ion-col size="3" class="ion-text-center">
|
||||
<ion-button (click)="getIconGallery()" fill="clear" color="light">
|
||||
|
||||
<ion-icon name="videocam" (click)="openChatVideo()"></ion-icon>
|
||||
<ion-icon src="assets/icon/chat/Ellipselast.svg" ></ion-icon>
|
||||
|
||||
|
||||
</ion-button>
|
||||
</ion-col>
|
||||
<ion-col size="3" class="ion-text-center">
|
||||
<ion-button (click)="getIconShare()" fill="clear" color="light">
|
||||
|
||||
<ion-icon src="assets/icon/chat/Ellipse 9.svg" ></ion-icon>
|
||||
|
||||
|
||||
</ion-button>
|
||||
</ion-col>
|
||||
|
||||
@@ -7,7 +7,7 @@ ion-slides {
|
||||
}
|
||||
|
||||
.redla{
|
||||
color: rgb(250, 248, 248);
|
||||
color: rgb(250, 250, 4);
|
||||
background-color: rgb(255, 238, 0);
|
||||
border-radius: 120px;
|
||||
width: 30px;
|
||||
@@ -18,7 +18,7 @@ ion-slides {
|
||||
}
|
||||
|
||||
.cardconteudo {
|
||||
background: rgb(8, 8, 8);
|
||||
background: rgb(253, 252, 252);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { IonSlides, ModalController, NavParams } from '@ionic/angular';
|
||||
import { ImageCroppedEvent } from 'ngx-image-cropper';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { GroupIconsPage } from '../group-icons/group-icons.page';
|
||||
import { Share } from '@capacitor/share';
|
||||
|
||||
@Component({
|
||||
selector: 'app-preview-camera',
|
||||
@@ -11,7 +13,8 @@ import { GroupIconsPage } from '../group-icons/group-icons.page';
|
||||
export class PreviewCameraPage implements OnInit {
|
||||
|
||||
constructor( private modalController: ModalController,
|
||||
private navParams:NavParams) { }
|
||||
private navParams:NavParams,
|
||||
private publicService: PublicationsService) { }
|
||||
|
||||
|
||||
@ViewChild(IonSlides) slides : IonSlides
|
||||
@@ -72,7 +75,7 @@ async getIconGallery(){
|
||||
const modal = await this.modalController.create({
|
||||
component: GroupIconsPage ,
|
||||
animated: true,
|
||||
cssClass: 'transparentblack-modal',
|
||||
cssClass: 'transparent-modal',
|
||||
});
|
||||
modal.present();
|
||||
}
|
||||
@@ -80,11 +83,38 @@ async getIconGallery(){
|
||||
openChat(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.getIconGallery()
|
||||
|
||||
}
|
||||
|
||||
openChatVideo(){
|
||||
|
||||
}
|
||||
deleteImage(){
|
||||
window.onload = function(){
|
||||
const delmage = document.getElementById("img")
|
||||
delmage.onclick = function(){
|
||||
return window.localStorage.removeItem("img")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
async getIconShare(){
|
||||
await Share.share({
|
||||
title: 'See cool stuff',
|
||||
text: 'Really awesome thing you need to see right meow',
|
||||
url: this.image,
|
||||
dialogTitle: 'Share with buddies',
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@
|
||||
|
||||
<!-- List -->
|
||||
<ul *ngIf="showTimelineFilterState">
|
||||
<li [class.active]="segment == 'Combinado' " (click)="changeSegment('Combinado')" class="cursor-pointer">Todos</li>
|
||||
<li [class.active]="segment == 'Oficial' " (click)="changeSegment('Oficial')" class="cursor-pointer">Oficial</li>
|
||||
<li [class.active]="segment == 'Pessoal' " (click)="changeSegment('Pessoal')" class="cursor-pointer">Pessoal</li>
|
||||
<li class="changeText" [class.active]="segment == 'Combinado' " (click)="changeSegment('Combinado')" class="cursor-pointer">Todos</li>
|
||||
<li class="changeText" [class.active]="segment == 'Oficial' " (click)="changeSegment('Oficial')" class="cursor-pointer">Oficial</li>
|
||||
<li class="changeText" [class.active]="segment == 'Pessoal' " (click)="changeSegment('Pessoal')" class="cursor-pointer">Pessoal</li>
|
||||
</ul>
|
||||
|
||||
</ion-row>
|
||||
|
||||
@@ -292,6 +292,11 @@ td.monthview-primary-with-event {
|
||||
|
||||
.segment {
|
||||
|
||||
}
|
||||
|
||||
div ion-raw > ul > li{
|
||||
font-size: 11pt;
|
||||
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* Timeline */
|
||||
@@ -794,4 +799,17 @@ app-approve-event{
|
||||
border-top-right-radius: 25px;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
||||
$font-size: 11pt;
|
||||
|
||||
.changeText{
|
||||
font-family: $font-family;
|
||||
font-size: $font-size;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
||||
import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, CurrentRecordingStatus } from 'capacitor-voice-recorder';
|
||||
import { Haptics, ImpactStyle } from '@capacitor/haptics';
|
||||
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
||||
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
|
||||
import { Share } from '@capacitor/share';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -88,7 +90,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private gestureController: GestureController,
|
||||
private processes: ProcessesService,
|
||||
public ThemeService: ThemeService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private socialSharing: SocialSharing
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
@@ -652,6 +655,7 @@ touchStart(card) {
|
||||
modal.present();
|
||||
}
|
||||
|
||||
|
||||
imageSize(img){
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
@@ -670,6 +674,16 @@ getPicture(img){
|
||||
document.body.appendChild(canvas);
|
||||
|
||||
}
|
||||
|
||||
async ShareEmail(msg){
|
||||
// Check if sharing via email is supported
|
||||
await Share.share({
|
||||
title: msg.u.username,
|
||||
text: msg._updatedAt,
|
||||
url: msg.attachments[0].image_url,
|
||||
dialogTitle: 'Share with buddies',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera
|
||||
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { NgxImageCompressService } from "ngx-image-compress";
|
||||
|
||||
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
interface LocalFile {
|
||||
@@ -87,7 +87,8 @@ export class NewPublicationPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
private platform: Platform,
|
||||
private loadingCtrl: LoadingController,
|
||||
public imageCompress: NgxImageCompressService
|
||||
public imageCompress: NgxImageCompressService,
|
||||
private socialSharing: SocialSharing
|
||||
) {
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
@@ -111,6 +112,8 @@ export class NewPublicationPage implements OnInit {
|
||||
const image = await Camera.getPhoto({
|
||||
quality: 20,
|
||||
allowEditing: false,
|
||||
width:50,
|
||||
height: 50,
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Camera // Camera, Photos or Prompt!
|
||||
|
||||
@@ -120,6 +123,8 @@ export class NewPublicationPage implements OnInit {
|
||||
this.saveImage(image)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -393,8 +398,6 @@ export class NewPublicationPage implements OnInit {
|
||||
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
|
||||
} */
|
||||
|
||||
|
||||
|
||||
async selectImage() {
|
||||
const image = await Camera.getPhoto({
|
||||
quality: 20,
|
||||
@@ -402,7 +405,6 @@ export class NewPublicationPage implements OnInit {
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Camera // Camera, Photos or Prompt!
|
||||
});
|
||||
|
||||
if (image) {
|
||||
this.saveImage(image)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { PublicationDetailPageModule } from 'src/app/shared/publication/view-pub
|
||||
import { HeaderPageModule } from 'src/app/shared/header/header.module';
|
||||
import { EditActionPageModule } from 'src/app/shared/publication/edit-action/edit-action.module';
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
import { LazyLoadImageModule } from 'ng-lazyload-image'; // <-- import it
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -29,6 +30,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
PublicationDetailPageModule,
|
||||
NewActionPageModule,
|
||||
EditActionPageModule,
|
||||
LazyLoadImageModule
|
||||
],
|
||||
declarations: [
|
||||
PublicationsPage,
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
|
||||
<div class="post-item overflow-y-auto">
|
||||
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
|
||||
<img src="{{publication.FileBase64}}" alt="image" tappable (click)="openPreview(publication.FileBase64)">
|
||||
<img src="{{publication.FileBase64}}" alt="image" >
|
||||
</div>
|
||||
<div *ngIf="publication.FileBase64.length < 30" class="post-img">
|
||||
<img src="/assets/icon/icon-no-image.svg" alt="image">
|
||||
|
||||
@@ -10,6 +10,9 @@ import { ViewPublicationsPage } from './view-publications.page';
|
||||
|
||||
import { HeaderPageModule } from 'src/app/shared/header/header.module';
|
||||
|
||||
import { LazyLoadImageModule } from 'ng-lazyload-image'; // <-- import it
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
@@ -18,6 +21,7 @@ import { HeaderPageModule } from 'src/app/shared/header/header.module';
|
||||
|
||||
ViewPublicationsPageRoutingModule,
|
||||
HeaderPageModule,
|
||||
LazyLoadImageModule
|
||||
],
|
||||
exports: [ViewPublicationsPage],
|
||||
declarations: [ViewPublicationsPage]
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
(click)="goToPublicationDetail(publication.DocumentId)"
|
||||
>
|
||||
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
|
||||
<img src="{{publication.FileBase64}}" alt="image">
|
||||
<ion-img src="{{publication.FileBase64}}" alt="image"></ion-img>
|
||||
</div>
|
||||
<div *ngIf="publication.FileBase64.length < 30" class="post-img">
|
||||
<img src="/assets/icon/icon-no-image.svg" alt="image">
|
||||
|
||||
@@ -13,6 +13,7 @@ import { PublicationDetailPage } from './publication-detail/publication-detail.p
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { forkJoin } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-publications',
|
||||
@@ -25,7 +26,9 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
publicationList: Publication[] = new Array();
|
||||
item: PublicationFolder;
|
||||
defaultImage = "https://governo.gov.ao/ao/noticias/presidente-joao-lourenco-ouviu-a-voz-da-igreja/"
|
||||
folderId: string;
|
||||
id: string;
|
||||
error: any;
|
||||
|
||||
publicationListStorage = PublicationListStorage
|
||||
@@ -66,14 +69,15 @@ export class ViewPublicationsPage implements OnInit {
|
||||
this.folderId = this.folderId['ProcessId']
|
||||
}
|
||||
|
||||
this.getPublicationsIds()
|
||||
this.getPublicationDetail();
|
||||
setTimeout(() => {
|
||||
this.getPublications();
|
||||
this.getPublicationsIds();
|
||||
}, 1000);
|
||||
|
||||
this.backgroundservice.registerBackService('Online',() => {
|
||||
this.backgroundservice.registerBackService('Online', () => {
|
||||
this.getPublicationDetail();
|
||||
this.getPublications();
|
||||
this.getPublicationsIds();
|
||||
|
||||
})
|
||||
|
||||
@@ -85,14 +89,19 @@ export class ViewPublicationsPage implements OnInit {
|
||||
this.folderId = this.folderId['ProcessId']
|
||||
}
|
||||
|
||||
// if (typeof (this.id == 'object') {
|
||||
// this.id = this.id['ProcessId']
|
||||
// }
|
||||
this.testForkJoin()
|
||||
this.getPublicationDetail();
|
||||
this.getPublications();
|
||||
this.getPublicationsIds();
|
||||
}
|
||||
|
||||
doRefresh = (event) => {
|
||||
setTimeout(() => {
|
||||
this.testForkJoin()
|
||||
this.getPublicationDetail();
|
||||
this.getPublications();
|
||||
this.getPublicationsIds();
|
||||
event.target.complete();
|
||||
}, 3000);
|
||||
|
||||
@@ -119,6 +128,68 @@ export class ViewPublicationsPage implements OnInit {
|
||||
}, 100);
|
||||
|
||||
}
|
||||
// goes to fork
|
||||
getPublicationsIds() {
|
||||
|
||||
this.showLoader = true;
|
||||
const folderId = this.folderId
|
||||
|
||||
this.publications.GetIdsPublicationsImages(this.id).subscribe(res => {
|
||||
|
||||
console.log(this.id)
|
||||
|
||||
this.publicationList = new Array();
|
||||
|
||||
// getPublicationsIds() {
|
||||
|
||||
// this.showLoader = true;
|
||||
// const folderId = this.folderId
|
||||
|
||||
// this.publications.GetPublicationsID(this.folderId).subscribe(res => {
|
||||
|
||||
// console.log('publications ids', res)
|
||||
// this.publicationList = new Array();
|
||||
|
||||
// for(let i of res) {
|
||||
// this.publications.GetPublicationById(i).subscribe(ress => {
|
||||
// console.log('publications by ids', ress)
|
||||
// let item: Publication = this.publicationPipe.itemList(ress)
|
||||
// console.log('publications by ids 2', item)
|
||||
// this.publicationList.push(item);
|
||||
// })
|
||||
// }
|
||||
|
||||
/* res.forEach(element => {
|
||||
console.log('publications elements', element)
|
||||
this.publications.GetPublicationById(element).subscribe(ress => {
|
||||
console.log('publications by ids', ress)
|
||||
let item: Publication = this.publicationPipe.itemList(ress)
|
||||
console.log('publications by ids 2', item)
|
||||
this.publicationList.push(ress);
|
||||
})
|
||||
|
||||
}); */
|
||||
|
||||
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
|
||||
|
||||
this.publicationListStorage.add(folderId, this.publicationList)
|
||||
this.getpublication = this.publicationList;
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
/* this.publicationList = new Array();
|
||||
|
||||
res.forEach(element => {
|
||||
console.log('getPublications', element)
|
||||
let item: Publication = this.publicationPipe.itemList(element)
|
||||
this.publicationList.push(item);
|
||||
});
|
||||
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
|
||||
|
||||
this.publicationListStorage.add(folderId, this.publicationList)
|
||||
this.getpublication = this.publicationList; */
|
||||
});
|
||||
}
|
||||
|
||||
getPublications() {
|
||||
|
||||
@@ -135,6 +206,8 @@ export class ViewPublicationsPage implements OnInit {
|
||||
console.log('getPublications', element)
|
||||
let item: Publication = this.publicationPipe.itemList(element)
|
||||
this.publicationList.push(item);
|
||||
console.log('getPublications 222', item)
|
||||
|
||||
});
|
||||
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
|
||||
|
||||
@@ -144,7 +217,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
this.showLoader = false;
|
||||
}, (error) => {
|
||||
|
||||
if(error.status == '0') {
|
||||
if (error.status == '0') {
|
||||
this.getFromDB();
|
||||
}
|
||||
if (error.status == '404') {
|
||||
@@ -156,6 +229,17 @@ export class ViewPublicationsPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
testForkJoin(){
|
||||
forkJoin([
|
||||
this.getPublicationsIds(),
|
||||
this.getPublications(),
|
||||
|
||||
|
||||
]).subscribe(allResults =>{
|
||||
this.publicationList = allResults[2]
|
||||
})
|
||||
}
|
||||
|
||||
getFromDB() {
|
||||
|
||||
this.sqliteservice.getActionById(this.folderId).then((publications) => {
|
||||
@@ -223,7 +307,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(() => {
|
||||
this.getPublications();
|
||||
this.getPublicationsIds();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { CustomImageCachePage } from './custom-image-cache.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: CustomImageCachePage
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class CustomImageCachePageRoutingModule {}
|
||||
@@ -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 { CustomImageCachePageRoutingModule } from './custom-image-cache-routing.module';
|
||||
|
||||
import { CustomImageCachePage } from './custom-image-cache.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
CustomImageCachePageRoutingModule
|
||||
],
|
||||
exports: [CustomImageCachePage],
|
||||
declarations: [CustomImageCachePage]
|
||||
})
|
||||
export class CustomImageCachePageModule {}
|
||||
@@ -0,0 +1,5 @@
|
||||
<img [src]="_src" *ngIf="_src !=''; else loading;">
|
||||
|
||||
<ng-template #loading>
|
||||
<ion-spinner></ion-spinner>
|
||||
</ng-template>
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
|
||||
import { CustomImageCachePage } from './custom-image-cache.page';
|
||||
|
||||
describe('CustomImageCachePage', () => {
|
||||
let component: CustomImageCachePage;
|
||||
let fixture: ComponentFixture<CustomImageCachePage>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CustomImageCachePage ],
|
||||
imports: [IonicModule.forRoot()]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(CustomImageCachePage);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Directory, Filesystem } from '@capacitor/filesystem';
|
||||
// import { readFile } from 'fs';
|
||||
|
||||
|
||||
|
||||
const CACHE_FOLDER = 'CACHED-IMG'
|
||||
|
||||
@Component({
|
||||
selector: 'app-custom-image-cache',
|
||||
templateUrl: './custom-image-cache.page.html',
|
||||
styleUrls: ['./custom-image-cache.page.scss'],
|
||||
})
|
||||
export class CustomImageCachePage implements OnInit {
|
||||
|
||||
_src ="";
|
||||
@Input () spinner = false
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
constructor() { }
|
||||
|
||||
@Input()
|
||||
set src(imageUrl: string){
|
||||
console.log('SET SOURCE', imageUrl)
|
||||
|
||||
const imageName = imageUrl.split('/').pop()
|
||||
const fileType = imageName.split('.').pop()
|
||||
|
||||
Filesystem.readFile({
|
||||
directory: Directory.Cache,
|
||||
path: `${CACHE_FOLDER}/${imageName}`}).then(readFile =>{
|
||||
console.log('LOCAL FILE: ', readFile)
|
||||
// set to SRC
|
||||
this._src = `data:image/${fileType};base64ToFile, ${readFile.data}`
|
||||
}).catch(async e =>{
|
||||
await this.storedImage(imageUrl, imageName)
|
||||
})
|
||||
Filesystem.readFile({
|
||||
directory: Directory.Cache,
|
||||
path: `${CACHE_FOLDER}/${imageName}`
|
||||
}).then(readFile =>{
|
||||
this._src = `data:image/${fileType};base64ToFile, ${readFile.data}`
|
||||
})
|
||||
|
||||
}
|
||||
async storedImage(url, path){
|
||||
const response = await fetch(`http://api-cors-proxy-devdactic.herokuapp.com/${url}`)
|
||||
const blob = await response.blob()
|
||||
|
||||
const base64Data = await this.convertBlobToBase64(blob) as string;
|
||||
const savedFile = await Filesystem.writeFile({
|
||||
path: `${CACHE_FOLDER}/${path}`,
|
||||
data: base64Data,
|
||||
directory: Directory.Cache
|
||||
})
|
||||
return savedFile
|
||||
}
|
||||
|
||||
convertBlobToBase64(blob: Blob){
|
||||
return new Promise((resolve, reject) =>{
|
||||
const reader = new FileReader;
|
||||
reader.onerror = reject;
|
||||
reader.onload = () => {
|
||||
resolve(reader.result)
|
||||
}
|
||||
reader.readAsDataURL(blob)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, OnInit } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { AuthService } from '../services/auth.service';
|
||||
@@ -6,20 +6,27 @@ import { LoginUserRespose } from '../models/user.model';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators'
|
||||
import { Publication } from '../models/publication';
|
||||
import { getUrl } from 'ionicons/dist/types/components/icon/utils';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PublicationsService {
|
||||
export class PublicationsService {
|
||||
|
||||
|
||||
|
||||
authheader = {};
|
||||
loggeduser: LoginUserRespose;
|
||||
headers: HttpHeaders;
|
||||
|
||||
constructor(private http: HttpClient, user: AuthService) {
|
||||
constructor(private http: HttpClient, user: AuthService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.loggeduser = user.ValidatedUser;
|
||||
this.headers = new HttpHeaders();
|
||||
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||
|
||||
}
|
||||
|
||||
GetPublicationFolderList(){
|
||||
@@ -77,6 +84,20 @@ export class PublicationsService {
|
||||
return this.http.delete<any>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
GetPublicationsID(folder:any) {
|
||||
const geturl = environment.apiURL + 'presidentialActions/'+ folder +'/posts/ids';
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("folderId", folder);
|
||||
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
return this.http.get<Publication[]>(`${geturl}`, options)
|
||||
|
||||
}
|
||||
|
||||
GetPublications(id:any){
|
||||
const geturl = environment.apiURL + 'presidentialActions/'+ id +'/posts';
|
||||
let params = new HttpParams();
|
||||
@@ -90,19 +111,88 @@ export class PublicationsService {
|
||||
return this.http.get<Publication[]>(`${geturl}`, options)
|
||||
}
|
||||
|
||||
// this one too,goes to observable as a first api call
|
||||
GetIdsPublicationsImages(id:any) {
|
||||
const geturl = environment.apiURL + 'presidentialActions/'+ id +'/posts/ids';
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("folderId", id);
|
||||
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
return this.http.get<number[]>(`${geturl}`, options)
|
||||
}
|
||||
|
||||
|
||||
GetPublicationById( publicationId:any){
|
||||
const geturl = environment.apiURL + 'presidentialActions/posts/'+ publicationId;
|
||||
let params = new HttpParams();
|
||||
|
||||
/* params = params.set("id", publicationId); */
|
||||
params = params.set("id", publicationId);
|
||||
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
/* params: params */
|
||||
params: params
|
||||
};
|
||||
return this.http.get<any>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
// my own tries
|
||||
|
||||
GetPublicationByIdNext( publicationId:any){
|
||||
let geturl = environment.apiURL + 'presidentialActions/'+ publicationId + '/posts/ids';
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("folderId", publicationId);
|
||||
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
/* params: params */
|
||||
};
|
||||
|
||||
const imageLoads = !!(+localStorage.getItem('loadedimage'))
|
||||
if(imageLoads){
|
||||
return true
|
||||
}else{
|
||||
const navigation = this.router.getCurrentNavigation()
|
||||
console.log('nav:', navigation)
|
||||
|
||||
if(navigation){
|
||||
geturl = navigation.extractedUrl.toString()
|
||||
}
|
||||
|
||||
this.router.navigate([URL], {queryParams: {returnto: geturl}})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
GetIdsPublicationNext(id:any){
|
||||
let geturl = environment.apiURL + 'presidentialActions/posts/' + id;
|
||||
let params = new HttpParams();
|
||||
|
||||
params = params.set("id", id);
|
||||
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
};
|
||||
|
||||
var search = this.http.get<any>(`${geturl}`, options).subscribe(
|
||||
res => {
|
||||
res.this.activatedRoute.snapshot.queryParams.get('returnto') || '/posts'
|
||||
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
return search
|
||||
|
||||
}
|
||||
|
||||
//my last tries
|
||||
|
||||
CreatePublication(folderId:any,body:any){
|
||||
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/posts';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -31,9 +31,12 @@ export class PublicationListService {
|
||||
return this._document[folderId]
|
||||
}
|
||||
|
||||
|
||||
add(folderId, document = []) {
|
||||
this._document[folderId] = document
|
||||
|
||||
|
||||
|
||||
setTimeout(()=> {
|
||||
localstoreService.set(this.keyName, {
|
||||
document: this._document
|
||||
|
||||
Reference in New Issue
Block a user