v1.1.7
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using Saxonite.Net.Core.Web.Admin.Models;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
// Home - Ajax - Awaiting Activation controller
|
||||
//=======================================================================
|
||||
partial class HomeController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Items Awaiting Activation data.
|
||||
private class ActivationItemData
|
||||
{
|
||||
public String ItemType { get; set; }
|
||||
public String ItemTypeDesc { get; set; }
|
||||
public String ItemTypeDescPlural { get; set; }
|
||||
public long ItemCount { get; set; }
|
||||
public String ViewLink { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Items Awaiting Activation ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_ItemsAwaitingActivation : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_ItemsAwaitingActivation(SaxModel_Admin model) : base(model) { }
|
||||
// Table list.
|
||||
public List<ActivationItemData> Items { get; } = new List<ActivationItemData>();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Home/Ajax/GetItemsAwaitingActivation")]
|
||||
public IActionResult Ajax_GetItemsAwaitingActivation(Model_Sport model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetItemsAwaitingActivation";
|
||||
String messageTitle = Localiser["home.caption.application"];
|
||||
AjaxResponse_ItemsAwaitingActivation responseData = new AjaxResponse_ItemsAwaitingActivation(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Core Database connection.
|
||||
ISacsDatabase db = SaxGlobals.App.GetCoreDatabase(SessionContext);
|
||||
|
||||
// Query to count items awaiting activation.
|
||||
Dictionary<String, int> tableRowCounts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
List<String> query = new List<string>()
|
||||
{
|
||||
// User accounts.
|
||||
"SELECT",
|
||||
"ItemType = '" + DbQuery.FormatForCondition(nameof(Sax.DataItemType.UserAccount)) + "',",
|
||||
"ItemCount = Count(*)",
|
||||
"FROM UserAccount ua",
|
||||
"WHERE ua.Status = 'AWA'",
|
||||
// Organisations.
|
||||
"UNION SELECT",
|
||||
"ItemType = '" + DbQuery.FormatForCondition(nameof(Sax.DataItemType.Organisation)) + "',",
|
||||
"ItemCount = Count(*)",
|
||||
"FROM Organisation org",
|
||||
"WHERE org.Status = 'AWA'",
|
||||
};
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, query.Concat("\n")))
|
||||
{
|
||||
while (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
Sax.DataItemType itemType = EnumUtil.ParseEnum(dbResultSet.GetRecordValues().GetValue("ItemType").ToString(), Sax.DataItemType.Unknown);
|
||||
String itemTypeDesc = nameof(itemType);
|
||||
String itemTypeDescPlural = itemTypeDesc;
|
||||
String viewLink = "";
|
||||
switch (itemType)
|
||||
{
|
||||
case Sax.DataItemType.UserAccount:
|
||||
itemTypeDesc = "User Account";
|
||||
itemTypeDescPlural = "User Accounts";
|
||||
viewLink = Url.Action("", "User", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
|
||||
break;
|
||||
case Sax.DataItemType.Organisation:
|
||||
itemTypeDesc = "Organisation";
|
||||
itemTypeDescPlural = "Organisations";
|
||||
viewLink = Url.Action("", "Organisation", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
|
||||
break;
|
||||
}
|
||||
ActivationItemData activationItem = new ActivationItemData()
|
||||
{
|
||||
ItemType = nameof(itemType),
|
||||
ItemTypeDesc = itemTypeDesc,
|
||||
ItemTypeDescPlural = itemTypeDescPlural,
|
||||
ItemCount = dbResultSet.GetRecordValues().GetValue("ItemCount").AsLong(),
|
||||
ViewLink = viewLink,
|
||||
};
|
||||
responseData.Items.Add(activationItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -17,7 +17,7 @@ using System.Threading.Tasks;
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
public class HomeController : SaxController_Admin
|
||||
public partial class HomeController : SaxController_Admin
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
public IActionResult Index(String sta)
|
||||
{
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
@@ -37,6 +37,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
model.Paging.PageNo = 1;
|
||||
model.Paging.PageLength = 6;
|
||||
|
||||
// Default status.
|
||||
if (sta.StartsWithCI("Awa"))
|
||||
model.Filter.OrganisationStatusCategoryCode = nameof(SaxOrganisation.StatusCat.AwaitingOnly);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,9 +138,15 @@
|
||||
<data name="home.caption.application" xml:space="preserve">
|
||||
<value>Admin</value>
|
||||
</data>
|
||||
<data name="home.caption.awaiting.activation" xml:space="preserve">
|
||||
<value>Awaiting Activation</value>
|
||||
</data>
|
||||
<data name="home.caption.home" xml:space="preserve">
|
||||
<value>Home</value>
|
||||
</data>
|
||||
<data name="home.msg.no.items.awaiting.activation" xml:space="preserve">
|
||||
<value>No items are awaiting activation</value>
|
||||
</data>
|
||||
<data name="label.accounts" xml:space="preserve">
|
||||
<value>Accounts</value>
|
||||
</data>
|
||||
@@ -237,6 +243,9 @@
|
||||
<data name="label.items.available" xml:space="preserve">
|
||||
<value>Available items</value>
|
||||
</data>
|
||||
<data name="label.items.awaiting.activation" xml:space="preserve">
|
||||
<value>Items awaiting activation</value>
|
||||
</data>
|
||||
<data name="label.keep.signed.in" xml:space="preserve">
|
||||
<value>Keep me signed-in</value>
|
||||
</data>
|
||||
|
||||
@@ -4,9 +4,35 @@
|
||||
}
|
||||
|
||||
<script>
|
||||
sax.msg.noItemsAwaitAct = '@Localiser.GetJavascriptText("home.msg.no.items.awaiting.activation")';
|
||||
sax.msg.dbSchemaValid = '@Localiser.GetJavascriptText("system.msg.database.schema.valid")';
|
||||
</script>
|
||||
|
||||
@* Items Awaiting Activation *@
|
||||
<div class="sax-panel-info sax-panel-results AwaitActivate">
|
||||
|
||||
<div class="sax-header">
|
||||
<div class="sax-caption">@Localiser["home.caption.awaiting.activation"]</div>
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<div class="sax-panel-messages"></div>
|
||||
<div class="sax-panel-item-list"></div>
|
||||
@* Items awaiting activation templates *@
|
||||
<div class="sax-panel-item-template">
|
||||
<div class="sax-panel-item AwaitActivateItem">
|
||||
<div class="sax-header">
|
||||
<div class="sax-caption sax-action sax-view AwaitActivateItemType"></div>
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<div class="SchemaIndex">@(Localiser["label.items.awaiting.activation"]): <span class="AwaitActivateItemCount"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@* Database Schema *@
|
||||
<div class="sax-panel-info sax-panel-results DbSchema">
|
||||
|
||||
<div class="sax-header">
|
||||
@@ -16,6 +42,7 @@
|
||||
<div class="sax-panel-messages"></div>
|
||||
<div class="sax-panel-item-list"></div>
|
||||
<div class="sax-panel-item-template">
|
||||
@* Db Schema templates *@
|
||||
<div class="sax-panel-item DbSchemaItem">
|
||||
<div class="sax-header">
|
||||
<div class="sax-caption SchemaTable">@(Localiser["label.table"]): <span class="TableName"></span></div>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
margin: 24px auto;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
border: solid 2px #979797;
|
||||
border: solid 1px #979797;
|
||||
border-color: var(--color-primary);
|
||||
border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
|
||||
@@ -336,7 +336,7 @@ a:focus
|
||||
|
||||
.ui-dialog.ui-widget.ui-widget-content
|
||||
{
|
||||
border-width: 2px;
|
||||
border-width: 1px;
|
||||
border-color: #d4af37;
|
||||
-moz-box-shadow: 4px 4px 6px #ccc;
|
||||
-webkit-box-shadow: 4px 4px 6px #ccc;
|
||||
|
||||
@@ -5,17 +5,59 @@
|
||||
(function (win, doc, undef)
|
||||
{
|
||||
"use strict";
|
||||
let $pnl = sax.$pnl, $dlg = sax.$dlg, $frm = sax.$frm;
|
||||
sax.itemIdPrefix = 'Itm_';
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sax.refreshDbSchema= function (delay)
|
||||
sax.refreshAwaitActivate = function (delay)
|
||||
{
|
||||
if (sax.awaitingLogin) return;
|
||||
var $results = $('.sax-panel-results.DbSchema');
|
||||
if (!sax.awaitingRefreshResponse)
|
||||
{
|
||||
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
|
||||
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
var $items = $('.sax-panel-item-list', $pnl.awaitAct).fadeOut(200).empty();
|
||||
var $msgs = $('.sax-panel-messages', $pnl.awaitAct).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
}
|
||||
sax.ajax.awaitAct = sax.ajax.awaitAct || { url: sax.url.base + 'Home/Ajax/GetItemsAwaitingActivation', formId: 'frmNavigate', callbackFn: sax.handleAwaitActivateResponse, noWaitIcon: true };
|
||||
sax.doAjaxRequest(sax.ajax.awaitAct, delay || 50);
|
||||
sax.awaitingRefreshResponse = true;
|
||||
}
|
||||
sax.handleAwaitActivateResponse = function (response)
|
||||
{
|
||||
//sax.debug('handleAwaitActivateResponse', response);
|
||||
delete sax.awaitingRefreshResponse;
|
||||
var $msgs = $('.sax-panel-messages', $pnl.awaitAct).hide().empty();
|
||||
var $items = $('.sax-panel-item-list', $pnl.awaitAct).hide().empty();
|
||||
var $tmpl = $('.sax-panel-item-template .sax-panel-item.AwaitActivateItem', $pnl.awaitAct);
|
||||
if (!response.success) return;
|
||||
// Items.
|
||||
var items = response.items;
|
||||
if (!items.length)
|
||||
return $msgs.append($('<div class="sax-message">' + sax.msg.noItemsAwaitAct + '</div>')).fadeIn(500);
|
||||
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
|
||||
$items.append(sax.populateAwaitActivateItem($tmpl.clone(), items[itemIdx]));
|
||||
$items.slideDown(750);
|
||||
}
|
||||
sax.populateAwaitActivateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
if (item.viewLink)$('.sax-action.sax-view', $item).on('click', function () { sax.goToPage(item.viewLink); });
|
||||
$('.AwaitActivateItemType', $item).text(item.itemTypeDescPlural);
|
||||
$('.AwaitActivateItemCount', $item).text(item.itemCount);
|
||||
return $item;
|
||||
}
|
||||
sax.getAwaitActivateItemTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-panel-item.AwaitActivateItem', $pnl.results).clone();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sax.refreshDbSchema = function (delay)
|
||||
{
|
||||
if (sax.awaitingLogin) return;
|
||||
if (!sax.awaitingRefreshResponse)
|
||||
{
|
||||
var $items = $('.sax-panel-item-list', $pnl.dbSchema).fadeOut(200).empty();
|
||||
var $msgs = $('.sax-panel-messages', $pnl.dbSchema).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
}
|
||||
sax.ajax.dbSchema = sax.ajax.dbSchema || { url: sax.url.base + 'System/Ajax/ValidateDatabaseSchema', formId: 'frmNavigate', callbackFn: sax.handleDbSchemaResponse, noWaitIcon: true };
|
||||
sax.doAjaxRequest(sax.ajax.dbSchema, delay || 50);
|
||||
@@ -25,25 +67,19 @@
|
||||
{
|
||||
//sax.debug('handleDbSchemaResponse', response);
|
||||
delete sax.awaitingRefreshResponse;
|
||||
var $results = $('.sax-panel-results.DbSchema');
|
||||
var $msgs = $('.sax-panel-messages', $results).hide().empty();
|
||||
var $items = $('.sax-panel-item-list', $results).hide().empty();
|
||||
var $tmpl = $('.sax-panel-item-template .sax-panel-item.DbSchemaItem', $results);
|
||||
var $msgs = $('.sax-panel-messages', $pnl.dbSchema).hide().empty();
|
||||
var $items = $('.sax-panel-item-list', $pnl.dbSchema).hide().empty();
|
||||
var $tmpl = $('.sax-panel-item-template .sax-panel-item.DbSchemaItem', $pnl.dbSchema);
|
||||
if (!response.success) return;
|
||||
// Items.
|
||||
var items = response.items;
|
||||
if (!items.length)
|
||||
return $msgs.append($('<div class="sax-message">' + sax.msg.dbSchemaValid + '</div>')).fadeIn(500);
|
||||
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
|
||||
{
|
||||
let item = items[itemIdx];
|
||||
let $item = $tmpl.clone();
|
||||
sax.populateItem($item, item);
|
||||
$items.append($item);
|
||||
}
|
||||
$items.fadeIn(50);
|
||||
$items.append(sax.populateDbSchemaItem($tmpl.clone(), items[itemIdx]));
|
||||
$items.slideDown(750);
|
||||
}
|
||||
sax.populateItem = function ($item, item)
|
||||
sax.populateDbSchemaItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
$item.prop('id', sax.itemIdPrefix + item.id);
|
||||
@@ -53,11 +89,16 @@
|
||||
$('.ColumnName', $item).text(item.columnName);
|
||||
$('.SchemaColumn', $item).toggle(!!item.columnName);
|
||||
$('.Comment', $item).text(item.comment);
|
||||
return $item;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
$(function ()
|
||||
{
|
||||
$pnl.awaitAct = $('.sax-panel-results.AwaitActivate');
|
||||
$pnl.dbSchema = $('.sax-panel-results.DbSchema');
|
||||
|
||||
setTimeout(sax.refreshAwaitActivate, 250);
|
||||
setTimeout(sax.refreshDbSchema, 250);
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
$('.UserFirstName', $item).text(item.firstName);
|
||||
$('.UserLastName', $item).text(item.lastName);
|
||||
$('.UserRoleCount', $item).text(item.userRoleCount);
|
||||
$('.StatusDesc', $item).text(item.statusDesc);
|
||||
$('.StatusDesc', $item).text(item.statusDesc).addClass('sax-status-' + item.statusCode.toLowerCase());
|
||||
$('.sax-caption .sax-action').toggleClass('sax-action', !item.deleted);
|
||||
let $mnu = $('ul.sax-dropdown-menu', $item);
|
||||
if (!item.deleted)
|
||||
|
||||
Reference in New Issue
Block a user