using Blazor.FlexGrid.Components.Configuration;
using Blazor.FlexGrid.Components.Configuration.Builders;
using Blazor.FlexGrid.Components.Renderers;
using Blazor.FlexGrid.Permission;
using ETS.SUPPORT.Shared;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Builder;
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.Extensions.DependencyInjection;
namespace ETS.SUPPORT.Client
public void ConfigureServices(IServiceCollection services)
services.AddFlexGrid(cfg =>
cfg.ApplyConfiguration(new WeatherForecastGridConfiguration());
cfg.ApplyConfiguration(new PathsdConfiguration());
cfg.ApplyConfiguration(new ImagesConfiguration());
services.AddSingleton<ICurrentUserPermission,Permission>();
public void Configure(IComponentsApplicationBuilder app)
app.AddComponent<App>("app");
public class WeatherForecastGridConfiguration : IEntityTypeConfiguration<Step>
public void Configure(EntityTypeBuilder<Step> builder)
builder.Property(e => e.Id)
.HasCaption("Id").HasWritePermissionRestriction(x=>x.IsInRole("Write"));
builder.Property(e => e.Description)
.HasCaption("Description")
builder.Property(e => e.Paths).IsVisible(false);
builder.Property(e => e.NextPaths).IsVisible(false);
builder.Property(e => e.IsRoot).HasValueFormatter(w=>$"<input type=\"checkbox\" disabled checked=\"{w}\">").HasWritePermissionRestriction(x=>x.IsInRole("Write"));
builder.Property(e => e.Image).HasValueFormatter(w=> $"<img height=\"150\" width=\"200\" src=\"data:image/jpeg;base64,{Convert.ToBase64String(w.Source)}\" />");
builder.Property(e => e.Details) .HasValueFormatter(s => "<strong style=\"color: red;\">Click to modify details</strong>").HasWritePermissionRestriction(x=>x.IsInRole("Write"));
builder.Property(e => e.Name)
builder.AllowInlineEdit(conf =>
conf.AllowDeleting = true;
builder.AllowCreateItem<StepModel, Step>(conf =>
conf.CreateUri = "/api/steps/";
conf.CloseAfterSuccessfullySaved = true;
public class PathsdConfiguration : IEntityTypeConfiguration<Path>
public void Configure(EntityTypeBuilder<Path> builder)
builder.Property(e => e.Id).HasWritePermissionRestriction(x=>x.IsInRole("Write"));
builder.Property(e => e.Step).IsVisible(false);
builder.Property(e => e.NextStep).IsVisible(false);
builder.Property(e => e.Image).HasValueFormatter(w=> $"<img height=\"150\" width=\"200\" src=\"data:image/jpeg;base64,{Convert.ToBase64String(w.Source)}\" />");
builder.Property(e => e.Details) .HasValueFormatter(s => "<strong style=\"color: red;\">Click to modify details</strong>").HasWritePermissionRestriction(x=>x.IsInRole("Write"));;
builder.Property(e => e.Name)
builder.Property(e => e.StepId);
builder.Property(e => e.NextStepId);
builder.AllowInlineEdit(conf =>
conf.AllowDeleting = true;
builder.AllowCreateItem<PathModel, Path>(conf =>
conf.CreateUri = "/api/paths/";
conf.CloseAfterSuccessfullySaved = true;
public class ImagesConfiguration : IEntityTypeConfiguration<Image>
public void Configure(EntityTypeBuilder<Image> builder)
builder.Property(e => e.Id).HasWritePermissionRestriction(x=>x.IsInRole("Write"));
builder.Property(e => e.Source).HasValueFormatter(w=> $"<img height=\"150\" width=\"200\" src=\"data:image/jpeg;base64,{Convert.ToBase64String(w)}\" />");
builder.AllowInlineEdit(conf =>
conf.AllowDeleting = true;
public class Permission : ICurrentUserPermission
public bool IsInRole(string roleName)
public bool HasClaim(string claimName)