From e5472f297fe13fb993fd67da712026b0011b6634 Mon Sep 17 00:00:00 2001 From: mathisjay Date: Sun, 5 Jul 2020 15:58:46 -0400 Subject: [PATCH] Resolves #4 Resolves #5 Resolves #6 Resolves #7 (#8) --- AdminSiteList.ascx | 1 + AdminSiteList.ascx.cs | 6 ++ Controllers/SiteController.cs | 69 +++++++------- Dnn.Showcase.csproj | 2 - Module.css | 28 +++--- ModuleBase.cs | 1 - View.ascx | 1 + View.ascx.cs | 22 +---- app/controllers/category/category-list.js | 7 +- app/controllers/site/site-list-modal.js | 6 -- app/controllers/site/site-list.js | 12 ++- app/controllers/view.js | 74 +++++++++++++-- app/views/category/category-list.html | 87 ++++++++++-------- app/views/site/site-detail.html | 2 +- app/views/site/site-list-modal.html | 12 --- app/views/site/site-list.html | 104 ++++++++++++---------- app/views/view.html | 13 +-- 17 files changed, 254 insertions(+), 193 deletions(-) delete mode 100644 app/controllers/site/site-list-modal.js delete mode 100644 app/views/site/site-list-modal.html diff --git a/AdminSiteList.ascx b/AdminSiteList.ascx index 2e64d80..edd4a75 100644 --- a/AdminSiteList.ascx +++ b/AdminSiteList.ascx @@ -9,4 +9,5 @@ var portal_id = <%= PortalId %>; var sf = $.ServicesFramework(module_id); var apiUrlBase = "<%= ApiUrlBase %>"; + var navigateUrl = "<%= DotNetNuke.Common.Globals.NavigateURL(TabId) %>" diff --git a/AdminSiteList.ascx.cs b/AdminSiteList.ascx.cs index 4bb8920..3de2a22 100644 --- a/AdminSiteList.ascx.cs +++ b/AdminSiteList.ascx.cs @@ -5,8 +5,14 @@ namespace Dnn.Showcase { partial class AdminSiteList : ModuleBase { + public string NavigateUrl { + get { + return DotNetNuke.Common.Globals.NavigateURL(TabId); + } + } protected new void Page_Load(Object sender, EventArgs e) { + try { base.Page_Load(sender, e); diff --git a/Controllers/SiteController.cs b/Controllers/SiteController.cs index 1f5e61a..88dc6f3 100644 --- a/Controllers/SiteController.cs +++ b/Controllers/SiteController.cs @@ -67,15 +67,15 @@ public HttpResponseMessage Get( //} //else //{ - // order - if (ascending) - { - query = query.OrderBy(order_by); - } - else - { - query = query.OrderByDescending(order_by); - } + // order + if (ascending) + { + query = query.OrderBy(order_by); + } + else + { + query = query.OrderByDescending(order_by); + } //} int total_items = query.Count(); @@ -171,23 +171,22 @@ public HttpResponseMessage Post(SiteDTO dto) if (valid) { dc.SubmitChanges(); - - // move temp image - var old_path = System.Web.Hosting.HostingEnvironment.MapPath(site.thumbnail); - FileInfo fi = new FileInfo(old_path); - if (fi.Exists) + + string file_path = "/DNN_Showcase/" + site.id.ToString("00000") + ".jpg"; + string new_path = PortalSettings.HomeDirectoryMapPath + file_path; + + FileInfo old_thumbnail = new FileInfo(new_path); + if (old_thumbnail.Exists) { - string file_path = "/DNN_Showcase/" + site.id.ToString("00000") + ".jpg"; - string new_path = PortalSettings.HomeDirectoryMapPath + file_path; + old_thumbnail.Delete(); + } - FileInfo old_file = new FileInfo(new_path); - { - if (old_file.Exists) - { - old_file.Delete(); - } - } + // move image + var uploaded_mappath = System.Web.Hosting.HostingEnvironment.MapPath(site.thumbnail); + FileInfo fi = new FileInfo(uploaded_mappath); + if (fi.Exists) + { fi.MoveTo(new_path); site.thumbnail = PortalSettings.HomeDirectory + file_path; } @@ -231,24 +230,26 @@ public HttpResponseMessage Put(SiteDTO dto) var valid = ValidateSite(site); if (valid) { - // move temp image - var old_path = System.Web.Hosting.HostingEnvironment.MapPath(site.thumbnail); - FileInfo fi = new FileInfo(old_path); - if (fi.Exists) + if (site.thumbnail != dto.thumbnail) // new thumbnail image { string file_path = "/DNN_Showcase/" + site.id.ToString("00000") + ".jpg"; string new_path = PortalSettings.HomeDirectoryMapPath + file_path; - FileInfo old_file = new FileInfo(new_path); + FileInfo old_thumbnail = new FileInfo(new_path); + if (old_thumbnail.Exists) { - if (old_file.Exists) - { - old_file.Delete(); - } + old_thumbnail.Delete(); } - fi.MoveTo(new_path); - site.thumbnail = PortalSettings.HomeDirectory + file_path; + // move image + var uploaded_mappath = System.Web.Hosting.HostingEnvironment.MapPath(site.thumbnail); + + FileInfo fi = new FileInfo(uploaded_mappath); + if (fi.Exists) + { + fi.MoveTo(new_path); + site.thumbnail = PortalSettings.HomeDirectory + file_path; + } } dc.SubmitChanges(); diff --git a/Dnn.Showcase.csproj b/Dnn.Showcase.csproj index c376be1..545d69f 100644 --- a/Dnn.Showcase.csproj +++ b/Dnn.Showcase.csproj @@ -151,7 +151,6 @@ - @@ -167,7 +166,6 @@ - diff --git a/Module.css b/Module.css index 50109d5..2e99600 100644 --- a/Module.css +++ b/Module.css @@ -3,21 +3,8 @@ vertical-align: middle !important; } -/*.table .dropdown-toggle { - visibility: hidden; -} - .table .dropdown-toggle::after { - content: none; - } -.table tr:hover .dropdown-toggle { - visibility: visible; -}*/ - -.tab-pane { - padding-top: 10px; -} .modal-full { position: absolute !important; @@ -36,14 +23,21 @@ color: #dc3545; } -.modal.fade.in { - opacity: 1; +.editBarFrameContainer.personabar-shown{ + z-index: 1040 !important; } -.modal.fade .modal-dialog { - transform: translate(0, 0) !important; +.modal.fade { } + .modal.fade.in { + opacity: 1; + } + + .modal.fade .modal-dialog { + transform: translate(0, 0) !important; + } + .modal-backdrop.fade { opacity: 0.5 !important; } diff --git a/ModuleBase.cs b/ModuleBase.cs index 516fa90..111ee51 100644 --- a/ModuleBase.cs +++ b/ModuleBase.cs @@ -63,7 +63,6 @@ protected void Page_Load(Object sender, EventArgs e) ClientResourceManager.RegisterScript(this.Page, ResolveUrl("/DesktopModules/Dnn.Showcase/app/controllers/site/site-list.js"), 15); ClientResourceManager.RegisterScript(this.Page, ResolveUrl("/DesktopModules/Dnn.Showcase/app/controllers/site/site-edit.js"), 15); ClientResourceManager.RegisterScript(this.Page, ResolveUrl("/DesktopModules/Dnn.Showcase/app/controllers/site/site-delete.js"), 15); - ClientResourceManager.RegisterScript(this.Page, ResolveUrl("/DesktopModules/Dnn.Showcase/app/controllers/site/site-list-modal.js"), 15); ClientResourceManager.RegisterScript(this.Page, ResolveUrl("/DesktopModules/Dnn.Showcase/app/controllers/site/site-detail.js"), 15); } } diff --git a/View.ascx b/View.ascx index c2978ae..58e3595 100644 --- a/View.ascx +++ b/View.ascx @@ -10,4 +10,5 @@ var portal_id = <%= PortalId %>; var sf = $.ServicesFramework(module_id); var apiUrlBase = "<%= ApiUrlBase %>"; + var isEditable = <%= IsEditable.ToString().ToLower() %>; diff --git a/View.ascx.cs b/View.ascx.cs index a56c3ce..fda2c85 100644 --- a/View.ascx.cs +++ b/View.ascx.cs @@ -1,29 +1,13 @@ using DotNetNuke.Services.Exceptions; using System; -using DotNetNuke.Entities.Modules.Actions; -using DotNetNuke.Entities.Modules; namespace Dnn.Showcase { - partial class View : ModuleBase, IActionable + partial class View : ModuleBase { - public ModuleActionCollection ModuleActions - { - get - { - ModuleActionCollection Actions = new ModuleActionCollection(); - if (IsEditable) - { - Actions.Add(GetNextActionID(), "Manage Sites", ModuleActionType.AddContent, "", "", EditUrl("SiteList"), false, DotNetNuke.Security.SecurityAccessLevel.Edit, true, false); - Actions.Add(GetNextActionID(), "Manage Categories", ModuleActionType.AddContent, "", "", EditUrl("CategoryList"), false, DotNetNuke.Security.SecurityAccessLevel.Edit, true, false); - } - return Actions; - } - } - protected new void Page_Load(Object sender, EventArgs e) { - + try { base.Page_Load(sender, e); @@ -32,6 +16,6 @@ public ModuleActionCollection ModuleActions { Exceptions.ProcessModuleLoadException(this, ex); } - } + } } } diff --git a/app/controllers/category/category-list.js b/app/controllers/category/category-list.js index 816bed5..438abf3 100644 --- a/app/controllers/category/category-list.js +++ b/app/controllers/category/category-list.js @@ -1,6 +1,11 @@ -dnnShowcase.controller('categoryListController', ['$rootScope', '$scope', '$q', '$uibModal', 'toastr', 'categoryService', function ($rootScope, $scope, $q, $uibModal, toastr, categoryService) { +dnnShowcase.controller('categoryListController', ['$rootScope', '$scope', '$q', '$uibModal', '$uibModalInstance', 'toastr', 'categoryService', function ($rootScope, $scope, $q, $uibModal, $uibModalInstance, toastr, categoryService) { $scope.loading = true; + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + + $scope.categorys = []; $scope.getCategorys = function () { diff --git a/app/controllers/site/site-list-modal.js b/app/controllers/site/site-list-modal.js deleted file mode 100644 index ba6b867..0000000 --- a/app/controllers/site/site-list-modal.js +++ /dev/null @@ -1,6 +0,0 @@ -dnnShowcase.controller('siteListModalController', [ '$scope', '$uibModalInstance', function ($scope, $uibModalInstance) { - $scope.close = function () { - $uibModalInstance.dismiss('cancel'); - }; -}]); - diff --git a/app/controllers/site/site-list.js b/app/controllers/site/site-list.js index 75bc200..0a58bdc 100644 --- a/app/controllers/site/site-list.js +++ b/app/controllers/site/site-list.js @@ -1,15 +1,21 @@ -dnnShowcase.controller('siteListController', ['$rootScope', '$scope', '$q', '$uibModal', 'toastr', 'siteService', function ($rootScope, $scope, $q, $uibModal, toastr, siteService) { +dnnShowcase.controller('siteListController', ['$scope', '$q', '$uibModal', '$uibModalInstance', 'toastr', 'siteService', 'user_id', function ($scope, $q, $uibModal, $uibModalInstance, toastr, siteService, user_id) { $scope.loading = true; + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + + $scope.sites = []; + $scope.user_id = user_id; $scope.getSites = function () { var deferred = $q.defer(); $scope.loading = true; var filter = {}; - if ($rootScope.user_id) { - filter.user_id = $rootScope.user_id; + if ($scope.user_id) { + filter.user_id = $scope.user_id; } siteService.list(filter).then( diff --git a/app/controllers/view.js b/app/controllers/view.js index 7f596e3..9d85470 100644 --- a/app/controllers/view.js +++ b/app/controllers/view.js @@ -4,7 +4,9 @@ $scope.categories = []; $scope.sites = []; - $scope.category_id = null; + $scope.category = null; + + $scope.isEditable = isEditable; $scope.page_size_options = [ { "value": 6, "text": "6 per page" }, @@ -28,12 +30,68 @@ }; $scope.listShowcases = function () { - $uibModal.open({ - templateUrl: '/DesktopModules/Dnn.Showcase/app/views/site/site-list-modal.html?c=' + new Date().getTime(), - controller: 'siteListModalController', + + var modalInstance = $uibModal.open({ + templateUrl: '/DesktopModules/Dnn.Showcase/app/views/site/site-list.html?c=' + new Date().getTime(), + controller: 'siteListController', + size: 'lg', + backdrop: 'static', + resolve: { + user_id: function () { + return user_id; + } + } + }); + + modalInstance.result.then( + function () { + $scope.getSites(); + }, + function () { + $scope.getSites(); + } + ); + }; + $scope.listAllShowcases = function () { + + var modalInstance = $uibModal.open({ + templateUrl: '/DesktopModules/Dnn.Showcase/app/views/site/site-list.html?c=' + new Date().getTime(), + controller: 'siteListController', + size: 'lg', + backdrop: 'static', + resolve: { + user_id: function () { + return null; + } + } + }); + + modalInstance.result.then( + function () { + $scope.getSites(); + }, + function () { + $scope.getSites(); + } + ); + }; + $scope.listCategories = function () { + + var modalInstance = $uibModal.open({ + templateUrl: '/DesktopModules/Dnn.Showcase/app/views/category/category-list.html?c=' + new Date().getTime(), + controller: 'categoryListController', size: 'lg', backdrop: 'static' }); + + modalInstance.result.then( + function () { + $scope.getCategories(); + }, + function () { + $scope.getCategories(); + } + ); }; $scope.getCategories = function () { @@ -65,7 +123,7 @@ page_number: $scope.pagination.page_number, page_size: $scope.pagination.items_per_page, - category_id: $scope.category_id, + category_id: $scope.category ? $scope.category.id : null, user_id: null, active: true }; @@ -95,9 +153,9 @@ $scope.getSites(); }; - $scope.filterCategory = function (category_id) { - console.log(category_id); - $scope.category_id = category_id; + $scope.filterCategory = function (category) { + + $scope.category = category; $scope.pagination.page_number = 1; $scope.getSites(); }; diff --git a/app/views/category/category-list.html b/app/views/category/category-list.html index 452c0f4..9e5d2a9 100644 --- a/app/views/category/category-list.html +++ b/app/views/category/category-list.html @@ -1,45 +1,56 @@ -
- + -
+