diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js deleted file mode 100644 index 0d83028cc3..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @ngdoc service - * @name umbraco.resources.publishedContentResource - * @description service to retrieve published content from the umbraco cache - * - * - **/ -function publishedContentResource($q, $http, umbRequestHelper) { - - //TODO: Why do we have this ? If we want a URL why isn't it just on the content controller ? - - //the factory object returned - return { - - - }; -} - -angular.module('umbraco.resources').factory('publishedContentResource', publishedContentResource); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js b/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js index 0f4457f95b..fd4609da01 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js @@ -26,43 +26,60 @@ angular.module('umbraco.services') var nArray = []; - function add(item) { - angularHelper.safeApply($rootScope, function () { - - //add a colon after the headline if there is a message as well - if (item.message) { - item.headline += ":"; - if(item.message.length > 200) { - item.sticky = true; - } - } + var service = { - //we need to ID the item, going by index isn't good enough because people can remove at different indexes - // whenever they want. Plus once we remove one, then the next index will be different. The only way to - // effectively remove an item is by an Id. - item.id = String.CreateGuid(); - - nArray.push(item); - - if(!item.sticky) { - $timeout(function() { - var found = _.find(nArray, function(i) { - return i.id === item.id; - }); + /** + * @ngdoc method + * @name umbraco.services.notificationsService#add + * @methodOf umbraco.services.notificationsService + * + * @description + * Lower level api for adding notifcations, support more advanced options + * @param {Object} item The notification item + * @param {String} item.headline Short headline + * @param {String} item.message longer text for the notication, trimmed after 200 characters, which can then be exanded + * @param {String} item.type Notification type, can be: "success","warning","error" or "info" + * @param {String} item.url url to open when notification is clicked + * @param {Boolean} item.sticky if set to true, the notification will not auto-close + * @returns {Object} args notification object + */ - if (found) { - var index = nArray.indexOf(found); - nArray.splice(index, 1); - } + add: function(item) { + angularHelper.safeApply($rootScope, function () { - }, 7000); - } + //add a colon after the headline if there is a message as well + if (item.message) { + item.headline += ":"; + if(item.message.length > 200) { + item.sticky = true; + } + } - return item; - }); - } + //we need to ID the item, going by index isn't good enough because people can remove at different indexes + // whenever they want. Plus once we remove one, then the next index will be different. The only way to + // effectively remove an item is by an Id. + item.id = String.CreateGuid(); - return { + nArray.push(item); + + if(!item.sticky) { + $timeout(function() { + var found = _.find(nArray, function(i) { + return i.id === item.id; + }); + + if (found) { + var index = nArray.indexOf(found); + nArray.splice(index, 1); + } + + }, 7000); + } + + return item; + }); + + }, /** * @ngdoc method @@ -123,9 +140,8 @@ angular.module('umbraco.services') * @returns {Object} notification object */ success: function (headline, message) { - return add({ headline: headline, message: message, type: 'success', time: new Date() }); - - }, + return service.add({ headline: headline, message: message, type: 'success', time: new Date() }); + }, /** * @ngdoc method * @name umbraco.services.notificationsService#error @@ -140,7 +156,7 @@ angular.module('umbraco.services') * @returns {Object} notification object */ error: function (headline, message) { - return add({ headline: headline, message: message, type: 'error', time: new Date() }); + return service.add({ headline: headline, message: message, type: 'error', time: new Date() }); }, /** @@ -158,7 +174,7 @@ angular.module('umbraco.services') * @returns {Object} notification object */ warning: function (headline, message) { - return add({ headline: headline, message: message, type: 'warning', time: new Date() }); + return service.add({ headline: headline, message: message, type: 'warning', time: new Date() }); }, /** @@ -176,7 +192,7 @@ angular.module('umbraco.services') * @returns {Object} notification object */ info: function (headline, message) { - return add({ headline: headline, message: message, type: 'info', time: new Date() }); + return service.add({ headline: headline, message: message, type: 'info', time: new Date() }); }, /** @@ -233,4 +249,6 @@ angular.module('umbraco.services') return nArray; } }; + + return service; }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js index 1fc040527a..0dc30be9c4 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js @@ -20,6 +20,32 @@ function legacyJsLoader(assetsService, umbRequestHelper) { } angular.module('umbraco.services').factory('legacyJsLoader', legacyJsLoader); +/** + * @ngdoc function + * @name umbraco.services.updateChecker + * @function + * + * @description + * used to check for updates and display a notifcation + */ +function updateChecker($http, umbRequestHelper) { + return { + + /** Called to load in the legacy tree js which is required on startup if a user is logged in or + after login, but cannot be called until they are authenticated which is why it needs to be lazy loaded. */ + check: function() { + + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "updateCheckApiBaseUrl", + "GetCheck")), + 'Failed to retreive update status'); + } + }; +} +angular.module('umbraco.services').factory('updateChecker', updateChecker); + /** * @ngdoc service * @name umbraco.services.umbPropertyEditorHelper diff --git a/src/Umbraco.Web.UI.Client/src/less/alerts.less b/src/Umbraco.Web.UI.Client/src/less/alerts.less index 2841642600..51961aefdc 100644 --- a/src/Umbraco.Web.UI.Client/src/less/alerts.less +++ b/src/Umbraco.Web.UI.Client/src/less/alerts.less @@ -14,7 +14,8 @@ .border-radius(@baseBorderRadius); } .alert, -.alert h4 { +.alert h4, +.alert a { // Specified for the h4 to prevent conflicts of changing @headingsColor color: @warningText; } diff --git a/src/Umbraco.Web.UI.Client/src/less/variables.less b/src/Umbraco.Web.UI.Client/src/less/variables.less index 06a48483d2..b604f73bb8 100644 --- a/src/Umbraco.Web.UI.Client/src/less/variables.less +++ b/src/Umbraco.Web.UI.Client/src/less/variables.less @@ -254,7 +254,7 @@ @successBorder: transparent; @infoText: @white; -@infoBackground: @purple; +@infoBackground: @blue; @infoBorder: transparent; // SD: Had to duplicate the above but prefix with 'form' with the bootstrap original colors 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 068bc7baab..8d3ae53640 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, $location, $routeParams, $rootScope, $timeout, $http, $log, notificationsService, userService, navigationService, legacyJsLoader) { +function MainController($scope, $location, $routeParams, $rootScope, $timeout, $http, $log, notificationsService, userService, navigationService, legacyJsLoader, updateChecker) { var legacyTreeJsLoaded = false; @@ -57,10 +57,8 @@ function MainController($scope, $location, $routeParams, $rootScope, $timeout, $ //when a user logs out or timesout $scope.$on("notAuthenticated", function() { - $scope.authenticated = null; $scope.user = null; - }); //when a user is authorized setup the data @@ -79,6 +77,21 @@ function MainController($scope, $location, $routeParams, $rootScope, $timeout, $ $scope.authenticated = data.authenticated; $scope.user = data.user; + updateChecker.check().then(function(update){ + if(update && update !== "null"){ + if(update.type !== "Nones"){ + var notification = { + headline: "Update available", + message: "Click to download", + sticky: true, + type: "info", + url: update.url + }; + notificationsService.add(notification); + } + } + }); + //if the user has changed we need to redirect to the root so they don't try to continue editing the //last item in the URL if (data.lastUserId && data.lastUserId !== data.user.id) { diff --git a/src/Umbraco.Web.UI.Client/src/views/directives/umb-notifications.html b/src/Umbraco.Web.UI.Client/src/views/directives/umb-notifications.html index 63e88429df..9dcc5b4a4f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/directives/umb-notifications.html +++ b/src/Umbraco.Web.UI.Client/src/views/directives/umb-notifications.html @@ -2,11 +2,13 @@ diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 8f1cc51846..d358a0b1b1 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -140,6 +140,10 @@ namespace Umbraco.Web.Editors "memberTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl( controller => controller.GetAllTypes()) }, + { + "updateCheckApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl( + controller => controller.GetCheck()) + }, } }, { @@ -165,28 +169,7 @@ namespace Umbraco.Web.Editors return JavaScript(ServerVariablesParser.Parse(d)); } - [HttpGet] - public UpgradeCheckResponse UpdateChecker() - { - //PP: The statehelper is obsolete, but there are NO directions on what to use instead, so keeping it here... - var updChkCookie = new global::umbraco.BusinessLogic.StateHelper.Cookies.Cookie("UMB_UPDCHK", GlobalSettings.VersionCheckPeriod); - string updateCheckCookie = updChkCookie.HasValue ? updChkCookie.GetValue() : ""; - - if (GlobalSettings.VersionCheckPeriod > 0 && String.IsNullOrEmpty(updateCheckCookie) && Security.CurrentUser.UserType.Alias == "admin") - { - updChkCookie.SetValue("1"); - - var check = new global::umbraco.presentation.org.umbraco.update.CheckForUpgrade(); - var result = check.CheckUpgrade(UmbracoVersion.Current.Major, - UmbracoVersion.Current.Minor, - UmbracoVersion.Current.Build, - UmbracoVersion.CurrentComment); - - return new UpgradeCheckResponse(result.UpgradeType.ToString(), result.Comment, result.UpgradeUrl); - } - - return null; - } + private IEnumerable> GetTreePluginsMetaData() { diff --git a/src/Umbraco.Web/Editors/UpdateCheckController.cs b/src/Umbraco.Web/Editors/UpdateCheckController.cs new file mode 100644 index 0000000000..3cae1f55a0 --- /dev/null +++ b/src/Umbraco.Web/Editors/UpdateCheckController.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Mvc; + +using Umbraco.Core.Configuration; +using Umbraco.Web.Models; + +namespace Umbraco.Web.Editors +{ + public class UpdateCheckController : UmbracoAuthorizedJsonController + { + [HttpGet] + public UpgradeCheckResponse GetCheck() + { + //PP: The statehelper is obsolete, but there are NO directions on what to use instead, so keeping it here... + var updChkCookie = new global::umbraco.BusinessLogic.StateHelper.Cookies.Cookie("UMB_UPDCHK", GlobalSettings.VersionCheckPeriod); + string updateCheckCookie = updChkCookie.HasValue ? updChkCookie.GetValue() : ""; + + if (GlobalSettings.VersionCheckPeriod > 0 && String.IsNullOrEmpty(updateCheckCookie) && Security.CurrentUser.UserType.Alias == "admin") + { + updChkCookie.SetValue("1"); + + var check = new global::umbraco.presentation.org.umbraco.update.CheckForUpgrade(); + var result = check.CheckUpgrade(UmbracoVersion.Current.Major, + UmbracoVersion.Current.Minor, + UmbracoVersion.Current.Build, + UmbracoVersion.CurrentComment); + return new UpgradeCheckResponse(result.UpgradeType.ToString(), result.Comment, result.UpgradeUrl); + } + + return null; + } + } +} diff --git a/src/Umbraco.Web/Models/UpgradeCheckResponse.cs b/src/Umbraco.Web/Models/UpgradeCheckResponse.cs index b93aeab0e1..df384a51cd 100644 --- a/src/Umbraco.Web/Models/UpgradeCheckResponse.cs +++ b/src/Umbraco.Web/Models/UpgradeCheckResponse.cs @@ -9,10 +9,12 @@ using Umbraco.Core.Configuration; namespace Umbraco.Web.Models { + [DataContract(Name = "upgrade", Namespace = "")] public class UpgradeCheckResponse { [DataMember(Name = "type")] public string Type { get; set; } + [DataMember(Name = "comment")] public string Comment { get; set; } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 7ab66c8fc7..4be0a1c630 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -312,6 +312,7 @@ +