Merge branch 'ClearUnassignedCards-#69' into Release0.2
This commit is contained in:
commit
552abaac49
@ -66,6 +66,10 @@ namespace Interfaces
|
||||
/// <see cref="IdentifierList"/> with nested <see cref="Identifier"/> list
|
||||
/// </returns>
|
||||
IdentifierList GetUnassignedIdentifierList();
|
||||
/// <summary>
|
||||
/// Remove all unassigned identifiers from the system.
|
||||
/// </summary>
|
||||
void ClearUnassignedIdentifiers();
|
||||
|
||||
/// <summary>
|
||||
/// Update a user in the system with the new values.
|
||||
|
||||
@ -63,6 +63,9 @@ namespace SQLiteRepository
|
||||
public const string GET_UNASSIGNED_CARD_LIST =
|
||||
"select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?";
|
||||
|
||||
public const string CLEAR_UNASSIGNED_CARDS =
|
||||
"delete from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?";
|
||||
|
||||
public const string UPDATE_CARD_USER_ID =
|
||||
"update " + nameof(CardUniqueId) + " set " + nameof(CardUniqueId.UserId_FK) + "=? where " +
|
||||
nameof(CardUniqueId.Id) + "=?";
|
||||
|
||||
@ -309,6 +309,13 @@ namespace SQLiteRepository
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void ClearUnassignedIdentifiers()
|
||||
{
|
||||
_connection.Execute(
|
||||
SQLiteProcedures.CLEAR_UNASSIGNED_CARDS,
|
||||
Constants.UNASSIGNED_CARD_USER_ID);
|
||||
}
|
||||
|
||||
//TODO: Check time logs table on update to ensure associated cards/unique identifiers are removed/added as appropriate.
|
||||
public OperationResponse UpdateUser(User user, out int userIdResult)
|
||||
{
|
||||
|
||||
@ -77,7 +77,6 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyVersionInfo.cs" />
|
||||
<Compile Include="CardUniqueId.cs" />
|
||||
<Compile Include="DBVersion.cs" />
|
||||
<Compile Include="GroupDb.cs" />
|
||||
@ -107,9 +106,6 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="UpgradeScripts\0.2.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="UpgradeScripts\0.3.sql" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
||||
@ -27,5 +27,15 @@ namespace WindowsDataCenter
|
||||
_logger.Trace("Call to GetUnassignedCards, returning {0} items", unassignedCards.data.Count);
|
||||
return Ok(unassignedCards);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
[Route("unassigned")]
|
||||
[CacheControl(MaxAge = 0)]
|
||||
public IHttpActionResult ClearUnassignedCards()
|
||||
{
|
||||
_repo.ClearUnassignedIdentifiers();
|
||||
_logger.Trace("Call to ClearUnassignedCards, removed all identifiers.");
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,8 +76,34 @@
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="CardManagement" class="container">
|
||||
<div class="row">
|
||||
<h2 class="col-md-4">Unassigned Cards</h2>
|
||||
<button class="col-md-1 btn btn-default pull-right" style="margin-top: 20px;" data-bind="click: $root.clearUnassignedCards">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div data-bind="with: unassignedCardList">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Card Unique Id</th>
|
||||
<th>Last Used Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: data">
|
||||
<tr>
|
||||
<td data-bind="text: UniqueId"></td>
|
||||
<td data-bind="text: $root.convertToDisplayDateTime(LastUsed)"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="Helpers.min.js" type="text/javascript"></script>
|
||||
<script src="admin.min.js" type="text/javascript"></script>
|
||||
<script src="admin.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -2,6 +2,7 @@
|
||||
var self = this;
|
||||
self.groupsList = ko.observable(null);
|
||||
self.groupEditItem = ko.observable(null);
|
||||
self.unassignedCardList = ko.observable(null);
|
||||
self.helpers = new Helpers();
|
||||
self.uiPages = {
|
||||
overview: "overview",
|
||||
@ -11,7 +12,9 @@
|
||||
self.apiEndpoints = {
|
||||
deleteGroups:"/api/groups/delete",
|
||||
getGroups: "/api/groups",
|
||||
editGroup: "/api/groups/edit"
|
||||
editGroup: "/api/groups/edit",
|
||||
getUnassignedCards: "/api/cards/unassigned",
|
||||
clearUnassignedCards: "/api/cards/unassigned"
|
||||
};
|
||||
self.clearGroupForm = function () {
|
||||
self.helpers.goToMenuOption(self.uiPages.group);
|
||||
@ -69,10 +72,48 @@
|
||||
var errorObj = self.helpers.processRequestFailure(resp, status, error);
|
||||
});
|
||||
};
|
||||
self.getUnassignedCardData = function() {
|
||||
var url = self.helpers.createRequestUrl(self.apiEndpoints.getUnassignedCards, null, false);
|
||||
$.getJSON(url,
|
||||
function(res) {
|
||||
self.unassignedCardList(res);
|
||||
}).fail(function(resp, status, error) {
|
||||
console.log("error - getUnassignedCards");
|
||||
var errorObj = self.helpers.processRequestFailure(resp, status, error);
|
||||
});
|
||||
};
|
||||
self.clearUnassignedCards = function() {
|
||||
var url = self.helpers.createRequestUrl(self.apiEndpoints.clearUnassignedCards, null, false);
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: url,
|
||||
data: "",
|
||||
success: function() {
|
||||
self.getUnassignedCardData(); //update
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
console.log("error - clearUnassignedCards");
|
||||
var errorObj = self.helpers.processRequestFailure(resp, status, error);
|
||||
}
|
||||
});
|
||||
};
|
||||
self.padNumber = function (number) {
|
||||
return (number < 10 ? "0" : "") + number;
|
||||
};
|
||||
self.convertToDisplayDateTime = function (dateValue) {
|
||||
var date = new Date(dateValue); // dd MM YY HH:mm:ss e.g.: 01 Mar 17 17:34:02
|
||||
return date.getDate() + " "
|
||||
+ date.toLocaleString("en-us", { month: "long" }) + " "
|
||||
+ (date.getYear()-100) + " "
|
||||
+ self.padNumber(date.getHours()) + ":"
|
||||
+ self.padNumber(date.getMinutes()) + ":"
|
||||
+ self.padNumber(date.getSeconds());
|
||||
};
|
||||
Sammy(function () {
|
||||
this.disable_push_state = true;
|
||||
this.get("#overview", function () {
|
||||
self.getGroups();
|
||||
self.getUnassignedCardData();
|
||||
});
|
||||
this.post("#editgroup", function () {
|
||||
self.submitGroupEdit(self.groupEditItem());
|
||||
|
||||
@ -1 +1 @@
|
||||
function AdminVM(){var n=this;n.groupsList=ko.observable(null);n.groupEditItem=ko.observable(null);n.helpers=new Helpers;n.uiPages={overview:"overview",group:"groups",home:function(){return this.overview}};n.apiEndpoints={deleteGroups:"/api/groups/delete",getGroups:"/api/groups",editGroup:"/api/groups/edit"};n.clearGroupForm=function(){n.helpers.goToMenuOption(n.uiPages.group);n.groupEditItem(null)};n.hideGroupForm=function(){n.groupEditItem(null)};n.newGroupForm=function(){n.groupEditItem({Id:-1,Name:""});n.helpers.goToMenuOption(n.uiPages.group)};n.groupFormHidden=ko.computed(function(){return n.groupEditItem()==null},n);n.editGroupClick=function(t){n.helpers.goToMenuOption(n.uiPages.group);n.groupEditItem(t)};n.getGroups=function(){var t=n.helpers.createRequestUrl(n.apiEndpoints.getGroups,null,!1);$.getJSON(t,function(t){n.groupsList(t)}).fail(function(t,i,r){console.log("error - getGroups");var u=n.helpers.processRequestFailure(t,i,r)})};n.deleteGroup=function(t){var i=n.helpers.createRequestUrl(n.apiEndpoints.deleteGroups,[{key:"groupId",value:t}],!1,!1);$.ajax({url:i,type:"DELETE",success:function(){console.log("deleted "+t);n.hideGroupForm();n.helpers.goToMenuOption(n.uiPages.home())}});console.log("delete: "+t)};n.submitGroupEdit=function(t){var i=n.helpers.createRequestUrl(n.apiEndpoints.editGroup,null,!1);$.post(i,t,function(){},"json").done(function(){n.groupEditItem(null);n.helpers.goToMenuOption(n.uiPages.home())}).fail(function(t,i,r){n.helpers.goToMenuOption(n.uiPages.home());var u=n.helpers.processRequestFailure(t,i,r)})};Sammy(function(){this.disable_push_state=!0;this.get("#overview",function(){n.getGroups()});this.post("#editgroup",function(){return n.submitGroupEdit(n.groupEditItem()),!1});this.get("",function(){this.app.runRoute("get","#"+n.uiPages.home())})}).run()}ko.applyBindings(new AdminVM)
|
||||
function AdminVM(){var n=this;n.groupsList=ko.observable(null);n.groupEditItem=ko.observable(null);n.unassignedCardList=ko.observable(null);n.helpers=new Helpers;n.uiPages={overview:"overview",group:"groups",home:function(){return this.overview}};n.apiEndpoints={deleteGroups:"/api/groups/delete",getGroups:"/api/groups",editGroup:"/api/groups/edit",getUnassignedCards:"/api/cards/unassigned",clearUnassignedCards:"/api/cards/unassigned"};n.clearGroupForm=function(){n.helpers.goToMenuOption(n.uiPages.group);n.groupEditItem(null)};n.hideGroupForm=function(){n.groupEditItem(null)};n.newGroupForm=function(){n.groupEditItem({Id:-1,Name:""});n.helpers.goToMenuOption(n.uiPages.group)};n.groupFormHidden=ko.computed(function(){return n.groupEditItem()==null},n);n.editGroupClick=function(t){n.helpers.goToMenuOption(n.uiPages.group);n.groupEditItem(t)};n.getGroups=function(){var t=n.helpers.createRequestUrl(n.apiEndpoints.getGroups,null,!1);$.getJSON(t,function(t){n.groupsList(t)}).fail(function(t,i,r){console.log("error - getGroups");var u=n.helpers.processRequestFailure(t,i,r)})};n.deleteGroup=function(t){var i=n.helpers.createRequestUrl(n.apiEndpoints.deleteGroups,[{key:"groupId",value:t}],!1,!1);$.ajax({url:i,type:"DELETE",success:function(){console.log("deleted "+t);n.hideGroupForm();n.helpers.goToMenuOption(n.uiPages.home())}});console.log("delete: "+t)};n.submitGroupEdit=function(t){var i=n.helpers.createRequestUrl(n.apiEndpoints.editGroup,null,!1);$.post(i,t,function(){},"json").done(function(){n.groupEditItem(null);n.helpers.goToMenuOption(n.uiPages.home())}).fail(function(t,i,r){n.helpers.goToMenuOption(n.uiPages.home());var u=n.helpers.processRequestFailure(t,i,r)})};n.getUnassignedCardData=function(){var t=n.helpers.createRequestUrl(n.apiEndpoints.getUnassignedCards,null,!1);$.getJSON(t,function(t){n.unassignedCardList(t)}).fail(function(t,i,r){console.log("error - getUnassignedCards");var u=n.helpers.processRequestFailure(t,i,r)})};n.clearUnassignedCards=function(){var t=n.helpers.createRequestUrl(n.apiEndpoints.clearUnassignedCards,null,!1);$.ajax({type:"DELETE",url:t,data:"",success:function(){n.getUnassignedCardData()},error:function(t,i,r){console.log("error - clearUnassignedCards");var u=n.helpers.processRequestFailure(resp,i,r)}})};n.padNumber=function(n){return(n<10?"0":"")+n};n.convertToDisplayDateTime=function(t){var i=new Date(t);return i.getDate()+" "+i.toLocaleString("en-us",{month:"long"})+" "+(i.getYear()-100)+" "+n.padNumber(i.getHours())+":"+n.padNumber(i.getMinutes())+":"+n.padNumber(i.getSeconds())};Sammy(function(){this.disable_push_state=!0;this.get("#overview",function(){n.getGroups();n.getUnassignedCardData()});this.post("#editgroup",function(){return n.submitGroupEdit(n.groupEditItem()),!1});this.get("",function(){this.app.runRoute("get","#"+n.uiPages.home())})}).run()}ko.applyBindings(new AdminVM)
|
||||
Loading…
Reference in New Issue
Block a user