diff --git a/public/index.html b/public/index.html index 6b5eab7..0f8d0f3 100644 --- a/public/index.html +++ b/public/index.html @@ -94,7 +94,7 @@ - + diff --git a/src/js/app.js b/src/js/app.js index 8a55972..194053d 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -3,17 +3,4 @@ import './../styles/css/base.css'; require('./event-toggles.js'); -// var getUrlParameter = function getUrlParameter(sParam) { -// var sPageURL = decodeURIComponent(window.location.search.substring(1)), -// sURLVariables = sPageURL.split('&'), -// sParameterName, -// i; -// for (i = 0; i < sURLVariables.length; i++) { -// sParameterName = sURLVariables[i].split('='); - -// if (sParameterName[0] === sParam) { -// return sParameterName[1] === undefined ? true : sParameterName[1]; -// } -// } -// }; diff --git a/src/js/event-toggles.js b/src/js/event-toggles.js index 1c5e561..7052a21 100644 --- a/src/js/event-toggles.js +++ b/src/js/event-toggles.js @@ -21,16 +21,16 @@ module.exports = $(document).ready(function () { $('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').hover(function () { $('#content nav div.collapse li a.nav-link i.far.fa-paper-plane').toggleClass('fas'); }); - $('#command').keyup(function(e){ + $('#command').keyup(function (e) { var code = (e.keyCode ? e.keyCode : e.which); - if(code == 13) { + if (code == 13) { $('#widgets').children().addClass('hide'); $('#successAlert').addClass('hide'); $('#dangetAlert').addClass('hide'); $('#intentBox').addClass('hide'); var command = document.getElementById('command').value; - if(command) { - var text = { "text": command}; + if (command) { + var text = { "text": command }; recastclient.getAndCallProcessIntent(command, text); dom.addGitOperationHistory(command, 'command'); } else { @@ -38,29 +38,47 @@ module.exports = $(document).ready(function () { } } }); - $('#btnSubmitConfirm').on('click', function() { + $('#btnSubmitConfirm').on('click', function () { $('#submitConfirm').removeClass('hide'); - }) - $('#submitGitData').on('click', function() { + }); + $('#submitGitData').on('click', function () { var data = dom.getDataFromFormAsJSON(); var intent = $('#' + $config.costants.hiddenIntentFieldId).val(); - if(intent) { + if (intent) { var operation = $config.intentSlugToOperations[intent]['githubOperation']; app[operation](data); } - }) - $("#hideInfoAlert").on('click', function(){ + }); + $("#hideInfoAlert").on('click', function () { $('#intentBox').addClass('hide'); }) - $("#hideSuccessAlert").on('click', function(){ + $("#hideSuccessAlert").on('click', function () { $('#successAlert').addClass('hide'); - }) - $('.close').click(function(){ + }); + $('.close').click(function () { var $target = $(this).closest('.card'); - $target.hide('slow', function(){ $target.remove(); }); - }) - $("#hideDangerAlert").on('click', function(){ + $target.hide('slow', function () { $target.remove(); }); + }); + $("#hideDangerAlert").on('click', function () { $('#dangerAlert').addClass('hide'); - }) + }); -}); \ No newline at end of file + var urlParam = getUrlParameter('code'); + app.getToken(urlParam); + +}); + +var getUrlParameter = function getUrlParameter(sParam) { + var sPageURL = decodeURIComponent(window.location.search.substring(1)), + sURLVariables = sPageURL.split('&'), + sParameterName, + i; + + for (i = 0; i < sURLVariables.length; i++) { + sParameterName = sURLVariables[i].split('='); + + if (sParameterName[0] === sParam) { + return sParameterName[1] === undefined ? true : sParameterName[1]; + } + } +}; \ No newline at end of file diff --git a/src/js/github-ops.js b/src/js/github-ops.js index 513b5ef..b658506 100644 --- a/src/js/github-ops.js +++ b/src/js/github-ops.js @@ -10,8 +10,24 @@ module.exports = class Github { this.authorizationToken = "token " + config.gitToken; } - getToken() { - + getToken(getTokenRequest) { + var token = ''; + let url = 'https://github.com/login/oauth/access_token'; + fetch(url, { + method: "POST", + body: JSON.stringify(getTokenRequest) + } + ) + .then(function(response) { + response.json().then(function(body){ + repositories = body; + console.log(repositories); + return repositories; + }); + // dom.toggleModals(response); + }) + .catch(error => console.error('Fetch Error =\n', error)); + return repositories; } authenticate() { diff --git a/src/js/microbot-ops.js b/src/js/microbot-ops.js index e9812ef..0e84d3a 100644 --- a/src/js/microbot-ops.js +++ b/src/js/microbot-ops.js @@ -9,6 +9,14 @@ module.exports = class Microbot { this.clientSecret = '7e9a33d05ffdb36b4a498140bb9bb06d62de4f0e'; } + getToken(code) { + $github.getToken({ + 'client_id': 'f6f649a1fe2dfea082ba', + 'client_secret': '7e9a33d05ffdb36b4a498140bb9bb06d62de4f0e', + 'code': code + }); + } + viewRepositories() { return $github.viewRepositories(); } diff --git a/src/styles/scss/base.scss b/src/styles/scss/base.scss index 409a006..464e327 100644 --- a/src/styles/scss/base.scss +++ b/src/styles/scss/base.scss @@ -263,6 +263,20 @@ a.article:hover { color: #bcb !important; } } + +@media(min-width: 576px) { + .card-group>.card:first-child { + border-top-right-radius: .25rem; + border-bottom-right-radius: .25rem; + } + .card-group>.card:not(:first-child):not(:last-child):not(:only-child) { + border-radius: .25rem; + } + .card-group>.card:last-child { + border-top-left-radius: .25rem; + border-bottom-left-radius: .25rem; + } +} /* ------------------------------------------------- ADDITIONS --------------------------------------------------*/ @@ -337,6 +351,22 @@ ADDITIONS padding: 0.2em; } +.loader { + border: 0px solid #f3f3f3; + border-radius: 50%; + border-top: 2px solid #3498db; + border-right: 2px solid #3498db; + width: 20px; + height: 20px; + -webkit-animation: spin 2s linear infinite; /* Safari */ + animation: spin 2s linear infinite; + } + + @keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } + } + /* -------------------------------------------------- OVERRIDES --------------------------------------------------*/ @@ -371,18 +401,4 @@ ADDITIONS .ml-auto { margin-left: 0!important; - } - -@media(min-width: 576px) { - .card-group>.card:first-child { - border-top-right-radius: .25rem; - border-bottom-right-radius: .25rem; - } - .card-group>.card:not(:first-child):not(:last-child):not(:only-child) { - border-radius: .25rem; - } - .card-group>.card:last-child { - border-top-left-radius: .25rem; - border-bottom-left-radius: .25rem; - } -} \ No newline at end of file + } \ No newline at end of file