Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ab042c7617 | |||
| 0861e18cec | |||
| dfa097eb43 | |||
| c18f0b7fb1 | |||
| 50828d23ec | |||
| f3966705ad | |||
| b4d8497ea7 | |||
| 7b77062aa7 | |||
| 9490718c04 | |||
| 0d1aa4f6be | |||
| 637af06a9c | |||
| 334bf2a567 | |||
| 9c2edd4712 | |||
| 5c7b5f7b10 | |||
| b07cd06477 | |||
| 9a0aaf629b | |||
| 859ae0b50d | |||
| 09c3985fad | |||
| 8dab3c0dc0 | |||
| a6f9a0a530 | |||
| c303514414 | |||
| 18f7981ccc |
@@ -4,10 +4,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Entity Framework Core -->
|
<!-- Entity Framework Core -->
|
||||||
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
|
<PackageVersion Include="HrynCo.DAL.Abstract" Version="1.0.11" />
|
||||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.5" />
|
<PackageVersion Include="HrynCo.DAL.EF" Version="1.0.11" />
|
||||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
|
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.7" />
|
||||||
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7" />
|
||||||
|
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.7" />
|
||||||
|
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
||||||
<!-- MediatR -->
|
<!-- MediatR -->
|
||||||
<PackageVersion Include="MediatR" Version="12.4.1" />
|
<PackageVersion Include="MediatR" Version="12.4.1" />
|
||||||
<PackageVersion Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
|
<PackageVersion Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
|
||||||
@@ -29,8 +31,6 @@
|
|||||||
<!-- HrynCo shared packages -->
|
<!-- HrynCo shared packages -->
|
||||||
<PackageVersion Include="HrynCo.Common" Version="1.0.11" />
|
<PackageVersion Include="HrynCo.Common" Version="1.0.11" />
|
||||||
<PackageVersion Include="HrynCo.RabbitMq" Version="1.0.15" />
|
<PackageVersion Include="HrynCo.RabbitMq" Version="1.0.15" />
|
||||||
<PackageVersion Include="HrynCo.DAL.Abstract" Version="1.0.1" />
|
|
||||||
<PackageVersion Include="HrynCo.DAL.EF" Version="1.0.1" />
|
|
||||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||||
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
|
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
|
||||||
<PackageVersion Include="xunit" Version="2.9.3" />
|
<PackageVersion Include="xunit" Version="2.9.3" />
|
||||||
|
|||||||
+4
-4
@@ -1,13 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="HrynCo.DAL.Abstract" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="HrynCo.DAL.Abstract" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
using HrynCo.DAL.Abstract.Entities;
|
|
||||||
|
|
||||||
namespace HrynCo.NotificationService.DAL.Abstract.Providers;
|
namespace HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tracks email send counts per EmailChannel per calendar day.
|
/// Tracks email send counts per EmailChannel per calendar day.
|
||||||
/// Monthly counts are derived by summing daily records within a month.
|
/// Monthly counts are derived by summing daily records within a month.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EmailChannelUsage : Entity
|
public class EmailChannelUsage
|
||||||
{
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public DateTimeOffset Created { get; set; }
|
||||||
|
public DateTimeOffset? Updated { get; set; }
|
||||||
public Guid ProviderId { get; set; }
|
public Guid ProviderId { get; set; }
|
||||||
public DateOnly Date { get; set; }
|
public DateOnly Date { get; set; }
|
||||||
public int SentCount { get; set; }
|
public int SentCount { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
namespace HrynCo.NotificationService.DAL.EF.Core;
|
||||||
|
|
||||||
|
using HrynCo.DAL.Abstract.Entities;
|
||||||
|
using HrynCo.DAL.EF.Core;
|
||||||
|
|
||||||
|
public abstract class NotificationBaseRepository<TEntity>
|
||||||
|
: BaseRepository<NotificationEfRepository<TEntity>, NotificationDbContext, TEntity, Guid> where TEntity : Entity
|
||||||
|
{
|
||||||
|
protected NotificationBaseRepository(NotificationDbContext dbContext)
|
||||||
|
{
|
||||||
|
DbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NotificationDbContext DbContext { get; set; }
|
||||||
|
|
||||||
|
protected override NotificationEfRepository<TEntity> CreateEfRepository()
|
||||||
|
{
|
||||||
|
return new NotificationEfRepository<TEntity>(DbContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace HrynCo.NotificationService.DAL.EF.Core;
|
||||||
|
|
||||||
|
using HrynCo.DAL.Abstract.Entities;
|
||||||
|
using HrynCo.DAL.EF.Core;
|
||||||
|
|
||||||
|
public class NotificationEfRepository<TEntity> : BaseEfRepository<NotificationDbContext, TEntity, Guid>
|
||||||
|
where TEntity : class, IEntity<Guid>
|
||||||
|
{
|
||||||
|
public NotificationEfRepository(NotificationDbContext dbContext) :
|
||||||
|
base(dbContext)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
using HrynCo.DAL.EF.Core;
|
|
||||||
|
|
||||||
namespace HrynCo.NotificationService.DAL.EF.Core;
|
|
||||||
|
|
||||||
internal sealed class UnitOfWork : EfUnitOfWork<NotificationDbContext>
|
|
||||||
{
|
|
||||||
public UnitOfWork(NotificationDbContext context) : base(context)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="HrynCo.DAL.EF" />
|
<PackageReference Include="HrynCo.DAL.EF" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace HrynCo.NotificationService.DAL.EF;
|
||||||
|
|
||||||
|
using HrynCo.DAL.EF.Core;
|
||||||
|
|
||||||
|
public class NotificationUnitOfWork : EfUnitOfWork<NotificationDbContext>
|
||||||
|
{
|
||||||
|
public NotificationUnitOfWork(NotificationDbContext context) : base(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
|
namespace HrynCo.NotificationService.DAL.EF.Repositories;
|
||||||
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.DAL.EF.Core;
|
using HrynCo.NotificationService.DAL.EF.Core;
|
||||||
using HrynCo.NotificationService.DAL.EF.Entities;
|
using HrynCo.NotificationService.DAL.EF.Entities;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace HrynCo.NotificationService.DAL.EF.Repositories;
|
internal sealed class EmailChannelRepository : NotificationBaseRepository<EmailChannelEntity>, IEmailChannelRepository
|
||||||
|
|
||||||
internal sealed class EmailChannelRepository : EfRepository<NotificationDbContext, EmailChannelEntity>, IEmailChannelRepository
|
|
||||||
{
|
{
|
||||||
public EmailChannelRepository(NotificationDbContext dbContext) : base(dbContext)
|
public EmailChannelRepository(NotificationDbContext dbContext) : base(dbContext)
|
||||||
{
|
{
|
||||||
@@ -15,20 +15,14 @@ internal sealed class EmailChannelRepository : EfRepository<NotificationDbContex
|
|||||||
|
|
||||||
public async Task<IReadOnlyList<EmailChannel>> GetAllAsync(CancellationToken ct = default)
|
public async Task<IReadOnlyList<EmailChannel>> GetAllAsync(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var entities = await DbSet
|
var entities = await EfRepository.Get().ToListAsync(ct);
|
||||||
.AsNoTracking()
|
|
||||||
.OrderBy(x => x.ServiceName)
|
|
||||||
.ThenBy(x => x.Priority)
|
|
||||||
.ToListAsync(ct);
|
|
||||||
|
|
||||||
return entities.Select(MapToDomain).ToList();
|
return entities.Select(MapToDomain).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IReadOnlyList<EmailChannel>> GetByServiceAsync(string serviceName, CancellationToken ct = default)
|
public async Task<IReadOnlyList<EmailChannel>> GetByServiceAsync(string serviceName, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var entities = await DbSet
|
var entities = await EfRepository.Get(x => x.ServiceName == serviceName)
|
||||||
.AsNoTracking()
|
|
||||||
.Where(x => x.ServiceName == serviceName)
|
|
||||||
.OrderBy(x => x.Priority)
|
.OrderBy(x => x.Priority)
|
||||||
.ToListAsync(ct);
|
.ToListAsync(ct);
|
||||||
|
|
||||||
@@ -38,8 +32,7 @@ internal sealed class EmailChannelRepository : EfRepository<NotificationDbContex
|
|||||||
public async Task<IReadOnlyList<ChannelWithUsage>> GetAllWithUsageSummaryAsync(
|
public async Task<IReadOnlyList<ChannelWithUsage>> GetAllWithUsageSummaryAsync(
|
||||||
DateOnly today, CancellationToken ct = default)
|
DateOnly today, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var rows = await DbSet
|
var rows = await EfRepository.Get()
|
||||||
.AsNoTracking()
|
|
||||||
.OrderBy(c => c.ServiceName)
|
.OrderBy(c => c.ServiceName)
|
||||||
.ThenBy(c => c.Priority)
|
.ThenBy(c => c.Priority)
|
||||||
.Select(c => new
|
.Select(c => new
|
||||||
@@ -61,30 +54,24 @@ internal sealed class EmailChannelRepository : EfRepository<NotificationDbContex
|
|||||||
|
|
||||||
public async Task<EmailChannel?> GetByIdAsync(Guid id, CancellationToken ct = default)
|
public async Task<EmailChannel?> GetByIdAsync(Guid id, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
EmailChannelEntity? entity = await DbSet.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id, ct);
|
EmailChannelEntity? entity = await EfRepository.GetByIdAsync(id);
|
||||||
return entity is null ? null : MapToDomain(entity);
|
return entity is null ? null : MapToDomain(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task AddAsync(EmailChannel channel, CancellationToken ct = default)
|
public Task AddAsync(EmailChannel channel, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
return base.AddAsync(MapToEntity(channel), ct);
|
return EfRepository.AddAsync(MapToEntity(channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task UpdateAsync(EmailChannel channel, CancellationToken ct = default)
|
public async Task UpdateAsync(EmailChannel channel, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
EmailChannelEntity entity = MapToEntity(channel);
|
EmailChannelEntity entity = MapToEntity(channel);
|
||||||
entity.Updated = DateTimeOffset.UtcNow;
|
await EfRepository.UpdateAsync(entity);
|
||||||
Update(entity);
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAsync(EmailChannel channel, CancellationToken ct = default)
|
public async Task DeleteAsync(EmailChannel channel, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
EmailChannelEntity? entity = await DbSet.FindAsync([channel.Id], ct);
|
await EfRepository.DeleteAsync(channel.Id);
|
||||||
if (entity is not null)
|
|
||||||
{
|
|
||||||
Delete(entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EmailChannel MapToDomain(EmailChannelEntity e)
|
private static EmailChannel MapToDomain(EmailChannelEntity e)
|
||||||
@@ -128,8 +115,8 @@ internal sealed class EmailChannelRepository : EfRepository<NotificationDbContex
|
|||||||
return type switch
|
return type switch
|
||||||
{
|
{
|
||||||
EmailChannelType.Smtp => JsonSerializer.Deserialize<SmtpChannelSettings>(json)
|
EmailChannelType.Smtp => JsonSerializer.Deserialize<SmtpChannelSettings>(json)
|
||||||
?? throw new InvalidOperationException(
|
?? throw new InvalidOperationException(
|
||||||
"Failed to deserialize SMTP EmailChannel settings."),
|
"Failed to deserialize SMTP EmailChannel settings."),
|
||||||
_ => throw new InvalidOperationException($"Unknown or undefined email channel type: {type}")
|
_ => throw new InvalidOperationException($"Unknown or undefined email channel type: {type}")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.DAL.EF.Core;
|
using HrynCo.NotificationService.DAL.EF.Core;
|
||||||
using HrynCo.NotificationService.DAL.EF.Entities;
|
using HrynCo.NotificationService.DAL.EF.Entities;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace HrynCo.NotificationService.DAL.EF.Repositories;
|
namespace HrynCo.NotificationService.DAL.EF.Repositories;
|
||||||
|
|
||||||
internal sealed class EmailChannelUsageRepository : EfRepository<NotificationDbContext, EmailChannelUsageEntity>, IEmailChannelUsageRepository
|
internal sealed class EmailChannelUsageRepository : NotificationBaseRepository<EmailChannelUsageEntity>, IEmailChannelUsageRepository
|
||||||
{
|
{
|
||||||
public EmailChannelUsageRepository(NotificationDbContext dbContext) : base(dbContext)
|
public EmailChannelUsageRepository(NotificationDbContext dbContext) : base(dbContext)
|
||||||
{
|
{
|
||||||
@@ -13,7 +13,8 @@ internal sealed class EmailChannelUsageRepository : EfRepository<NotificationDbC
|
|||||||
|
|
||||||
public async Task<int> GetDailyCountAsync(Guid providerId, DateOnly date, CancellationToken ct = default)
|
public async Task<int> GetDailyCountAsync(Guid providerId, DateOnly date, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
EmailChannelUsageEntity? entity = await DbSet
|
EmailChannelUsageEntity? entity = await EfRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
.FirstOrDefaultAsync(x => x.ProviderId == providerId && x.Date == date, ct);
|
.FirstOrDefaultAsync(x => x.ProviderId == providerId && x.Date == date, ct);
|
||||||
|
|
||||||
return entity?.SentCount ?? 0;
|
return entity?.SentCount ?? 0;
|
||||||
@@ -21,7 +22,7 @@ internal sealed class EmailChannelUsageRepository : EfRepository<NotificationDbC
|
|||||||
|
|
||||||
public async Task<int> GetMonthlyCountAsync(Guid providerId, int year, int month, CancellationToken ct = default)
|
public async Task<int> GetMonthlyCountAsync(Guid providerId, int year, int month, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
return await DbSet
|
return await EfRepository.Get()
|
||||||
.Where(x => x.ProviderId == providerId
|
.Where(x => x.ProviderId == providerId
|
||||||
&& x.Date.Year == year
|
&& x.Date.Year == year
|
||||||
&& x.Date.Month == month)
|
&& x.Date.Month == month)
|
||||||
@@ -30,15 +31,16 @@ internal sealed class EmailChannelUsageRepository : EfRepository<NotificationDbC
|
|||||||
|
|
||||||
public async Task IncrementUsageAsync(Guid providerId, DateOnly date, CancellationToken ct = default)
|
public async Task IncrementUsageAsync(Guid providerId, DateOnly date, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
EmailChannelUsageEntity? entity = await DbSet
|
EmailChannelUsageEntity? entity = await EfRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
.FirstOrDefaultAsync(x => x.ProviderId == providerId && x.Date == date, ct);
|
.FirstOrDefaultAsync(x => x.ProviderId == providerId && x.Date == date, ct);
|
||||||
|
|
||||||
if (entity is null)
|
if (entity is null)
|
||||||
await AddAsync(new EmailChannelUsageEntity { ProviderId = providerId, Date = date, SentCount = 1 }, ct);
|
await EfRepository.AddAsync(new EmailChannelUsageEntity { ProviderId = providerId, Date = date, SentCount = 1 });
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entity.SentCount++;
|
entity.SentCount++;
|
||||||
Update(entity);
|
await EfRepository.UpdateAsync(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||||
using HrynCo.DAL.EF.Core;
|
using HrynCo.NotificationService.DAL.EF.Core;
|
||||||
using HrynCo.NotificationService.DAL.EF.Entities;
|
using HrynCo.NotificationService.DAL.EF.Entities;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace HrynCo.NotificationService.DAL.EF.Repositories;
|
namespace HrynCo.NotificationService.DAL.EF.Repositories;
|
||||||
|
|
||||||
internal sealed class EmailTemplateRepository : EfRepository<NotificationDbContext, EmailTemplateEntity>, IEmailTemplateRepository
|
internal sealed class EmailTemplateRepository
|
||||||
|
: NotificationBaseRepository<EmailTemplateEntity>, IEmailTemplateRepository
|
||||||
{
|
{
|
||||||
public EmailTemplateRepository(NotificationDbContext dbContext) : base(dbContext)
|
public EmailTemplateRepository(NotificationDbContext dbContext) : base(dbContext)
|
||||||
{
|
{
|
||||||
@@ -14,13 +15,16 @@ internal sealed class EmailTemplateRepository : EfRepository<NotificationDbConte
|
|||||||
|
|
||||||
public async Task<IReadOnlyList<EmailTemplate>> GetAllAsync(CancellationToken ct = default)
|
public async Task<IReadOnlyList<EmailTemplate>> GetAllAsync(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
List<EmailTemplateEntity> entities = await DbSet.ToListAsync(ct);
|
List<EmailTemplateEntity> entities = await EfRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToListAsync(ct);
|
||||||
return entities.Select(MapToDomain).ToList();
|
return entities.Select(MapToDomain).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IReadOnlyList<EmailTemplate>> GetByServiceAsync(string serviceName, CancellationToken ct = default)
|
public async Task<IReadOnlyList<EmailTemplate>> GetByServiceAsync(string serviceName, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
List<EmailTemplateEntity> entities = await DbSet
|
List<EmailTemplateEntity> entities = await EfRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
.Where(x => x.ServiceName == serviceName)
|
.Where(x => x.ServiceName == serviceName)
|
||||||
.ToListAsync(ct);
|
.ToListAsync(ct);
|
||||||
|
|
||||||
@@ -29,28 +33,48 @@ internal sealed class EmailTemplateRepository : EfRepository<NotificationDbConte
|
|||||||
|
|
||||||
public async Task<EmailTemplate?> GetAsync(string serviceName, string key, string languageCode, CancellationToken ct = default)
|
public async Task<EmailTemplate?> GetAsync(string serviceName, string key, string languageCode, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
EmailTemplateEntity? entity = await DbSet.FirstOrDefaultAsync(
|
EmailTemplateEntity? entity = await EfRepository.Get()
|
||||||
x => x.ServiceName == serviceName && x.Key == key && x.LanguageCode == languageCode, ct);
|
.AsNoTracking()
|
||||||
|
.FirstOrDefaultAsync(
|
||||||
|
x => x.ServiceName == serviceName && x.Key == key && x.LanguageCode == languageCode, ct);
|
||||||
|
|
||||||
return entity is null ? null : MapToDomain(entity);
|
return entity is null ? null : MapToDomain(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task AddAsync(EmailTemplate EmailTemplate, CancellationToken ct = default) =>
|
public Task AddAsync(EmailTemplate EmailTemplate, CancellationToken ct = default)
|
||||||
base.AddAsync(MapToEntity(EmailTemplate), ct);
|
|
||||||
|
|
||||||
public Task UpdateAsync(EmailTemplate EmailTemplate, CancellationToken ct = default)
|
|
||||||
{
|
{
|
||||||
EmailTemplateEntity entity = MapToEntity(EmailTemplate);
|
return EfRepository.AddAsync(MapToEntity(EmailTemplate));
|
||||||
entity.Updated = DateTimeOffset.UtcNow;
|
}
|
||||||
Update(entity);
|
|
||||||
return Task.CompletedTask;
|
public async Task UpdateAsync(EmailTemplate EmailTemplate, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
EmailTemplateEntity? entity = await EfRepository.Get()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == EmailTemplate.Id, ct);
|
||||||
|
|
||||||
|
if (entity is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.ServiceName = EmailTemplate.ServiceName;
|
||||||
|
entity.Key = EmailTemplate.Key;
|
||||||
|
entity.LanguageCode = EmailTemplate.LanguageCode;
|
||||||
|
entity.Subject = EmailTemplate.Subject;
|
||||||
|
entity.HtmlBody = EmailTemplate.HtmlBody;
|
||||||
|
entity.TextBody = EmailTemplate.TextBody;
|
||||||
|
entity.Variables = EmailTemplate.Variables
|
||||||
|
.Select(v => new EmailTemplateVariableData { Name = v.Name, Required = v.Required })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
await EfRepository.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAsync(EmailTemplate EmailTemplate, CancellationToken ct = default)
|
public async Task DeleteAsync(EmailTemplate EmailTemplate, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
EmailTemplateEntity? entity = await DbSet.FindAsync([EmailTemplate.Id], ct);
|
EmailTemplateEntity? entity = await EfRepository.Get()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == EmailTemplate.Id, ct);
|
||||||
if (entity is not null)
|
if (entity is not null)
|
||||||
Delete(entity);
|
await EfRepository.DeleteAsync(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EmailTemplate MapToDomain(EmailTemplateEntity e) => new()
|
private static EmailTemplate MapToDomain(EmailTemplateEntity e) => new()
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ public static class ServiceCollectionExtensions
|
|||||||
services.AddDbContext<NotificationDbContext>(options =>
|
services.AddDbContext<NotificationDbContext>(options =>
|
||||||
options.UseNpgsql(connectionString));
|
options.UseNpgsql(connectionString));
|
||||||
|
|
||||||
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
||||||
services.AddScoped<IEmailTemplateRepository, EmailTemplateRepository>();
|
services.AddScoped<IEmailTemplateRepository, EmailTemplateRepository>();
|
||||||
services.AddScoped<IEmailChannelRepository, EmailChannelRepository>();
|
services.AddScoped<IEmailChannelRepository, EmailChannelRepository>();
|
||||||
services.AddScoped<IEmailChannelUsageRepository, EmailChannelUsageRepository>();
|
services.AddScoped<IEmailChannelUsageRepository, EmailChannelUsageRepository>();
|
||||||
|
services.AddScoped<IUnitOfWork, NotificationUnitOfWork>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,15 @@ public class TransactionBehavior<TRequest, TResponse> : IPipelineBehavior<TReque
|
|||||||
|
|
||||||
public Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken) =>
|
public Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken) =>
|
||||||
_profiler.MeasureExecutionAsync(
|
_profiler.MeasureExecutionAsync(
|
||||||
() => _unitOfWork.ExecuteInTransactionAsync(async () =>
|
async () =>
|
||||||
{
|
{
|
||||||
TResponse response = await next();
|
TResponse? response = default;
|
||||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
await _unitOfWork.ExecuteInTransactionAsync(async () =>
|
||||||
return response;
|
{
|
||||||
}),
|
response = await next();
|
||||||
|
});
|
||||||
|
|
||||||
|
return response!;
|
||||||
|
},
|
||||||
typeof(TRequest).Name);
|
typeof(TRequest).Name);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.Services.Logging;
|
using HrynCo.NotificationService.Services.Logging;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
@@ -8,14 +7,12 @@ namespace HrynCo.NotificationService.Services.Core;
|
|||||||
public abstract class RequestHandler<TRequest, TResponse> : IRequestHandler<TRequest, TResponse>
|
public abstract class RequestHandler<TRequest, TResponse> : IRequestHandler<TRequest, TResponse>
|
||||||
where TRequest : IRequest<TResponse>
|
where TRequest : IRequest<TResponse>
|
||||||
{
|
{
|
||||||
protected RequestHandler(IContextualSerilogLogger<TRequest> logger, IUnitOfWork unitOfWork)
|
protected RequestHandler(IContextualSerilogLogger<TRequest> logger)
|
||||||
{
|
{
|
||||||
Logger = logger.Logger;
|
Logger = logger.Logger;
|
||||||
UnitOfWork = unitOfWork;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ILogger Logger { get; }
|
protected ILogger Logger { get; }
|
||||||
protected IUnitOfWork UnitOfWork { get; }
|
|
||||||
|
|
||||||
public Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken)
|
public Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-2
@@ -14,9 +14,8 @@ internal sealed class CreateEmailChannelHandler
|
|||||||
|
|
||||||
public CreateEmailChannelHandler(
|
public CreateEmailChannelHandler(
|
||||||
IContextualSerilogLogger<CreateEmailChannelCommand> logger,
|
IContextualSerilogLogger<CreateEmailChannelCommand> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channels)
|
IEmailChannelRepository channels)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -13,9 +13,8 @@ internal sealed class DeleteEmailChannelHandler
|
|||||||
|
|
||||||
public DeleteEmailChannelHandler(
|
public DeleteEmailChannelHandler(
|
||||||
IContextualSerilogLogger<DeleteEmailChannelCommand> logger,
|
IContextualSerilogLogger<DeleteEmailChannelCommand> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channels)
|
IEmailChannelRepository channels)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -14,9 +13,8 @@ internal sealed class GetEmailChannelHandler
|
|||||||
|
|
||||||
public GetEmailChannelHandler(
|
public GetEmailChannelHandler(
|
||||||
IContextualSerilogLogger<GetEmailChannelQuery> logger,
|
IContextualSerilogLogger<GetEmailChannelQuery> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channels)
|
IEmailChannelRepository channels)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -14,9 +13,8 @@ internal sealed class GetAllEmailChannelsHandler
|
|||||||
|
|
||||||
public GetAllEmailChannelsHandler(
|
public GetAllEmailChannelsHandler(
|
||||||
IContextualSerilogLogger<GetAllEmailChannelsQuery> logger,
|
IContextualSerilogLogger<GetAllEmailChannelsQuery> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channels)
|
IEmailChannelRepository channels)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -14,9 +13,8 @@ internal sealed class GetEmailChannelsHandler
|
|||||||
|
|
||||||
public GetEmailChannelsHandler(
|
public GetEmailChannelsHandler(
|
||||||
IContextualSerilogLogger<GetEmailChannelsQuery> logger,
|
IContextualSerilogLogger<GetEmailChannelsQuery> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channels)
|
IEmailChannelRepository channels)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
using HrynCo.NotificationService.Services.Logging;
|
using HrynCo.NotificationService.Services.Logging;
|
||||||
@@ -13,9 +12,8 @@ internal sealed class GetChannelUsageSummaryHandler
|
|||||||
|
|
||||||
public GetChannelUsageSummaryHandler(
|
public GetChannelUsageSummaryHandler(
|
||||||
IContextualSerilogLogger<GetChannelUsageSummaryQuery> logger,
|
IContextualSerilogLogger<GetChannelUsageSummaryQuery> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channelsRepository)
|
IEmailChannelRepository channelsRepository)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channelsRepository = channelsRepository;
|
_channelsRepository = channelsRepository;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -17,10 +16,9 @@ internal sealed class SendEmailHandler
|
|||||||
|
|
||||||
public SendEmailHandler(
|
public SendEmailHandler(
|
||||||
IContextualSerilogLogger<SendEmailCommand> logger,
|
IContextualSerilogLogger<SendEmailCommand> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channels,
|
IEmailChannelRepository channels,
|
||||||
IEmailChannelUsageRepository usage)
|
IEmailChannelUsageRepository usage)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
_usage = usage;
|
_usage = usage;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
using HrynCo.NotificationService.Services.Logging;
|
using HrynCo.NotificationService.Services.Logging;
|
||||||
using static HrynCo.NotificationService.Services.Core.ServiceResultHelper;
|
using static HrynCo.NotificationService.Services.Core.ServiceResultHelper;
|
||||||
@@ -11,9 +10,8 @@ internal sealed class TestSmtpHandler
|
|||||||
: RequestHandler<TestSmtpCommand, ServiceResult<Unit>>
|
: RequestHandler<TestSmtpCommand, ServiceResult<Unit>>
|
||||||
{
|
{
|
||||||
public TestSmtpHandler(
|
public TestSmtpHandler(
|
||||||
IContextualSerilogLogger<TestSmtpCommand> logger,
|
IContextualSerilogLogger<TestSmtpCommand> logger)
|
||||||
IUnitOfWork unitOfWork)
|
: base(logger)
|
||||||
: base(logger, unitOfWork)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -13,9 +13,8 @@ internal sealed class UpdateEmailChannelHandler
|
|||||||
|
|
||||||
public UpdateEmailChannelHandler(
|
public UpdateEmailChannelHandler(
|
||||||
IContextualSerilogLogger<UpdateEmailChannelCommand> logger,
|
IContextualSerilogLogger<UpdateEmailChannelCommand> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailChannelRepository channels)
|
IEmailChannelRepository channels)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -14,9 +13,8 @@ internal sealed class CreateEmailTemplateHandler
|
|||||||
|
|
||||||
public CreateEmailTemplateHandler(
|
public CreateEmailTemplateHandler(
|
||||||
IContextualSerilogLogger<CreateEmailTemplateCommand> logger,
|
IContextualSerilogLogger<CreateEmailTemplateCommand> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailTemplateRepository templates)
|
IEmailTemplateRepository templates)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_templates = templates;
|
_templates = templates;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -13,9 +13,8 @@ internal sealed class DeleteEmailTemplateHandler
|
|||||||
|
|
||||||
public DeleteEmailTemplateHandler(
|
public DeleteEmailTemplateHandler(
|
||||||
IContextualSerilogLogger<DeleteEmailTemplateCommand> logger,
|
IContextualSerilogLogger<DeleteEmailTemplateCommand> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailTemplateRepository templates)
|
IEmailTemplateRepository templates)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_templates = templates;
|
_templates = templates;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -14,9 +13,8 @@ internal sealed class GetEmailTemplateHandler
|
|||||||
|
|
||||||
public GetEmailTemplateHandler(
|
public GetEmailTemplateHandler(
|
||||||
IContextualSerilogLogger<GetEmailTemplateQuery> logger,
|
IContextualSerilogLogger<GetEmailTemplateQuery> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailTemplateRepository templates)
|
IEmailTemplateRepository templates)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_templates = templates;
|
_templates = templates;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -14,9 +13,8 @@ internal sealed class GetAllEmailTemplatesHandler
|
|||||||
|
|
||||||
public GetAllEmailTemplatesHandler(
|
public GetAllEmailTemplatesHandler(
|
||||||
IContextualSerilogLogger<GetAllEmailTemplatesQuery> logger,
|
IContextualSerilogLogger<GetAllEmailTemplatesQuery> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailTemplateRepository templates)
|
IEmailTemplateRepository templates)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_templates = templates;
|
_templates = templates;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
using HrynCo.DAL.Abstract;
|
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||||
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
using HrynCo.NotificationService.DAL.Abstract.Templates;
|
||||||
using HrynCo.NotificationService.Services.Core;
|
using HrynCo.NotificationService.Services.Core;
|
||||||
@@ -14,9 +13,8 @@ internal sealed class GetEmailTemplatesHandler
|
|||||||
|
|
||||||
public GetEmailTemplatesHandler(
|
public GetEmailTemplatesHandler(
|
||||||
IContextualSerilogLogger<GetEmailTemplatesQuery> logger,
|
IContextualSerilogLogger<GetEmailTemplatesQuery> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailTemplateRepository templates)
|
IEmailTemplateRepository templates)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_templates = templates;
|
_templates = templates;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -13,9 +13,8 @@ internal sealed class UpdateEmailTemplateHandler
|
|||||||
|
|
||||||
public UpdateEmailTemplateHandler(
|
public UpdateEmailTemplateHandler(
|
||||||
IContextualSerilogLogger<UpdateEmailTemplateCommand> logger,
|
IContextualSerilogLogger<UpdateEmailTemplateCommand> logger,
|
||||||
IUnitOfWork unitOfWork,
|
|
||||||
IEmailTemplateRepository templates)
|
IEmailTemplateRepository templates)
|
||||||
: base(logger, unitOfWork)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_templates = templates;
|
_templates = templates;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,47 @@
|
|||||||
@HrynCo.NotificationService.Api_HostAddress = http://localhost:5188
|
@host = http://localhost:5188
|
||||||
|
|
||||||
GET {{HrynCo.NotificationService.Api_HostAddress}}/weatherforecast/
|
### Create a new email template
|
||||||
Accept: application/json
|
POST {{host}}/api/v1/email-templates
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
###
|
{
|
||||||
|
"ServiceName": "StoreMate-Prod",
|
||||||
|
"Key": "ShareInvite",
|
||||||
|
"LanguageCode": "uk",
|
||||||
|
"Subject": "Вас запрошено",
|
||||||
|
"HtmlBody": "<html><body><div style=\"font-family: Arial, sans-serif; color: #1f2937;\"><p>Вітаємо, \u007b\u007bRecipientName\u007d\u007d.</p><h1>Вас запрошено</h1><p>\u007b\u007bInviterName\u007d\u007d запросив вас приєднатися до \u007b\u007bAppName\u007d\u007d, щоб ви могли безпечно співпрацювати.</p><p><a href=\"\u007b\u007bInviteLink\u007d\u007d\">Відкрити запрошення</a></p><p>Запрошення дійсне до <strong>\u007b\u007bValidUntil\u007d\u007d</strong>.</p></div></body></html>",
|
||||||
|
"TextBody": "Вітаємо, \u007b\u007bRecipientName\u007d\u007d.\n\n\u007b\u007bInviterName\u007d\u007d запросив вас приєднатися до \u007b\u007bAppName\u007d\u007d, щоб ви могли безпечно співпрацювати.\n\nВідкрийте запрошення: \u007b\u007bInviteLink\u007d\u007d\nДійсне до: \u007b\u007bValidUntil\u007d\u007d",
|
||||||
|
"Variables": [
|
||||||
|
{ "Name": "RecipientName", "Required": false },
|
||||||
|
{ "Name": "InviterName", "Required": false },
|
||||||
|
{ "Name": "AppName", "Required": false },
|
||||||
|
{ "Name": "InviteLink", "Required": false },
|
||||||
|
{ "Name": "ValidUntil", "Required": false }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
### Get the created template
|
||||||
|
GET {{host}}/api/v1/email-templates/StoreMate-Prod/ShareInvite/uk
|
||||||
|
|
||||||
|
### List all templates for the service
|
||||||
|
GET {{host}}/api/v1/email-templates?serviceName=StoreMate-Prod
|
||||||
|
|
||||||
|
### Update the template
|
||||||
|
PUT {{host}}/api/v1/email-templates/StoreMate-Prod/ShareInvite/uk
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"Subject": "Вас запрошено",
|
||||||
|
"HtmlBody": "<html><body><p>Вітаємо, \u007b\u007bRecipientName\u007d\u007d.</p><p>\u007b\u007bInviterName\u007d\u007d запросив вас приєднатися до \u007b\u007bAppName\u007d\u007d.</p><p><a href=\"\u007b\u007bInviteLink\u007d\u007d\">Відкрити запрошення</a></p><p>Дійсне до <strong>\u007b\u007bValidUntil\u007d\u007d</strong>.</p></body></html>",
|
||||||
|
"TextBody": "Вітаємо, \u007b\u007bRecipientName\u007d\u007d.\n\n\u007b\u007bInviterName\u007d\u007d запросив вас приєднатися до \u007b\u007bAppName\u007d\u007d.\n\nВідкрийте запрошення: \u007b\u007bInviteLink\u007d\u007d\nДійсне до: \u007b\u007bValidUntil\u007d\u007d",
|
||||||
|
"Variables": [
|
||||||
|
{ "Name": "RecipientName", "Required": false },
|
||||||
|
{ "Name": "InviterName", "Required": false },
|
||||||
|
{ "Name": "AppName", "Required": false },
|
||||||
|
{ "Name": "InviteLink", "Required": false },
|
||||||
|
{ "Name": "ValidUntil", "Required": false }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
### Delete the template
|
||||||
|
DELETE {{host}}/api/v1/email-templates/StoreMate-Prod/ShareInvite/uk
|
||||||
|
|||||||
@@ -21,47 +21,95 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="row g-3 mb-3">
|
<ul class="nav nav-tabs template-editor-tabs mb-3" id="templateEditorTabs" role="tablist">
|
||||||
<div class="col-md-5">
|
<li class="nav-item" role="presentation">
|
||||||
<label asp-for="ServiceName" class="form-label fw-semibold">Service Name</label>
|
<button class="nav-link active" id="edit-tab" data-bs-toggle="tab" data-bs-target="#edit-pane" type="button" role="tab" aria-controls="edit-pane" aria-selected="true">
|
||||||
<input asp-for="ServiceName" class="form-control" readonly="@(!Model.IsNew)" />
|
Edit
|
||||||
<span asp-validation-for="ServiceName" class="text-danger small"></span>
|
</button>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item" role="presentation">
|
||||||
|
<button class="nav-link" id="preview-tab" data-bs-toggle="tab" data-bs-target="#preview-pane" type="button" role="tab" aria-controls="preview-pane" aria-selected="false">
|
||||||
|
Preview
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane fade show active" id="edit-pane" role="tabpanel" aria-labelledby="edit-tab" tabindex="0">
|
||||||
|
<div class="row g-3 mb-3">
|
||||||
|
<div class="col-md-5">
|
||||||
|
<label asp-for="ServiceName" class="form-label fw-semibold">Service Name</label>
|
||||||
|
<input asp-for="ServiceName" class="form-control" readonly="@(!Model.IsNew)" />
|
||||||
|
<span asp-validation-for="ServiceName" class="text-danger small"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<label asp-for="Key" class="form-label fw-semibold">Key</label>
|
||||||
|
<input asp-for="Key" class="form-control" readonly="@(!Model.IsNew)" />
|
||||||
|
<span asp-validation-for="Key" class="text-danger small"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<label asp-for="LanguageCode" class="form-label fw-semibold">Language</label>
|
||||||
|
<input asp-for="LanguageCode" class="form-control" readonly="@(!Model.IsNew)" />
|
||||||
|
<span asp-validation-for="LanguageCode" class="text-danger small"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="Subject" class="form-label fw-semibold">Subject</label>
|
||||||
|
<input asp-for="Subject" class="form-control" />
|
||||||
|
<span asp-validation-for="Subject" class="text-danger small"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="HtmlBody" class="form-label fw-semibold">HTML Body</label>
|
||||||
|
<textarea asp-for="HtmlBody" class="form-control font-monospace" rows="10"></textarea>
|
||||||
|
<span asp-validation-for="HtmlBody" class="text-danger small"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="TextBody" class="form-label fw-semibold">Text Body</label>
|
||||||
|
<textarea asp-for="TextBody" class="form-control font-monospace" rows="5"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="VariablesJson" class="form-label fw-semibold">Variables (JSON)</label>
|
||||||
|
<textarea asp-for="VariablesJson" class="form-control font-monospace" rows="4"
|
||||||
|
placeholder='[{"name":"UserName","required":true}]'></textarea>
|
||||||
|
<span asp-validation-for="VariablesJson" class="text-danger small"></span>
|
||||||
|
<div class="form-text">JSON array of <code>{"name":"...", "required":true|false}</code></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
|
||||||
<label asp-for="Key" class="form-label fw-semibold">Key</label>
|
<div class="tab-pane fade" id="preview-pane" role="tabpanel" aria-labelledby="preview-tab" tabindex="0">
|
||||||
<input asp-for="Key" class="form-control" readonly="@(!Model.IsNew)" />
|
<div class="template-preview-panel mb-3">
|
||||||
<span asp-validation-for="Key" class="text-danger small"></span>
|
<div class="template-preview-panel-header">
|
||||||
|
<div>
|
||||||
|
<div class="template-preview-title">Preview</div>
|
||||||
|
<div class="template-preview-subtitle">Rendered with sample values from the variable list.</div>
|
||||||
|
</div>
|
||||||
|
<span id="previewStatus" class="badge text-bg-secondary">Ready</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="template-preview-body">
|
||||||
|
<div class="template-preview-source template-preview-section-block">
|
||||||
|
<div class="template-preview-section-title">Sample values</div>
|
||||||
|
<div id="previewVariables" class="template-preview-variables"></div>
|
||||||
|
<div class="form-text mt-2">Change these values to see the rendered output update immediately.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="template-preview-output">
|
||||||
|
<div class="template-preview-section-title">Rendered subject</div>
|
||||||
|
<div id="previewSubject" class="template-preview-subject"></div>
|
||||||
|
|
||||||
|
<div class="template-preview-section-title mt-3">Rendered HTML</div>
|
||||||
|
<iframe id="previewHtmlFrame" class="template-preview-frame" title="Email HTML preview"></iframe>
|
||||||
|
|
||||||
|
<div class="template-preview-section-title mt-3">Rendered text</div>
|
||||||
|
<pre id="previewText" class="template-preview-text mb-0"></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
|
||||||
<label asp-for="LanguageCode" class="form-label fw-semibold">Language</label>
|
|
||||||
<input asp-for="LanguageCode" class="form-control" readonly="@(!Model.IsNew)" />
|
|
||||||
<span asp-validation-for="LanguageCode" class="text-danger small"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label asp-for="Subject" class="form-label fw-semibold">Subject</label>
|
|
||||||
<input asp-for="Subject" class="form-control" />
|
|
||||||
<span asp-validation-for="Subject" class="text-danger small"></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label asp-for="HtmlBody" class="form-label fw-semibold">HTML Body</label>
|
|
||||||
<textarea asp-for="HtmlBody" class="form-control font-monospace" rows="10"></textarea>
|
|
||||||
<span asp-validation-for="HtmlBody" class="text-danger small"></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label asp-for="TextBody" class="form-label fw-semibold">Text Body</label>
|
|
||||||
<textarea asp-for="TextBody" class="form-control font-monospace" rows="5"></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label asp-for="VariablesJson" class="form-label fw-semibold">Variables (JSON)</label>
|
|
||||||
<textarea asp-for="VariablesJson" class="form-control font-monospace" rows="4"
|
|
||||||
placeholder='[{"name":"UserName","required":true}]'></textarea>
|
|
||||||
<span asp-validation-for="VariablesJson" class="text-danger small"></span>
|
|
||||||
<div class="form-text">JSON array of <code>{"name":"...", "required":true|false}</code></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@section FormActions {
|
@section FormActions {
|
||||||
@@ -72,4 +120,179 @@
|
|||||||
<i class="bi bi-x-lg me-1"></i> Cancel
|
<i class="bi bi-x-lg me-1"></i> Cancel
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
const subjectField = document.getElementById('Subject');
|
||||||
|
const htmlField = document.getElementById('HtmlBody');
|
||||||
|
const textField = document.getElementById('TextBody');
|
||||||
|
const variablesField = document.getElementById('VariablesJson');
|
||||||
|
const previewVariablesHost = document.getElementById('previewVariables');
|
||||||
|
const previewSubject = document.getElementById('previewSubject');
|
||||||
|
const previewText = document.getElementById('previewText');
|
||||||
|
const previewFrame = document.getElementById('previewHtmlFrame');
|
||||||
|
const previewStatus = document.getElementById('previewStatus');
|
||||||
|
const previewTab = document.getElementById('preview-tab');
|
||||||
|
|
||||||
|
if (!subjectField || !htmlField || !textField || !variablesField || !previewVariablesHost || !previewSubject || !previewText || !previewFrame || !previewStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return String(value)
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''');
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseVariables() {
|
||||||
|
const raw = variablesField.value?.trim() || '[]';
|
||||||
|
const parsed = JSON.parse(raw);
|
||||||
|
|
||||||
|
if (!Array.isArray(parsed)) {
|
||||||
|
throw new Error('Variables JSON must be an array.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed
|
||||||
|
.filter(item => item && typeof item.Name === 'string' && item.Name.trim().length > 0)
|
||||||
|
.map(item => ({
|
||||||
|
name: item.Name.trim(),
|
||||||
|
required: !!item.Required
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildSampleValue(name) {
|
||||||
|
return `Sample ${name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderVariableInputs() {
|
||||||
|
let variables = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
variables = parseVariables();
|
||||||
|
previewStatus.className = 'badge text-bg-secondary';
|
||||||
|
previewStatus.textContent = 'Ready';
|
||||||
|
} catch (error) {
|
||||||
|
previewVariablesHost.innerHTML = `<div class="alert alert-warning mb-0">${escapeHtml(error.message || 'Invalid variables JSON')}</div>`;
|
||||||
|
previewStatus.className = 'badge text-bg-danger';
|
||||||
|
previewStatus.textContent = 'Invalid JSON';
|
||||||
|
updatePreview();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variables.length === 0) {
|
||||||
|
previewVariablesHost.innerHTML = '<div class="text-muted small">No variables defined.</div>';
|
||||||
|
updatePreview();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentValues = readVariableValues();
|
||||||
|
previewVariablesHost.innerHTML = variables.map(variable => {
|
||||||
|
const value = Object.prototype.hasOwnProperty.call(currentValues, variable.name)
|
||||||
|
? currentValues[variable.name]
|
||||||
|
: buildSampleValue(variable.name);
|
||||||
|
return `
|
||||||
|
<div class="mb-2">
|
||||||
|
<label class="form-label small fw-semibold mb-1">${escapeHtml(variable.name)}${variable.required ? ' *' : ''}</label>
|
||||||
|
<input type="text" class="form-control form-control-sm preview-variable-input" data-variable-name="${escapeHtml(variable.name)}" value="${escapeHtml(value)}" />
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
previewVariablesHost.querySelectorAll('.preview-variable-input').forEach(input => {
|
||||||
|
input.addEventListener('input', updatePreview);
|
||||||
|
});
|
||||||
|
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
function readVariableValues() {
|
||||||
|
const values = {};
|
||||||
|
previewVariablesHost.querySelectorAll('.preview-variable-input').forEach(input => {
|
||||||
|
values[input.dataset.variableName] = input.value;
|
||||||
|
});
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
function interpolate(text, values) {
|
||||||
|
let result = text || '';
|
||||||
|
|
||||||
|
Object.keys(values).forEach(key => {
|
||||||
|
const token = new RegExp(`\\{\\{${key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\}\\}`, 'g');
|
||||||
|
result = result.replace(token, values[key] ?? '');
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePreview() {
|
||||||
|
let values = {};
|
||||||
|
|
||||||
|
try {
|
||||||
|
values = readVariableValues();
|
||||||
|
} catch (error) {
|
||||||
|
values = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderedSubject = interpolate(subjectField.value, values);
|
||||||
|
const renderedHtml = interpolate(htmlField.value, values);
|
||||||
|
const renderedText = interpolate(textField.value, values);
|
||||||
|
|
||||||
|
previewSubject.textContent = renderedSubject || '(empty subject)';
|
||||||
|
previewText.textContent = renderedText || '(empty text body)';
|
||||||
|
previewFrame.srcdoc = `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 24px;
|
||||||
|
background: #eef2f7;
|
||||||
|
color: #1f2937;
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
.email-shell {
|
||||||
|
max-width: 640px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid #dbe3ee;
|
||||||
|
border-radius: 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 12px 30px rgba(15, 23, 42, .08);
|
||||||
|
}
|
||||||
|
.email-body {
|
||||||
|
padding: 28px 36px;
|
||||||
|
}
|
||||||
|
img { max-width: 100%; height: auto; }
|
||||||
|
a { color: #2563eb; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="email-shell">
|
||||||
|
<div class="email-body">
|
||||||
|
${renderedHtml || '<div style="color:#6b7280">No HTML body provided.</div>'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
variablesField.addEventListener('input', renderVariableInputs);
|
||||||
|
subjectField.addEventListener('input', updatePreview);
|
||||||
|
htmlField.addEventListener('input', updatePreview);
|
||||||
|
textField.addEventListener('input', updatePreview);
|
||||||
|
if (previewTab) {
|
||||||
|
previewTab.addEventListener('shown.bs.tab', updatePreview);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderVariableInputs();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
}
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -14,3 +14,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@RenderSection("Scripts", required: false)
|
||||||
|
|||||||
@@ -118,9 +118,10 @@ body {
|
|||||||
.empty-state .bi { font-size: 2.5rem; opacity: .35; display: block; margin-bottom: .75rem; }
|
.empty-state .bi { font-size: 2.5rem; opacity: .35; display: block; margin-bottom: .75rem; }
|
||||||
.empty-state p { font-size: .9rem; margin-bottom: 0; }
|
.empty-state p { font-size: .9rem; margin-bottom: 0; }
|
||||||
|
|
||||||
/* ── Editor wrapper — constrains width ───────────────── */
|
/* ── Editor wrapper ──────────────────────────────────── */
|
||||||
.editor-wrapper {
|
.editor-wrapper {
|
||||||
max-width: 860px;
|
width: 100%;
|
||||||
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Editor card ──────────────────────────────────────── */
|
/* ── Editor card ──────────────────────────────────────── */
|
||||||
@@ -154,6 +155,149 @@ body {
|
|||||||
border-radius: 0 0 .5rem .5rem !important;
|
border-radius: 0 0 .5rem .5rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Editor tabs ─────────────────────────────────────── */
|
||||||
|
.template-editor-tabs {
|
||||||
|
border-bottom-color: #dce3eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-editor-tabs .nav-link {
|
||||||
|
color: #526072;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: .5rem .5rem 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-editor-tabs .nav-link.active {
|
||||||
|
color: #0d6efd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Tab content ──────────────────────────────────────── */
|
||||||
|
.tab-content {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Email template preview ───────────────────────────── */
|
||||||
|
.template-preview-panel {
|
||||||
|
border: 1px solid #dce3eb;
|
||||||
|
border-radius: .75rem;
|
||||||
|
background: #fff;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-panel-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
background: linear-gradient(180deg, #f9fbff 0%, #f3f6fb 100%);
|
||||||
|
border-bottom: 1px solid #e1e7ef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-title {
|
||||||
|
font-size: .9rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-subtitle {
|
||||||
|
font-size: .82rem;
|
||||||
|
color: #6b7280;
|
||||||
|
margin-top: .15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-body {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1rem 1.25rem 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-source,
|
||||||
|
.template-preview-output {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-section-block {
|
||||||
|
padding: 1rem;
|
||||||
|
border: 1px solid #e5ebf2;
|
||||||
|
border-radius: .65rem;
|
||||||
|
background: #fafcff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-section-title {
|
||||||
|
font-size: .7rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: .08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: #6b7280;
|
||||||
|
margin-bottom: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-variables {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||||
|
gap: .75rem 1rem;
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-variables > div {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-variables .form-label {
|
||||||
|
font-size: .72rem;
|
||||||
|
margin-bottom: .2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-variables .form-control-sm {
|
||||||
|
background: #fff;
|
||||||
|
min-height: calc(1.5em + .45rem + 2px);
|
||||||
|
padding: .2rem .45rem;
|
||||||
|
font-size: .82rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-subject {
|
||||||
|
padding: .75rem 1rem;
|
||||||
|
border: 1px dashed #cfd8e3;
|
||||||
|
border-radius: .5rem;
|
||||||
|
background: #f8fafc;
|
||||||
|
min-height: 3rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111827;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-frame {
|
||||||
|
width: 100%;
|
||||||
|
height: 420px;
|
||||||
|
border: 1px solid #cfd8e3;
|
||||||
|
border-radius: .5rem;
|
||||||
|
background: #eef2f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-text {
|
||||||
|
padding: .75rem 1rem;
|
||||||
|
border: 1px solid #cfd8e3;
|
||||||
|
border-radius: .5rem;
|
||||||
|
background: #0f172a;
|
||||||
|
color: #e2e8f0;
|
||||||
|
min-height: 120px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 992px) {
|
||||||
|
.template-preview-body {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-preview-frame {
|
||||||
|
height: 360px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Form-section divider ─────────────────────────────── */
|
/* ── Form-section divider ─────────────────────────────── */
|
||||||
.form-section-title {
|
.form-section-title {
|
||||||
font-size: .68rem;
|
font-size: .68rem;
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
DB_NAME=notification_service
|
||||||
|
DB_USER=postgres
|
||||||
|
DB_PASS=postgres
|
||||||
|
VOLUME_PREFIX=ns-dev
|
||||||
|
RABBITMQ_USER=guest
|
||||||
|
RABBITMQ_PASSWORD=guest
|
||||||
|
RABBITMQ_AMQP_PORT=5672
|
||||||
|
RABBITMQ_MANAGEMENT_PORT=15672
|
||||||
|
WEB_PORT=5200
|
||||||
Reference in New Issue
Block a user