From b1e29b8d8d5aba96df2f29bbfbb7b9ac55f8c615 Mon Sep 17 00:00:00 2001 From: Jon Lambson Date: Mon, 30 Oct 2017 15:45:58 -0600 Subject: [PATCH] fixing trailing slashes ui.router --- js/app.js | 19 ++++++++++++---- js/controllers/login-controller.js | 2 ++ js/controllers/website-controller.js | 33 +++++++++++++++++++--------- templates/website.html | 6 +++-- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/js/app.js b/js/app.js index 46b5613..4555a2c 100644 --- a/js/app.js +++ b/js/app.js @@ -20,15 +20,19 @@ app.directive('daplieFileChange', function () { }; }); -app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', - function ($stateProvider, $urlRouterProvider, localStorageServiceProvider) { +app.config([ + '$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', '$urlMatcherFactoryProvider', + function ($stateProvider, $urlRouterProvider, localStorageServiceProvider, $urlMatcherFactoryProvider) { + + $urlMatcherFactoryProvider.strictMode(false); localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage'); $urlRouterProvider.otherwise('/splash-page'); + $stateProvider .state('splash-page', { - data: { requiresLogin: false, session: null }, + data: { requiresLogin: false, session: null }, url: '/splash-page', templateUrl: '/templates/splash-page.html', controller: 'loginCtrl as vm' @@ -152,12 +156,18 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $state, Auth, $location) { $rootScope.urlArray = []; + $rootScope.urlInfo = { + url: $location.$$url, + path: $location.$$path, + params: $location.$$search + }; $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { var requiresLogin = toState.data.requiresLogin; - toState.data.session = $location.search(); + // toState.data.session = $location.search(); $rootScope.redirectedURL = toState.url; var query = $location.search(); $rootScope.urlArray.push($rootScope.redirectedURL); + if (requiresLogin && !Auth.isLoggedIn()) { event.preventDefault(); if (!angular.equals(toState.data.session, {})) { @@ -169,6 +179,7 @@ app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $stat $state.go('splash-page', { 'toState': toState.name }); } } + }); }]); }()); diff --git a/js/controllers/login-controller.js b/js/controllers/login-controller.js index 09499bf..3fd0d41 100644 --- a/js/controllers/login-controller.js +++ b/js/controllers/login-controller.js @@ -106,8 +106,10 @@ app.controller('loginCtrl', [ session.issuer = issuer; Auth.add(session); if ($rootScope.redirectedURL === '/splash-page') { + debugger; $location.path('/home'); } else { + debugger; $location.path('/' + $rootScope.redirectedURL); } }, function (err) { diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index f35ba52..5cae9b8 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -66,8 +66,8 @@ app.directive('notificationBar', [function () { }]); app.controller('websiteCtrl', [ - '$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout', '$sce', - function ($scope, $q, Auth, Oauth3, $timeout, $sce) { + '$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout', '$sce', '$rootScope', + function ($scope, $q, Auth, Oauth3, $timeout, $sce, $rootScope) { var vm = this; var angular = window.angular; @@ -186,6 +186,17 @@ app.controller('websiteCtrl', [ console.log(vm.record); }; + vm.shareInit = function () { + if ($rootScope.urlInfo.params.token !== undefined) { + console.log('FISH STICKS', $rootScope.urlInfo); + var result = { data: { info: true } }; + var msg = "You can only view inside the "; + vm.buildNotification(result, msg); + // debugger; + } + }; + + vm.selectRecord = function (record) { vm.record = record; vm.newRecord = record.sub; @@ -206,7 +217,6 @@ app.controller('websiteCtrl', [ vm._uploadFile = function (pkg, opts) { vm.newFileUploaded = opts.newFile.name; opts.progress = opts.progress || opts; - debugger; return pkg.add({ hostname: opts.domain , domain: opts.domain @@ -232,12 +242,13 @@ app.controller('websiteCtrl', [ vm.uploadFolderContainer = false; vm.uploadFileContainer = false; } - opts.progress.uploadTotal = 0; vm.buildNotification(result, msg); vm.cleanArrays(); var path = vm.breadcrumbsPath.join('/'); cleanPathQuery(path); vm.Sites.contents(vm.copyR, vm.cleanedPath); + }, function (err) { + console.log(err); }); }; @@ -360,7 +371,6 @@ app.controller('websiteCtrl', [ vm.Sites.allContents = function (r) { vm.copyR = r; var pkg = Auth.oauth3.pkg('www@daplie.com'); - debugger; return pkg.contents({ hostname: r.domain , domain: r.domain @@ -370,7 +380,6 @@ app.controller('websiteCtrl', [ , path: r.shareAccess.path }).then(function (result) { vm.cleanArrays(); - debugger; vm.folderStructure = result; result.data.forEach(function(data){ if (data.file) { @@ -404,7 +413,6 @@ app.controller('websiteCtrl', [ vm.previousSearchQuery = dir; vm.displaySpinner = ''; var pkg = Auth.oauth3.pkg('www@daplie.com'); - debugger; return pkg.contents({ hostname: r.domain, domain: r.domain, @@ -514,7 +522,6 @@ app.controller('websiteCtrl', [ }; vm.Sites.remove = function (r, opts) { - debugger; if (!window.confirm("Delete files for this site?")) { return; } @@ -831,8 +838,14 @@ app.controller('websiteCtrl', [ hidden: '', message: msg }; - } - else { + } else if (result.data.info) { + vm.alertNotification = { + className: 'info', + title: 'Info', + hidden: '', + message: msg + }; + } else { vm.alertNotification = { className: 'success', title: 'Success', diff --git a/templates/website.html b/templates/website.html index ca1e56c..9166f29 100644 --- a/templates/website.html +++ b/templates/website.html @@ -1,4 +1,7 @@ -
+
+
+ +

Create Share

@@ -89,7 +92,6 @@
-

Enter Invite Code