Skip to content

Commit

Permalink
Resolves #4 Resolves #5 Resolves #6 Resolves #7 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
X3Technology authored Jul 5, 2020
1 parent ff5b5fb commit e5472f2
Show file tree
Hide file tree
Showing 17 changed files with 254 additions and 193 deletions.
1 change: 1 addition & 0 deletions AdminSiteList.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
var portal_id = <%= PortalId %>;
var sf = $.ServicesFramework(module_id);
var apiUrlBase = "<%= ApiUrlBase %>";
var navigateUrl = "<%= DotNetNuke.Common.Globals.NavigateURL(TabId) %>"
</script>
6 changes: 6 additions & 0 deletions AdminSiteList.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
69 changes: 35 additions & 34 deletions Controllers/SiteController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions Dnn.Showcase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
<Content Include="app\controllers\category\category-delete.js" />
<Content Include="app\controllers\category\category-edit.js" />
<Content Include="app\controllers\category\category-list.js" />
<Content Include="app\controllers\site\site-list-modal.js" />
<Content Include="app\controllers\admin-site-list.js" />
<Content Include="app\controllers\view.js" />
<Content Include="app\controllers\site\site-delete.js" />
Expand All @@ -167,7 +166,6 @@
<Content Include="app\views\category\category-list.html" />
<Content Include="app\views\site\site-delete.html" />
<Content Include="app\views\site\site-edit.html" />
<Content Include="app\views\site\site-list-modal.html" />
<Content Include="app\views\site\site-list.html" />
<Content Include="app\views\view.html" />
<Content Include="Module.css" />
Expand Down
28 changes: 11 additions & 17 deletions Module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion ModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions View.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
var portal_id = <%= PortalId %>;
var sf = $.ServicesFramework(module_id);
var apiUrlBase = "<%= ApiUrlBase %>";
var isEditable = <%= IsEditable.ToString().ToLower() %>;
</script>
22 changes: 3 additions & 19 deletions View.ascx.cs
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -32,6 +16,6 @@ public ModuleActionCollection ModuleActions
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
}
}
}
7 changes: 6 additions & 1 deletion app/controllers/category/category-list.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/site/site-list-modal.js

This file was deleted.

12 changes: 9 additions & 3 deletions app/controllers/site/site-list.js
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
74 changes: 66 additions & 8 deletions app/controllers/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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 () {
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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();
};
Expand Down
Loading

0 comments on commit e5472f2

Please sign in to comment.