Fixing busted config adder thingy
This commit is contained in:
parent
67575cda53
commit
c667f69d0e
@ -1,21 +1,12 @@
|
||||
const { ipcRenderer } = require('electron')
|
||||
const $ = require('jquery')
|
||||
|
||||
|
||||
// Path is from pages/index.html
|
||||
const auth = require('../src/auth.js')
|
||||
const { add_to_server_config } = require('../src/settings.js')
|
||||
const message = require('../src/messages.js')
|
||||
const settings = require('../src/settings.js')
|
||||
|
||||
|
||||
$('#add-admin-json').click(async () => { await add_server_to_config() } )
|
||||
$('#message-box').on('keypress', async (event) => {
|
||||
if(event.keyCode == 13 && !event.shiftKey ) {
|
||||
await message.send()
|
||||
}
|
||||
})
|
||||
|
||||
$('#message-btn').on('click', () => console.log('submitting'))
|
||||
$('#add-admin-json').click(async () => { await settings.add_server_to_config() } )
|
||||
|
||||
auth.init()
|
||||
.then(
|
||||
|
@ -3,14 +3,15 @@ const $ = require('jquery')
|
||||
const auth = require('./auth.js')
|
||||
|
||||
exports.add_server_to_config = async function() {
|
||||
$('#admin-json-err').text('')
|
||||
$('#admin-json-err').html('<div class="spinner-border" role="status"> <span class="sr-only">Loading...</span> </div>')
|
||||
|
||||
try {
|
||||
const data = JSON.parse($('#admin-json').val())
|
||||
let data = JSON.parse($('#admin-json').val())
|
||||
let config = await ipcRenderer.invoke('config-request')
|
||||
if(!config['servers']) {
|
||||
config['servers'] = []
|
||||
if(!config.data['servers']) {
|
||||
config.data['servers'] = []
|
||||
}
|
||||
config['servers'].push(data)
|
||||
config.data['servers'].push(data)
|
||||
|
||||
await ipcRenderer.invoke('config-update', config)
|
||||
|
||||
@ -27,7 +28,7 @@ exports.add_server_to_config = async function() {
|
||||
if(err.name == 'TypeError') {
|
||||
$('#admin-json-err').text("New server config did not have required JSON values to login but was saved")
|
||||
} else {
|
||||
$('#admin-json-err').text("Config parsed but couldn't login")
|
||||
$('#admin-json-err').text("Config saved but couldn't login")
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user