ask for OAuth token directly

This commit is contained in:
Stephen Birarda 2015-05-14 11:19:07 -07:00
parent aff83be768
commit fabe19a92c
5 changed files with 28 additions and 59 deletions

View file

@ -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, " "));
}

View file

@ -26,7 +26,7 @@ var viewHelpers = {
form_group = "<div class='form-group " + (isAdvanced ? Settings.ADVANCED_CLASS : "") + "'>";
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

View file

@ -1,33 +0,0 @@
$(document).ready(function(){
/*
* Clamped-width.
* Usage:
* <div data-clampedwidth=".myParent">This long content will force clamped width</div>
*
* 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));
});
}
});

View file

@ -5,6 +5,7 @@
</div>
<div class="col-xs-12" id="stats-container"></div>
<!--#include virtual="footer.html"-->
<script src='/js/query-string.js'></script>
<script src='js/stats.js'></script>
<script src='js/json.human.js'></script>
<script src='js/highcharts-custom.js'></script>

View file

@ -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();
});