Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down Expand Up @@ -199,3 +199,4 @@ FakesAssemblies/
License.config
/Blomsterringen.Web/imagecache
maildrop
.idea
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ All notable changes to this project will be documented in this file.

## [11.0.0]
- Upgraded to CMS 11
- Upgraded to framework version 4.6.1
- Upgraded to framework version 4.6.1

## [11.0.4.6]
- Adding query string capability to filter data by column and exact value
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Where can I get it?
1. Add [EPiServer Nuget feed](http://nuget.episerver.com/en/Feed/) in Visual Studio Package Manager options (Tools ->Options -> Package Manager -> Package Sources).
1. Install DDSAdmin via NuGet in Visual Studio. Ensure that you also install the required dependencies.
1. Rebuild your solution.
1. Start editing your data in EPiServer DDS storages. It will be available in CMS menu: Geta->DDS Admin.
1. Start editing your data in EPiServer DDS storage's. It will be available in CMS menu: Geta->DDS Admin.

Where can I get more info?
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/Dds/Interfaces/ICrudService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public interface ICrudService
{
StringResponse Create(string storeName, Dictionary<string, string> values);
StringResponse Delete(string storeName, string identityId);
ReadResponse Read(string storeName, int start, int pageSize, string search, int sortByColumn, string sortDirection);
ReadResponse Read(string storeName, int start, int pageSize, string search, int sortByColumn, string sortDirection, string filterByColumn, string filterValue);
StringResponse Update(string storeName, int columnId, string value, string id, string columnName);
}
}
38 changes: 27 additions & 11 deletions src/Dds/Services/CrudService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public StringResponse Delete(string storeName, string identityId)
return response;
}

