small fixes
This commit is contained in:
@@ -62,6 +62,10 @@ func migrateClientSchema(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteOldWebSecret(db *gorm.DB) error {
|
||||
return db.Exec("DELETE FROM settings WHERE key = ?", "webSecret").Error
|
||||
}
|
||||
|
||||
func changesObj(db *gorm.DB) error {
|
||||
return db.Exec("UPDATE changes SET obj = CAST('\"' || CAST(obj AS TEXT) || '\"' AS BLOB) WHERE actor = ? and obj not like ?", "DepleteJob", "\"%\"").Error
|
||||
}
|
||||
@@ -71,6 +75,10 @@ func to1_1(db *gorm.DB) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = deleteOldWebSecret(db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = changesObj(db)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -5,55 +5,6 @@ type OBJ = {
|
||||
}
|
||||
|
||||
export const FindDiff = {
|
||||
Config(obj1: OBJ, obj2: OBJ): any[] {
|
||||
const differences: any[] = []
|
||||
|
||||
if(!obj2){
|
||||
return [ { key: "all", obj: obj1 } ]
|
||||
}
|
||||
|
||||
for (const key in obj1) {
|
||||
if (obj2.hasOwnProperty(key)) {
|
||||
const value1 = obj1[key]
|
||||
const value2 = obj2[key]
|
||||
|
||||
if (Array.isArray(value1)){
|
||||
value1.forEach((v1,index) => {
|
||||
if(index >= value2.length){
|
||||
differences.push({key: key, action: "new", index: index, obj: v1})
|
||||
} else if(!this.deepCompare(v1,value2[index])) {
|
||||
differences.push({key: key, action: "edit", index: index, obj: v1})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (!this.deepCompare(value1,value2)) {
|
||||
differences.push({ key: key, action: "set", obj: value1})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
differences.push({ key: key, action: "set", obj: obj1[key]})
|
||||
}
|
||||
}
|
||||
|
||||
return differences
|
||||
},
|
||||
ArrObj(value1: any[], value2: any[], key: string): any {
|
||||
const differences: any[] = []
|
||||
value1.forEach((v1,index) => {
|
||||
if(index >= value2.length) differences.push({key: key, action: "new", obj: v1})
|
||||
else if(!this.deepCompare(v1,value2[index])) differences.push({key: key, action: "edit", obj: v1})
|
||||
})
|
||||
return differences
|
||||
},
|
||||
Settings(obj1: OBJ, obj2: OBJ): any {
|
||||
const differences: any[] = []
|
||||
for (const key in obj1) {
|
||||
if (obj1[key] != obj2[key]) {
|
||||
differences.push({ key: key, action: "set", obj: obj1[key]})
|
||||
}
|
||||
}
|
||||
return differences
|
||||
},
|
||||
deepCompare(obj1: any, obj2: any): boolean {
|
||||
// Check if the types of both objects are the same
|
||||
if (typeof obj1 !== typeof obj2) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { FindDiff } from '@/plugins/utils'
|
||||
import HttpUtils from '@/plugins/httputil'
|
||||
import { defineStore } from 'pinia'
|
||||
import { push } from 'notivue'
|
||||
@@ -56,15 +55,11 @@ const Data = defineStore('Data', {
|
||||
}
|
||||
return <Inbound[]>[]
|
||||
},
|
||||
async save (object: string, action: string, data: any, userLinks: any[] | null = null, outJsons: any[] | null = null): Promise<boolean> {
|
||||
async save (object: string, action: string, data: any): Promise<boolean> {
|
||||
let postData = {
|
||||
object: object,
|
||||
action: action,
|
||||
data: JSON.stringify(data, null, 2),
|
||||
userLinks: userLinks == null ? undefined : JSON.stringify(userLinks),
|
||||
}
|
||||
if (userLinks == null) {
|
||||
delete postData.userLinks
|
||||
}
|
||||
const msg = await HttpUtils.post('api/save', postData)
|
||||
if (msg.success) {
|
||||
@@ -78,7 +73,7 @@ const Data = defineStore('Data', {
|
||||
}
|
||||
return msg.success
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
export default Data
|
||||
@@ -234,7 +234,6 @@ import Data from '@/store/modules/data'
|
||||
import Dial from '@/components/Dial.vue'
|
||||
import { computed, ref, onMounted } from 'vue'
|
||||
import { Config, Ntp } from '@/types/config'
|
||||
import { Client } from '@/types/clients'
|
||||
import { FindDiff } from '@/plugins/utils'
|
||||
|
||||
const oldConfig = ref({})
|
||||
|
||||
Reference in New Issue
Block a user