From 70787b8efa9a777e37989d1c0dfad3ade21e128e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Pu=C5=A1nik?= Date: Thu, 15 Oct 2015 18:46:02 +0200 Subject: =?UTF-8?q?lep=C5=A1anje=20ali=20gr=C5=A1anje=20:)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/codeq/translation.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/codeq') diff --git a/js/codeq/translation.js b/js/codeq/translation.js index f0c8aab..1e85273 100644 --- a/js/codeq/translation.js +++ b/js/codeq/translation.js @@ -57,6 +57,9 @@ $('[data-tkey-value]').each(function () { translateElement($(this), 'tkey-value', lang); }); + $('[data-tkey-data-content]').each(function () { + translateElement($(this), 'tkey-data-content', lang); + }); }; // Translate the whole document when the user switches the display language -- cgit v1.2.1 From 5c1819eb694131b4503c7b95e0f4e47facab798a Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Fri, 16 Oct 2015 09:06:10 +0200 Subject: moved settings to its own page and changed the 'save' button from a normal button to a form submit --- js/codeq/navigation.js | 4 +++ js/codeq/settings.js | 71 +++++++++++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 30 deletions(-) (limited to 'js/codeq') diff --git a/js/codeq/navigation.js b/js/codeq/navigation.js index 5dbbf1e..9483e05 100644 --- a/js/codeq/navigation.js +++ b/js/codeq/navigation.js @@ -130,5 +130,9 @@ codeq.globalStateMachine.transition('changePassword'); e.preventDefault();//prevent this since we'll trigger a page reload otherwise }); + $('#settingsTrigger').on('click',function(e){ + codeq.globalStateMachine.transition('settings'); + e.preventDefault(); + }); })(); diff --git a/js/codeq/settings.js b/js/codeq/settings.js index dd844a5..1c15ad0 100644 --- a/js/codeq/settings.js +++ b/js/codeq/settings.js @@ -5,37 +5,48 @@ var guiLangSelect = $('#gui_lang_select'), robotAddressInput = $('#robot_address_input'), - previousGuiLang = guiLangSelect.val(), - closedWithSave = false; + jqDisabledOverlay = $('#disabled'), + jqSettForm = $("#settingsForm"), + jqSettCancelBtn = $("#settings_cancel_btn"), + jqScreenSettings = $('#screen_settings'); - guiLangSelect.on("change",function() { - var lang = guiLangSelect.val(); - if (lang in codeq.supportedLangs) { - codeq.setLang(lang); - } - }); - - $("#settings_save_btn").on("click", function() { - closedWithSave = true; - }); - - $("#settings_dropdown_menu").on("shown.bs.dropdown", function() { - closedWithSave = false; - previousGuiLang = codeq.settings['gui_lang']; - }).on("hidden.bs.dropdown", function() { - if(closedWithSave){ - codeq.settings['robot_address'] = robotAddressInput.val(); - codeq.comms.updateSettings(codeq.settings) - .then(function (data) { - if (data.code !== 0) { - throw new Error('Updating settings failed, code: ' + data.code + ', message: ' + data.message); - } - }) - .done(); - }else{ - guiLangSelect.val(previousGuiLang); - if (previousGuiLang in codeq.supportedLangs) codeq.setLang(previousGuiLang); - robotAddressInput.val(codeq.settings['robot_address']); + codeq.globalStateMachine.register('settings',{ + 'enter':function(){ + jqDisabledOverlay.css('display', ''); + robotAddressInput.val(codeq.settings['robot_address']);//set the robot address once we enter the state + var previousGuiLang = codeq.settings['gui_lang']; + jqSettForm.on("submit", function() { + codeq.settings['robot_address'] = robotAddressInput.val(); + codeq.comms.updateSettings(codeq.settings) + .then(function (data) { + if (data.code !== 0) { + throw new Error('Updating settings failed, code: ' + data.code + ', message: ' + data.message); + } + }) + .done(); + history.back(); + return false; + }); + jqSettCancelBtn.on("click",function(){ + guiLangSelect.val(previousGuiLang); + if (previousGuiLang in codeq.supportedLangs) codeq.setLang(previousGuiLang); + history.back(); + }); + guiLangSelect.on("change",function() { + var lang = guiLangSelect.val(); + if (lang in codeq.supportedLangs) { + codeq.setLang(lang); + } + }); + jqScreenSettings.css('display', ''); + jqDisabledOverlay.css('display', 'none'); + }, + 'exit':function(){ + jqSettForm.off('submit'); + jqSettCancelBtn.off('click'); + guiLangSelect.off('select'); + robotAddressInput.val(''); + jqScreenSettings.css('display', 'none'); } }); })(); -- cgit v1.2.1 From e5f4844fa6306aab17c15595c2da411d879ffa48 Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Fri, 16 Oct 2015 10:32:17 +0200 Subject: added a transition to the original login state if the saml login fails --- js/codeq/aaiLogin.js | 1 + js/codeq/settings.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'js/codeq') diff --git a/js/codeq/aaiLogin.js b/js/codeq/aaiLogin.js index 74a9ee4..2e49138 100644 --- a/js/codeq/aaiLogin.js +++ b/js/codeq/aaiLogin.js @@ -36,6 +36,7 @@ .fail(function(reason){ codeq.log.error('SAML login failed: ' + reason); alert('SAML login failed: ' + reason); + codeq.globalStateMachine.transition('login'); }) .done(); diff --git a/js/codeq/settings.js b/js/codeq/settings.js index 1c15ad0..8207c3f 100644 --- a/js/codeq/settings.js +++ b/js/codeq/settings.js @@ -15,7 +15,7 @@ jqDisabledOverlay.css('display', ''); robotAddressInput.val(codeq.settings['robot_address']);//set the robot address once we enter the state var previousGuiLang = codeq.settings['gui_lang']; - jqSettForm.on("submit", function() { + jqSettForm.on("submit", function(e) { codeq.settings['robot_address'] = robotAddressInput.val(); codeq.comms.updateSettings(codeq.settings) .then(function (data) { @@ -25,7 +25,7 @@ }) .done(); history.back(); - return false; + e.preventDefault(); }); jqSettCancelBtn.on("click",function(){ guiLangSelect.val(previousGuiLang); -- cgit v1.2.1 From 3fa8787e93ddb751c92412662db578aad841f120 Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Fri, 16 Oct 2015 11:26:32 +0200 Subject: added an error msg ot the settings screen if something goes wrong and moved the redirect to only happen if the update request is successful. Also tested validation - the auto validation works, but the regex might need tweaking --- js/codeq/settings.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/codeq') diff --git a/js/codeq/settings.js b/js/codeq/settings.js index 8207c3f..5b57c49 100644 --- a/js/codeq/settings.js +++ b/js/codeq/settings.js @@ -22,9 +22,13 @@ if (data.code !== 0) { throw new Error('Updating settings failed, code: ' + data.code + ', message: ' + data.message); } + history.back(); + }) + .fail(function(reason){ + codeq.log.error('Settings update failed: ' + reason); + alert('Settings update failed: ' + reason); }) .done(); - history.back(); e.preventDefault(); }); jqSettCancelBtn.on("click",function(){ -- cgit v1.2.1