mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix upload picture
This commit is contained in:
@@ -6,4 +6,4 @@ import { DexieRepository } from "src/app/infra/repository/dexie/dexie-repository
|
||||
|
||||
export abstract class IDistributionLocalRepository extends DexieRepository<DistributionTable, DistributionTable> implements IDistributionLocalRepository {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { File, IWriteOptions } from '@awesome-cordova-plugins/file/ngx';
|
||||
import { err, ok, Result } from 'neverthrow';
|
||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
|
||||
import { Filesystem, Directory, Encoding, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -54,4 +54,18 @@ export class FileSystemMobileService {
|
||||
}
|
||||
}
|
||||
|
||||
async readFile({resultUrl}) {
|
||||
try {
|
||||
const result = await Filesystem.readFile({
|
||||
path: resultUrl,
|
||||
//directory: Directory.Data,
|
||||
//encoding: Encoding.UTF8,
|
||||
})
|
||||
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
return err(e)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DistributionTable, DistributionTableSchema } from "src/app/infra/database/dexie/instance/chat/schema/destribution";
|
||||
import { DistributionTable, DistributionTableSchema,DistributionTableColumn } from "src/app/infra/database/dexie/instance/chat/schema/destribution";
|
||||
import { chatDatabase } from "src/app/infra/database/dexie/service";
|
||||
import { DexieRepository } from "src/app/infra/repository/dexie/dexie-repository.service";
|
||||
|
||||
@@ -11,4 +11,4 @@ export class DistributionLocalRepository extends DexieRepository<DistributionTa
|
||||
obj.$messageIdMemberId = `${obj.messageId}${obj.memberId}`
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,6 @@ export class RoomBoldSyncUseCaseService {
|
||||
const haveSeen = message.haveSeen()
|
||||
|
||||
if(!haveSeen && !message.meSender()) {
|
||||
console.log('to see', roomEntity.roomName , roomEntity.messages[0], )
|
||||
await this.boldLocalRepository.open()
|
||||
const result = await this.boldLocalRepository.findOne({roomId: roomEntity.id})
|
||||
|
||||
|
||||
@@ -75,14 +75,25 @@ export class EventsService {
|
||||
private changeProfileService: ChangeProfileService,
|
||||
private offlinemanager: OfflineManagerService) {
|
||||
|
||||
this.setHeader()
|
||||
this.changeProfileService.registerCallback(() => {
|
||||
try {
|
||||
this.setHeader()
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
this.changeProfileService.registerCallback(() => {
|
||||
try {
|
||||
this.setHeader()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async setHeader () {
|
||||
try {
|
||||
|
||||
|
||||
|
||||
this.headers = new HttpHeaders();;
|
||||
this.headersMdOficial = new HttpHeaders();;
|
||||
@@ -380,6 +391,9 @@ export class EventsService {
|
||||
|
||||
this.onLoadCalendars.forEach(e=> e());
|
||||
this.loadCalendars = true
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -462,7 +462,10 @@ export class ChatPage implements OnInit {
|
||||
|
||||
modal.onDidDismiss().then((Data) => {
|
||||
console.log('Data', Data.data)
|
||||
this.openMessagesToStartDirectConversation(Data.data);
|
||||
if(Data.data) {
|
||||
this.openMessagesToStartDirectConversation(Data.data);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -519,7 +522,12 @@ export class ChatPage implements OnInit {
|
||||
},
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss();
|
||||
modal.onDidDismiss().then(e => {
|
||||
this.roomId = null;
|
||||
this.selectedRoomId = null;
|
||||
console.log('RoomSelected', room)
|
||||
this.RoomSelected = null
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1081,6 +1081,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.messages1[this.room.$id].push(Ballon)
|
||||
}
|
||||
|
||||
this.messages1[this.room.$id].push(message)
|
||||
setTimeout(() => {
|
||||
this.scrollToBottomClicked()
|
||||
}, 100)
|
||||
|
||||
@@ -33,7 +33,7 @@ import { CameraService } from 'src/app/infra/camera/camera.service'
|
||||
import { FilePickerMobileService } from 'src/app/infra/file-picker/mobile/file-picker-mobile.service'
|
||||
import { FilePickerWebService } from 'src/app/infra/file-picker/web/file-picker-web.service'
|
||||
import { allowedDocExtension } from 'src/app/utils/allowedDocExtension';
|
||||
import { JSFileToDataUrl } from 'src/app/utils/ToBase64';
|
||||
import { createDataURL, JSFileToDataUrl } from 'src/app/utils/ToBase64';
|
||||
import { RoomType } from "src/app/core/chat/entity/group";
|
||||
import { MessageViewModal } from '../../store/model/message';
|
||||
import { ChatPopoverPage } from '../chat-popover/chat-popover.page';
|
||||
@@ -46,6 +46,7 @@ import { RoomViewModel } from '../../store/model/room';
|
||||
import { RoomStore } from '../../store/roomStore'
|
||||
import { GroupContactsPage, IGroupContactsPageOutPutSchema } from '../group-messages/group-contacts/group-contacts.page';
|
||||
import { EditGroupPage } from '../edit-group/edit-group.page';
|
||||
import { imageMimeTypes } from 'src/app/utils/allowedImageExtension';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -134,7 +135,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private file: File,
|
||||
private fileOpener: FileOpener,
|
||||
private fileSystemMobileService: FileSystemMobileService,
|
||||
public RoomStore: RoomStore
|
||||
public RoomStore: RoomStore,
|
||||
) {
|
||||
|
||||
this.room = this.navParams.get('room');
|
||||
@@ -667,43 +668,78 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
async pickPicture() {
|
||||
|
||||
const file = await this.FilePickerService.getPicture({
|
||||
cameraResultType: CameraResultType.Base64
|
||||
const result = await this.FilePickerMobileService.getFile({
|
||||
types: imageMimeTypes,
|
||||
multiple: false,
|
||||
readData: true,
|
||||
})
|
||||
|
||||
if(file.isOk()) {
|
||||
|
||||
var base64 = 'data:image/jpeg;base64,' + file.value.base64String
|
||||
if (file.value.format == "jpeg" || file.value.format == "png" || file.value.format == "gif") {
|
||||
|
||||
const compressedImage = await compressImageBase64(
|
||||
base64,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
)
|
||||
|
||||
if(compressedImage.isOk()) {
|
||||
if(result.isOk()) {
|
||||
const file = result.value.files[0]
|
||||
if(file) {
|
||||
let resultUrl = decodeURIComponent(file.path);
|
||||
const base64 = await this.fileSystemMobileService.readFile({resultUrl})
|
||||
|
||||
if(base64.isOk()) {
|
||||
// console.log('1', base64.value)
|
||||
// console.log('base64.value.data', base64.value.data)
|
||||
// console.log('file', file)
|
||||
// console.log('3',createDataURL(base64.value.data, file.mimeType))
|
||||
|
||||
this.RoomStore.sendMessage('', [{
|
||||
file: compressedImage.value,
|
||||
file: base64.value.data,
|
||||
fileName: "foto",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Image,
|
||||
mimeType: 'image/'+file.value.format
|
||||
mimeType: file.mimeType
|
||||
}])
|
||||
} else {
|
||||
console.log(base64.error)
|
||||
}
|
||||
} else {
|
||||
console.log('no file')
|
||||
}
|
||||
} else {
|
||||
console.log('error', result.error)
|
||||
}
|
||||
|
||||
} else {
|
||||
if(file.error.type == 'PERMISSION_DENIED') {
|
||||
this.toastService._badRequest("Sem acesso a camera")
|
||||
}
|
||||
Logger.error('failed to pick picture from the device', {
|
||||
error: file.error
|
||||
})
|
||||
}
|
||||
// const file = await this.FilePickerService.getPicture({
|
||||
// cameraResultType: CameraResultType.Base64
|
||||
// })
|
||||
|
||||
// if(file.isOk()) {
|
||||
|
||||
// var base64 = 'data:image/jpeg;base64,' + file.value.base64String
|
||||
// if (file.value.format == "jpeg" || file.value.format == "png" || file.value.format == "gif") {
|
||||
|
||||
// const compressedImage = await compressImageBase64(
|
||||
// base64,
|
||||
// 800, // maxWidth
|
||||
// 800, // maxHeight
|
||||
// 0.9 // quality
|
||||
// )
|
||||
|
||||
// if(compressedImage.isOk()) {
|
||||
|
||||
|
||||
// this.RoomStore.sendMessage('', [{
|
||||
// file: compressedImage.value,
|
||||
// fileName: "foto",
|
||||
// source: MessageAttachmentSource.Device,
|
||||
// fileType: MessageAttachmentFileType.Image,
|
||||
// mimeType: 'image/'+file.value.format
|
||||
// }])
|
||||
// }
|
||||
// }
|
||||
|
||||
// } else {
|
||||
// if(file.error.type == 'PERMISSION_DENIED') {
|
||||
// this.toastService._badRequest("Sem acesso a camera")
|
||||
// }
|
||||
// Logger.error('failed to pick picture from the device', {
|
||||
// error: file.error
|
||||
// })
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ export class RoomInfoPage implements OnInit {
|
||||
this.ChatServiceService.getUserPhoto({wxUserId: member.wxUserId, attachmentId: member.userPhoto}).then((result)=> {
|
||||
|
||||
if(result.isOk()) {
|
||||
console.log('get photo', result.value)
|
||||
this.ObjectURL[member.wxUserId] = 'data:image/jpeg;base64,'+result.value
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export const imageMimeTypes = [
|
||||
'image/jpeg', // JPEG/JPG
|
||||
'image/png', // PNG
|
||||
'image/gif', // GIF
|
||||
'image/bmp', // BMP
|
||||
'image/webp', // WebP
|
||||
'image/tiff', // TIFF
|
||||
'image/svg+xml', // SVG
|
||||
'image/x-icon', // ICO
|
||||
'image/heif', // HEIF
|
||||
'image/heic', // HEIC
|
||||
'image/avif', // AVIF
|
||||
'image/x-xcf', // XCF (GIMP)
|
||||
'image/vnd.adobe.photoshop', // PSD (Photoshop)
|
||||
'image/x-pict' // PICT
|
||||
];
|
||||
@@ -1,6 +1,5 @@
|
||||
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
|
||||
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
|
||||
importScripts('./assets/dexie/dist/dexie.js');
|
||||
|
||||
// Initialize the Firebase app in the service worker by passing the generated config
|
||||
var firebaseConfig = {
|
||||
@@ -70,46 +69,3 @@ self.addEventListener('message', function(event){
|
||||
}
|
||||
});
|
||||
}); */
|
||||
|
||||
|
||||
|
||||
|
||||
// Define the schema using a plain object (similar to zod schema in TypeScript)
|
||||
const tableSharedCalendarSchema = {
|
||||
wxUserId: 'number',
|
||||
wxFullName: 'string',
|
||||
wxeMail: 'string',
|
||||
role: 'string',
|
||||
roleId: 'number',
|
||||
shareType: 'number',
|
||||
startDate: 'string',
|
||||
endDate: 'string'
|
||||
};
|
||||
|
||||
// Database declaration
|
||||
const AgendaDataSource = new Dexie('AgendaDataSource');
|
||||
|
||||
// Define the database schema
|
||||
AgendaDataSource.version(1).stores({
|
||||
shareCalendar: '++wxUserId, wxFullName, wxeMail, role, roleId, shareType, startDate, endDate'
|
||||
});
|
||||
|
||||
// Define the table schema using Dexie.js' Table interface (optional)
|
||||
const shareCalendarTable = AgendaDataSource.table('shareCalendar');
|
||||
|
||||
(async()=> {
|
||||
console.log(await shareCalendarTable.toArray())
|
||||
})();
|
||||
|
||||
|
||||
// setInterval(()=>{
|
||||
// shareCalendarTable.add({
|
||||
// wxUserId: new Date().getTime(),
|
||||
// wxFullName: "3-",
|
||||
// wxeMail: "SessionStore.user.Email",
|
||||
// role: "SessionStore.user.RoleDescription",
|
||||
// roleId: "SessionStore.user.RoleID",
|
||||
// shareType: 3,
|
||||
// date: '',
|
||||
// })
|
||||
// }, 1000)
|
||||
|
||||
+127
-2
@@ -11,7 +11,8 @@ import { SendIntent } from "send-intent";
|
||||
import { Filesystem } from '@capacitor/filesystem';
|
||||
import 'src/app/services/shareIntent'
|
||||
import 'src/app/services/monitoring/opentelemetry/matrix';
|
||||
|
||||
// import { SourceMapConsumer } from 'source-map';
|
||||
//import { SourceMapConsumer } from 'source-map-js';
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
@@ -34,7 +35,7 @@ if (environment.production) {
|
||||
); */
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('firebase-messaging-sw.js')
|
||||
navigator.serviceWorker.register('/firebase-messaging-sw.js')
|
||||
.then(registration => {
|
||||
console.log('Service Worker registrado com sucesso:', registration);
|
||||
|
||||
@@ -60,3 +61,127 @@ platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
// Call the element loader after the platform has been bootstrapped
|
||||
|
||||
defineCustomElements(window);
|
||||
|
||||
|
||||
// const trace = `
|
||||
// Error: Uncaught (in promise): TypeError: Cannot set properties of undefined (setting 'Oficial')
|
||||
// TypeError: Cannot set properties of undefined (setting 'Oficial')
|
||||
// at main-es2017.251dcec9a0796e6dfef5.js:1:2853300
|
||||
// at Generator.next (<anonymous>)
|
||||
// at r (main-es2017.251dcec9a0796e6dfef5.js:1:5152059)
|
||||
// at s (main-es2017.251dcec9a0796e6dfef5.js:1:5152261)
|
||||
// at l.invoke (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:6540)
|
||||
// at Object.onInvoke (main-es2017.251dcec9a0796e6dfef5.js:1:439735)
|
||||
// at l.invoke (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:6480)
|
||||
// at t.run (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:1939)
|
||||
// at polyfills-es2017.7eddec01cc10d4e8cd34.js:1:16627
|
||||
// at l.invokeTask (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:7158)
|
||||
// at Object.onInvokeTask (main-es2017.251dcec9a0796e6dfef5.js:1:439551)
|
||||
// at l.invokeTask (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:7079)
|
||||
// at t.runTask (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:2554)
|
||||
// at m (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:9152)
|
||||
// at u.invokeTask [as invoke] (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:8237)
|
||||
// at _ (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:20025)
|
||||
// at XMLHttpRequest.k (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:20346)
|
||||
// at Z (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:15821)
|
||||
// at polyfills-es2017.7eddec01cc10d4e8cd34.js:1:14908
|
||||
// at r (main-es2017.251dcec9a0796e6dfef5.js:1:5152094)
|
||||
// at s (main-es2017.251dcec9a0796e6dfef5.js:1:5152261)
|
||||
// at l.invoke (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:6540)
|
||||
// at Object.onInvoke (main-es2017.251dcec9a0796e6dfef5.js:1:439735)
|
||||
// at l.invoke (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:6480)
|
||||
// at t.run (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:1939)
|
||||
// at polyfills-es2017.7eddec01cc10d4e8cd34.js:1:16627
|
||||
// at l.invokeTask (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:7158)
|
||||
// at Object.onInvokeTask (main-es2017.251dcec9a0796e6dfef5.js:1:439551)
|
||||
// at l.invokeTask (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:7079)
|
||||
// at t.runTask (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:2554)
|
||||
// at m (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:9152)
|
||||
// at u.invokeTask [as invoke] (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:8237)
|
||||
// at _ (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:20025)
|
||||
// at XMLHttpRequest.k (polyfills-es2017.7eddec01cc10d4e8cd34.js:1:20346)
|
||||
// `;
|
||||
|
||||
// const regex = /([a-zA-Z0-9._-]+\.js):(\d+):(\d+)/g;
|
||||
// const matches = [];
|
||||
// let match;
|
||||
|
||||
// while ((match = regex.exec(trace)) !== null) {
|
||||
// matches.push({
|
||||
// file: match[1],
|
||||
// line: parseInt(match[2], 10),
|
||||
// column: parseInt(match[3], 10)
|
||||
// });
|
||||
// }
|
||||
|
||||
// function parseErrorStack(stack) {
|
||||
// const lines = stack.split('\n');
|
||||
|
||||
// const errorMessage = lines.slice(0, 2).join('\n').trim();
|
||||
// const fileLocation = lines.find(line => line.includes('.js'));
|
||||
|
||||
// if (fileLocation) {
|
||||
// const locationMatch = fileLocation.match(/(.*\.js):(\d+):(\d+)/);
|
||||
// if (locationMatch) {
|
||||
// const [, filePath, lineNumber, columnNumber] = locationMatch;
|
||||
// return {
|
||||
// errorMessage,
|
||||
// filePath,
|
||||
// lineNumber,
|
||||
// columnNumber
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
|
||||
// return { errorMessage, filePath: null, lineNumber: null, columnNumber: null };
|
||||
// }
|
||||
|
||||
// async function fetchAndHandleSourceMap(matches) {
|
||||
// try {
|
||||
// const mapResponse = await fetch('https://gd-fo-dev.dyndns.info/main-es2017.7f4c6682bbbe369ef4d8.js.map');
|
||||
// const mapContent = await mapResponse.json();
|
||||
|
||||
// // Create SourceMapConsumer
|
||||
// const consumer = await new SourceMapConsumer(mapContent);
|
||||
|
||||
// console.log({matches})
|
||||
// for (const match of matches) {
|
||||
// // Use the source map to find the original position
|
||||
// let originalPosition = consumer.originalPositionFor({
|
||||
// line: match.line,
|
||||
// column: match.column
|
||||
// });
|
||||
|
||||
// if (originalPosition.source && originalPosition.source.includes('src')) {
|
||||
// console.log(`Original file: ${originalPosition.source}, Line: ${originalPosition.line}, Column: ${originalPosition.column}`);
|
||||
|
||||
// // Extract the source content for the original file
|
||||
// const code = consumer.sourceContentFor(originalPosition.source);
|
||||
|
||||
// // Output the specific line from the source
|
||||
// const lines = code.split('\n');
|
||||
// const lineNumber = originalPosition.line;
|
||||
// if (lineNumber >= 1 && lineNumber <= lines.length) {
|
||||
// console.log(`Line ${lineNumber}: ${lines[lineNumber - 1]}`);
|
||||
// } else {
|
||||
// console.log(`Line ${lineNumber} is out of range. The code has ${lines.length} lines.`);
|
||||
// }
|
||||
// } else {
|
||||
// console.log(originalPosition)
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// } catch (error) {
|
||||
// console.error('Error handling source map:', error);
|
||||
// }
|
||||
// }
|
||||
|
||||
// const parsedError = parseErrorStack(trace);
|
||||
// console.log('Error Message:', parsedError.errorMessage);
|
||||
// console.log('File Path:', parsedError.filePath);
|
||||
// console.log('Line:', parsedError.lineNumber);
|
||||
// console.log('Column:', parsedError.columnNumber);
|
||||
|
||||
// fetchAndHandleSourceMap(matches);
|
||||
|
||||
Reference in New Issue
Block a user