feature: update expression browser and add plugin expression extensions

This commit is contained in:
Gary Sharp
2025-01-16 12:36:01 +11:00
parent 963970feeb
commit a3e1e1d030
23 changed files with 652 additions and 555 deletions
+1 -1
View File
@@ -191,7 +191,7 @@
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateBulkGenerate.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateCreatePackageModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateCreateModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateExpressionBrowserModel.cs" />
<Compile Include="UI\Config\Expressions\ConfigExpressionsBrowserModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateImportStatusModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateIndexModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateShowPackageModel.cs" />
@@ -1,8 +1,8 @@
using System.Collections.Generic;
namespace Disco.Models.UI.Config.DocumentTemplate
namespace Disco.Models.UI.Config.Expressions
{
public interface ConfigDocumentTemplateExpressionBrowserModel : BaseUIModel
public interface ConfigExpressionsBrowserModel : BaseUIModel
{
string DeviceType { get; set; }
string UserType { get; set; }
@@ -10,5 +10,6 @@ namespace Disco.Models.UI.Config.DocumentTemplate
Dictionary<string, string> Variables { get; set; }
Dictionary<string, string> ExtensionLibraries { get; set; }
Dictionary<string, string> PluginExtensionLibraries { get; set; }
}
}
+2
View File
@@ -531,6 +531,8 @@
<Compile Include="Plugins\Features\DetailsProvider\DetailsProviderService.cs" />
<Compile Include="Plugins\Features\DetailsProvider\UserContactFeature.cs" />
<Compile Include="Plugins\Features\DocumentHandlerProvider\DocumentHandlerProviderFeature.cs" />
<Compile Include="Plugins\Features\ExpressionExtensionProvider\ExpressionExtensionProviderFeature.cs" />
<Compile Include="Plugins\Features\ExpressionExtensionProvider\ExpressionExtensionRegistration.cs" />
<Compile Include="Plugins\Features\InsuranceProvider\InsuranceProviderFeature.cs" />
<Compile Include="Plugins\Features\InsuranceProvider\InsuranceProviderSubmitJobException.cs" />
<Compile Include="Plugins\Features\RepairProvider\RepairProvider2Feature.cs" />
@@ -5,9 +5,9 @@ namespace Disco.Services.Expressions
{
public class EvaluateExpressionPart : IExpressionPart
{
private Spring.Expressions.IExpression _Expression;
private RecognitionException _ExpressionParseException;
private EvaluateExpressionParseException _EvaluateParseException;
private Spring.Expressions.IExpression expression;
private RecognitionException expressionParseException;
private EvaluateExpressionParseException evaluateParseException;
public string RawSource { get; set; }
public string Source { get; set; }
@@ -18,18 +18,18 @@ namespace Disco.Services.Expressions
{
get
{
if (_ExpressionParseException == null)
if (expressionParseException == null)
return null;
else
if (_EvaluateParseException == null)
_EvaluateParseException = EvaluateExpressionParseException.FromRecognitionException(_ExpressionParseException, Source);
return _EvaluateParseException;
if (evaluateParseException == null)
evaluateParseException = EvaluateExpressionParseException.FromRecognitionException(expressionParseException, Source);
return evaluateParseException;
}
}
public bool ParseError
{
get { return (_ExpressionParseException != null); }
get { return (expressionParseException != null); }
}
public string ParseErrorMessage
{
@@ -61,21 +61,21 @@ namespace Disco.Services.Expressions
}
try
{
_Expression = Spring.Expressions.Expression.Parse(this.Source);
expression = Spring.Expressions.Expression.Parse(this.Source);
}
catch (RecognitionException ex)
{
_ExpressionParseException = ex;
expressionParseException = ex;
}
}
object IExpressionPart.Evaluate(object ExpressionContext, IDictionary Variables)
{
if (_ExpressionParseException == null)
if (expressionParseException == null)
{
return _Expression.GetValue(ExpressionContext, Variables);
return expression.GetValue(ExpressionContext, Variables);
}
throw _ExpressionParseException;
throw expressionParseException;
}
}
-5
View File
@@ -73,11 +73,6 @@ namespace Disco.Services.Expressions
return result;
}
internal static IExpression Parse(string source)
{
throw new NotImplementedException();
}
public Tuple<string, bool, object> Evaluate(object ExpressionContext, IDictionary Variables)
{
if (Count == 0)
@@ -11,7 +11,7 @@ namespace Disco.Services.Expressions
public string Name { get; set; }
public List<ExpressionTypeMemberDescriptor> Members { get; set; }
public static ExpressionTypeDescriptor Build(Type t, bool StaticDeclaredMembersOnly = true)
public static ExpressionTypeDescriptor Build(Type t, bool staticMembersOnly = true)
{
ExpressionTypeDescriptor i = new ExpressionTypeDescriptor
{
@@ -21,7 +21,7 @@ namespace Disco.Services.Expressions
i.Members = new List<ExpressionTypeMemberDescriptor>();
MemberInfo[] members;
if (StaticDeclaredMembersOnly)
if (staticMembersOnly)
members = t.GetMembers(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
else
members = t.GetMembers(BindingFlags.Public | BindingFlags.Instance);
@@ -46,10 +46,7 @@ namespace Disco.Services.Expressions
}
}
}
i.Members = (
from mi in i.Members
orderby mi.Name
select mi).ToList();
i.Members = i.Members.OrderBy(m => m.Name).ToList();
return i;
}
}
@@ -0,0 +1,40 @@
using Spring.Core.TypeResolution;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Disco.Services.Plugins.Features.ExpressionExtensionProvider
{
[PluginFeatureCategory(DisplayName = "Expression Extension")]
public abstract class ExpressionExtensionProviderFeature : PluginFeature
{
private static readonly Dictionary<string, ExpressionExtensionRegistration> registrations = new Dictionary<string, ExpressionExtensionRegistration>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, Assembly> pluginAssemblies = new Dictionary<string, Assembly>(StringComparer.OrdinalIgnoreCase);
public void RegisterExpressionExtension(string alias, Type extensionType)
{
if (!extensionType.IsClass || !extensionType.IsAbstract || !extensionType.IsSealed)
throw new ArgumentException("Expression Extension Types must be a static class", nameof(extensionType));
lock (registrations)
{
registrations.Add(alias, new ExpressionExtensionRegistration(Manifest, alias, extensionType));
var assemblyName = extensionType.Assembly.FullName.Substring(0, extensionType.Assembly.FullName.IndexOf(','));
pluginAssemblies[assemblyName] = extensionType.Assembly;
TypeRegistry.RegisterType(alias, extensionType);
}
}
public static List<ExpressionExtensionRegistration> GetExpressionExtensionRegistrations()
{
lock (registrations)
{
return registrations.Values.ToList();
}
}
public static bool TryGetExtensionAssembly(string assemblyName, out Assembly assembly)
=> pluginAssemblies.TryGetValue(assemblyName, out assembly);
}
}
@@ -0,0 +1,18 @@
using System;
namespace Disco.Services.Plugins.Features.ExpressionExtensionProvider
{
public class ExpressionExtensionRegistration
{
public PluginFeatureManifest FeatureManifest { get; }
public string Alias { get; }
public Type ExtensionType { get; }
public ExpressionExtensionRegistration(PluginFeatureManifest featureManifest, string alias, Type extensionType)
{
FeatureManifest = featureManifest;
Alias = alias;
ExtensionType = extensionType;
}
}
}
@@ -1,17 +1,46 @@
using Disco.Services.Authorization;
using Disco.Services.Expressions;
using Disco.Services.Plugins.Features.ExpressionExtensionProvider;
using Disco.Services.Web;
using System;
using System.Web.Compilation;
using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers
{
[DiscoAuthorize(Claims.DiscoAdminAccount)]
public partial class ExpressionsController : AuthorizedDatabaseController
{
[HttpPost, DiscoAuthorize(Claims.DiscoAdminAccount)]
public virtual ActionResult ValidateExpression(string Expression)
{
var part = new EvaluateExpressionPart(Expression);
return Json(Models.Expressions.ValidateExpressionModel.FromEvaluateExpressionPart(part), JsonRequestBehavior.AllowGet);
return Json(Models.Expressions.ValidateExpressionModel.FromEvaluateExpressionPart(part));
}
[HttpPost, DiscoAuthorize(Claims.Config.Show), ValidateAntiForgeryToken]
public virtual ActionResult TypeDescriptor(string type, bool staticMembersOnly = false)
{
if (string.IsNullOrWhiteSpace(type))
return new HttpStatusCodeResult(400, "Type is required");
var t = Type.GetType(type, false);
if (t == null)
{
var typeNameParts = type.Split(new string[] { ", " }, StringSplitOptions.None);
if (typeNameParts.Length < 2)
return Json("Invalid Type Specified");
if (!ExpressionExtensionProviderFeature.TryGetExtensionAssembly(typeNameParts[1], out var assembly))
return Json("Invalid Type Specified");
t = assembly.GetType(typeNameParts[0]);
if (t == null)
return Json("Invalid Type Specified");
}
return Json(ExpressionTypeDescriptor.Build(t, staticMembersOnly));
}
}
}
@@ -7,6 +7,7 @@ using Disco.Services.Authorization;
using Disco.Services.Documents;
using Disco.Services.Documents.ManagedGroups;
using Disco.Services.Expressions;
using Disco.Services.Plugins.Features.ExpressionExtensionProvider;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using Disco.Web.Areas.Config.Models.DocumentTemplate;
@@ -24,7 +25,7 @@ namespace Disco.Web.Areas.Config.Controllers
{
if (string.IsNullOrEmpty(id))
{
var m = new Models.DocumentTemplate.IndexModel()
var m = new IndexModel()
{
DocumentTemplates = Database.DocumentTemplates
.Select(dt => new
@@ -47,7 +48,7 @@ namespace Disco.Web.Areas.Config.Controllers
else
{
// Normal Document Template
var m = new Models.DocumentTemplate.ShowModel()
var m = new ShowModel()
{
DocumentTemplate = Database.DocumentTemplates.Include("JobSubTypes").FirstOrDefault(at => at.Id == id)
};
@@ -78,7 +79,7 @@ namespace Disco.Web.Areas.Config.Controllers
public virtual ActionResult ShowPackage(string id)
{
// Document Template Package
var m = new Models.DocumentTemplate.ShowPackageModel()
var m = new ShowPackageModel()
{
Package = DocumentTemplatePackages.GetPackage(id)
};
@@ -104,7 +105,7 @@ namespace Disco.Web.Areas.Config.Controllers
[DiscoAuthorize(Claims.Config.DocumentTemplate.ShowStatus)]
public virtual ActionResult ImportStatus()
{
var m = new Models.DocumentTemplate.ImportStatusModel();
var m = new ImportStatusModel();
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateImportStatusModel>(this.ControllerContext, m);
@@ -115,7 +116,7 @@ namespace Disco.Web.Areas.Config.Controllers
[DiscoAuthorize(Claims.Config.DocumentTemplate.UndetectedPages)]
public virtual ActionResult UndetectedPages()
{
var m = new Models.DocumentTemplate.UndetectedPagesModel()
var m = new UndetectedPagesModel()
{
DocumentTemplates = Database.DocumentTemplates.ToList()
};
@@ -129,7 +130,7 @@ namespace Disco.Web.Areas.Config.Controllers
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Create, Claims.Config.DocumentTemplate.Configure)]
public virtual ActionResult Create()
{
var m = new Models.DocumentTemplate.CreateModel();
var m = new CreateModel();
m.UpdateModel(Database);
// UI Extensions
@@ -139,7 +140,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Create, Claims.Config.DocumentTemplate.Configure), HttpPost]
public virtual ActionResult Create(Models.DocumentTemplate.CreateModel model)
public virtual ActionResult Create(CreateModel model)
{
model.UpdateModel(Database);
@@ -179,7 +180,7 @@ namespace Disco.Web.Areas.Config.Controllers
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Create, Claims.Config.DocumentTemplate.Configure)]
public virtual ActionResult CreatePackage()
{
var m = new Models.DocumentTemplate.CreatePackageModel();
var m = new CreatePackageModel();
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreatePackageModel>(this.ControllerContext, m);
@@ -188,7 +189,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Create, Claims.Config.DocumentTemplate.Configure), HttpPost]
public virtual ActionResult CreatePackage(Models.DocumentTemplate.CreatePackageModel model)
public virtual ActionResult CreatePackage(CreatePackageModel model)
{
if (ModelState.IsValid)
{
@@ -292,37 +293,10 @@ namespace Disco.Web.Areas.Config.Controllers
return View(MVC.Config.DocumentTemplate.Views.BulkGenerate, model);
}
[DiscoAuthorize(Claims.Config.Show)]
public virtual ActionResult ExpressionBrowser(string type, bool StaticDeclaredMembersOnly = false)
public virtual ActionResult ExpressionBrowser()
{
if (string.IsNullOrWhiteSpace(type))
{
var m = new Models.DocumentTemplate.ExpressionBrowserModel()
{
DeviceType = typeof(Disco.Models.Repository.Device).AssemblyQualifiedName,
JobType = typeof(Disco.Models.Repository.Job).AssemblyQualifiedName,
UserType = typeof(Disco.Models.Repository.User).AssemblyQualifiedName,
Variables = Expression.StandardVariableTypes(),
ExtensionLibraries = Expression.ExtensionLibraryTypes()
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateExpressionBrowserModel>(this.ControllerContext, m);
return View(m);
}
else
{
var t = Type.GetType(type);
if (t != null)
{
return Json(ExpressionTypeDescriptor.Build(t, StaticDeclaredMembersOnly), JsonRequestBehavior.AllowGet);
}
else
{
return Json("Invalid Type Specified", JsonRequestBehavior.AllowGet);
}
}
// for backwards compatibility
return RedirectToAction(MVC.Config.Expressions.Browser());
}
}
@@ -1,24 +1,42 @@
using Disco.Services.Authorization;
using Disco.Models.Repository;
using Disco.Models.UI.Config.Expressions;
using Disco.Services.Authorization;
using Disco.Services.Expressions;
using Disco.Services.Plugins.Features.ExpressionExtensionProvider;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using Disco.Web.Areas.Config.Models.Expressions;
using System;
using System.Linq;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
[DiscoAuthorize(Claims.DiscoAdminAccount)]
public partial class ExpressionsController : AuthorizedDatabaseController
{
// Under Construction - Not In Production
[DiscoAuthorize(Claims.DiscoAdminAccount)]
public virtual ActionResult Index()
{
throw new NotImplementedException();
//return View(Views.Editor, new Models.Expressions.EditorModel()
//{
// Expression = @"JobComponentsTotalCost() < 100 ? JobComponentsTotalCost().ToString('c') : '$100.00'"
//});
}
[DiscoAuthorize(Claims.Config.Show)]
public virtual ActionResult Browser()
{
var m = new BrowserModel()
{
DeviceType = typeof(Device).AssemblyQualifiedName,
JobType = typeof(Job).AssemblyQualifiedName,
UserType = typeof(User).AssemblyQualifiedName,
Variables = Expression.StandardVariableTypes(),
ExtensionLibraries = Expression.ExtensionLibraryTypes(),
PluginExtensionLibraries = ExpressionExtensionProviderFeature.GetExpressionExtensionRegistrations().ToDictionary(r => r.Alias, r => r.ExtensionType.AssemblyQualifiedName)
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigExpressionsBrowserModel>(ControllerContext, m);
return View(m);
}
}
}
@@ -1,9 +1,9 @@
using Disco.Models.UI.Config.DocumentTemplate;
using Disco.Models.UI.Config.Expressions;
using System.Collections.Generic;
namespace Disco.Web.Areas.Config.Models.DocumentTemplate
namespace Disco.Web.Areas.Config.Models.Expressions
{
public class ExpressionBrowserModel : ConfigDocumentTemplateExpressionBrowserModel
public class BrowserModel : ConfigExpressionsBrowserModel
{
public string DeviceType { get; set; }
public string UserType { get; set; }
@@ -11,5 +11,6 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
public Dictionary<string, string> Variables { get; set; }
public Dictionary<string, string> ExtensionLibraries { get; set; }
public Dictionary<string, string> PluginExtensionLibraries { get; set; }
}
}
@@ -1,134 +0,0 @@
@model Disco.Web.Areas.Config.Models.DocumentTemplate.ExpressionBrowserModel
@{
Authorization.Require(Claims.Config.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), "Expression Browser");
Html.BundleDeferred("~/Style/jQueryUI/dynatree");
Html.BundleDeferred("~/ClientScripts/Modules/jQueryUI-DynaTree");
}
<div id="configurationDocumentTemplateExpressionBrowser">
Expressions within Disco ICT are based on the <a href="http://www.springframework.net/"
target="_blank">Spring.NET Framework</a>. Please refer to the <a href="http://www.springframework.net/doc-latest/reference/html/expressions.html"
target="_blank">Expression Evaluation</a> documentation.
<h2 id="DeviceScope">
Device Scope</h2>
<div id="deviceScopeTree" class="expressionTree">
</div>
<h2 id="JobScope">
Job Scope</h2>
<div id="jobScopeTree" class="expressionTree">
</div>
<h2 id="UserScope">
User Scope</h2>
<div id="userScopeTree" class="expressionTree">
</div>
<h2 id="Variables">
Variables
</h2>
<div id="variableScopeTree" class="expressionTree">
</div>
<h2 id="ExtensionLibraries">
Extension Libraries</h2>
<div id="extScopeTree" class="expressionTree">
</div>
</div>
<script type="text/javascript">
$(function () {
if (!document.DiscoFunctions) {
document.DiscoFunctions = {};
}
var typeLib = {};
var loadTypeUrl = '@(Url.Action(MVC.Config.DocumentTemplate.ExpressionBrowser()))';
var deviceScopeTree = $('#deviceScopeTree');
var jobScopeTree = $('#jobScopeTree');
var userScopeTree = $('#userScopeTree');
var variableScopeTree = $('#variableScopeTree');
var extScopeTree = $('#extScopeTree');
var lazyLoadNode = function (node) {
if (node.data.expressionType) {
node.setLazyNodeStatus(DTNodeStatus_Loading);
loadType(node, node.data.expressionType, node.data.staticDeclaredMembersOnly);
} else {
if (node.data.memberDescriptor) {
loadMember(node);
} else {
node.setLazyNodeStatus(DTNodeStatus_Ok);
}
}
}
var loadMember = function (memberNode) {
var previousUpdateMode = memberNode.tree.enableUpdate(false);
var memberDescriptor = memberNode.data.memberDescriptor;
// Return Type
memberNode.addChild({ title: 'Returns: ' + memberDescriptor.ReturnType, tooltip: memberDescriptor.ReturnExpressionType, isFolder: true, expressionType: memberDescriptor.ReturnExpressionType, isLazy: true, addClass: 'object' });
// Parameters
var parametersNode = memberNode.addChild({ title: 'Parameters', isFolder: true, addClass: 'parameter' });
for (var i = 0; i < memberDescriptor.Parameters.length; i++) {
var p = memberDescriptor.Parameters[i];
parametersNode.addChild({ title: p.Name + ' [' + p.ReturnType + ']', tooltip: p.ReturnExpressionType, addClass: 'object' });
}
memberNode.setLazyNodeStatus(DTNodeStatus_Ok);
memberNode.tree.enableUpdate(previousUpdateMode);
}
var typeLoaded = function (parentNode, typeDescriptor) {
var previousUpdateMode = parentNode.tree.enableUpdate(false);
for (var i = 0; i < typeDescriptor.Members.length; i++) {
var memberDescriptor = typeDescriptor.Members[i];
parentNode.addChild({ title: memberDescriptor.Name, tooltip: memberDescriptor.ReturnType, isFolder: true, addClass: memberDescriptor.Kind, memberDescriptor: memberDescriptor, isLazy: true });
}
parentNode.setLazyNodeStatus(DTNodeStatus_Ok);
parentNode.tree.enableUpdate(previousUpdateMode);
}
var loadType = function (parentNode, type, staticDeclaredMembersOnly) {
if (typeLib[type]) {
typeLoaded(parentNode, typeLib[type]);
} else {
var requestData = { type: type, StaticDeclaredMembersOnly: staticDeclaredMembersOnly };
$.getJSON(loadTypeUrl, requestData, function (data) {
typeLib[type] = data;
typeLoaded(parentNode, data);
});
}
}
var initVariable = function (name, type) {
variableScopeTree.dynatree('getRoot').addChild({ title: name, tooltip: type, isFolder: true, addClass: 'object', expressionType: type, isLazy: true });
}
var initExpressionLibrary = function (name, type) {
extScopeTree.dynatree('getRoot').addChild({ title: name, tooltip: type, isFolder: true, addClass: 'object', expressionType: type, staticDeclaredMembersOnly: true, isLazy: true });
}
// Init
deviceScopeTree.dynatree({ onLazyRead: lazyLoadNode });
loadType(deviceScopeTree.dynatree('getRoot'), '@(Model.DeviceType)');
jobScopeTree.dynatree({ onLazyRead: lazyLoadNode });
loadType(jobScopeTree.dynatree('getRoot'), '@(Model.JobType)');
userScopeTree.dynatree({ onLazyRead: lazyLoadNode });
loadType(userScopeTree.dynatree('getRoot'), '@(Model.UserType)');
variableScopeTree.dynatree({ onLazyRead: lazyLoadNode });
document.DiscoFunctions.expressionInitVariable = initVariable;
extScopeTree.dynatree({ onLazyRead: lazyLoadNode });
document.DiscoFunctions.expressionInitExpressionLibrary = initExpressionLibrary;
});
</script>
<script type="text/javascript">
$(function () {
@{
foreach (var variable in Model.Variables)
{
<text>document.DiscoFunctions.expressionInitVariable('@(variable.Key)', '@variable.Value');</text>
}
foreach (var variable in Model.ExtensionLibraries)
{
<text>document.DiscoFunctions.expressionInitExpressionLibrary('@(variable.Key)', '@variable.Value');</text>
}
}
});
</script>
@@ -1,306 +0,0 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.DocumentTemplate
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DocumentTemplate/ExpressionBrowser.cshtml")]
public partial class ExpressionBrowser : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DocumentTemplate.ExpressionBrowserModel>
{
public ExpressionBrowser()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Authorization.Require(Claims.Config.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), "Expression Browser");
Html.BundleDeferred("~/Style/jQueryUI/dynatree");
Html.BundleDeferred("~/ClientScripts/Modules/jQueryUI-DynaTree");
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"configurationDocumentTemplateExpressionBrowser\"");
WriteLiteral(">\r\n Expressions within Disco ICT are based on the <a");
WriteLiteral(" href=\"http://www.springframework.net/\"");
WriteLiteral("\r\n target=\"_blank\"");
WriteLiteral(">Spring.NET Framework</a>. Please refer to the <a");
WriteLiteral(" href=\"http://www.springframework.net/doc-latest/reference/html/expressions.html\"" +
"");
WriteLiteral("\r\n target=\"_blank\"");
WriteLiteral(">Expression Evaluation</a> documentation.\r\n <h2");
WriteLiteral(" id=\"DeviceScope\"");
WriteLiteral(">\r\n Device Scope</h2>\r\n <div");
WriteLiteral(" id=\"deviceScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"JobScope\"");
WriteLiteral(">\r\n Job Scope</h2>\r\n <div");
WriteLiteral(" id=\"jobScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"UserScope\"");
WriteLiteral(">\r\n User Scope</h2>\r\n <div");
WriteLiteral(" id=\"userScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"Variables\"");
WriteLiteral(">\r\n Variables\r\n </h2>\r\n <div");
WriteLiteral(" id=\"variableScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"ExtensionLibraries\"");
WriteLiteral(">\r\n Extension Libraries</h2>\r\n <div");
WriteLiteral(" id=\"extScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n</div>\r\n<script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n if (!document.DiscoFunctions) {\r\n docu" +
"ment.DiscoFunctions = {};\r\n }\r\n\r\n var typeLib = {};\r\n var l" +
"oadTypeUrl = \'");
#line 42 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(Url.Action(MVC.Config.DocumentTemplate.ExpressionBrowser()));
#line default
#line hidden
WriteLiteral("\';\r\n var deviceScopeTree = $(\'#deviceScopeTree\');\r\n var jobScopeTre" +
"e = $(\'#jobScopeTree\');\r\n var userScopeTree = $(\'#userScopeTree\');\r\n " +
" var variableScopeTree = $(\'#variableScopeTree\');\r\n var extScopeTree = " +
"$(\'#extScopeTree\');\r\n\r\n var lazyLoadNode = function (node) {\r\n " +
" if (node.data.expressionType) {\r\n node.setLazyNodeStatus(DTNodeS" +
"tatus_Loading);\r\n loadType(node, node.data.expressionType, node.d" +
"ata.staticDeclaredMembersOnly);\r\n } else {\r\n if (node." +
"data.memberDescriptor) {\r\n loadMember(node);\r\n " +
" } else {\r\n node.setLazyNodeStatus(DTNodeStatus_Ok);\r\n " +
" }\r\n }\r\n }\r\n var loadMember = function (memberN" +
"ode) {\r\n var previousUpdateMode = memberNode.tree.enableUpdate(false)" +
";\r\n var memberDescriptor = memberNode.data.memberDescriptor;\r\n " +
" // Return Type\r\n memberNode.addChild({ title: \'Returns: \' + memb" +
"erDescriptor.ReturnType, tooltip: memberDescriptor.ReturnExpressionType, isFolde" +
"r: true, expressionType: memberDescriptor.ReturnExpressionType, isLazy: true, ad" +
"dClass: \'object\' });\r\n // Parameters\r\n var parametersNode " +
"= memberNode.addChild({ title: \'Parameters\', isFolder: true, addClass: \'paramete" +
"r\' });\r\n for (var i = 0; i < memberDescriptor.Parameters.length; i++)" +
" {\r\n var p = memberDescriptor.Parameters[i];\r\n par" +
"ametersNode.addChild({ title: p.Name + \' [\' + p.ReturnType + \']\', tooltip: p.Ret" +
"urnExpressionType, addClass: \'object\' });\r\n }\r\n memberNode" +
".setLazyNodeStatus(DTNodeStatus_Ok);\r\n memberNode.tree.enableUpdate(p" +
"reviousUpdateMode);\r\n }\r\n var typeLoaded = function (parentNode, t" +
"ypeDescriptor) {\r\n var previousUpdateMode = parentNode.tree.enableUpd" +
"ate(false);\r\n for (var i = 0; i < typeDescriptor.Members.length; i++)" +
" {\r\n var memberDescriptor = typeDescriptor.Members[i];\r\n " +
" parentNode.addChild({ title: memberDescriptor.Name, tooltip: memberDescri" +
"ptor.ReturnType, isFolder: true, addClass: memberDescriptor.Kind, memberDescript" +
"or: memberDescriptor, isLazy: true });\r\n }\r\n parentNode.se" +
"tLazyNodeStatus(DTNodeStatus_Ok);\r\n parentNode.tree.enableUpdate(prev" +
"iousUpdateMode);\r\n }\r\n\r\n var loadType = function (parentNode, type" +
", staticDeclaredMembersOnly) {\r\n if (typeLib[type]) {\r\n " +
" typeLoaded(parentNode, typeLib[type]);\r\n } else {\r\n " +
"var requestData = { type: type, StaticDeclaredMembersOnly: staticDeclaredMembers" +
"Only };\r\n $.getJSON(loadTypeUrl, requestData, function (data) {\r\n" +
" typeLib[type] = data;\r\n typeLoaded(parent" +
"Node, data);\r\n });\r\n }\r\n }\r\n\r\n var initV" +
"ariable = function (name, type) {\r\n variableScopeTree.dynatree(\'getRo" +
"ot\').addChild({ title: name, tooltip: type, isFolder: true, addClass: \'object\', " +
"expressionType: type, isLazy: true });\r\n }\r\n var initExpressionLib" +
"rary = function (name, type) {\r\n extScopeTree.dynatree(\'getRoot\').add" +
"Child({ title: name, tooltip: type, isFolder: true, addClass: \'object\', expressi" +
"onType: type, staticDeclaredMembersOnly: true, isLazy: true });\r\n }\r\n\r\n " +
" // Init\r\n deviceScopeTree.dynatree({ onLazyRead: lazyLoadNode });\r\n" +
" loadType(deviceScopeTree.dynatree(\'getRoot\'), \'");
#line 106 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(Model.DeviceType);
#line default
#line hidden
WriteLiteral("\');\r\n\r\n jobScopeTree.dynatree({ onLazyRead: lazyLoadNode });\r\n load" +
"Type(jobScopeTree.dynatree(\'getRoot\'), \'");
#line 109 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(Model.JobType);
#line default
#line hidden
WriteLiteral("\');\r\n\r\n userScopeTree.dynatree({ onLazyRead: lazyLoadNode });\r\n loa" +
"dType(userScopeTree.dynatree(\'getRoot\'), \'");
#line 112 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(Model.UserType);
#line default
#line hidden
WriteLiteral(@"');
variableScopeTree.dynatree({ onLazyRead: lazyLoadNode });
document.DiscoFunctions.expressionInitVariable = initVariable;
extScopeTree.dynatree({ onLazyRead: lazyLoadNode });
document.DiscoFunctions.expressionInitExpressionLibrary = initExpressionLibrary;
});
</script>
<script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n");
#line 123 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
foreach (var variable in Model.Variables)
{
#line default
#line hidden
WriteLiteral(" ");
WriteLiteral("document.DiscoFunctions.expressionInitVariable(\'");
#line 126 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(variable.Key);
#line default
#line hidden
WriteLiteral("\', \'");
#line 126 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(variable.Value);
#line default
#line hidden
WriteLiteral("\');");
WriteLiteral("\r\n");
#line 127 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
}
foreach (var variable in Model.ExtensionLibraries)
{
#line default
#line hidden
WriteLiteral(" ");
WriteLiteral("document.DiscoFunctions.expressionInitExpressionLibrary(\'");
#line 130 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(variable.Key);
#line default
#line hidden
WriteLiteral("\', \'");
#line 130 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
Write(variable.Value);
#line default
#line hidden
WriteLiteral("\');");
WriteLiteral("\r\n");
#line 131 "..\..\Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml"
}
#line default
#line hidden
WriteLiteral("\r\n });\r\n </script>");
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,160 @@
@model Disco.Web.Areas.Config.Models.Expressions.BrowserModel
@{
Authorization.Require(Claims.Config.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Expression Browser");
Html.BundleDeferred("~/Style/jQueryUI/dynatree");
Html.BundleDeferred("~/ClientScripts/Modules/jQueryUI-DynaTree");
}
<div id="Config_Expressions_Browser">
Expressions within Disco ICT are based on the <a href="http://www.springframework.net/" target="_blank">Spring.NET Framework</a>. Please refer to the <a href="http://www.springframework.net/doc-latest/reference/html/expressions.html" target="_blank">Expression Evaluation</a> documentation.
<h2 id="DeviceScope">
Device Scope
</h2>
<div id="deviceScopeTree" class="expressionTree">
</div>
<h2 id="JobScope">
Job Scope
</h2>
<div id="jobScopeTree" class="expressionTree">
</div>
<h2 id="UserScope">
User Scope
</h2>
<div id="userScopeTree" class="expressionTree">
</div>
<h2 id="Variables">
Variables
</h2>
<div id="variableScopeTree" class="expressionTree">
</div>
<h2 id="ExtensionLibraries">
Extension Libraries
</h2>
<div id="extScopeTree" class="expressionTree">
</div>
@if (Model.PluginExtensionLibraries.Any())
{
<h2 id="PluginExtensionLibraries">
Plugin Extension Libraries
</h2>
<div id="pluginExtScopeTree" class="expressionTree">
</div>
}
</div>
<script id="expressionBrowserModel" type="application/json">
@Html.Raw(Json.Encode(Model))
</script>
@using (Html.BeginForm(MVC.API.Expressions.TypeDescriptor(), FormMethod.Post, new { id = "expressionBrowserForm" }))
{
@Html.AntiForgeryToken()
}
<script type="text/javascript">
$(function () {
if (!document.DiscoFunctions) {
document.DiscoFunctions = {};
}
const typeLib = {};
const model = JSON.parse($('#expressionBrowserModel').html());
function lazyLoadNode(node) {
if (node.data.expressionType) {
node.setLazyNodeStatus(DTNodeStatus_Loading);
loadType(node, node.data.expressionType, node.data.staticMembersOnly);
} else {
if (node.data.memberDescriptor) {
loadMember(node);
} else {
node.setLazyNodeStatus(DTNodeStatus_Ok);
}
}
}
function loadMember(memberNode) {
const previousUpdateMode = memberNode.tree.enableUpdate(false);
const memberDescriptor = memberNode.data.memberDescriptor;
// Return Type
memberNode.addChild({ title: 'Returns: ' + memberDescriptor.ReturnType, tooltip: memberDescriptor.ReturnExpressionType, isFolder: true, expressionType: memberDescriptor.ReturnExpressionType, isLazy: true, addClass: 'object' });
// Parameters
const parametersNode = memberNode.addChild({ title: 'Parameters', isFolder: true, addClass: 'parameter' });
for (let i = 0; i < memberDescriptor.Parameters.length; i++) {
const p = memberDescriptor.Parameters[i];
parametersNode.addChild({ title: p.Name + ' [' + p.ReturnType + ']', tooltip: p.ReturnExpressionType, addClass: 'object' });
}
memberNode.setLazyNodeStatus(DTNodeStatus_Ok);
memberNode.tree.enableUpdate(previousUpdateMode);
}
function typeLoaded(parentNode, typeDescriptor) {
const previousUpdateMode = parentNode.tree.enableUpdate(false);
for (let i = 0; i < typeDescriptor.Members.length; i++) {
const memberDescriptor = typeDescriptor.Members[i];
parentNode.addChild({ title: memberDescriptor.Name, tooltip: memberDescriptor.ReturnType, isFolder: true, addClass: memberDescriptor.Kind, memberDescriptor: memberDescriptor, isLazy: true });
}
parentNode.setLazyNodeStatus(DTNodeStatus_Ok);
parentNode.tree.enableUpdate(previousUpdateMode);
}
async function loadType(parentNode, type, staticMembersOnly) {
let typeDef = typeLib[type];
if (!typeDef) {
$form = $('#expressionBrowserForm');
const url = $form.attr('action');
const body = new FormData($form[0]);
body.append('type', type);
if (staticMembersOnly) {
body.append('staticMembersOnly', staticMembersOnly);
}
const response = await fetch(url, {
method: 'POST',
body: body
});
if (!response.ok) {
console.error('Failed to load type', response);
return;
}
typeDef = await response.json();
typeLib[type] = typeDef;
}
typeLoaded(parentNode, typeDef);
}
const deviceScopeTree = $('#deviceScopeTree');
deviceScopeTree.dynatree({ onLazyRead: lazyLoadNode });
loadType(deviceScopeTree.dynatree('getRoot'), model.DeviceType);
const jobScopeTree = $('#jobScopeTree');
jobScopeTree.dynatree({ onLazyRead: lazyLoadNode });
loadType(jobScopeTree.dynatree('getRoot'), model.JobType);
const userScopeTree = $('#userScopeTree');
userScopeTree.dynatree({ onLazyRead: lazyLoadNode });
loadType(userScopeTree.dynatree('getRoot'), model.UserType);
const variableScopeTree = $('#variableScopeTree');
variableScopeTree.dynatree({ onLazyRead: lazyLoadNode });
Object.keys(model.Variables).forEach(name => {
const type = model.Variables[name];
variableScopeTree.dynatree('getRoot').addChild({ title: name, tooltip: type, isFolder: true, addClass: 'object', expressionType: type, isLazy: true });
})
const extScopeTree = $('#extScopeTree');
extScopeTree.dynatree({ onLazyRead: lazyLoadNode });
Object.keys(model.ExtensionLibraries).forEach(name => {
const type = model.ExtensionLibraries[name];
extScopeTree.dynatree('getRoot').addChild({ title: name, tooltip: type, isFolder: true, addClass: 'object', expressionType: type, staticMembersOnly: true, isLazy: true });
})
const pluginExtScopeTree = $('#pluginExtScopeTree');
if (pluginExtScopeTree.length) {
pluginExtScopeTree.dynatree({ onLazyRead: lazyLoadNode });
Object.keys(model.PluginExtensionLibraries).forEach(name => {
const type = model.PluginExtensionLibraries[name];
pluginExtScopeTree.dynatree('getRoot').addChild({ title: name, tooltip: type, isFolder: true, addClass: 'object', expressionType: type, staticMembersOnly: true, isLazy: true });
})
}
});
</script>
@@ -0,0 +1,277 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.Expressions
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/Expressions/Browser.cshtml")]
public partial class Browser : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.Expressions.BrowserModel>
{
public Browser()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
Authorization.Require(Claims.Config.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Expression Browser");
Html.BundleDeferred("~/Style/jQueryUI/dynatree");
Html.BundleDeferred("~/ClientScripts/Modules/jQueryUI-DynaTree");
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"Config_Expressions_Browser\"");
WriteLiteral(">\r\n Expressions within Disco ICT are based on the <a");
WriteLiteral(" href=\"http://www.springframework.net/\"");
WriteLiteral(" target=\"_blank\"");
WriteLiteral(">Spring.NET Framework</a>. Please refer to the <a");
WriteLiteral(" href=\"http://www.springframework.net/doc-latest/reference/html/expressions.html\"" +
"");
WriteLiteral(" target=\"_blank\"");
WriteLiteral(">Expression Evaluation</a> documentation.\r\n <h2");
WriteLiteral(" id=\"DeviceScope\"");
WriteLiteral(">\r\n Device Scope\r\n </h2>\r\n <div");
WriteLiteral(" id=\"deviceScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"JobScope\"");
WriteLiteral(">\r\n Job Scope\r\n </h2>\r\n <div");
WriteLiteral(" id=\"jobScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"UserScope\"");
WriteLiteral(">\r\n User Scope\r\n </h2>\r\n <div");
WriteLiteral(" id=\"userScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"Variables\"");
WriteLiteral(">\r\n Variables\r\n </h2>\r\n <div");
WriteLiteral(" id=\"variableScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n <h2");
WriteLiteral(" id=\"ExtensionLibraries\"");
WriteLiteral(">\r\n Extension Libraries\r\n </h2>\r\n <div");
WriteLiteral(" id=\"extScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n");
#line 36 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
#line default
#line hidden
#line 36 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
if (Model.PluginExtensionLibraries.Any())
{
#line default
#line hidden
WriteLiteral(" <h2");
WriteLiteral(" id=\"PluginExtensionLibraries\"");
WriteLiteral(">\r\n Plugin Extension Libraries\r\n </h2>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"pluginExtScopeTree\"");
WriteLiteral(" class=\"expressionTree\"");
WriteLiteral(">\r\n </div>\r\n");
#line 43 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
}
#line default
#line hidden
WriteLiteral("</div>\r\n<script");
WriteLiteral(" id=\"expressionBrowserModel\"");
WriteLiteral(" type=\"application/json\"");
WriteLiteral(">\r\n");
#line 46 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
Write(Html.Raw(Json.Encode(Model)));
#line default
#line hidden
WriteLiteral("\r\n</script>\r\n");
#line 48 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
using (Html.BeginForm(MVC.API.Expressions.TypeDescriptor(), FormMethod.Post, new { id = "expressionBrowserForm" }))
{
#line default
#line hidden
#line 50 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
Write(Html.AntiForgeryToken());
#line default
#line hidden
#line 50 "..\..\Areas\Config\Views\Expressions\Browser.cshtml"
}
#line default
#line hidden
WriteLiteral("<script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n if (!document.DiscoFunctions) {\r\n docu" +
"ment.DiscoFunctions = {};\r\n }\r\n\r\n const typeLib = {};\r\n con" +
"st model = JSON.parse($(\'#expressionBrowserModel\').html());\r\n\r\n function " +
"lazyLoadNode(node) {\r\n if (node.data.expressionType) {\r\n " +
" node.setLazyNodeStatus(DTNodeStatus_Loading);\r\n loadType(node," +
" node.data.expressionType, node.data.staticMembersOnly);\r\n } else {\r\n" +
" if (node.data.memberDescriptor) {\r\n loadMembe" +
"r(node);\r\n } else {\r\n node.setLazyNodeStatus(D" +
"TNodeStatus_Ok);\r\n }\r\n }\r\n }\r\n function " +
"loadMember(memberNode) {\r\n const previousUpdateMode = memberNode.tree" +
".enableUpdate(false);\r\n const memberDescriptor = memberNode.data.memb" +
"erDescriptor;\r\n // Return Type\r\n memberNode.addChild({ tit" +
"le: \'Returns: \' + memberDescriptor.ReturnType, tooltip: memberDescriptor.ReturnE" +
"xpressionType, isFolder: true, expressionType: memberDescriptor.ReturnExpression" +
"Type, isLazy: true, addClass: \'object\' });\r\n // Parameters\r\n " +
" const parametersNode = memberNode.addChild({ title: \'Parameters\', isFolder: t" +
"rue, addClass: \'parameter\' });\r\n for (let i = 0; i < memberDescriptor" +
".Parameters.length; i++) {\r\n const p = memberDescriptor.Parameter" +
"s[i];\r\n parametersNode.addChild({ title: p.Name + \' [\' + p.Return" +
"Type + \']\', tooltip: p.ReturnExpressionType, addClass: \'object\' });\r\n " +
" }\r\n memberNode.setLazyNodeStatus(DTNodeStatus_Ok);\r\n memb" +
"erNode.tree.enableUpdate(previousUpdateMode);\r\n }\r\n function typeL" +
"oaded(parentNode, typeDescriptor) {\r\n const previousUpdateMode = pare" +
"ntNode.tree.enableUpdate(false);\r\n for (let i = 0; i < typeDescriptor" +
".Members.length; i++) {\r\n const memberDescriptor = typeDescriptor" +
".Members[i];\r\n parentNode.addChild({ title: memberDescriptor.Name" +
", tooltip: memberDescriptor.ReturnType, isFolder: true, addClass: memberDescript" +
"or.Kind, memberDescriptor: memberDescriptor, isLazy: true });\r\n }\r\n " +
" parentNode.setLazyNodeStatus(DTNodeStatus_Ok);\r\n parentNode" +
".tree.enableUpdate(previousUpdateMode);\r\n }\r\n\r\n async function loa" +
"dType(parentNode, type, staticMembersOnly) {\r\n let typeDef = typeLib[" +
"type];\r\n if (!typeDef) {\r\n $form = $(\'#expressionBrows" +
"erForm\');\r\n const url = $form.attr(\'action\');\r\n co" +
"nst body = new FormData($form[0]);\r\n body.append(\'type\', type);\r\n" +
" if (staticMembersOnly) {\r\n body.append(\'stati" +
"cMembersOnly\', staticMembersOnly);\r\n }\r\n\r\n const r" +
"esponse = await fetch(url, {\r\n method: \'POST\',\r\n " +
" body: body\r\n });\r\n\r\n if (!response.ok) {\r\n " +
" console.error(\'Failed to load type\', response);\r\n " +
" return;\r\n }\r\n\r\n typeDef = await response.j" +
"son();\r\n\r\n typeLib[type] = typeDef;\r\n }\r\n t" +
"ypeLoaded(parentNode, typeDef);\r\n }\r\n\r\n const deviceScopeTree = $(" +
"\'#deviceScopeTree\');\r\n deviceScopeTree.dynatree({ onLazyRead: lazyLoadNod" +
"e });\r\n loadType(deviceScopeTree.dynatree(\'getRoot\'), model.DeviceType);\r" +
"\n\r\n const jobScopeTree = $(\'#jobScopeTree\');\r\n jobScopeTree.dynatr" +
"ee({ onLazyRead: lazyLoadNode });\r\n loadType(jobScopeTree.dynatree(\'getRo" +
"ot\'), model.JobType);\r\n\r\n const userScopeTree = $(\'#userScopeTree\');\r\n " +
" userScopeTree.dynatree({ onLazyRead: lazyLoadNode });\r\n loadType(use" +
"rScopeTree.dynatree(\'getRoot\'), model.UserType);\r\n\r\n const variableScopeT" +
"ree = $(\'#variableScopeTree\');\r\n variableScopeTree.dynatree({ onLazyRead:" +
" lazyLoadNode });\r\n Object.keys(model.Variables).forEach(name => {\r\n " +
" const type = model.Variables[name];\r\n variableScopeTree.dynatr" +
"ee(\'getRoot\').addChild({ title: name, tooltip: type, isFolder: true, addClass: \'" +
"object\', expressionType: type, isLazy: true });\r\n })\r\n\r\n const ext" +
"ScopeTree = $(\'#extScopeTree\');\r\n extScopeTree.dynatree({ onLazyRead: laz" +
"yLoadNode });\r\n Object.keys(model.ExtensionLibraries).forEach(name => {\r\n" +
" const type = model.ExtensionLibraries[name];\r\n extScopeTr" +
"ee.dynatree(\'getRoot\').addChild({ title: name, tooltip: type, isFolder: true, ad" +
"dClass: \'object\', expressionType: type, staticMembersOnly: true, isLazy: true })" +
";\r\n })\r\n\r\n const pluginExtScopeTree = $(\'#pluginExtScopeTree\');\r\n " +
" if (pluginExtScopeTree.length) {\r\n pluginExtScopeTree.dynatree" +
"({ onLazyRead: lazyLoadNode });\r\n Object.keys(model.PluginExtensionLi" +
"braries).forEach(name => {\r\n const type = model.PluginExtensionLi" +
"braries[name];\r\n pluginExtScopeTree.dynatree(\'getRoot\').addChild(" +
"{ title: name, tooltip: type, isFolder: true, addClass: \'object\', expressionType" +
": type, staticMembersOnly: true, isLazy: true });\r\n })\r\n }\r\n " +
" });\r\n</script>\r\n");
}
}
}
#pragma warning restore 1591
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8 -9
View File
@@ -296,6 +296,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>ShowPackage.cshtml</DependentUpon>
</Compile>
<Compile Include="Areas\Config\Views\Expressions\Browser.generated.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Browser.cshtml</DependentUpon>
</Compile>
<Compile Include="Areas\Config\Views\JobPreferences\Index.generated.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -443,7 +448,6 @@
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RazorGeneratorMvcStart.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Areas\API\APIAreaRegistration.cs" />
<Compile Include="Areas\API\Controllers\BootstrapperController.cs" />
<Compile Include="Areas\API\Controllers\DeviceBatchController.cs" />
@@ -501,7 +505,7 @@
<Compile Include="Areas\Config\Models\DeviceProfile\ShowModel.cs" />
<Compile Include="Areas\Config\Models\DeviceProfile\_IndexModelItem.cs" />
<Compile Include="Areas\Config\Models\DocumentTemplate\CreateModel.cs" />
<Compile Include="Areas\Config\Models\DocumentTemplate\ExpressionBrowserModel.cs" />
<Compile Include="Areas\Config\Models\Expressions\BrowserModel.cs" />
<Compile Include="Areas\Config\Models\DocumentTemplate\IndexModel.cs" />
<Compile Include="Areas\Config\Models\DocumentTemplate\ShowModel.cs" />
<Compile Include="Areas\Config\Models\DocumentTemplate\UndetectedPagesModel.cs" />
@@ -594,11 +598,6 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Areas\Config\Views\DocumentTemplate\ExpressionBrowser2.generated.cs">
<DependentUpon>ExpressionBrowser.cshtml</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Areas\Config\Views\DocumentTemplate\ImportStatus.generated.cs">
<DependentUpon>ImportStatus.cshtml</DependentUpon>
<AutoGen>True</AutoGen>
@@ -2337,9 +2336,9 @@
<Generator>RazorGenerator</Generator>
<LastGenOutput>Create.generated.cs</LastGenOutput>
</None>
<None Include="Areas\Config\Views\DocumentTemplate\ExpressionBrowser.cshtml">
<None Include="Areas\Config\Views\Expressions\Browser.cshtml">
<Generator>RazorGenerator</Generator>
<LastGenOutput>ExpressionBrowser2.generated.cs</LastGenOutput>
<LastGenOutput>Browser.generated.cs</LastGenOutput>
</None>
<None Include="Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml">
<Generator>RazorGenerator</Generator>
@@ -65,6 +65,12 @@ namespace Disco.Web.Areas.API.Controllers
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ValidateExpression);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult TypeDescriptor()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.TypeDescriptor);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ExpressionsController Actions { get { return MVC.API.Expressions; } }
@@ -82,12 +88,14 @@ namespace Disco.Web.Areas.API.Controllers
public class ActionNamesClass
{
public readonly string ValidateExpression = "ValidateExpression";
public readonly string TypeDescriptor = "TypeDescriptor";
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNameConstants
{
public const string ValidateExpression = "ValidateExpression";
public const string TypeDescriptor = "TypeDescriptor";
}
@@ -99,6 +107,15 @@ namespace Disco.Web.Areas.API.Controllers
{
public readonly string Expression = "Expression";
}
static readonly ActionParamsClass_TypeDescriptor s_params_TypeDescriptor = new ActionParamsClass_TypeDescriptor();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_TypeDescriptor TypeDescriptorParams { get { return s_params_TypeDescriptor; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_TypeDescriptor
{
public readonly string type = "type";
public readonly string staticMembersOnly = "staticMembersOnly";
}
static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } }
@@ -130,6 +147,19 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo;
}
[NonAction]
partial void TypeDescriptorOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string type, bool staticMembersOnly);
[NonAction]
public override System.Web.Mvc.ActionResult TypeDescriptor(string type, bool staticMembersOnly)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.TypeDescriptor);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "type", type);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "staticMembersOnly", staticMembersOnly);
TypeDescriptorOverride(callInfo, type, staticMembersOnly);
return callInfo;
}
}
}
@@ -77,12 +77,6 @@ namespace Disco.Web.Areas.Config.Controllers
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.BulkGenerate);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult ExpressionBrowser()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExpressionBrowser);
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public DocumentTemplateController Actions { get { return MVC.Config.DocumentTemplate; } }
@@ -165,15 +159,6 @@ namespace Disco.Web.Areas.Config.Controllers
{
public readonly string id = "id";
}
static readonly ActionParamsClass_ExpressionBrowser s_params_ExpressionBrowser = new ActionParamsClass_ExpressionBrowser();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_ExpressionBrowser ExpressionBrowserParams { get { return s_params_ExpressionBrowser; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_ExpressionBrowser
{
public readonly string type = "type";
public readonly string StaticDeclaredMembersOnly = "StaticDeclaredMembersOnly";
}
static readonly ViewsClass s_views = new ViewsClass();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ViewsClass Views { get { return s_views; } }
@@ -188,7 +173,6 @@ namespace Disco.Web.Areas.Config.Controllers
public readonly string BulkGenerate = "BulkGenerate";
public readonly string Create = "Create";
public readonly string CreatePackage = "CreatePackage";
public readonly string ExpressionBrowser = "ExpressionBrowser";
public readonly string ImportStatus = "ImportStatus";
public readonly string Index = "Index";
public readonly string Show = "Show";
@@ -199,7 +183,6 @@ namespace Disco.Web.Areas.Config.Controllers
public readonly string BulkGenerate = "~/Areas/Config/Views/DocumentTemplate/BulkGenerate.cshtml";
public readonly string Create = "~/Areas/Config/Views/DocumentTemplate/Create.cshtml";
public readonly string CreatePackage = "~/Areas/Config/Views/DocumentTemplate/CreatePackage.cshtml";
public readonly string ExpressionBrowser = "~/Areas/Config/Views/DocumentTemplate/ExpressionBrowser.cshtml";
public readonly string ImportStatus = "~/Areas/Config/Views/DocumentTemplate/ImportStatus.cshtml";
public readonly string Index = "~/Areas/Config/Views/DocumentTemplate/Index.cshtml";
public readonly string Show = "~/Areas/Config/Views/DocumentTemplate/Show.cshtml";
@@ -320,15 +303,13 @@ namespace Disco.Web.Areas.Config.Controllers
}
[NonAction]
partial void ExpressionBrowserOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string type, bool StaticDeclaredMembersOnly);
partial void ExpressionBrowserOverride(T4MVC_System_Web_Mvc_ActionResult callInfo);
[NonAction]
public override System.Web.Mvc.ActionResult ExpressionBrowser(string type, bool StaticDeclaredMembersOnly)
public override System.Web.Mvc.ActionResult ExpressionBrowser()
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ExpressionBrowser);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "type", type);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "StaticDeclaredMembersOnly", StaticDeclaredMembersOnly);
ExpressionBrowserOverride(callInfo, type, StaticDeclaredMembersOnly);
ExpressionBrowserOverride(callInfo);
return callInfo;
}
@@ -76,12 +76,14 @@ namespace Disco.Web.Areas.Config.Controllers
public class ActionNamesClass
{
public readonly string Index = "Index";
public readonly string Browser = "Browser";
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNameConstants
{
public const string Index = "Index";
public const string Browser = "Browser";
}
@@ -95,8 +97,10 @@ namespace Disco.Web.Areas.Config.Controllers
public _ViewNamesClass ViewNames { get { return s_ViewNames; } }
public class _ViewNamesClass
{
public readonly string Browser = "Browser";
public readonly string Editor = "Editor";
}
public readonly string Browser = "~/Areas/Config/Views/Expressions/Browser.cshtml";
public readonly string Editor = "~/Areas/Config/Views/Expressions/Editor.cshtml";
}
}
@@ -117,6 +121,17 @@ namespace Disco.Web.Areas.Config.Controllers
return callInfo;
}
[NonAction]
partial void BrowserOverride(T4MVC_System_Web_Mvc_ActionResult callInfo);
[NonAction]
public override System.Web.Mvc.ActionResult Browser()
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Browser);
BrowserOverride(callInfo);
return callInfo;
}
}
}