Skip to content

Commit dca4e3b

Browse files
committed
Plugins page enable/disable functionality
1 parent 95d4c5e commit dca4e3b

6 files changed

Lines changed: 44 additions & 40 deletions

File tree

BlogEngine/BlogEngine.Core/Data/PackageRepository.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ public IEnumerable<Package> Find(int take = 10, int skip = 0, string filter = ""
3535
{
3636
if (!Security.IsAuthorizedTo(Rights.ManageExtensions))
3737
throw new UnauthorizedAccessException();
38-
pkgsToLoad = Packaging.FileSystem.LoadExtensions();
38+
39+
var fullList = Packaging.FileSystem.LoadExtensions();
40+
string[] coreExts = { "bbcode", "logger", "breakpost", "resolvelinks", "sendcommentmail", "sendpings", "smilies" };
41+
42+
foreach (var pkg in fullList)
43+
{
44+
if(!coreExts.Contains(pkg.Id.ToLower()))
45+
{
46+
pkgsToLoad.Add(pkg);
47+
}
48+
}
3949
}
4050
else if (filter.ToLower() == "themes")
4151
{
@@ -112,6 +122,7 @@ public bool Update(Package item)
112122
if (ext != null)
113123
{
114124
ext.Priority = item.Priority;
125+
ext.Enabled = item.Enabled;
115126
ExtensionManager.ChangeStatus(item.Id, item.Enabled);
116127
ExtensionManager.SaveToStorage(ext);
117128
Blog.CurrentInstance.Cache.Remove(Constants.CacheKey);

BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
[assembly: CLSCompliant(false)]
2020
[assembly: ComVisible(false)]
2121
[assembly: AllowPartiallyTrustedCallers]
22-
[assembly: AssemblyVersion("3.1.3.4")]
22+
[assembly: AssemblyVersion("3.1.3.5")]
2323
[assembly: SecurityRules(SecurityRuleSet.Level1)]

BlogEngine/BlogEngine.NET/AppCode/Api/PackagesController.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ public HttpResponseMessage ProcessChecked([FromBody]List<Package> items)
5656
throw new HttpResponseException(HttpStatusCode.InternalServerError);
5757
}
5858
}
59+
60+
if (action == "enable")
61+
{
62+
foreach (var item in items)
63+
{
64+
item.Enabled = true;
65+
repository.Update(item);
66+
}
67+
}
68+
if (action == "disable")
69+
{
70+
foreach (var item in items)
71+
{
72+
item.Enabled = false;
73+
repository.Update(item);
74+
}
75+
}
5976
return Request.CreateResponse(HttpStatusCode.OK);
6077
}
6178
catch (System.Exception ex)

