Skip to content

Commit

Permalink
Refactor config acquisition + fix issue with default config begin time
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed Apr 22, 2021
1 parent 40fba6c commit c09f910
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func ResetBotConfig() BotConfigYaml {
Activated: true,
},
Schedule: ScheduleYaml{
BeginAt: "8:00",
BeginAt: "08:00",
EndAt: "18:00",
Activated: true,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
var igopherConfig;
document.addEventListener('astilectron-ready', function() {
getIgopherConfig()
});

ready(() => {
document.addEventListener('astilectron-ready', function() {

// Get actual IGopher configuration to fill inputs
astilectron.sendMessage({ "msg": "getConfig" }, function(message) {
if (message.status === SUCCESS) {
igopherConfig = JSON.parse(message.msg);
console.log(igopherConfig);
fillInputs();
} else {
iziToast.error({
message: message.msg,
});
}
});

let dmBotLaunchBtn = document.querySelector('#dmBotLaunchBtn')
let dmBotLaunchIcon = document.querySelector('#dmBotLaunchIcon')
let dmBotLaunchSpan = document.querySelector('#dmBotLaunchSpan')
Expand Down
19 changes: 5 additions & 14 deletions resources/static/app/assets/js/controllers/settingsController.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
var igopherConfig;
document.addEventListener('astilectron-ready', function() {
getIgopherConfig()
});

ready(() => {
document.addEventListener('astilectron-ready', function() {

// Get actual IGopher configuration to fill inputs
astilectron.sendMessage({ "msg": "getConfig" }, function(message) {
if (message.status === SUCCESS) {
igopherConfig = JSON.parse(message.msg);
console.log(igopherConfig);
fillInputs();
} else {
iziToast.error({
message: message.msg,
});
}
});

/// Buttons
document.querySelector("#resetGlobalDefaultSettingsBtn").addEventListener("click", function() {
astilectron.sendMessage({ "msg": "resetGlobalDefaultSettings" }, function(message) {
if (message.status === SUCCESS) {
iziToast.success({
message: message.msg,
});
getIgopherConfig()
} else {
iziToast.error({
message: "Unknown error during global settings reset",
Expand All @@ -37,6 +27,7 @@ ready(() => {
iziToast.success({
message: message.msg,
});
getIgopherConfig()
} else {
iziToast.error({
message: message.msg,
Expand Down
19 changes: 18 additions & 1 deletion resources/static/app/assets/js/init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var igopherConfig;

// iziToast configuration for notification system
iziToast.settings({
position: 'topRight',
Expand Down Expand Up @@ -31,4 +33,19 @@ document.addEventListener('astilectron-ready', function() {
}
}
});
})
})

function getIgopherConfig() {
// Get actual IGopher configuration to fill inputs
astilectron.sendMessage({ "msg": "getConfig" }, function(message) {
if (message.status === SUCCESS) {
igopherConfig = JSON.parse(message.msg);
console.log(igopherConfig);
fillInputs();
} else {
iziToast.error({
message: message.msg,
});
}
});
}

0 comments on commit c09f910

Please sign in to comment.