diff --git a/package-lock.json b/package-lock.json index 8401eca5b..ed31999fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,7 +49,12 @@ "@capacitor/share": "^4.1.0", "@capacitor/storage": "^1.2.5", "@capawesome/capacitor-file-picker": "^5.3.0", +<<<<<<< HEAD "@capawesome/capacitor-screen-orientation": "^5.0.1", +======= + "@ffmpeg/core": "^0.12.6", + "@ffmpeg/ffmpeg": "^0.12.10", +>>>>>>> feature/upload-streaming-videos "@fortawesome/angular-fontawesome": "^0.9.0", "@fortawesome/fontawesome-free": "^5.15.3", "@fortawesome/fontawesome-svg-core": "^1.2.35", @@ -154,6 +159,7 @@ "lite-server": "^2.6.1", "minisearch": "^6.0.1", "moment": "^2.29.3", + "mux.js": "^6.3.0", "neverthrow": "^6.1.0", "ng-lazyload-image": "^9.1.2", "ng2-pdf-viewer": "^3.0.8", @@ -3616,7 +3622,6 @@ "version": "7.14.8", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.8.tgz", "integrity": "sha512-twj3L8Og5SaCRCErB4x4ajbvBIVV77CGeFglHpeg5WC5FF8TZzBWXtTJ4MqaD9QszLYTtr+IsaAL2rEUevb+eg==", - "dev": true, "dependencies": { "regenerator-runtime": "^0.13.4" }, @@ -4022,6 +4027,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/@capawesome/capacitor-file-picker/-/capacitor-file-picker-5.3.0.tgz", "integrity": "sha512-r+cfD+9FCBXMYtckSovgi7WoMWT5cxzNDaH3SDNuiORiyQklOl+7DExfhW00p1DqsDR+f50nADk/NBb4IsGVYg==", +<<<<<<< HEAD "funding": [ { "type": "github", @@ -4040,6 +4046,8 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@capawesome/capacitor-screen-orientation/-/capacitor-screen-orientation-5.0.1.tgz", "integrity": "sha512-IaF7HjlxS1EXjUNCa8Ztu9EpxsplAYsNcDUHVX2x3B+KRqB0f7DQYi96cnKYeWpMt9JhrLPXc8XGRP4suU4NYw==", +======= +>>>>>>> feature/upload-streaming-videos "funding": [ { "type": "github", @@ -4250,6 +4258,33 @@ "node": ">=10.0.0" } }, + "node_modules/@ffmpeg/core": { + "version": "0.12.6", + "resolved": "https://registry.npmjs.org/@ffmpeg/core/-/core-0.12.6.tgz", + "integrity": "sha512-PrjWBTfGn2WVn9T7wGnzfFwChbqWeZc7tM9vvJZVRadYFUDakfzy7W0LpYC0cvvK0xT82qlBsk38lQhJ/Hps5A==", + "engines": { + "node": ">=16.x" + } + }, + "node_modules/@ffmpeg/ffmpeg": { + "version": "0.12.10", + "resolved": "https://registry.npmjs.org/@ffmpeg/ffmpeg/-/ffmpeg-0.12.10.tgz", + "integrity": "sha512-lVtk8PW8e+NUzGZhPTWj2P1J4/NyuCrbDD3O9IGpSeLYtUZKBqZO8CNj1WYGghep/MXoM8e1qVY1GztTkf8YYQ==", + "dependencies": { + "@ffmpeg/types": "^0.12.2" + }, + "engines": { + "node": ">=18.x" + } + }, + "node_modules/@ffmpeg/types": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/@ffmpeg/types/-/types-0.12.2.tgz", + "integrity": "sha512-NJtxwPoLb60/z1Klv0ueshguWQ/7mNm106qdHkB4HL49LXszjhjCCiL+ldHJGQ9ai2Igx0s4F24ghigy//ERdA==", + "engines": { + "node": ">=16.x" + } + }, "node_modules/@firebase/analytics": { "version": "0.6.18", "resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.6.18.tgz", @@ -26836,6 +26871,22 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, + "node_modules/mux.js": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-6.3.0.tgz", + "integrity": "sha512-/QTkbSAP2+w1nxV+qTcumSDN5PA98P0tjrADijIzQHe85oBK3Akhy9AHlH0ne/GombLMz1rLyvVsmrgRxoPDrQ==", + "dependencies": { + "@babel/runtime": "^7.11.2", + "global": "^4.4.0" + }, + "bin": { + "muxjs-transmux": "bin/transmux.js" + }, + "engines": { + "node": ">=8", + "npm": ">=5" + } + }, "node_modules/nan": { "version": "2.17.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", @@ -46204,7 +46255,6 @@ "version": "7.14.8", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.8.tgz", "integrity": "sha512-twj3L8Og5SaCRCErB4x4ajbvBIVV77CGeFglHpeg5WC5FF8TZzBWXtTJ4MqaD9QszLYTtr+IsaAL2rEUevb+eg==", - "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } @@ -46516,12 +46566,15 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/@capawesome/capacitor-file-picker/-/capacitor-file-picker-5.3.0.tgz", "integrity": "sha512-r+cfD+9FCBXMYtckSovgi7WoMWT5cxzNDaH3SDNuiORiyQklOl+7DExfhW00p1DqsDR+f50nADk/NBb4IsGVYg==", +<<<<<<< HEAD "requires": {} }, "@capawesome/capacitor-screen-orientation": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@capawesome/capacitor-screen-orientation/-/capacitor-screen-orientation-5.0.1.tgz", "integrity": "sha512-IaF7HjlxS1EXjUNCa8Ztu9EpxsplAYsNcDUHVX2x3B+KRqB0f7DQYi96cnKYeWpMt9JhrLPXc8XGRP4suU4NYw==", +======= +>>>>>>> feature/upload-streaming-videos "requires": {} }, "@cnakazawa/watch": { @@ -46684,6 +46737,24 @@ "integrity": "sha512-Fxt+AfXgjMoin2maPIYzFZnQjAXjAL0PHscM5pRTtatFqB+vZxAM9tLp2Optnuw3QOQC40jTNeGYFOMvyf7v9g==", "dev": true }, + "@ffmpeg/core": { + "version": "0.12.6", + "resolved": "https://registry.npmjs.org/@ffmpeg/core/-/core-0.12.6.tgz", + "integrity": "sha512-PrjWBTfGn2WVn9T7wGnzfFwChbqWeZc7tM9vvJZVRadYFUDakfzy7W0LpYC0cvvK0xT82qlBsk38lQhJ/Hps5A==" + }, + "@ffmpeg/ffmpeg": { + "version": "0.12.10", + "resolved": "https://registry.npmjs.org/@ffmpeg/ffmpeg/-/ffmpeg-0.12.10.tgz", + "integrity": "sha512-lVtk8PW8e+NUzGZhPTWj2P1J4/NyuCrbDD3O9IGpSeLYtUZKBqZO8CNj1WYGghep/MXoM8e1qVY1GztTkf8YYQ==", + "requires": { + "@ffmpeg/types": "^0.12.2" + } + }, + "@ffmpeg/types": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/@ffmpeg/types/-/types-0.12.2.tgz", + "integrity": "sha512-NJtxwPoLb60/z1Klv0ueshguWQ/7mNm106qdHkB4HL49LXszjhjCCiL+ldHJGQ9ai2Igx0s4F24ghigy//ERdA==" + }, "@firebase/analytics": { "version": "0.6.18", "resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.6.18.tgz", @@ -64286,6 +64357,15 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, + "mux.js": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-6.3.0.tgz", + "integrity": "sha512-/QTkbSAP2+w1nxV+qTcumSDN5PA98P0tjrADijIzQHe85oBK3Akhy9AHlH0ne/GombLMz1rLyvVsmrgRxoPDrQ==", + "requires": { + "@babel/runtime": "^7.11.2", + "global": "^4.4.0" + } + }, "nan": { "version": "2.17.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2e49c66c9..a8e9d3c9c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -11,6 +11,7 @@ import { environment } from 'src/environments/environment'; import { Storage } from '@ionic/storage'; import { ChatController } from './controller/chat'; import { register } from 'swiper/element/bundle'; +import { DomSanitizer } from '@angular/platform-browser'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { @@ -39,9 +40,11 @@ export class AppComponent { private statusBar: StatusBar, public ThemeService: ThemeService, private storage: Storage, - private ChatSystemService: ChatSystemService + private ChatSystemService: ChatSystemService, + private sanitizer: DomSanitizer ) { + window["sanitizer"] = this.sanitizer this.initializeApp(); this.storage.set('version', environment.version).then(() => {}) ChatController.ChatSystemService = this.ChatSystemService diff --git a/src/app/interceptors/token.interceptors.ts b/src/app/interceptors/token.interceptors.ts index e85eb81bc..1a4ad808d 100644 --- a/src/app/interceptors/token.interceptors.ts +++ b/src/app/interceptors/token.interceptors.ts @@ -22,6 +22,8 @@ export class TokenInterceptor implements HttpInterceptor { null ); + private excludedDomains = ['Login', environment.apiChatUrl]; // Add the domains you want to exclude + constructor(private http: HttpClient, private router: Router,) { } @@ -29,6 +31,11 @@ export class TokenInterceptor implements HttpInterceptor { request: HttpRequest, next: HttpHandler ): Observable> { + + if (this.shouldExcludeDomain(request)) { + return next.handle(request); + } + if (SessionStore.user.Authorization) { request = this.addToken(request, SessionStore.user.Authorization); } @@ -44,23 +51,24 @@ export class TokenInterceptor implements HttpInterceptor { ); } + private shouldExcludeDomain(request: HttpRequest): boolean { + const url = request.url.toLowerCase(); + return this.excludedDomains.some((domain) => url.includes(domain.toLowerCase())); + } + private addToken(request: HttpRequest, token: string) { - if(request.url.includes("Login")) { - return request.clone({}); - } else { - - return request.clone({ - setHeaders: { - //'Access-Control-Allow-Origin': '*', - Authorization: `Bearer ${token}`, - }, - }); - } + return request.clone({ + setHeaders: { + //'Access-Control-Allow-Origin': '*', + Authorization: `Bearer ${token}`, + }, + }); } private handle401Error(request: HttpRequest, next: HttpHandler) { + // if not getting the new token yet if (!this.isRefreshing) { this.isRefreshing = true; this.refreshTokenSubject.next(null); @@ -73,6 +81,7 @@ export class TokenInterceptor implements HttpInterceptor { }) ); } else { + // get new token return this.refreshTokenSubject.pipe( filter((token) => token != null), take(1), diff --git a/src/app/modals/view-document/view-document.page.html b/src/app/modals/view-document/view-document.page.html index 9c0b9e166..9a7639fbe 100644 --- a/src/app/modals/view-document/view-document.page.html +++ b/src/app/modals/view-document/view-document.page.html @@ -5,7 +5,7 @@ -
+
{{file.title}}
diff --git a/src/app/models/publication.ts b/src/app/models/publication.ts index 64c328a1c..3e48e5214 100644 --- a/src/app/models/publication.ts +++ b/src/app/models/publication.ts @@ -11,4 +11,4 @@ export class Publication{ Files:any = []; FileExtension?: string; OrganicEntityId?: number; -} \ No newline at end of file +} diff --git a/src/app/pages/publications/new-publication/new-publication.page.html b/src/app/pages/publications/new-publication/new-publication.page.html index b0bdbcfd7..f245317e4 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.html +++ b/src/app/pages/publications/new-publication/new-publication.page.html @@ -40,19 +40,23 @@ - +
-

mais {{ seletedContent.length - displayLimit }}

diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index 0e3e7a611..2718dc842 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -22,7 +22,6 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; import { PublicationFolderService } from 'src/app/store/publication-folder.service'; import { RouteService } from 'src/app/services/route.service'; import { FileService } from 'src/app/services/functions/file.service'; -import { readAndCompressImage } from 'browser-image-resizer'; import { FilePicker } from '@capawesome/capacitor-file-picker'; import { CapacitorVideoPlayer } from 'capacitor-video-player'; import { CaptureError, CaptureImageOptions, MediaCapture, MediaFile } from '@awesome-cordova-plugins/media-capture/ngx'; @@ -31,9 +30,7 @@ import { File } from '@ionic-native/file/ngx'; import { Media } from '@ionic-native/media/ngx'; import { checkFileTypeService } from 'src/app/services/checkFileType.service'; import { FileValidatorService } from "src/app/services/file/file-validator.service" -import { App } from '@capacitor/app'; -import { Router } from '@angular/router'; - +import { PublicationAttachmentEntity } from 'src/app/shared/publication/upload/upload-streaming.service'; const config = { quality: 0.5, maxWidth: 800, @@ -95,6 +92,13 @@ export class NewPublicationPage implements OnInit { publicationTitle: string; imgUrl: any; + + ActionType = { + newRapid : "1", + new: "2", + edit: "3" + } + Defaultimage: any = ''; photo: SafeResourceUrl; @@ -115,7 +119,7 @@ export class NewPublicationPage implements OnInit { photoOrVideo: boolean = false; fileType = ""; filecontent: boolean; - seletedContent: any[] = [] + seletedContent: PublicationAttachmentEntity[] = [] // Set a limit for the number of images to display displayLimit = 4; filesSizeSum = 0; @@ -136,8 +140,7 @@ export class NewPublicationPage implements OnInit { public FileService: FileService, private mediaCapture: MediaCapture, public checkFileType: checkFileTypeService, - private FileValidatorService: FileValidatorService, - private router: Router, + private FileValidatorService: FileValidatorService ) { this.publicationType = this.navParams.get('publicationType'); @@ -146,6 +149,18 @@ export class NewPublicationPage implements OnInit { if (this.publication) { this.seletedContent = this.publication.Files; this.filecontent = true; + + this.seletedContent = this.publication.Files.map(e => { + return new PublicationAttachmentEntity( + { + base64: e.FileBase64, + extension: e.FileExtension, + OriginalFileName: e.OriginalFileName, + FileType: this.checkFileType.checkFileType(e.FileExtension) as any + } + ) + }) + } console.log('Edit', this.publication) this.publicationTitle = 'Nova Publicação'; @@ -165,12 +180,16 @@ export class NewPublicationPage implements OnInit { recursive: true }); - document.addEventListener("click", clickOutside, false); - function clickOutside(e) { - const inside = document.getElementById('container-multiselect').contains(e.target); - this.photoOrVideo = false; - console.log(this.photoOrVideo) - } + try { + document.addEventListener("click", clickOutside, false); + function clickOutside(e) { + const inside = document.getElementById('container-multiselect').contains(e.target); + this.photoOrVideo = false; + console.log(this.photoOrVideo) + } + } catch (error) {} + + } // in use @@ -197,11 +216,14 @@ export class NewPublicationPage implements OnInit { console.log('take picture', this.removeTextBeforeSlash(picture, ','),) this.filecontent = true; this.photoOrVideo = false; - let fileObject = { - FileBase64: this.removeTextBeforeSlash(picture, ','), - FileExtension: capturedImage.format, + + const fileObject = new PublicationAttachmentEntity({ + base64: this.removeTextBeforeSlash(picture, ','), + extension: capturedImage.format, + FileType: 'image', OriginalFileName: 'image' - } + }) + this.seletedContent.push(fileObject) @@ -255,11 +277,14 @@ export class NewPublicationPage implements OnInit { .then(async (content) => { this.filecontent = true; - let fileObject = { - FileBase64: 'data:video/mp4;base64,' + content.data, - FileExtension: 'mp4', - OriginalFileName: 'video' - } + let fileObject = new PublicationAttachmentEntity({ + base64: 'data:video/mp4;base64,'+content.data, + extension: 'mp4', + OriginalFileName: 'record', + FileType: 'video' + + }) + this.seletedContent.push(fileObject) }) .catch((err) => console.error(err)); @@ -282,7 +307,7 @@ export class NewPublicationPage implements OnInit { ({ multiple: true, }); - console.log(result.files) + console.log(result.files) result.files.forEach(element => { this.filesSizeSum = this.filesSizeSum + element.size @@ -297,18 +322,29 @@ export class NewPublicationPage implements OnInit { console.log(content) this.filecontent = true; let fileObject; - if (this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") { - fileObject = { - FileBase64: 'data:video/mp4;base64,' + content.data, - FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'), - OriginalFileName: 'video' - } + if(this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") { + + const extension = this.removeTextBeforeSlash(element.mimeType, '/') + + fileObject = new PublicationAttachmentEntity({ + base64: content.data, + extension: extension, + OriginalFileName: 'video', + FileType: 'video' + }) + } else { - fileObject = { - FileBase64: content.data, - FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'), - OriginalFileName: 'image' - } + + const extension = this.removeTextBeforeSlash(element.mimeType, '/') + + fileObject = new PublicationAttachmentEntity({ + base64: content.data, + extension: extension, + OriginalFileName: 'image', + FileType: 'image' + + }) + } this.seletedContent.push(fileObject) @@ -357,24 +393,24 @@ export class NewPublicationPage implements OnInit { /* // in use async laodPicture() { - + const capturedImage = await Camera.getPhoto({ quality: 90, // allowEditing: true, resultType: CameraResultType.Uri, source: CameraSource.Photos }); - + const response = await fetch(capturedImage.webPath!); const blob = await response.blob(); - + this.convertBlobToBase64Worker.postMessage(blob); this.convertBlobToBase64Worker.onmessage = async (oEvent)=> { this.capturedImage = oEvent.data this.capturedImageTitle = 'foto' - + } - + } */ @@ -409,52 +445,51 @@ export class NewPublicationPage implements OnInit { if (this.Form.invalid) return false - if (this.seletedContent.length != 0) { - if (this.publicationType == '3') { - const loader = this.toastService.loading() + if (this.publicationType == '3') { + const loader = this.toastService.loading() - // has file - if (this.PublicationFolderService.PublicationHasImage(this.publication)) { - this.publication = { - DateIndex: this.publication.DateIndex, - DocumentId: this.publication.DocumentId, - ProcessId: this.publication.ProcessId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: this.publication.DatePublication, - OriginalFileName: this.publication.OriginalFileName, - Files: this.seletedContent, - } + // has file + if (this.PublicationFolderService.PublicationHasImage(this.publication)) { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId: this.publication.DocumentId, + ProcessId: this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.publication.OriginalFileName, + Files: this.seletedContent, + } - /* } else if (this.capturedVideo != '' && this.capturedImage == '') { - this.publication = { - DateIndex: this.publication.DateIndex, - DocumentId: this.publication.DocumentId, - ProcessId: this.publication.ProcessId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: this.publication.DatePublication, - OriginalFileName: this.publication.OriginalFileName || 'video', - Files: this.seletedContent, - FileExtension: 'mp4', - } - } */ - // no names - } else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) { - this.publication = { - DateIndex: this.publication.DateIndex, - DocumentId: this.publication.DocumentId, - ProcessId: this.publication.ProcessId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: this.publication.DatePublication, - OriginalFileName: this.publication.OriginalFileName, - Files: this.seletedContent, - } + /* } else if (this.capturedVideo != '' && this.capturedImage == '') { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId: this.publication.DocumentId, + ProcessId: this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.publication.OriginalFileName || 'video', + Files: this.seletedContent, + FileExtension: 'mp4', + } + } */ + // no names + } else if (!this.PublicationFolderService.PublicationHasImage(this.publication)) { + this.publication = { + DateIndex: this.publication.DateIndex, + DocumentId: this.publication.DocumentId, + ProcessId: this.publication.ProcessId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: this.publication.DatePublication, + OriginalFileName: this.publication.OriginalFileName, + Files: this.seletedContent, + } - } /* else { + } /* else { this.publication = { DateIndex: this.publication.DateIndex, DocumentId: this.publication.DocumentId, @@ -470,96 +505,90 @@ export class NewPublicationPage implements OnInit { } */ - try { + try { - const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() + const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise() - this.httpErrorHandle.httpsSucessMessagge('Editar publicação') - console.log({ response }) + this.httpErrorHandle.httpsSucessMessagge('Editar publicação') + console.log({ response }) + this.close(); + } catch (error) { + if (error.status == 404) { + this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId) this.close(); - } catch (error) { - if (error.status == 404) { - this.PublicationFolderService.deletePost(this.publication.ProcessId, this.publication.DocumentId) - this.close(); - } - this.httpErrorHandle.httpStatusHandle(error) - } finally { - loader.remove() } - - } - else { - - const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss') - - /* this.seletedContent = this.seletedContent.map((e) => { - if(e.FileExtension == "mp4") { - return { - FileBase64: e.FileBase64, - FileExtension: 'data:video/mp4;base64,'+e.FileExtension, - OriginalFileName: "video", - } - } - - return e - }) */ - - /* if (this.capturedImage != '') { */ - this.publication = { - DateIndex: date, - DocumentId: null, - ProcessId: this.folderId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: date, - OriginalFileName: this.capturedImageTitle || 'foto', - Files: this.seletedContent, - /* FileExtension: 'jpeg', */ - } - - /* } else if (this.capturedVideo != '') { - this.publication = { - DateIndex: date, - DocumentId: null, - ProcessId: this.folderId, - Title: this.pub.Title, - Message: this.pub.Message, - DatePublication: date, - OriginalFileName: this.capturedImageTitle || 'video', - Files: this.seletedContent, - FileExtension: 'mp4', - } - } */ - - - const loader = this.toastService.loading() - - try { - - - await this.publications.CreatePublication(this.folderId, this.publication).toPromise(); - this.httpErrorHandle.httpsSucessMessagge('Criar publicação') - if(window["sharedContent"]) { - this.router.navigate(['/home/publications', this.folderId]); - return - } - - this.close(); - } catch (error) { - this.httpErrorHandle.httpStatusHandle(error) - } finally { - loader.remove() - } - + this.httpErrorHandle.httpStatusHandle(error) + } finally { + loader.remove() } - this.PublicationFolderService.getPublicationsIds(this.folderId) - - } else { - this.httpErrorHandle.validationMessagge("noFileSelected") } + else { + + const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss') + + /* this.seletedContent = this.seletedContent.map((e) => { + if(e.FileExtension == "mp4") { + return { + FileBase64: e.FileBase64, + FileExtension: 'data:video/mp4;base64,'+e.FileExtension, + OriginalFileName: "video", + } + } + + return e + }) */ + + /* if (this.capturedImage != '') { */ + this.publication = { + DateIndex: date, + DocumentId: null, + ProcessId: this.folderId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: date, + OriginalFileName: this.capturedImageTitle || 'foto', + Files: this.seletedContent, + /* FileExtension: 'jpeg', */ + } + + /* } else if (this.capturedVideo != '') { + this.publication = { + DateIndex: date, + DocumentId: null, + ProcessId: this.folderId, + Title: this.pub.Title, + Message: this.pub.Message, + DatePublication: date, + OriginalFileName: this.capturedImageTitle || 'video', + Files: this.seletedContent, + FileExtension: 'mp4', + } + } */ + + + const loader = this.toastService.loading() + + try { + + await this.publications.CreatePublication(this.folderId, this.publication).toPromise(); + this.close(); + this.httpErrorHandle.httpsSucessMessagge('Criar publicação') + window["sharedContent"] = null; + window["endSharedContent"] = null; + + this.close(); + } catch (error) { + this.httpErrorHandle.httpStatusHandle(error) + } finally { + loader.remove() + } + + } + + this.PublicationFolderService.getPublicationsIds(this.folderId) } @@ -567,10 +596,6 @@ export class NewPublicationPage implements OnInit { this.modalController.dismiss(this.publication).then(() => { this.showLoader = true; }); - - if(window["sharedContent"]) { - this.closeApp(); - } } clear() { @@ -753,23 +778,15 @@ export class NewPublicationPage implements OnInit { if (this.checkFileType.checkFileType(FileExtension) == 'image' || this.checkFileType.checkFileType(FileExtension) == 'video') { let resultUrl = decodeURIComponent(element.url); Filesystem.readFile({ path: resultUrl }).then(async (content) => { - let fileObject; - if (this.checkFileType.checkFileType(FileExtension) == 'image') { - fileObject = { - FileBase64: this.removeTextBeforeSlash(content.data, ','), - FileExtension: FileExtension, - OriginalFileName: 'shared', - } - } else if (this.checkFileType.checkFileType(FileExtension) == 'video') { - fileObject = { - FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','), - FileExtension: FileExtension, - OriginalFileName: 'shared', + let fileObject = new PublicationAttachmentEntity( + { + base64: this.removeTextBeforeSlash(content.data, ','), + extension: FileExtension, + OriginalFileName: "share-content", + FileType: this.checkFileType.checkFileType(FileExtension) as any } - - } - console.log('shared base', content.data) + ) this.seletedContent.push(fileObject) }) @@ -791,9 +808,5 @@ export class NewPublicationPage implements OnInit { this.seletedContent.splice(index, 1) } - closeApp() { - App.exitApp() - } - } diff --git a/src/app/pages/publications/publications.page.html b/src/app/pages/publications/publications.page.html index 391c47e29..e2464cccf 100644 --- a/src/app/pages/publications/publications.page.html +++ b/src/app/pages/publications/publications.page.html @@ -19,12 +19,9 @@
Acções -
- -
+ +
- +
diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index 2287fc8bf..39f73b349 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -82,7 +82,7 @@ export class PublicationsPage implements OnInit { 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"]; this.intent = window["sharedContent"] - + } ngOnInit() { diff --git a/src/app/pipes/pipes.module.ts b/src/app/pipes/pipes.module.ts index 2d3ab2605..f5a8d980a 100644 --- a/src/app/pipes/pipes.module.ts +++ b/src/app/pipes/pipes.module.ts @@ -8,10 +8,11 @@ import { ExpedienteTaskPipe } from './expediente-task.pipe'; import { ParticipantsPipe } from './participants.pipe'; import { SafehtmlPipe } from './safehtml.pipe'; import { EventoApprovePipe } from './evento-approve.pipe'; +import { SafePipe } from './safe.pipe'; @NgModule({ - declarations: [FilterPipe, SearchDocumentPipe, CustomTaskPipe, EventPipe, PublicationPipe, ExpedienteTaskPipe, ParticipantsPipe, SafehtmlPipe, EventoApprovePipe], + declarations: [FilterPipe, SearchDocumentPipe, CustomTaskPipe, EventPipe, PublicationPipe, ExpedienteTaskPipe, ParticipantsPipe, SafehtmlPipe, EventoApprovePipe, SafePipe], exports: [FilterPipe, SafehtmlPipe], imports: [] }) diff --git a/src/app/pipes/safe.pipe.spec.ts b/src/app/pipes/safe.pipe.spec.ts new file mode 100644 index 000000000..49ee0ad14 --- /dev/null +++ b/src/app/pipes/safe.pipe.spec.ts @@ -0,0 +1,8 @@ +import { SafePipe } from './safe.pipe'; + +describe('SafePipe', () => { + it('create an instance', () => { + const pipe = new SafePipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/app/pipes/safe.pipe.ts b/src/app/pipes/safe.pipe.ts new file mode 100644 index 000000000..e3e3e0c18 --- /dev/null +++ b/src/app/pipes/safe.pipe.ts @@ -0,0 +1,13 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; + +@Pipe({ + name: 'safe' +}) +export class SafePipe implements PipeTransform { + constructor(private sanitizer: DomSanitizer) { } + + transform(url: string): SafeUrl { + return this.sanitizer.bypassSecurityTrustUrl(url); + } +} diff --git a/src/app/services/socket-connection-mcr.service.ts b/src/app/services/socket-connection-mcr.service.ts index 9d8e440c7..4dbd9ac16 100644 --- a/src/app/services/socket-connection-mcr.service.ts +++ b/src/app/services/socket-connection-mcr.service.ts @@ -1,46 +1,450 @@ import { Injectable } from '@angular/core'; import * as signalR from "@microsoft/signalr" import { SessionStore } from '../store/session.service'; - - +import { v4 as uuidv4 } from 'uuid' +import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http'; +import { CMAPIService } from '../shared/repository/CMAPI/cmapi.service'; +import { HubConnectionBuilder } from '@microsoft/signalr'; +import { ok, err, Result } from 'neverthrow'; @Injectable({ providedIn: 'root' }) export class SocketConnectionMCRService { + // private callbacks: Function[] = [] + // private onDisconnect: Function[] = [] + // private onConnect: Function[] = [] - constructor() { } + constructor(private http: HttpClient, private _CMAPIService: CMAPIService) { + window["http"] = this.http + } + + // connect() { + + // var connection = new signalR.HubConnectionBuilder() + // .withUrl("https://gdcmapi-dev.dyndns.info/FileHub", { + // accessTokenFactory: () => "Bearer "+SessionStore.user.Authorization + // }).configureLogging(signalR.LogLevel.Information) + // .build(); + + // connection.on("ReceiveMessage", (message) => { + // console.log("ReceiveMessage", message) + // }) + + // connection.onreconnected((connectionId) => { + // console.assert(connection.state === signalR.HubConnectionState.Connected); + // console.log(`Reconnected with connectionId: ${connectionId}`); + // }); + + // connection.start() + // .then(() => { + // console.log("SignalR connection started."); + // }) + // .catch((error) => { + // console.error("Error starting SignalR connection:", error); + // }); + + // connection.onclose((error) => { + // connection.start() + // console.log("SignalR connection closed:", error); + // }); + + // } + + // subscribe(callback) { + // this.callbacks.push(callback); + // } + + // unsubscribe(callback) { + // this.callbacks = this.callbacks.filter(cb => cb !== callback); + // } + + // onDisconnectCallback(callback) { + // this.onDisconnect.push(callback) + // } + // onConnectCallback(callback) { + // this.onConnect.push(callback) + // } + +} + +class ReconnectingWebSocketSignalR { + + private connection: any + isOpen: boolean = false + private callbacks: Function[] = [] + private onDisconnect: Function[] = [] + private onConnect: Function[] = [] + private whenConnected: Function[] = [] + stop = true + + constructor() {} connect() { + console.log("try to connect=================================") + this.stop = false - var connection = new signalR.HubConnectionBuilder() + this.connection = new signalR.HubConnectionBuilder() .withUrl("https://gdcmapi-dev.dyndns.info/FileHub", { - accessTokenFactory: () => SessionStore.user.Authorization + transport: signalR.HttpTransportType.LongPolling, + accessTokenFactory: () => SessionStore.user.Authorization }).configureLogging(signalR.LogLevel.Information) .build(); - connection.on("ReceiveMessage", (message) => { - console.log("ReceiveMessage", message) - }) - - connection.onreconnected((connectionId) => { - console.assert(connection.state === signalR.HubConnectionState.Connected); - console.log(`Reconnected with connectionId: ${connectionId}`); - }); - - connection.start() + this.connection.start() .then(() => { - console.log("SignalR connection started."); + this.isOpen = true; + console.log('WebSocket connection established'); + + + this.onConnect.forEach(callback => callback()); + this.whenConnected.forEach(callback => callback()) }) .catch((error) => { - console.error("Error starting SignalR connection:", error); + console.error("Error starting SignalR connection:", error); }); - connection.onclose((error) => { - connection.start() - console.log("SignalR connection closed:", error); - }); + this.connection.on("ReceiveMessage", (message) => { + const data: any = JSON.parse(message) + console.log("ReceiveMessage", data) + this.callbacks.forEach(callback => callback(data)); + }) + + this.connection.onclose((error) => { + console.log('WebSocket connection closed..'); + this.isOpen = false; + this.onDisconnect.forEach(callback => callback()); + // Attempt to reconnect after a delay + if(this.stop == false) { + setTimeout(() => { + this.connect(); + }, 1000); // Adjust the delay as needed + } + + }); + } + + commit(path): Promise> { + return new Promise((resolve, reject) => { + this.connection.invoke("CommitUpload", path).then((e) => { + console.log("commit message", e) + resolve(ok(true)) + }).catch(err => { + resolve(err(false)) + console.error(err.toString()) + }); + }) + } + + disconnect() { + this.stop = true + if(this.isOpen == true) { + this.connection.stop() + .then(() => { + console.log('WebSocket connection was closed by client'); + this.isOpen = false; + this.onDisconnect.forEach(callback => callback()); + console.log("SignalR connection stopped."); + }) + .catch((error) => { + console.error("Error stopping SignalR connection by client:", error); + }); + } + } + + subscribe(callback) { + this.callbacks.push(callback); + } + + unsubscribe(callback) { + this.callbacks = this.callbacks.filter(cb => cb !== callback); + } + + onDisconnectCallback(callback) { + this.onDisconnect.push(callback) + } + onConnectCallback(callback) { + this.onConnect.push(callback) + } + + registerWhenConnected(f: Function) { + if(this.isOpen) { + f(); + } else { + this.whenConnected.push(f); + } + + } +} + +interface socketResponse { + + index: string + Guid: string + IsCompleted: Boolean +} +// class ReconnectingWebSocket { + +// private url: string +// private socket +// isOpen: boolean +// private callbacks: Function[] = [] +// private onDisconnect: Function[] = [] +// private onConnect: Function[] = [] +// private whenConnected: Function[] = [] +// private stop = true +// http: HttpClient = window["http"] + +// constructor(url) { +// this.url = url; +// this.socket = null; +// this.isOpen = false; +// } + +// connect() { +// this.socket = new WebSocket(this.url); + +// this.socket.addEventListener('open', (event) => { +// this.isOpen = true; +// console.log('WebSocket connection established'); + +// // Example: Send a message to the server +// this.socket.send('Hello, WebSocket Server!'); +// this.onConnect.forEach(callback => callback()); +// this.whenConnected.forEach(callback => callback()) +// }); + +// this.socket.addEventListener('message', (event) => { +// const data: socketResponse = JSON.parse(event.data) +// this.callbacks.forEach(callback => callback(data)); +// }); + +// this.socket.addEventListener('close', (event) => { +// console.log('WebSocket connection closed'); +// this.isOpen = false; +// this.onDisconnect.forEach(callback => callback()); +// // Attempt to reconnect after a delay +// if(this.stop == false) { +// setTimeout(() => { +// this.connect(); +// }, 1000); // Adjust the delay as needed +// } +// }); +// } + +// send(message) { +// if (this.isOpen) { +// this.socket.send(message); +// } else { +// console.error('WebSocket connection is not open. Unable to send message.'); +// } +// } + +// disconnect() { +// this.stop = true +// if (this.isOpen) { +// this.isOpen = false; +// this.socket.close(); +// } +// } + +// subscribe(callback) { +// this.callbacks.push(callback); +// } + +// unsubscribe(callback) { +// this.callbacks = this.callbacks.filter(cb => cb !== callback); +// } + +// onDisconnectCallback(callback) { +// this.onDisconnect.push(callback) +// } +// onConnectCallback(callback) { +// this.onConnect.push(callback) +// } + +// registerWhenConnected(f: Function) { +// if(this.isOpen) { +// f(); +// } else { +// this.whenConnected.push(f); +// } + +// } +// } + +// export class ObjectMergeNotification{ + +// socket = new ReconnectingWebSocket('ws://localhost:3002'); +// callbacks: {[GUID: string]: Function} = {} +// runWatch = true +// CMAPIService: CMAPIService = window["CMAPIAPIRepository"] +// watchCount = 0 + +// constructor() { +// this.socket.onDisconnectCallback(()=> { +// console.log("run watch") +// this.runWatch = true +// this.watch() +// }) + +// this.socket.onConnectCallback(()=> { +// console.log("open trigger") +// this.runWatch = false +// }) + +// this.socket.subscribe((data: socketResponse) => { +// if(data.IsCompleted == true) { +// console.log("==================!!!====================") +// try { +// this.callbacks[data.Guid](data) +// delete this.callbacks[data.Guid] +// } catch (error) {} +// } else { +// console.log("else", data) +// } +// }) + +// this.watch() +// } + +// connect() { +// this.socket.connect() +// } + +// async watch() { + +// this.watchCount = 0; + +// if(this.runWatch) { +// setTimeout(async () => { +// for(const [key, funx] of Object.entries(this.callbacks)) { + +// const request = await this.CMAPIService.getVideoHeader(key) + +// if(request.isOk()) { +// funx() +// delete this.callbacks[key] +// } +// } + +// this.watchCount++ +// if(this.watchCount <= 15) { +// this.watch() +// } else { +// this.runWatch = false +// } + +// }, 1000) + + +// } else { +// console.log("end loop============================") +// } +// } + +// close() { +// this.socket.disconnect(); +// this.watchCount = 0; +// this.runWatch = false +// } + +// subscribe(GUID, callback:Function) { +// this.callbacks[GUID] = callback; +// } + +// unsubscribe(GUID) { +// delete this.callbacks[GUID] +// } + +// } + + +export class ObjectMergeNotification{ + + socket = new ReconnectingWebSocketSignalR() + callbacks: {[GUID: string]: Function} = {} + runWatch = true + CMAPIService: CMAPIService = window["CMAPIAPIRepository"] + watchCount = 0 + + constructor() { + this.socket.onDisconnectCallback(()=> { + console.log("run watch") + this.runWatch = true + this.watch() + }) + + this.socket.onConnectCallback(()=> { + + console.log("open trigger") + this.runWatch = false + }) + + this.socket.subscribe((data: socketResponse) => { + if(data.IsCompleted == true) { + console.log("==================!!!====================") + try { + this.callbacks[data.Guid](data) + delete this.callbacks[data.Guid] + } catch (error) {} + } else { + console.log("else", data) + } + }) + + this.socket.connect(); + this.watch() + } + + connect() { + this.socket.connect(); + } + + close() { + this.socket.disconnect(); + this.watchCount = 0; + this.runWatch = false + } + + async watch() { + + // this.watchCount = 0; + + // if(this.runWatch) { + // setTimeout(async () => { + // for(const [key, funx] of Object.entries(this.callbacks)) { + + // const request = await this.CMAPIService.getVideoHeader(key) + + // if(request.isOk()) { + // funx() + // delete this.callbacks[key] + // } + // } + + // this.watchCount++ + // if(this.watchCount <= 15) { + // this.watch() + // } else { + // this.runWatch = false + // } + + // }, 1000) + + + // } else { + // console.log("end loop============================") + // } + } + + subscribe(GUID, callback:Function) { + this.callbacks[GUID] = callback; + } + + unsubscribe(GUID) { + delete this.callbacks[GUID] } } diff --git a/src/app/services/stream/stream.service.ts b/src/app/services/stream/stream.service.ts index f1c12c1ef..d37e653f1 100644 --- a/src/app/services/stream/stream.service.ts +++ b/src/app/services/stream/stream.service.ts @@ -12,97 +12,6 @@ export class StreamService { window["StreamService"] = this } - - async uploadFile() { - const API_URL = 'http://localhost:3000/upload'; // Replace with your server URL - const filePath = 'path/to/large-file.zip'; // Replace with the path to your file - const fileName = 'my-file'; // Specify your desired filename - const fileExtension = 'zip'; // Specify the file extension - - const headers = new HttpHeaders() - .append('X-File-Name', fileName) - .append('X-File-Extension', fileExtension); - - const file = await this.readFileInChunks(filePath); - const chunkSize = 1024 * 1024; // 1 MB chunk size (adjust as needed) - - for (let offset = 0; offset < file.length; offset += chunkSize) { - const chunk = file.slice(offset, offset + chunkSize); - // await this.uploadChunk(API_URL, chunk, headers); - } - - console.log('Upload completed.'); - } - - async readFileInChunks(filePath: string): Promise { - const response = await fetch(filePath); - const reader = response.body.getReader(); - const chunks: Uint8Array[] = []; - let done = false; - - while (!done) { - const { value, done: isDone } = await reader.read(); - if (!isDone) { - chunks.push(value); - } - done = isDone; - } - - return new Uint8Array([].concat(...chunks.map((chunk) => Array.from(chunk)))); - } - - async uploadChunk(url: string, chunks: Uint8Array[], fileName, fileExtension): Promise { - - let i = 1 - - console.log('123', chunks.length) - for(const chunk of chunks) { - try { - - console.log("iterate") - - const headers = new HttpHeaders() - .append('X-File-Name', fileName) - .append('X-File-Extension', fileExtension) - .append('X-File-Content-Length', chunks.length.toString()) - .append('X-File-Index', i.toString()) - - await this.http.post('http://localhost:3001/upload', chunk.buffer, { headers, responseType: 'blob' }).toPromise(); - i++ - - } catch (error) { - console.error('Upload error:', error); - } - } - - } - - - async uploadChunkNoLoop(url: string, chunk: Uint8Array, fileName, fileExtension, i, length): Promise { - - console.log("iterate") - - const headers = new HttpHeaders() - .append('X-File-Name', fileName) - .append('X-File-Extension', fileExtension) - .append('X-File-Content-Length', length) - .append('X-File-Index', i.toString()) - - await this.http.post('http://localhost:3001/upload', chunk.buffer, { headers, responseType: 'blob' }).toPromise(); - - } - - uploadChunk1(chunk: Blob, chunkNumber: number, totalChunks: number, filename: string) { - - console.log(chunk) - - const headers = new HttpHeaders() - .append('X-File-Name', filename) - .append('X-File-Content-Length', totalChunks.toString()) - .append('X-File-Index', chunkNumber.toString()) - - return this.http.post('http://localhost:3001/upload-chunk', Blob, { headers, responseType: 'blob' }); - } } // const text = 'Hello, World00120301010asdf1002sdf 0fsdfasf0001230 12300!\n'; diff --git a/src/app/shared/API/CMAPI/cmapi-api.service.spec.ts b/src/app/shared/API/CMAPI/cmapi-api.service.spec.ts new file mode 100644 index 000000000..b50b8ad56 --- /dev/null +++ b/src/app/shared/API/CMAPI/cmapi-api.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { CMAPIAPIService } from './cmapi-api.service'; + +describe('CMAPIAPIService', () => { + let service: CMAPIAPIService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(CMAPIAPIService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/shared/API/CMAPI/cmapi-api.service.ts b/src/app/shared/API/CMAPI/cmapi-api.service.ts new file mode 100644 index 000000000..ae13fb503 --- /dev/null +++ b/src/app/shared/API/CMAPI/cmapi-api.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; +import { HttpServiceService } from 'src/app/services/http/http-service.service'; +import { HttpClient, HttpEvent, HttpHeaders, HttpParams } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class CMAPIAPIService { + + constructor( private HttpServiceService: HttpServiceService, + private http: HttpClient,) { } + + + getVideoHeader(url: string) { + //return this.http.head('http://localhost:3001/static/'+url, { observe: 'response' }) + return this.http.head(environment.apiURL+'ObjectServer/StreamFiles?path='+url, { observe: 'response' }) + } +} diff --git a/src/app/shared/API/CMAPI/cmapi.service.spec.ts b/src/app/shared/API/CMAPI/cmapi.service.spec.ts new file mode 100644 index 000000000..09602502b --- /dev/null +++ b/src/app/shared/API/CMAPI/cmapi.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { CMAPIService } from './cmapi.service'; + +describe('CMAPIService', () => { + let service: CMAPIService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(CMAPIService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/shared/API/CMAPI/cmapi.service.ts b/src/app/shared/API/CMAPI/cmapi.service.ts new file mode 100644 index 000000000..e9519cddf --- /dev/null +++ b/src/app/shared/API/CMAPI/cmapi.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { HttpServiceService } from 'src/app/services/http/http-service.service'; +import { HttpClient, HttpEvent, HttpHeaders, HttpParams } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class CMAPIService { + + constructor( private HttpServiceService: HttpServiceService, + private http: HttpClient,) { + window["CMAPIService"] = this + } + + getVideoHeader(url: string): Observable { + return this.http.head(url, { observe: 'response' }) + .map(response => response.status === 200) + .catch(() => Observable.of(false)); + } +} diff --git a/src/app/shared/API/middleware/middleware-service.service.ts b/src/app/shared/API/middleware/middleware-service.service.ts index 4211a26ad..78196de22 100644 --- a/src/app/shared/API/middleware/middleware-service.service.ts +++ b/src/app/shared/API/middleware/middleware-service.service.ts @@ -23,7 +23,7 @@ export class MiddlewareServiceService { window["MiddlewareServiceService"] = this } - refreshToken(refreshToken: string){ + refreshToken(refreshToken: string) { const data = { refreshToken: refreshToken } @@ -158,7 +158,7 @@ export class MiddlewareServiceService { // =========================================================================== - CMAPIFileContent({length, path, index, blobFile}) { + CMAPIPing() { const headers = new HttpHeaders(); headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization); @@ -172,19 +172,16 @@ export class MiddlewareServiceService { const formData = new FormData(); - formData.append("blobFile", blobFile); - formData.append("length", length); - formData.append("index", index.toString()); + formData.append("blobFile", "blobFile"); + formData.append("length", "length"); + formData.append("index", "index.toString("); - if(path) { - formData.append("path", path); - } return this.http.post(`${geturl}`, formData, options) } - GetViewer(DocId: string, FsId: string) { + GetViewer(DocId: string, FsId: string) { const geturl = environment.apiURL + 'ecm/document/viewfile'; let params = new HttpParams(); @@ -197,4 +194,39 @@ export class MiddlewareServiceService { }; return this.http.get(`${geturl}`, options); } + + CMAPIFileContent({length, path, index, base64}) { + + // const geturl = 'http://localhost:3001/FileHub'; + const geturl = environment.apiPCURL + 'FileContent/UploadFile'; + + const data = { + index, + length, + base64, + path, + } + + return this.http.post(`${geturl}`, data) + } + + CMAPIRequestUpload() { + const geturl = environment.apiPCURL + 'FileContent/RequestUpload'; + return this.http.get(`${geturl}`) + } + + CMAPIUploadStatus() { + const geturl = environment.apiPCURL + 'FileContent/UploadStatus'; + return this.http.get(`${geturl}`) + } + + + tryToReachTheServer() { + let opts = { + headers: {}, + } + + return this.http.post(environment.apiURL + "UserAuthentication/Login", '', opts) + } + } diff --git a/src/app/shared/publication/new-publication/new-publication.page.html b/src/app/shared/publication/new-publication/new-publication.page.html index ea7b7deb4..507ae0b7f 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.html +++ b/src/app/shared/publication/new-publication/new-publication.page.html @@ -53,45 +53,32 @@ X - +
+ -
-
--> - - -