BlogEngine/BlogEngine.NET/admin/app/controllers/custom.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ angular.module('blogAdmin').controller('CustomController', ["$rootScope", "$scop
1515
$scope.lst = ($location.search()).lst;
1616
$scope.galleryFilter = getFromQueryString('ftr');
1717

18-
$scope.order = 'LastUpdated desc';
19-
$scope.sortingOrder = 'LastUpdated';
18+
$scope.order = 'DownloadCount desc';
19+
$scope.sortingOrder = 'DownloadCount';
2020
$scope.reverse = true;
2121

2222
$scope.showRating = false;
@@ -172,12 +172,6 @@ angular.module('blogAdmin').controller('CustomController', ["$rootScope", "$scop
172172
});
173173
}
174174

175-
$scope.enableExtension = function (item, enable) {
176-
$scope.package = item;
177-
$scope.package.Enabled = enable;
178-
$scope.save();
179-
}
180-
181175
$scope.setFilter = function () {
182176
if ($scope.galleryFilter == 'plugin') {
183177
$scope.gridFilter('PackageType', 'Extension', 'pub');

BlogEngine/BlogEngine.NET/admin/views/custom/gallery.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2 class="page-title pull-left">
1111
</div>
1212
<div class="dropdown pull-right">
1313
<button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
14-
LATEST
14+
Most downloaded
1515
<i class="fa fa-angle-down"></i>
1616
</button>
1717
<ul class="dropdown-menu dropdown-menu-filter">

BlogEngine/BlogEngine.NET/admin/views/custom/plugins.html

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ <h2 class="page-title pull-left">
66
</h2>
77
<a ng-if="IsPrimary" href="{{SiteVars.RelativeWebRoot}}admin/#/custom/gallery?ftr=plugin" class="btn btn-success btn-sm btn-hasicon pull-left"><i class="fa fa-plus"></i>{{lbl.add}}</a>
88
<div ng-if="IsPrimary" class="btn-group befdv pull-left">
9-
<button ng-click="processChecked('uninstall')" ng-disabled="itemsChecked() === false" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></button>
9+
<a ng-click="processChecked('uninstall')" ng-disabled="itemsChecked() === false" class="btn btn-sm btn-danger" angular-tooltip tooltip="lbl.doDelete"><i class="fa fa-trash"></i></a>
10+
<a ng-click="processChecked('disable')" ng-disabled="itemsChecked() === false" class="btn btn-sm btn-warning" angular-tooltip tooltip="lbl.disable"><i class="fa fa-close"></i></a>
11+
<a ng-click="processChecked('enable')" ng-disabled="itemsChecked() === false" class="btn btn-sm btn-success" angular-tooltip tooltip="lbl.enable"><i class="fa fa-check"></i></a>
1012
</div>
1113
<div class="search pull-right">
1214
<i class="fa fa-search"></i>
@@ -18,54 +20,34 @@ <h2 class="page-title pull-left">
1820
<table class="table table-item-plugins">
1921
<thead>
2022
<tr>
21-
<th class="item-checkbox"><input type="checkbox" id="chkAll" ng-click="checkAll($event)" /></th>
22-
<th class="item-title">{{lbl.title}}</th>
23-
<th class="item-desc">{{lbl.description}}</th>
24-
<th class="item-version">{{lbl.version}}</th>
25-
<th class="item-priority">{{lbl.priority}}</th>
26-
<th class="item-checkbox">{{lbl.enabled}}</th>
27-
<th class="item-button">{{lbl.status}}</th>
23+
<th><input type="checkbox" id="chkAll" ng-click="checkAll($event)" /></th>
24+
<th>{{lbl.title}}</th>
25+
<th>{{lbl.description}}</th>
26+
<th>{{lbl.version}}</th>
27+
<th>{{lbl.priority}}</th>
28+
<th>{{lbl.enabled}}</th>
2829
</tr>
2930
</thead>
3031
<tbody>
3132
<tr data-ng-repeat="item in pagedItems[currentPage]">
3233
<td class="item-checkbox">
33-
<input ng-if="IsPrimary" type="checkbox" id="{{item.Id}}" data-ng-model="item.IsChecked" ng-disabled="item.OnlineVersion === ''" />
34+
<input ng-if="IsPrimary" type="checkbox" id="{{item.Id}}" data-ng-model="item.IsChecked" />
3435
</td>
3536
<td class="item-title">
3637
<a title="{{item.Title}}" href="#/custom/package?id={{item.Id}}">
3738
{{item.Title}}
3839
</a>
3940
</td>
40-
<td class="item-desc"><span class=" text-ellipsis">{{item.Description}}</span></td>
41+
<td class="item"><span class="text-ellipsis">{{item.Description}}</span></td>
4142
<td class="item-version">
4243
<span ng-if="item.OnlineVersion.length == 0">{{item.LocalVersion}}</span>
4344
<span ng-if="item.OnlineVersion.length > 0">{{item.OnlineVersion}}</span>
4445
</td>
4546
<td class="item-priority">{{item.Priority}}</td>
4647
<td class="item-state"><input type="checkbox" data-ng-model="item.Enabled" data-ng-disabled="true"></td>
47-
<td>
48-
<a ng-if="IsPrimary && item.Enabled" href="" ng-click="enableExtension(item, false)" class="btn btn-sm btn-danger">Disable</a>
49-
<a ng-if="IsPrimary && !item.Enabled" href="" ng-click="enableExtension(item, true)" class="btn btn-sm btn-success">Enable</a>
50-
</td>
5148
</tr>
5249
</tbody>
5350
</table>
54-
55-
56-
<!--<div data-ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse">
57-
<input ng-if="IsPrimary" type="checkbox" id="{{item.Id}}" data-ng-model="item.IsChecked" ng-disabled="item.OnlineVersion === ''" />
58-
<a title="{{item.Title}}" href="#/custom/package?id={{item.Id}}">
59-
<img width="48" ng-if="item.IconUrl === ''" src="../Content/images/blog/ext.png" />
60-
<img width="48" ng-if="item.IconUrl != ''" ng-src="{{item.IconUrl}}" />
61-
</a>
62-
<p ng-if="!item.Enabled">{{item.Title}} (Disabled)</p>
63-
<p ng-if="item.Enabled">{{item.Title}}</p>
64-
<a ng-if="IsPrimary && item.Enabled" href="" ng-click="enableExtension(item, false)" class="btn btn-sm btn-danger">Disable</a>
65-
<a ng-if="IsPrimary && !item.Enabled" href="" ng-click="enableExtension(item, true)" class="btn btn-sm btn-success">Enable</a>
66-
<a ng-if="item.SettingsUrl != ''" href="#/custom/package?id={{item.Id}}" class="btn btn-sm btn-default">Customize</a>
67-
<hr />
68-
</div>-->
6951
<ul class="pagination" ng-if="items.length > itemsPerPage">
7052
<li data-ng-class="{disabled: currentPage == 0}">
7153
<a data-ng-click="prevPage()" title="{{lbl.prev}}"><i class="fa fa-angle-left"></i></a>

0 commit comments

Comments
 (0)