From 2e90e354bc7ffd2dcf4b841470bc7d76cc0af118 Mon Sep 17 00:00:00 2001 From: perploug Date: Tue, 20 Aug 2013 15:20:46 +0200 Subject: [PATCH 1/6] Fixes dashboard redirect on login --- .../src/views/common/dialogs/login.controller.js | 16 +++++++++------- .../src/views/common/legacy.controller.js | 6 ++++-- .../src/views/common/legacy.html | 4 ++-- .../src/views/common/main.controller.js | 12 +++++++++++- .../src/views/common/navigation.controller.js | 5 ++--- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js index 8976706456..f6cf8b6e41 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js @@ -1,4 +1,4 @@ -angular.module("umbraco").controller("Umbraco.Dialogs.LoginController", function ($scope, userService, legacyJsLoader) { +angular.module("umbraco").controller("Umbraco.Dialogs.LoginController", function ($scope, userService, legacyJsLoader, $routeParams) { /** * @ngdoc function @@ -13,11 +13,9 @@ var weekday = new Array("Super Sunday", "Manic Monday", "Tremendous Tuesday", "Wonderfull Wednesday", "Thunder Thursday", "Friendly Friday", "Shiny Saturday"); $scope.today = weekday[d.getDay()]; - $scope.errorMsg = ""; - $scope.loginSubmit = function (login, password) { - + $scope.loginSubmit = function (login, password) { if ($scope.loginForm.$invalid) { return; } @@ -27,11 +25,15 @@ //We need to load in the legacy tree js. legacyJsLoader.loadLegacyTreeJs($scope).then( function(result) { - var iframe = document.getElementById("right"); + var iframe = $("#right"); if(iframe){ - iframe.contentDocument.location.reload(true); + var url = decodeURIComponent($routeParams.url); + if(!url){ + url ="dashboard.aspx"; + } + iframe.attr("src", url); } - + $scope.submit(true); }); }, function (reason) { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js index 7fdaf50322..9f159393fd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js @@ -8,11 +8,13 @@ * */ function LegacyController($scope, $routeParams, $element) { - //set the legacy path - $scope.legacyPath = decodeURIComponent($routeParams.url); + + $scope.legacyPath = decodeURIComponent($routeParams.url); + //$scope.$on('$routeChangeSuccess', function () { // var asdf = $element; //}); } + angular.module("umbraco").controller('Umbraco.LegacyController', LegacyController); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/legacy.html b/src/Umbraco.Web.UI.Client/src/views/common/legacy.html index 4dc61c234f..78d9e141d7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/legacy.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/legacy.html @@ -1,3 +1,3 @@ -
- +
+
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js index fdfc4c349f..cd1c6c0162 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js @@ -8,7 +8,7 @@ * The main application controller * */ -function MainController($scope, $routeParams, $rootScope, $timeout, notificationsService, userService, navigationService, legacyJsLoader) { +function MainController($scope, $routeParams, $rootScope, $timeout, $http, notificationsService, userService, navigationService, legacyJsLoader) { //debugmode so I can easily turn on/off json output of property models: //TODO: find a better way $scope.$umbdebugmode = true; @@ -17,6 +17,7 @@ function MainController($scope, $routeParams, $rootScope, $timeout, notification //the null is important because we do an explicit bool check on this in the view $scope.authenticated = null; + $scope.avatar = "assets/img/application/logo.png"; //subscribes to notifications in the notification service $scope.notifications = notificationsService.current; @@ -58,6 +59,15 @@ function MainController($scope, $routeParams, $rootScope, $timeout, notification $scope.authenticated = data.authenticated; $scope.user = data.user; + + + if($scope.user.avatar){ + $http.get($scope.user.avatar).then(function(){ + alert($scope.user.avatar); + $scope.avatar = $scope.user.avatar; + }); + } + }, function (reason) { notificationsService.error("An error occurred checking authentication."); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js index 6186cb7532..c285532917 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js @@ -18,7 +18,7 @@ function NavigationController($scope,$rootScope, $location, $log, navigationServ //trigger search with a hotkey: keyboardService.bind("ctrl+shift+s", function(){ - $scope.nav.showTree($scope.ui.currentSection); + $scope.nav.showTree($scope.nav.currentSection); }); //the tree event handler i used to subscribe to the main tree click events @@ -90,8 +90,7 @@ function NavigationController($scope,$rootScope, $location, $log, navigationServ }); /** Opens a dialog but passes in this scope instance to be used for the dialog */ - $scope.openDialog = function (currentNode, action, currentSection) { - + $scope.openDialog = function (currentNode, action, currentSection) { navigationService.showDialog({ scope: $scope, node: currentNode, From dd7e4f19babdfac704d2c38e4c2fe9cd28882de1 Mon Sep 17 00:00:00 2001 From: perploug Date: Tue, 20 Aug 2013 15:21:12 +0200 Subject: [PATCH 2/6] Removed keyboard service debug logging --- .../src/common/directives/hotkey.directive.js | 9 --------- .../src/common/services/keyboard.service.js | 2 +- .../common/services/keyboard-service.spec.js | 20 ++++--------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/hotkey.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/hotkey.directive.js index 4406ad4edd..fbe3d2d636 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/hotkey.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/hotkey.directive.js @@ -5,22 +5,13 @@ angular.module("umbraco.directives") .directive('hotkey', function ($window, keyboardService, $log) { return function (scope, el, attrs) { - var keyCombo = attrs["hotkey"]; - $log.log(keyCombo); - keyboardService.bind(keyCombo, function() { var element = $(el); - - $log.log(element); - if(element.is("a,button,input[type='button'],input[type='submit']")){ element.click(); - $log.log("click"); - }else{ element.focus(); - $log.log("focus"); } }); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/keyboard.service.js b/src/Umbraco.Web.UI.Client/src/common/services/keyboard.service.js index 8328d3e476..fda9f007cc 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/keyboard.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/keyboard.service.js @@ -25,6 +25,7 @@ angular.module('umbraco.services') elt = document.getElementById(opt.target); } + fct = function (e) { e = e || $window.event; @@ -217,7 +218,6 @@ angular.module('umbraco.services') return false; } } - }; // Store shortcut keyboardManagerService.keyboardEvent[label] = { diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/keyboard-service.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/keyboard-service.spec.js index 32888d9a02..82f7766d40 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/keyboard-service.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/keyboard-service.spec.js @@ -2,7 +2,7 @@ describe('keyboard service tests', function () { var keyboardService, $window; var createKeyEvent = function (mainKey, alt, ctrl, shift, meta) { - var keyEvent = jQuery.Event("keypress"); + var keyEvent = jQuery.Event("keydown"); keyEvent.keyCode = mainKey.charCodeAt(0); keyEvent.altKey = alt; keyEvent.ctrlKey = ctrl; @@ -26,17 +26,8 @@ describe('keyboard service tests', function () { var el = $(""); var ev = createKeyEvent("s", false, true, false); - el.keypress(function(ev) { - console.log(ev); - console.log("Handler for .keypress() called."); - }); - - - console.log("loaded"); - keyboardService.bind("ctrl+s", function(){ ctrls = true; - console.log("triggered"); }, el); //initially it should be false @@ -45,12 +36,9 @@ describe('keyboard service tests', function () { //trigger the ctrls+s event el.trigger(ev); - //it should now be true -// expect(ctrls).toBe(true); - - // expect(iconHelper.isFileBasedIcon(legacyBased)).toBe(false); - // expect(iconHelper.isFileBasedIcon(belleBased)).toBe(false); - }); + //it should now be true - this failes for some reason + //expect(ctrls).toBe(true); + }); /* it('detects a legacy icon', function () { From 3b7f12c883388bec18b91e203143c878392f5898 Mon Sep 17 00:00:00 2001 From: perploug Date: Tue, 20 Aug 2013 15:21:27 +0200 Subject: [PATCH 3/6] set content to default section in the routes --- src/Umbraco.Web.UI.Client/src/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/routes.js b/src/Umbraco.Web.UI.Client/src/routes.js index deb972df24..d26a5ae4a8 100644 --- a/src/Umbraco.Web.UI.Client/src/routes.js +++ b/src/Umbraco.Web.UI.Client/src/routes.js @@ -2,7 +2,7 @@ app.config(function ($routeProvider) { $routeProvider .when('/:section', { templateUrl: function (rp) { - if (rp.section === "default") + if (rp.section === "default" || rp.section === "") { rp.section = "content"; } From ff5afb91e6185159aeeed5f2427e4d8b3c31d95b Mon Sep 17 00:00:00 2001 From: perploug Date: Tue, 20 Aug 2013 15:22:06 +0200 Subject: [PATCH 4/6] Set a default avatar on navivation --- .../src/views/directives/umb-navigation.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html b/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html index 6cc0e2e1de..adbfb642c0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html +++ b/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html @@ -4,7 +4,7 @@
  • - +
  • From 5c5926934058c0a32b61be284ab52b34639c7418 Mon Sep 17 00:00:00 2001 From: perploug Date: Tue, 20 Aug 2013 15:22:30 +0200 Subject: [PATCH 5/6] Fixes broken scope reference for rebinder --- .../src/views/content/content.edit.controller.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js index e033657124..f87f02896f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js @@ -58,11 +58,10 @@ function ContentEditController($scope, $routeParams, $location, contentResource, contentResource.publish(cnt, $routeParams.create, $scope.files) .then(function (data) { - contentEditingHelper.handleSuccessfulSave({ scope: $scope, newContent: data, - rebindCallback: contentEditingHelper.reBindChangedProperties(scope.content, data) + rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data) }); }, function (err) { @@ -84,7 +83,7 @@ function ContentEditController($scope, $routeParams, $location, contentResource, contentEditingHelper.handleSuccessfulSave({ scope: $scope, newContent: data, - rebindCallback: contentEditingHelper.reBindChangedProperties(scope.content, data) + rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data) }); }, function (err) { From 121d5462e9eb90d088b02d38418447f3d4107f01 Mon Sep 17 00:00:00 2001 From: perploug Date: Tue, 20 Aug 2013 16:07:46 +0200 Subject: [PATCH 6/6] Missing $scope in content edit controller --- .../src/views/common/legacy.controller.js | 1 - .../src/views/content/content.edit.controller.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js index 9f159393fd..520c22e4a4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/legacy.controller.js @@ -11,7 +11,6 @@ function LegacyController($scope, $routeParams, $element) { $scope.legacyPath = decodeURIComponent($routeParams.url); - //$scope.$on('$routeChangeSuccess', function () { // var asdf = $element; //}); diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js index e193e1f3f5..8b34ef129b 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.edit.controller.js @@ -78,7 +78,7 @@ function ContentEditController($scope, $routeParams, $location, contentResource, allOrigProps: contentEditingHelper.getAllProps($scope.content), rebindCallback: contentEditingHelper.reBindChangedProperties(allOrigProps, allNewProps) }); - }); + }); }; $scope.save = function () { @@ -97,7 +97,7 @@ function ContentEditController($scope, $routeParams, $location, contentResource, contentEditingHelper.handleSuccessfulSave({ scope: $scope, newContent: data, - rebindCallback: contentEditingHelper.reBindChangedProperties(scope.content, data) + rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data) }); }, function (err) {