From 3d2fda7dd39e2363682f1fa353c951ab0d44ddfa Mon Sep 17 00:00:00 2001 From: Fulup Ar Foll Date: Tue, 9 Feb 2016 18:40:49 +0100 Subject: Implemented URL query parsing for initial token /opa/?token=abcde --- afb-client/app/Frontend/app.js | 11 +++++++++-- afb-client/app/Frontend/etc/ConfigApp.js | 6 ++---- .../Frontend/widgets/Buttons/SubmitButtons/SubmitButtons.js | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'afb-client/app/Frontend') diff --git a/afb-client/app/Frontend/app.js b/afb-client/app/Frontend/app.js index 72e8123..ed4d2ea 100644 --- a/afb-client/app/Frontend/app.js +++ b/afb-client/app/Frontend/app.js @@ -1,5 +1,13 @@ (function() { 'use strict'; + + function ParseQueryString () { + var qd = {}; + location.search.substr(1).split("&").forEach(function(item) { + var k = item.split("=")[0], v = decodeURIComponent(item.split("=")[1]); (k in qd) ? qd[k].push(v) : qd[k] = [v]; + }); + return qd; + } angular.module('@@APPNAME@@', [ // Warning: Appname should fit with gulpfile.js & index.html 'ui.router', @@ -24,14 +32,13 @@ 'RangeSlider', 'ModalNotification' ]) + .value ('urlquery', ParseQueryString()) .config(config) .run(run) ; config.$inject = ['$urlRouterProvider', '$locationProvider']; - console.log ("***location=" + window.location + " search" + window.search); - function config($urlProvider, $locationProvider, ConfigApp) { $urlProvider.otherwise('/home'); diff --git a/afb-client/app/Frontend/etc/ConfigApp.js b/afb-client/app/Frontend/etc/ConfigApp.js index 27e2e3e..a6a0cad 100644 --- a/afb-client/app/Frontend/etc/ConfigApp.js +++ b/afb-client/app/Frontend/etc/ConfigApp.js @@ -5,9 +5,7 @@ angular.module('ConfigApp', []) // Factory is a singleton and share its context within all instances. - .factory('ConfigApp', function ($location, $window) { - - // console.log ("URL="+ $location.url() + " Query=" + location.href+ " window=" + document.referrer); + .factory('ConfigApp', function (urlquery) { var myConfig = { paths: { // Warning paths should end with / @@ -27,7 +25,7 @@ check : '/api/token/check', reset : '/api/token/reset', ping : '/api/token/check', - initial : '123456789', // typical dev initial token + initial : urlquery.token || '123456789', // typical dev initial token timeout : 3600, // timeout is updated client sessin context creation pingrate: 60, // Ping rate to check if server is still alive uuid : '', // uuid map with cookie or long term session access key diff --git a/afb-client/app/Frontend/widgets/Buttons/SubmitButtons/SubmitButtons.js b/afb-client/app/Frontend/widgets/Buttons/SubmitButtons/SubmitButtons.js index 1b94e25..cba2aeb 100644 --- a/afb-client/app/Frontend/widgets/Buttons/SubmitButtons/SubmitButtons.js +++ b/afb-client/app/Frontend/widgets/Buttons/SubmitButtons/SubmitButtons.js @@ -24,7 +24,7 @@ var tmpl = '
' + '' + '{{label}}' + - '
'; + ''; angular.module('SubmitButton', []) .directive('submitButton', function () { -- cgit