From be901a6f8ada1dfdaad741e5eee39ff1d87d9517 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Sun, 29 Jan 2017 23:33:54 +0100 Subject: [PATCH] add test credentials button to settings --- app/scripts/main/global-services/jira-s.js | 2 +- app/scripts/main/global-services/simple-toast-s.js | 7 +++++-- app/scripts/routes/settings/settings-c.html | 7 ++++++- app/scripts/routes/settings/settings-c.js | 14 +++++--------- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/scripts/main/global-services/jira-s.js b/app/scripts/main/global-services/jira-s.js index ddb7e4f486..110d2f20c6 100644 --- a/app/scripts/main/global-services/jira-s.js +++ b/app/scripts/main/global-services/jira-s.js @@ -51,7 +51,7 @@ if (!res || res.error) { $log.log('FRONTEND_REQUEST', currentRequest); $log.log('RESPONSE', res); - SimpleToast('ERROR', 'Jira Request failed: ' + currentRequest.clientRequest.apiMethod + ' – ' + (res && res.error), 'ERROR'); + SimpleToast('ERROR', 'Jira Request failed: ' + currentRequest.clientRequest.apiMethod + ' – ' + (res && res.error)); currentRequest.defer.reject(res); } else { currentRequest.defer.resolve(res); diff --git a/app/scripts/main/global-services/simple-toast-s.js b/app/scripts/main/global-services/simple-toast-s.js index a3f8ec46bf..6ed88495bd 100644 --- a/app/scripts/main/global-services/simple-toast-s.js +++ b/app/scripts/main/global-services/simple-toast-s.js @@ -15,12 +15,15 @@ /* @ngInject */ function SimpleToast($mdToast) { + const DEFAULT_HIDE_DELAY = 4000; + return (textContent, type, hideDelay) => { + if (!type) { return $mdToast.show($mdToast.simple() .textContent(textContent) .capsule(false) - .hideDelay(hideDelay || 4000) + .hideDelay(hideDelay || DEFAULT_HIDE_DELAY) .position('bottom')); } else { let icon; @@ -54,7 +57,7 @@ ${textContent} `, - hideDelay: hideDelay || 4000 + hideDelay: hideDelay || DEFAULT_HIDE_DELAY }); } }; diff --git a/app/scripts/routes/settings/settings-c.html b/app/scripts/routes/settings/settings-c.html index 6e68642e23..fa25468de1 100644 --- a/app/scripts/routes/settings/settings-c.html +++ b/app/scripts/routes/settings/settings-c.html @@ -99,7 +99,12 @@ aria-label="Update issue description on jira if task notes are updated"> Update issue description on jira if task notes are updated - + + + Test credentials +

Worklog

diff --git a/app/scripts/routes/settings/settings-c.js b/app/scripts/routes/settings/settings-c.js index 0471a8876c..18ed7efbf0 100644 --- a/app/scripts/routes/settings/settings-c.js +++ b/app/scripts/routes/settings/settings-c.js @@ -14,7 +14,7 @@ .controller('SettingsCtrl', SettingsCtrl); /* @ngInject */ - function SettingsCtrl($localStorage, $window, $scope, Projects, Dialogs, DEFAULT_THEME, THEMES, IS_ELECTRON, SimpleToast, $mdDialog) { + function SettingsCtrl($localStorage, $window, $scope, Projects, Dialogs, DEFAULT_THEME, THEMES, IS_ELECTRON, SimpleToast, $mdDialog, Jira) { let vm = this; const _ = $window._; @@ -77,14 +77,10 @@ }; // jira stuff - vm.saveJiraSettings = (settings) => { - $localStorage.jiraSettings = $localStorage.jiraSettings = settings; - // for some reason project needs to be updated directly - if ($localStorage.currentProject && $localStorage.currentProject.data) { - $localStorage.currentProject.data.jiraSettings = settings; - } - - SimpleToast('SUCCESS', 'Jira settings saved'); + vm.testJiraCredentials = () => { + Jira.getSuggestions().then(() => { + SimpleToast('SUCCESS', 'Connection successful!'); + }); }; // theme stuff