From fabe19a92c57d37ed9fd1bc1cdbd26fa9348fef1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 14 May 2015 11:19:07 -0700 Subject: [PATCH] ask for OAuth token directly --- .../resources/web/js/query-string.js | 5 +++ domain-server/resources/web/js/settings.js | 10 +++-- domain-server/resources/web/js/setup.js | 33 ---------------- domain-server/resources/web/stats/index.shtml | 1 + domain-server/resources/web/stats/js/stats.js | 38 ++++++++----------- 5 files changed, 28 insertions(+), 59 deletions(-) create mode 100644 domain-server/resources/web/js/query-string.js delete mode 100644 domain-server/resources/web/js/setup.js diff --git a/domain-server/resources/web/js/query-string.js b/domain-server/resources/web/js/query-string.js new file mode 100644 index 0000000000..7bf8f2dda1 --- /dev/null +++ b/domain-server/resources/web/js/query-string.js @@ -0,0 +1,5 @@ +function qs(key) { + key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars + var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)")); + return match && decodeURIComponent(match[1].replace(/\+/g, " ")); +} diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index 273d35b1d8..26df779626 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -26,7 +26,7 @@ var viewHelpers = { form_group = "
"; setting_value = _(values).valueForKeyPath(keypath); - if (setting_value === undefined || setting_value === null) { + if (typeof setting_value == 'undefined' || setting_value === null) { if (_.has(setting, 'default')) { setting_value = setting.default; } else { @@ -40,11 +40,11 @@ var viewHelpers = { } function common_attrs(extra_classes) { - extra_classes = typeof extra_classes !== 'undefined' ? extra_classes : ""; + extra_classes = (typeof extra_classes !== 'undefined' ? extra_classes : ""); return " class='" + (setting.type !== 'checkbox' ? 'form-control' : '') + " " + Settings.TRIGGER_CHANGE_CLASS + " " + extra_classes + "' data-short-name='" + setting.name + "' name='" + keypath + "' " - + "id='" + (setting.id !== 'undefined' ? setting.id : keypath) + "'"; + + "id='" + (typeof setting.id !== 'undefined' ? setting.id : keypath) + "'"; } if (setting.type === 'checkbox') { @@ -239,7 +239,9 @@ function setupHFAccountButton() { // This is the hard coded client ID for a localhost domain. // Users who access their domain remotely will in the future need to create an OAuth application and for now // will need to generate an access token the old fashioned way - buttonSetting.href = "https://metaverse.highfidelity.com/oauth/authorize?client_id=38e572ed35bc4d34c41fbf1fb4d00071bb7328b3d0ba06d1fba64aa3f44e71e4&redirect_uri=http%3A%2F%2Flocalhost%3A40100%2Foauth&response_type=code&scope=domains" + buttonSetting.href = "https://metaverse.highfidelity.com/oauth/authorize?" + + "client_id=38e572ed35bc4d34c41fbf1fb4d00071bb7328b3d0ba06d1fba64aa3f44e71e4" + + "&redirect_uri=http%3A%2F%2Flocalhost%3A40100%2Foauth&response_type=token&scope=domains" } // use the existing getFormGroup helper to ask for a button diff --git a/domain-server/resources/web/js/setup.js b/domain-server/resources/web/js/setup.js deleted file mode 100644 index 2f49fc0cc9..0000000000 --- a/domain-server/resources/web/js/setup.js +++ /dev/null @@ -1,33 +0,0 @@ -$(document).ready(function(){ - /* - * Clamped-width. - * Usage: - *
This long content will force clamped width
- * - * Author: LV - */ - - $('[data-clampedwidth]').each(function () { - var elem = $(this); - var parentPanel = elem.data('clampedwidth'); - var resizeFn = function () { - var sideBarNavWidth = $(parentPanel).width() - parseInt(elem.css('paddingLeft')) - parseInt(elem.css('paddingRight')) - parseInt(elem.css('marginLeft')) - parseInt(elem.css('marginRight')) - parseInt(elem.css('borderLeftWidth')) - parseInt(elem.css('borderRightWidth')); - elem.css('width', sideBarNavWidth); - }; - - resizeFn(); - $(window).resize(resizeFn); - }); - - - var listSource = $('#list-group-template').html(); - var listTemplate = _.template(listSource); - - reloadSettings(); - - function reloadSettings() { - $.getJSON('describe-setup.json', function(data){ - $('.list-group').html(listTemplate(data)); - }); - } -}); \ No newline at end of file diff --git a/domain-server/resources/web/stats/index.shtml b/domain-server/resources/web/stats/index.shtml index 13967d4e36..c60f156cea 100644 --- a/domain-server/resources/web/stats/index.shtml +++ b/domain-server/resources/web/stats/index.shtml @@ -5,6 +5,7 @@
+ diff --git a/domain-server/resources/web/stats/js/stats.js b/domain-server/resources/web/stats/js/stats.js index 9b6fdb217b..1ad824aa53 100644 --- a/domain-server/resources/web/stats/js/stats.js +++ b/domain-server/resources/web/stats/js/stats.js @@ -1,24 +1,18 @@ -function qs(key) { - key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars - var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)")); - return match && decodeURIComponent(match[1].replace(/\+/g, " ")); -} - $(document).ready(function(){ var currentHighchart; // setup a function to grab the nodeStats function getNodeStats() { - + var uuid = qs("uuid"); - + $.getJSON("/nodes/" + uuid + ".json", function(json){ - + // update the table header with the right node type $('#stats-lead h3').html(json.node_type + " stats (" + uuid + ")"); - + delete json.node_type; - + var stats = JsonHuman.format(json); $('#stats-container').html(stats); @@ -27,33 +21,33 @@ $(document).ready(function(){ var x = (new Date()).getTime(); // get the last value using underscore-keypath - var y = _(json).valueForKeyPath(graphKeypath); - + var y = _(json).valueForKeyPath(graphKeypath); + // start shifting the chart once we hit 20 data points var shift = currentHighchart.series[0].data.length > 20; currentHighchart.series[0].addPoint([x, y], true, shift); - } + } }).fail(function(data) { $('#stats-container th').each(function(){ $(this).addClass('stale'); }); - }); + }); } - + // do the first GET on page load getNodeStats(); // grab the new assignments JSON every second var getNodeStatsInterval = setInterval(getNodeStats, 1000); - + var graphKeypath = ""; - + // set the global Highcharts option Highcharts.setOptions({ global: { useUTC: false } }); - + // add a function to help create the graph modal function createGraphModal() { var chartModal = bootbox.dialog({ @@ -66,7 +60,7 @@ $(document).ready(function(){ chartModal.on('hidden.bs.modal', function(e) { currentHighchart.destroy(); currentHighchart = null; - }); + }); currentHighchart = new Highcharts.Chart({ chart: { @@ -94,11 +88,11 @@ $(document).ready(function(){ }] }); } - + // handle clicks on numerical values - this lets the user show a line graph in a modal $('#stats-container').on('click', '.jh-type-number', function(){ graphKeypath = $(this).data('keypath'); - + // setup the new graph modal createGraphModal(); });