public ReadResponse Read(string storeName, int start, int pageSize, string search, int sortByColumn, string sortDirection)
public ReadResponse Read(string storeName, int start, int pageSize, string search, int sortByColumn, string sortDirection, string filterByColumn, string filterValue)
{
var response = new ReadResponse { Success = false };
logger.Debug("Read started");
Expand All @@ -83,22 +83,38 @@ public ReadResponse Read(string storeName, int start, int pageSize, string searc
var store = DynamicDataStoreFactory.Instance.GetStore(storeName);
var storeMetadata = store.Metadata();

// TODO: we cannot order here due to fact that this is PropertyBag, if we could it would be great performance boost
// var orderBy = sortByColumn == 0 ? "Id" : StoreMetadata.Columns.ToList()[sortByColumn - 1].PropertyName;
var query = store.ItemsAsPropertyBag(); // .OrderBy(orderBy);
List<PropertyBag> data;
int count;

var data = sortByColumn == 0 && string.IsNullOrEmpty(search)
? (sortDirection == "asc"
? query.OrderBy(r => r.Id).Skip(start).Take(pageSize).ToList()
: query.OrderByDescending(r => r.Id).Skip(start).Take(pageSize).ToList())
: query.ToList();
var preSorted = false;

if (string.IsNullOrWhiteSpace(filterByColumn))
{
// TODO: we cannot order here due to fact that this is PropertyBag, if we could it would be great performance boost
// var orderBy = sortByColumn == 0 ? "Id" : StoreMetadata.Columns.ToList()[sortByColumn - 1].PropertyName;
var query = store.ItemsAsPropertyBag(); // .OrderBy(orderBy);

preSorted = sortByColumn == 0 && string.IsNullOrEmpty(search);
Comment thread
gatisb marked this conversation as resolved.

data = preSorted
? (sortDirection == "asc"
? query.OrderBy(r => r.Id).Skip(start).Take(pageSize).ToList()
: query.OrderByDescending(r => r.Id).Skip(start).Take(pageSize).ToList())
: query.ToList();
count = query.Count();
}
else
{
data = store.FindAsPropertyBag(filterByColumn, filterValue).ToList();
count = data.Count;
}

List<List<string>> stringData;
if (sortByColumn == 0 && string.IsNullOrEmpty(search))
if (preSorted)
{
// no sorting and no filtering, use fast code then
stringData = FormatData(storeMetadata, data);
totalCount = query.Count();
totalCount = count;
}
else
{
Expand Down
16 changes: 14 additions & 2 deletions src/Dds/Services/StoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,24 @@ public bool Delete(string storeName, Identity id)
}
}

public bool Flush(string storeName)
public bool Flush(string storeName, string filterColumnName, string filter)
Comment thread
gatisb marked this conversation as resolved.
{
try
{
var store = DynamicDataStoreFactory.Instance.GetStore(storeName);
store.DeleteAll();
if (!string.IsNullOrWhiteSpace(filterColumnName))
{
var itemsToBeDeleted = store.FindAsPropertyBag(filterColumnName, filter).ToList();
foreach (var itemToBeDeleted in itemsToBeDeleted)
{
store.Delete(itemToBeDeleted.Id);
}
}
else
{
store.DeleteAll();
}

return true;
}
catch (Exception ex)
Expand Down
Binary file modified src/modules/_protected/Geta.DdsAdmin/Admin/Constants.cs
Binary file not shown.
10 changes: 7 additions & 3 deletions src/modules/_protected/Geta.DdsAdmin/Admin/Data.ashx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private BaseResponse Delete(HttpContext context, string storeName)
return SerializeResponse(context, deleteResponse);
}

private BaseResponse Read(HttpContext context, string storeName)
private BaseResponse Read(HttpContext context, string storeName, string filterColumnName, string filter)
Comment thread
gatisb marked this conversation as resolved.
{
int start = Convert.ToInt32(context.Request.QueryString["iDisplayStart"]);
int pageSize = Convert.ToInt32(context.Request.QueryString["iDisplayLength"]);
Expand All @@ -82,7 +82,7 @@ private BaseResponse Read(HttpContext context, string storeName)
int sortByColumn = Convert.ToInt32(context.Request.QueryString["iSortCol_0"]);
string sortDirection = context.Request.QueryString["sSortDir_0"];

var readResponse = this.crudService.Read(storeName, start, pageSize, search, sortByColumn, sortDirection);
var readResponse = this.crudService.Read(storeName, start, pageSize, search, sortByColumn, sortDirection, filterColumnName, filter);

var result = new
{
Expand Down Expand Up @@ -113,6 +113,10 @@ private void WriteResponse(HttpContext context)
logger.InfoFormat("Operation:{0}", operation);
string storeName = context.Request.QueryString[Constants.StoreKey];
logger.InfoFormat("Store:{0}", operation);
string filterColumnName = context.Request.QueryString[Constants.FilterColumnNameKey];
logger.InfoFormat("Filter column name:{0}", filterColumnName);
string filter = context.Request.QueryString[Constants.FilterKey];
logger.InfoFormat("Filter:{0}", filter);

context.Response.Clear();
context.Response.ClearContent();
Expand All @@ -123,7 +127,7 @@ private void WriteResponse(HttpContext context)
{
case "read":
{
response = Read(context, storeName);
response = Read(context, storeName, filterColumnName, filter);
}
break;
case "update":
Expand Down
33 changes: 24 additions & 9 deletions src/modules/_protected/Geta.DdsAdmin/Admin/DdsAdmin.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<html>
<head runat="server" ID="head1">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<title><%# CurrentStoreName %></title>
<title><%# CurrentStoreName %> <%# CurrentFilterMessage%></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"> </script>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
Expand Down Expand Up @@ -49,15 +49,30 @@
</asp:repeater>
</form>

<h3><%= string.IsNullOrEmpty(CustomHeading) ? string.Format("Selected Store Type: {0}", CurrentStoreName) : CustomHeading %></h3>
<h3><%= string.IsNullOrEmpty(CustomHeading) ? string.Format("Selected Store Type: {0}", CurrentStoreName) : CustomHeading %> <%= CurrentFilterMessage %></h3>
<%= CustomMessage %>

<form runat="server">
<label for="CurrentFilterColumnName">Filter by column:</label>
<select id="CurrentFilterColumnName" name="CurrentFilterColumnName">
<option value="">--</option>
<% foreach(var columnName in Store.Columns.Select(x=> x.PropertyName).ToList()) { %>
<option value="<%= columnName %>" <%= CurrentFilterColumnName == columnName ? "selected='selected'" : string.Empty %>><%= columnName %></option>
<% } %>
</select>
<label for="CurrentFilter">by exact value:</label>
<input type="text" id="CurrentFilter" name="CurrentFilter" value="<%= CurrentFilter %>"/>
<span class="epi-cmsButton">
<asp:Button runat="server" ID="Flush" Text="Delete All Data" OnClick="FlushStore" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Delete" OnClientClick="return confirm('Are you really want to delete all data from ths table??')"/>
<asp:Button runat="server" ID="Filter" OnClick="FilterClick" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Search" Text="Filter"/>
</span>

<br/>

<span class="epi-cmsButton">
<asp:Button runat="server" ID="Flush" OnClick="FlushStoreClick" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Delete" />
</span>
<span class="epi-cmsButton">
<asp:Button runat="server" ID="Export" Text="Export to Excel" OnClick="ExportStore" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Export"/>
<asp:Button runat="server" ID="Export" OnClick="ExportStoreClick" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Export"/>
</span>
<input type="hidden" name="CurrentStoreName" value="<%= CurrentStoreName %>"/>
</form>
Expand All @@ -84,23 +99,23 @@

<script type="text/javascript" charset="utf-8">
$(function() {
var storeParameter = "<%= Constants.StoreKey %>=<%= CurrentStoreName %>";
var parameters = "<%= GetParameters() %>";
var dataTable = $('#storeItems').dataTable({
sDom: "Rlfrtip",
bJQueryUI: true,
bProcessing: true,
bServerSide: true,
sPaginationType: "full_numbers",
sAjaxSource: "Data.ashx?<%= Constants.OperationKey %>=read&" + storeParameter,
sAjaxSource: "Data.ashx?<%= Constants.OperationKey %>=read&" + parameters,
fnInitComplete: function(oSettings, json) {
initTooltip();
}
}).makeEditable({
sUpdateURL: "Data.ashx?<%= Constants.OperationKey %>=update&" + storeParameter,
sAddURL: "Data.ashx?<%= Constants.OperationKey %>=create&" + storeParameter,
sUpdateURL: "Data.ashx?<%= Constants.OperationKey %>=update&" + parameters,
sAddURL: "Data.ashx?<%= Constants.OperationKey %>=create&" + parameters,
sAddHttpMethod: "POST",
sDeleteHttpMethod: "POST",
sDeleteURL: "Data.ashx?<%= Constants.OperationKey %>=delete&" + storeParameter,
sDeleteURL: "Data.ashx?<%= Constants.OperationKey %>=delete&" + parameters,
oAddNewRowButtonOptions: {
label: "Add...",
icons: { primary: 'ui-icon-plus' }
Expand Down
Loading