From a7f5576fee1205de745ac43e54bf2da242e9c5c7 Mon Sep 17 00:00:00 2001 From: perploug Date: Tue, 29 Oct 2013 21:49:40 +0100 Subject: [PATCH] Wires up the help dialog with our and tv feeds --- .../src/common/services/help.service.js | 70 +++++++++++++++++++ src/Umbraco.Web.UI.Client/src/less/main.less | 1 - src/Umbraco.Web.UI.Client/src/less/navs.less | 9 +++ src/Umbraco.Web.UI.Client/src/less/tree.less | 2 +- .../views/common/dialogs/help.controller.js | 37 +++++++++- .../src/views/common/dialogs/help.html | 48 +++++++++++-- .../config/feedProxy.Release.config | 1 + src/Umbraco.Web.UI/config/feedProxy.config | 1 + src/Umbraco.Web/Editors/UserController.cs | 1 + .../Models/ContentEditing/UserDetail.cs | 4 ++ .../Models/Mapping/UserModelMapper.cs | 1 + 11 files changed, 165 insertions(+), 10 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/common/services/help.service.js diff --git a/src/Umbraco.Web.UI.Client/src/common/services/help.service.js b/src/Umbraco.Web.UI.Client/src/common/services/help.service.js new file mode 100644 index 0000000000..6d7d341a57 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/services/help.service.js @@ -0,0 +1,70 @@ +angular.module('umbraco.services') + .factory('helpService', function ($http, $q){ + var helpTopics = {}; + + var defaultUrl = "http://our.umbraco.org/rss/help"; + var tvUrl = "http://umbraco.tv/feeds/help"; + + function getCachedHelp(url){ + if(helpTopics[url]){ + return helpTopics[cacheKey]; + }else{ + return null; + } + } + + function setCachedHelp(url, data){ + helpTopics[url] = data; + } + + function fetchUrl(url){ + var deferred = $q.defer(); + var found = getCachedHelp(url); + + if(found){ + deferred.resolve(found); + }else{ + + var proxyUrl = "dashboard/feedproxy.aspx?url=" + url; + $http.get(proxyUrl).then(function(data){ + var feed = $(data.data); + var topics = []; + + $('item', feed).each(function (i, item) { + var topic = {}; + topic.thumbnail = $(item).find('thumbnail').attr('url'); + topic.title = $("title", item).text(); + topic.link = $("guid", item).text(); + topic.description = $("description", item).text(); + topics.push(topic); + }); + + setCachedHelp(topics); + deferred.resolve(topics); + }); + } + + return deferred.promise; + } + + + + var service = { + findHelp: function (args) { + var url = service.getUrl(defaultUrl, args); + return fetchUrl(url); + }, + + findVideos: function (args) { + var url = service.getUrl(tvUrl, args); + return fetchUrl(url); + }, + + getUrl: function(url, args){ + return url + "?" + $.param(args); + } + }; + + return service; + + }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/less/main.less b/src/Umbraco.Web.UI.Client/src/less/main.less index 90b3f4b8ab..51ef4c3016 100644 --- a/src/Umbraco.Web.UI.Client/src/less/main.less +++ b/src/Umbraco.Web.UI.Client/src/less/main.less @@ -65,7 +65,6 @@ h5{ /*BUTTONS */ - .thumbnails > li.umb-plus-btn { margin: 0 10px 10px 0 } diff --git a/src/Umbraco.Web.UI.Client/src/less/navs.less b/src/Umbraco.Web.UI.Client/src/less/navs.less index cf65ff97f5..7671ab73d6 100644 --- a/src/Umbraco.Web.UI.Client/src/less/navs.less +++ b/src/Umbraco.Web.UI.Client/src/less/navs.less @@ -2,6 +2,15 @@ // Navs // -------------------------------------------------- +.list-icons li{ + padding-left: 35px; +} + +.list-icons li > i.icon{ + margin-left: -25px; + padding-right: 7px; +} + // BASE CLASS // ---------- diff --git a/src/Umbraco.Web.UI.Client/src/less/tree.less b/src/Umbraco.Web.UI.Client/src/less/tree.less index 00011cf6aa..b4ae7f008e 100644 --- a/src/Umbraco.Web.UI.Client/src/less/tree.less +++ b/src/Umbraco.Web.UI.Client/src/less/tree.less @@ -238,10 +238,10 @@ div.has-unpublished-version:before{ } div.not-allowed > i.icon,div.not-allowed > a{ - color: @grayLight; cursor: not-allowed; } + // Tree context menu // ------------------------- .umb-actions { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.controller.js index 9de519cce0..be778d03be 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.controller.js @@ -1,7 +1,42 @@ angular.module("umbraco") - .controller("Umbraco.Dialogs.HelpController", function ($scope, $location, $routeParams) { + .controller("Umbraco.Dialogs.HelpController", function ($scope, $location, $routeParams, helpService, userService) { $scope.section = $routeParams.section; if(!$scope.section){ $scope.section ="content"; } + + var rq = {}; + rq.section = $scope.section; + + userService.getCurrentUser().then(function(user){ + + rq.usertype = user.userType; + rq.lang = user.locale; + + if($routeParams.url){ + rq.path = decodeURIComponent($routeParams.url); + + if(rq.path.indexOf(Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath) === 0){ + rq.path = rq.path.substring(Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath.length); + } + + if(rq.path.indexOf(".aspx") > 0){ + rq.path = rq.path.substring(0, rq.path.indexOf(".aspx")); + } + + }else{ + rq.path = rq.section + "/" + $routeParams.tree + "/" + $routeParams.method; + } + + helpService.findHelp(rq).then(function(topics){ + $scope.topics = topics; + }); + + helpService.findVideos(rq).then(function(videos){ + $scope.videos = videos; + }); + + }); + + }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.html index 54d649a45b..a32658aa15 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/help.html @@ -5,20 +5,54 @@
-
Help topics for: {{section}}
-

- This area will contain manuals, references and tutorials, downloaded from our.umbraco.org... -

+ + +
Video chapters for: {{section}}
-

- This area will contain relevant videos from umbraco.tv -

+ + + +
+ \ No newline at end of file diff --git a/src/Umbraco.Web.UI/config/feedProxy.Release.config b/src/Umbraco.Web.UI/config/feedProxy.Release.config index cbbbba6a9b..e76284c13f 100644 --- a/src/Umbraco.Web.UI/config/feedProxy.Release.config +++ b/src/Umbraco.Web.UI/config/feedProxy.Release.config @@ -7,4 +7,5 @@ + diff --git a/src/Umbraco.Web.UI/config/feedProxy.config b/src/Umbraco.Web.UI/config/feedProxy.config index 2229d276da..afce5316b0 100644 --- a/src/Umbraco.Web.UI/config/feedProxy.config +++ b/src/Umbraco.Web.UI/config/feedProxy.config @@ -7,4 +7,5 @@ + diff --git a/src/Umbraco.Web/Editors/UserController.cs b/src/Umbraco.Web/Editors/UserController.cs index ca8974d852..bea40acc81 100644 --- a/src/Umbraco.Web/Editors/UserController.cs +++ b/src/Umbraco.Web/Editors/UserController.cs @@ -56,6 +56,7 @@ namespace Umbraco.Web.Editors { throw new HttpResponseException(HttpStatusCode.NotFound); } + return Mapper.Map(user); } diff --git a/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs b/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs index 70bbddfa8a..b6b17d0336 100644 --- a/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs +++ b/src/Umbraco.Web/Models/ContentEditing/UserDetail.cs @@ -20,6 +20,10 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "emailHash")] public string EmailHash { get; set; } + [DataMember(Name = "userType", IsRequired = true)] + [Required] + public string UserType { get; set; } + /// /// Gets/sets the number of seconds for the user's auth ticket to expire /// diff --git a/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs b/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs index d72f7b33d9..0648bba260 100644 --- a/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs @@ -13,6 +13,7 @@ namespace Umbraco.Web.Models.Mapping { config.CreateMap() .ForMember(detail => detail.UserId, opt => opt.MapFrom(user => GetIntId(user.Id))) + .ForMember(detail => detail.UserType, opt => opt.MapFrom(user => user.UserType.Alias)) .ForMember( detail => detail.EmailHash, opt => opt.MapFrom(user => user.Email.ToLowerInvariant().Trim().ToMd5()));