mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
remove rocket chat
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
import { AES, SHA1, enc } from "crypto-js";
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
|
||||
function prefix() {
|
||||
return environment.version.lastCommitNumber + environment.id+"-";
|
||||
}
|
||||
|
||||
export function GET({key, instance}) {
|
||||
if(environment.storageProduction) {
|
||||
|
||||
try {
|
||||
const newKey = prefix() + SHA1(key).toString()
|
||||
const cipherText = localStorage.getItem(newKey)
|
||||
const bytes = AES.decrypt(cipherText, newKey)
|
||||
var decryptedData = bytes.toString(enc.Utf8);
|
||||
const restoredData = JSON.parse(decryptedData)
|
||||
|
||||
Object.assign(instance, restoredData);
|
||||
|
||||
return restoredData
|
||||
|
||||
} catch(error) {
|
||||
console.log(error)
|
||||
return {}
|
||||
}
|
||||
|
||||
} else {
|
||||
const newKey = prefix() + key
|
||||
const restoredData = JSON.parse(localStorage.getItem(newKey))
|
||||
Object.assign(instance, restoredData);
|
||||
|
||||
return restoredData
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function SAVE({key, instance, dataToSave}) {
|
||||
if(environment.storageProduction) {
|
||||
const newKey = prefix() + SHA1(key).toString()
|
||||
const stringifyData = JSON.stringify(dataToSave)
|
||||
|
||||
const cipherText = AES.encrypt(stringifyData, newKey).toString();
|
||||
|
||||
localStorage.setItem(newKey, cipherText)
|
||||
|
||||
} else {
|
||||
const stringifyData = JSON.stringify(dataToSave)
|
||||
const newKey = prefix() + key
|
||||
|
||||
localStorage.setItem(newKey, stringifyData)
|
||||
}
|
||||
}
|
||||
|
||||
export function DELETE({key, instance}) {
|
||||
if(environment.storageProduction) {
|
||||
const newKey = prefix() + SHA1(key).toString()
|
||||
localStorage.removeItem(newKey)
|
||||
|
||||
} else {
|
||||
const newKey = prefix() + key
|
||||
localStorage.removeItem(newKey)
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
//import { models } from 'beast-orm'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { models } from 'src/plugin/src'
|
||||
const { ArrayField, JsonField} = models.indexedDB.fields
|
||||
|
||||
export class MessageModel extends models.Model {
|
||||
channels = ArrayField()
|
||||
mentions = ArrayField()
|
||||
msg = models.CharField()
|
||||
sendAttempt = models.IntegerField()
|
||||
rid = models.CharField()
|
||||
t = models.CharField({default:'', blank: true})
|
||||
ts = JsonField({blank:true})
|
||||
u = JsonField()
|
||||
_id = models.CharField({blank:true})
|
||||
origin = models.CharField({blank:true})
|
||||
_updatedAt = models.IntegerField()
|
||||
messageSend = models.BooleanField()
|
||||
offline = models.BooleanField()
|
||||
hasFile = models.BooleanField({blank:true})
|
||||
viewed = ArrayField({blank:true})
|
||||
received = ArrayField({blank:true})
|
||||
localReference = models.CharField({blank:true, unique: true})
|
||||
attachments = ArrayField({blank:true})
|
||||
file = JsonField({blank:true})
|
||||
UploadAttachmentsTemp = models.IntegerField()
|
||||
|
||||
async getAttachments() {
|
||||
console.log('this[id]', this['id'])
|
||||
const _attachments = await attachments.filter({messageId: this['id']}).execute()
|
||||
return _attachments[0]
|
||||
}
|
||||
}
|
||||
|
||||
export class attachments extends models.Model {
|
||||
messageId = models.IntegerField()
|
||||
attachments = ArrayField({blank:true})
|
||||
file = JsonField({blank:true})
|
||||
}
|
||||
|
||||
export class DeleteMessageModel extends models.Model {
|
||||
messageId = models.CharField()
|
||||
rid = models.CharField()
|
||||
u = JsonField()
|
||||
needToReceiveBy = ArrayField()
|
||||
}
|
||||
|
||||
models.register({
|
||||
databaseName: 'chat-storage'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
|
||||
type: 'indexedDB',
|
||||
version: 11,
|
||||
models: [MessageModel, DeleteMessageModel, attachments]
|
||||
})
|
||||
|
||||
|
||||
|
||||
// // acçoes
|
||||
export class ActionModel extends models.Model{
|
||||
static $tableName = 'ActionModel11'
|
||||
|
||||
ProcessId = models.IntegerField({unique: true})
|
||||
Description = models.CharField()
|
||||
Detail = models.CharField()
|
||||
DateBegin = models.CharField()
|
||||
DateEnd = models.CharField()
|
||||
ActionType = models.CharField()
|
||||
|
||||
}
|
||||
|
||||
|
||||
export class PublicationFolderModel extends models.Model{
|
||||
|
||||
DateBegin = models.CharField()
|
||||
Description = models.CharField()
|
||||
Detail = models.CharField()
|
||||
}
|
||||
|
||||
export class PublicationDetailsModel extends models.Model{
|
||||
|
||||
DateIndex = models.CharField()
|
||||
DocumentId = models.IntegerField({unique: true})
|
||||
ProcessId = models.CharField()
|
||||
Title = models.CharField()
|
||||
Message = models.CharField()
|
||||
DatePublication = models.CharField()
|
||||
OriginalFileName = models.CharField()
|
||||
FileBase64 = models.CharField()
|
||||
FileExtension = models.CharField()
|
||||
OrganicEntityId = models.IntegerField()
|
||||
}
|
||||
|
||||
|
||||
export class WebtrixUserModel extends models.Model {
|
||||
|
||||
FullName = models.CharField()
|
||||
Role = models.CharField()
|
||||
}
|
||||
|
||||
models.register({
|
||||
databaseName: 'webtrix'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
|
||||
type: 'indexedDB',
|
||||
version: 1,
|
||||
models: [WebtrixUserModel]
|
||||
})
|
||||
|
||||
|
||||
models.register({
|
||||
databaseName: 'actions'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
|
||||
type: 'indexedDB',
|
||||
version: 14,
|
||||
models: [PublicationDetailsModel, ActionModel, PublicationFolderModel]
|
||||
})
|
||||
|
||||
|
||||
|
||||
window["MessageModel"] = MessageModel
|
||||
Reference in New Issue
Block a user