Added logging to module framework
Implemented logging to Adafruit and changed database loading behavior.
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
namespace Props.Options
|
||||
{
|
||||
public class ContentOptions
|
||||
{
|
||||
public const string Content = "Content";
|
||||
public string Dir { get; set; }
|
||||
}
|
||||
}
|
@@ -3,7 +3,8 @@ namespace Props.Options
|
||||
public class ModulesOptions
|
||||
{
|
||||
public const string Modules = "Modules";
|
||||
public string ShopsDir { get; set; }
|
||||
public string ModulesDir { get; set; }
|
||||
public string ModuleDataDir { get; set; }
|
||||
public bool RecursiveLoad { get; set; }
|
||||
public string ShopRegex { get; set; }
|
||||
}
|
||||
|
8
Props/Options/TextualOptions.cs
Normal file
8
Props/Options/TextualOptions.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Props.Options
|
||||
{
|
||||
public class TextualOptions
|
||||
{
|
||||
public const string Textual = "Textual";
|
||||
public string Dir { get; set; }
|
||||
}
|
||||
}
|
@@ -1,14 +1,15 @@
|
||||
@page
|
||||
@using Props.Services.Content
|
||||
@model IndexModel
|
||||
@inject IContentManager<IndexModel> ContentManager
|
||||
@inject ITextualManager<IndexModel> ContentManager
|
||||
@{
|
||||
ViewData["Title"] = "Home page";
|
||||
}
|
||||
|
||||
<section class="jumbotron d-flex flex-column align-items-center">
|
||||
<div>
|
||||
<img alt="Props logo" src="~/images/logo.svg" class="img-fluid" style="max-height: 540px;" asp-append-version="true" />
|
||||
<img alt="Props logo" src="~/images/logo.svg" class="img-fluid" style="max-height: 540px;"
|
||||
asp-append-version="true" />
|
||||
</div>
|
||||
<div class="text-center px-3 my-2 concise">
|
||||
<h1 class="my-2 display-1">Props</h1>
|
||||
@@ -24,7 +25,8 @@
|
||||
<h2 class="mb-3 mt-4">@ContentManager.Json.help.title</h2>
|
||||
<form class="concise my-4">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="What are you looking for?" aria-label="Search" aria-describedby="search-btn">
|
||||
<input type="text" class="form-control" placeholder="What are you looking for?" aria-label="Search"
|
||||
aria-describedby="search-btn">
|
||||
<button class="btn btn-outline-primary" type="button" id="search-btn">Search</button>
|
||||
</div>
|
||||
</form>
|
||||
|
@@ -1,28 +1,26 @@
|
||||
@page
|
||||
@using Props.Services.Content
|
||||
@model SearchModel
|
||||
@inject IContentManager<SearchModel> ContentManager
|
||||
@inject ITextualManager<SearchModel> ContentManager
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Search";
|
||||
ViewData["Specific"] = "Search";
|
||||
}
|
||||
|
||||
<div class="mt-4 mb-3">
|
||||
<div class="less-concise mx-auto">
|
||||
<form method="GET">
|
||||
<div class="mt-4 mb-3 less-concise mx-auto">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control border-primary" placeholder="What are you looking for?"
|
||||
aria-label="Search" aria-describedby="search-btn" id="search-bar" value="@Model.SearchQuery">
|
||||
aria-label="Search" aria-describedby="search-btn" id="search-bar" value="@Model.SearchQuery" name="q">
|
||||
<button class="btn btn-outline-secondary" type="button" id="configuration-toggle" data-bs-toggle="collapse"
|
||||
data-bs-target="#configuration"><i class="bi bi-sliders"></i></button>
|
||||
<button class="btn btn-primary" type="button" id="search-btn">Search</button>
|
||||
<button class="btn btn-primary" type="submit" id="search-btn">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="collapse tear" id="configuration" x-data="configuration">
|
||||
<div class="p-3">
|
||||
<div class="container">
|
||||
<div class="collapse tear" id="configuration">
|
||||
<div class="container my-3">
|
||||
<div class="d-flex">
|
||||
<h1 class="my-2 display-2 me-auto">Configuration</h1>
|
||||
<button class="btn align-self-start" type="button" id="configuration-close" data-bs-toggle="collapse"
|
||||
@@ -36,10 +34,13 @@
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">
|
||||
<input class="form-check-input mt-0" type="checkbox" id="max-price-enabled"
|
||||
x-model="maxPriceEnabled">
|
||||
checked="@Model.ActiveSearchOutline.Filters.EnableUpperPrice"
|
||||
name="ActiveSearchOutline.Filters.EnableUpperPrice">
|
||||
</div>
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="number" class="form-control" min="0" id="max-price" x-model="maxPrice">
|
||||
<input type="number" class="form-control" min="0" id="max-price"
|
||||
value="@Model.ActiveSearchOutline.Filters.UpperPrice"
|
||||
name="ActiveSearchOutline.Filters.UpperPrice">
|
||||
<span class="input-group-text">.00</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -47,7 +48,9 @@
|
||||
<label for="min-price" class="form-label">Minimum Price</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="number" class="form-control" min="0" id="min-price" x-model="minPrice">
|
||||
<input type="number" class="form-control" min="0" id="min-price"
|
||||
value="@Model.ActiveSearchOutline.Filters.LowerPrice"
|
||||
name="ActiveSearchOutline.Filters.LowerPrice">
|
||||
<span class="input-group-text">.00</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -55,17 +58,22 @@
|
||||
<label for="max-shipping" class="form-label">Maximum Shipping Fee</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">
|
||||
<input class="form-check-input mt-0" type="checkbox" id="max-shipping-enabled">
|
||||
<input class="form-check-input mt-0" type="checkbox" id="max-shipping-enabled"
|
||||
checked="@Model.ActiveSearchOutline.Filters.EnableMaxShippingFee"
|
||||
name="ActiveSearchOutline.Filters.EnableMaxShippingFee">
|
||||
</div>
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="number" class="form-control" min="0" id="max-shipping" x-model="maxShipping">
|
||||
<input type="number" class="form-control" min="0" id="max-shipping"
|
||||
value="@Model.ActiveSearchOutline.Filters.MaxShippingFee"
|
||||
name="ActiveSearchOutline.Filters.MaxShippingFee">
|
||||
<span class="input-group-text">.00</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="keep-unknown-shipping"
|
||||
x-model="keepUnknownShipping">
|
||||
checked="@Model.ActiveSearchOutline.Filters.KeepUnknownShipping"
|
||||
name="ActiveSearchOutline.Filters.KeepUnknownShipping">
|
||||
<label class="form-check-label" for="keep-unknown-shipping">Keep Unknown Shipping</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,28 +83,34 @@
|
||||
<div class="mb-3">
|
||||
<label for="min-purchases" class="form-label">Minimum Purchases</label>
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" min="0" id="min-purchases" x-model="minPurchases">
|
||||
<input type="number" class="form-control" min="0" id="min-purchases"
|
||||
value="@Model.ActiveSearchOutline.Filters.MinPurchases"
|
||||
name="ActiveSearchOutline.Filters.MinPurchases">
|
||||
<span class="input-group-text">Purchases</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="keep-unknown-purchases"
|
||||
x-model="keepUnknownPurchases">
|
||||
checked="@Model.ActiveSearchOutline.Filters.KeepUnknownPurchaseCount"
|
||||
name="ActiveSearchOutline.Filters.KeepUnknownPurchaseCount">
|
||||
<label class="form-check-label" for="keep-unknown-purchases">Keep Unknown Purchases</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="min-reviews" class="form-label">Minimum Reviews</label>
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" min="0" id="min-reviews" x-model="minReviews">
|
||||
<input type="number" class="form-control" min="0" id="min-reviews"
|
||||
value="@Model.ActiveSearchOutline.Filters.MinReviews"
|
||||
name="ActiveSearchOutline.Filters.MinReviews">
|
||||
<span class="input-group-text">Reviews</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="keep-unknown-reviews"
|
||||
x-model="keepUnknownReviews">
|
||||
checked="@Model.ActiveSearchOutline.Filters.KeepUnknownReviewCount"
|
||||
name="ActiveSearchOutline.Filters.KeepUnknownReviewCount">
|
||||
<label class="form-check-label" for="keep-unknown-reviews">Keep Unknown Number of
|
||||
Reviews</label>
|
||||
</div>
|
||||
@@ -104,12 +118,15 @@
|
||||
<div class="mb-1">
|
||||
<label for="min-rating" class="form-label">Minimum Rating</label>
|
||||
<input type="range" class="form-range" id="min-rating" min="0" max="100" step="1"
|
||||
x-model="minRating">
|
||||
<div id="min-rating-display" class="form-text">Minimum rating: <b x-text="minRating"></b>%</div>
|
||||
value="@Model.ActiveSearchOutline.Filters.MinRating"
|
||||
name="ActiveSearchOutline.Filters.MinRating">
|
||||
<div id="min-rating-display" class="form-text"></div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="keep-unrated" x-model="keepUnrated">
|
||||
<input class="form-check-input" type="checkbox" id="keep-unrated"
|
||||
checked="@Model.ActiveSearchOutline.Filters.KeepUnrated"
|
||||
name="ActiveSearchOutline.Filters.KeepUnrated">
|
||||
<label class="form-check-label" for="keep-unrated">Keep Unrated Items</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -117,20 +134,20 @@
|
||||
<section class="col-lg px-4">
|
||||
<h3>Shops Enabled</h3>
|
||||
<div class="mb-3 px-3" id="shop-checkboxes">
|
||||
<template x-for="shop in Object.keys(shops)">
|
||||
@foreach (string shopName in Model.SearchManager.ShopManager.GetAllShopNames())
|
||||
{
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" :id="`${shop}-enabled`"
|
||||
x-model="shops[shop]">
|
||||
<label class="form-check-label" :for="`${shop}-enabled`"><span
|
||||
x-text="shop"></span></label>
|
||||
<input class="form-check-input" type="checkbox" id="@($"{shopName}-enabled")"
|
||||
checked="@Model.ActiveSearchOutline.Enabled[shopName]">
|
||||
<label class="form-check-label" for="@($"{shopName}-enabled")">@shopName</label>
|
||||
</div>
|
||||
</template>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div id="content-pages" class="multipage mt-3 invisible">
|
||||
<ul class="nav nav-pills selectors">
|
||||
@@ -186,7 +203,10 @@
|
||||
|
||||
@if (Model.BestPrice != null)
|
||||
{
|
||||
<p>Looking for the lowest price? Well here it is.</p>
|
||||
<p>Here's the listing with the lowest price.</p>
|
||||
<div>
|
||||
@Model.BestPrice.Name
|
||||
</div>
|
||||
}
|
||||
|
||||
@* TODO: Add display for top results. *@
|
||||
|
@@ -28,22 +28,24 @@ namespace Props.Pages
|
||||
public ProductListing MostReviews { get; private set; }
|
||||
public ProductListing BestPrice { get; private set; }
|
||||
|
||||
private ISearchManager searchManager;
|
||||
public ISearchManager SearchManager { get; private set; }
|
||||
private UserManager<ApplicationUser> userManager;
|
||||
private IMetricsManager analytics;
|
||||
public SearchOutline ActiveSearchOutline { get; private set; }
|
||||
|
||||
public SearchModel(ISearchManager searchManager, UserManager<ApplicationUser> userManager, IMetricsManager analyticsManager)
|
||||
{
|
||||
this.searchManager = searchManager;
|
||||
this.SearchManager = searchManager;
|
||||
this.userManager = userManager;
|
||||
this.analytics = analyticsManager;
|
||||
}
|
||||
|
||||
public async Task OnGet()
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
ActiveSearchOutline = User.Identity.IsAuthenticated ? (await userManager.GetUserAsync(User)).searchOutlinePreferences.ActiveSearchOutline : new SearchOutline();
|
||||
if (string.IsNullOrWhiteSpace(SearchQuery)) return;
|
||||
SearchOutline activeSearchOutline = User.Identity.IsAuthenticated ? (await userManager.GetUserAsync(User)).searchOutlinePreferences.ActiveSearchOutline : new SearchOutline();
|
||||
this.SearchResults = searchManager.Search(SearchQuery, activeSearchOutline);
|
||||
Console.WriteLine(SearchQuery);
|
||||
this.SearchResults = await SearchManager.Search(SearchQuery, ActiveSearchOutline);
|
||||
BestRatingPriceRatio = (from result in SearchResults orderby result.GetRatingToPriceRatio() descending select result).FirstOrDefault((listing) => listing.GetRatingToPriceRatio() >= 0.5f);
|
||||
TopRated = (from result in SearchResults orderby result.Rating descending select result).FirstOrDefault();
|
||||
MostPurchases = (from result in SearchResults orderby result.PurchaseCount descending select result).FirstOrDefault();
|
||||
|
@@ -31,15 +31,6 @@
|
||||
<ProjectReference Include="..\Props-Modules\Props.Shop\Framework\Props.Shop.Framework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include=".\content\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include=".\shops\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Watch Include="**\*.js;**\*.scss" Exclude="node_modules\**\*;**\*.js.map;obj\**\*;bin\**\*" />
|
||||
</ItemGroup>
|
||||
|
@@ -7,6 +7,7 @@ namespace Props.Services.Modules
|
||||
{
|
||||
public interface ISearchManager
|
||||
{
|
||||
public IEnumerable<ProductListing> Search(string query, SearchOutline searchOutline);
|
||||
public IShopManager ShopManager { get; }
|
||||
public Task<IEnumerable<ProductListing>> Search(string query, SearchOutline searchOutline);
|
||||
}
|
||||
}
|
@@ -14,17 +14,17 @@ namespace Props.Services.Modules
|
||||
{
|
||||
private ILogger<LiveSearchManager> logger;
|
||||
private SearchOptions searchOptions;
|
||||
private IShopManager shopManager;
|
||||
public IShopManager ShopManager { get; private set; }
|
||||
private IMetricsManager metricsManager;
|
||||
|
||||
public LiveSearchManager(IMetricsManager metricsManager, IShopManager shopManager, IConfiguration configuration, ILogger<LiveSearchManager> logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.metricsManager = metricsManager;
|
||||
this.shopManager = shopManager;
|
||||
this.ShopManager = shopManager;
|
||||
this.searchOptions = configuration.GetSection(SearchOptions.Search).Get<SearchOptions>();
|
||||
}
|
||||
public IEnumerable<ProductListing> Search(string query, SearchOutline searchOutline)
|
||||
public async Task<IEnumerable<ProductListing>> Search(string query, SearchOutline searchOutline)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(query)) throw new ArgumentException($"Query \"{query}\" is null or whitepsace.");
|
||||
if (searchOutline == null) throw new ArgumentNullException("searchOutline");
|
||||
@@ -32,13 +32,13 @@ namespace Props.Services.Modules
|
||||
metricsManager.RegisterSearchQuery(query);
|
||||
logger.LogDebug("Searching for \"{0}\".", query);
|
||||
|
||||
foreach (string shopName in shopManager.GetAllShopNames())
|
||||
foreach (string shopName in ShopManager.GetAllShopNames())
|
||||
{
|
||||
if (searchOutline.Enabled[shopName])
|
||||
{
|
||||
logger.LogDebug("Checking \"{0}\".", shopName);
|
||||
int amount = 0;
|
||||
foreach (ProductListing product in shopManager.GetShop(shopName).Search(query, searchOutline.Filters))
|
||||
await foreach (ProductListing product in ShopManager.GetShop(shopName).Search(query, searchOutline.Filters))
|
||||
{
|
||||
if (searchOutline.Filters.Validate(product))
|
||||
{
|
||||
|
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualStudio.Web.CodeGeneration;
|
||||
using Props.Data;
|
||||
using Props.Models.Search;
|
||||
using Props.Options;
|
||||
@@ -18,26 +19,22 @@ namespace Props.Services.Modules
|
||||
{
|
||||
public class ModularShopManager : IShopManager
|
||||
{
|
||||
private ILoggerFactory loggerFactory;
|
||||
private ILogger<ModularShopManager> logger;
|
||||
private Dictionary<string, IShop> shops;
|
||||
private ModulesOptions options;
|
||||
private IConfiguration configuration;
|
||||
private bool disposedValue;
|
||||
|
||||
public ModularShopManager(IConfiguration configuration, ILogger<ModularShopManager> logger)
|
||||
public ModularShopManager(IConfiguration configuration, ILogger<ModularShopManager> logger, ILoggerFactory loggerFactory)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.loggerFactory = loggerFactory;
|
||||
this.logger = logger;
|
||||
this.configuration = configuration;
|
||||
options = configuration.GetSection(ModulesOptions.Modules).Get<ModulesOptions>();
|
||||
|
||||
Directory.CreateDirectory(options.ModuleDataDir);
|
||||
shops = new Dictionary<string, IShop>();
|
||||
foreach (IShop shop in LoadShops(options.ShopsDir, options.ShopRegex, options.RecursiveLoad))
|
||||
{
|
||||
if (!shops.TryAdd(shop.ShopName, shop))
|
||||
{
|
||||
logger.LogWarning("Duplicate shop {0} detected. Ignoring the latter.", shop.ShopName);
|
||||
}
|
||||
}
|
||||
LoadShops();
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllShopNames()
|
||||
@@ -56,9 +53,13 @@ namespace Props.Services.Modules
|
||||
return shops.Values;
|
||||
}
|
||||
|
||||
private IEnumerable<IShop> LoadShops(string shopsDir, string shopRegex, bool recursiveLoad)
|
||||
public void LoadShops()
|
||||
{
|
||||
Stack<Task> asyncInitTasks = new Stack<Task>();
|
||||
// TODO: Figure out how to best call this.
|
||||
string shopsDir = options.ModulesDir;
|
||||
string shopRegex = options.ShopRegex;
|
||||
bool recursiveLoad = options.RecursiveLoad;
|
||||
|
||||
Stack<string> directories = new Stack<string>();
|
||||
directories.Push(shopsDir);
|
||||
string currentDirectory = null;
|
||||
@@ -86,12 +87,14 @@ namespace Props.Services.Modules
|
||||
IShop shop = Activator.CreateInstance(type) as IShop;
|
||||
if (shop != null)
|
||||
{
|
||||
// TODO: load persisted shop data.
|
||||
shop.Initialize(null);
|
||||
asyncInitTasks.Push(shop.InitializeAsync(null));
|
||||
DirectoryInfo dataDir = Directory.CreateDirectory(Path.Combine(options.ModuleDataDir, file));
|
||||
shop.Initialize(dataDir.FullName, loggerFactory);
|
||||
success += 1;
|
||||
if (!shops.TryAdd(shop.ShopName, shop))
|
||||
{
|
||||
logger.LogWarning("Duplicate shop {0} detected. Ignoring the latter.", shop.ShopName);
|
||||
}
|
||||
logger.LogDebug("Loaded \"{0}\".", shop.ShopName);
|
||||
yield return shop;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +106,6 @@ namespace Props.Services.Modules
|
||||
}
|
||||
}
|
||||
logger.LogDebug("Waiting for all shops to finish asynchronous initialization.");
|
||||
Task.WaitAll(asyncInitTasks.ToArray());
|
||||
logger.LogDebug("All shops finished asynchronous initialization.");
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using Microsoft.Extensions.DependencyModel;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Props.Shop.Framework;
|
||||
|
||||
namespace Props.Services.Modules
|
||||
@@ -18,6 +19,7 @@ namespace Props.Services.Modules
|
||||
protected override Assembly Load(AssemblyName assemblyName)
|
||||
{
|
||||
if (assemblyName.FullName.Equals(typeof(IShop).Assembly.FullName)) return null;
|
||||
if (assemblyName.FullName.Equals(typeof(ILoggerFactory).Assembly.FullName)) return null;
|
||||
string assemblyPath = resolver.ResolveAssemblyToPath(assemblyName);
|
||||
return assemblyPath != null ? LoadFromAssemblyPath(assemblyPath) : null;
|
||||
}
|
||||
|
@@ -5,13 +5,13 @@ using Props.Options;
|
||||
|
||||
namespace Props.Services.Content
|
||||
{
|
||||
public class CachedContentManager<TPage> : IContentManager<TPage>
|
||||
public class CachedTextualManager<TPage> : ITextualManager<TPage>
|
||||
{
|
||||
private dynamic data;
|
||||
private readonly ContentOptions options;
|
||||
private readonly TextualOptions options;
|
||||
private readonly string fileName;
|
||||
|
||||
dynamic IContentManager<TPage>.Json
|
||||
dynamic ITextualManager<TPage>.Json
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -20,9 +20,9 @@ namespace Props.Services.Content
|
||||
}
|
||||
}
|
||||
|
||||
public CachedContentManager(IConfiguration configuration)
|
||||
public CachedTextualManager(IConfiguration configuration)
|
||||
{
|
||||
this.options = configuration.GetSection(ContentOptions.Content).Get<ContentOptions>();
|
||||
this.options = configuration.GetSection(TextualOptions.Textual).Get<TextualOptions>();
|
||||
this.fileName = typeof(TPage).Name.Replace("Model", "") + ".json";
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
namespace Props.Services.Content
|
||||
{
|
||||
public interface IContentManager<out TModel>
|
||||
public interface ITextualManager<out TModel>
|
||||
{
|
||||
dynamic Json { get; }
|
||||
}
|
@@ -54,7 +54,7 @@ namespace Props
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
services.AddRazorPages();
|
||||
|
||||
services.AddSingleton(typeof(IContentManager<>), typeof(CachedContentManager<>));
|
||||
services.AddSingleton(typeof(ITextualManager<>), typeof(CachedTextualManager<>));
|
||||
services.AddSingleton<IShopManager, ModularShopManager>();
|
||||
services.AddScoped<IMetricsManager, LiveMetricsManager>();
|
||||
services.AddScoped<ISearchManager, LiveSearchManager>();
|
||||
|
@@ -37,7 +37,6 @@ namespace Props.TagHelpers
|
||||
{
|
||||
output.AddClass(ActiveClass, HtmlEncoder.Default);
|
||||
output.Attributes.Add("aria-current", "page");
|
||||
output.Attributes.RemoveAll("href");
|
||||
}
|
||||
output.TagName = "a";
|
||||
}
|
||||
|
@@ -10,15 +10,16 @@
|
||||
}
|
||||
},
|
||||
"Modules": {
|
||||
"ShopsDir": "./shops",
|
||||
"ModulesDir": "./shops",
|
||||
"ModuleDataDir": "./shop-data",
|
||||
"RecursiveLoad": "false",
|
||||
"ShopRegex": "Props\\.Shop\\.."
|
||||
},
|
||||
"Search": {
|
||||
"MaxResults": 100
|
||||
},
|
||||
"Content": {
|
||||
"Dir": "./content"
|
||||
"Textual": {
|
||||
"Dir": "./textual"
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
@@ -1,6 +1,3 @@
|
||||
import Alpine from "alpinejs";
|
||||
import { apiHttp } from "~/assets/js/services/http.js";
|
||||
|
||||
const startingSlide = "#quick-picks-slide";
|
||||
|
||||
function initInteractiveElements() {
|
||||
@@ -14,33 +11,14 @@ function initInteractiveElements() {
|
||||
});
|
||||
}
|
||||
|
||||
async function initConfigurationData() {
|
||||
const givenConfig = (await apiHttp.get("/SearchOutline/Filters")).data;
|
||||
const disabledShops = (await apiHttp.get("/SearchOutline/DisabledShops")).data;
|
||||
const availableShops = (await apiHttp.get("/Search/Available")).data;
|
||||
document.addEventListener("alpine:init", () => {
|
||||
Alpine.data("configuration", () => {
|
||||
const configuration = {
|
||||
maxPriceEnabled: givenConfig.enableUpperPrice,
|
||||
maxPrice: givenConfig.upperPrice,
|
||||
minPrice: givenConfig.lowerPrice,
|
||||
maxShippingEnabled: givenConfig.enableMaxShippingFee,
|
||||
maxShipping: givenConfig.maxShippingFee,
|
||||
keepUnknownShipping: givenConfig.keepUnknownShipping,
|
||||
minRating: givenConfig.minRating * 100,
|
||||
keepUnrated: givenConfig.keepUnrated,
|
||||
minReviews: givenConfig.minReviews,
|
||||
keepUnknownReviews: givenConfig.keepUnknownReviewCount,
|
||||
keepUnknownPurchases: givenConfig.keepUnknownPurchaseCount,
|
||||
minPurchases: givenConfig.minPurchases,
|
||||
shops: {},
|
||||
};
|
||||
availableShops.forEach(shop => {
|
||||
configuration.shops[shop] = !disabledShops.includes(shop);
|
||||
});
|
||||
return configuration;
|
||||
});
|
||||
});
|
||||
function initConfigVisuals() {
|
||||
const minRatingDisplay = document.querySelector("#configuration #min-rating-display");
|
||||
const minRatingSlider = document.querySelector("#configuration #min-rating");
|
||||
const updateDisplay = function () {
|
||||
minRatingDisplay.innerHTML = `Minimum rating: ${minRatingSlider.value}%`;
|
||||
};
|
||||
minRatingSlider.addEventListener("input", updateDisplay);
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
function initSlides() {
|
||||
@@ -68,9 +46,8 @@ function initSlides() {
|
||||
|
||||
async function main() {
|
||||
initInteractiveElements();
|
||||
await initConfigurationData();
|
||||
initConfigVisuals();
|
||||
initSlides();
|
||||
Alpine.start();
|
||||
}
|
||||
|
||||
main();
|
||||
|
BIN
Props/shops/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
BIN
Props/shops/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
Binary file not shown.
@@ -10,8 +10,7 @@
|
||||
"dependencies": {
|
||||
"FuzzySharp": "2.0.2",
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"Props.Shop.Framework": "1.0.0",
|
||||
"System.Linq.Async": "5.0.0"
|
||||
"Props.Shop.Framework": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"Props.Shop.Adafruit.dll": {}
|
||||
@@ -25,6 +24,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Logging.Abstractions/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.20.51904"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Newtonsoft.Json.dll": {
|
||||
@@ -33,15 +40,10 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.1/System.Linq.Async.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.0.0.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Props.Shop.Framework/1.0.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Logging.Abstractions": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"Props.Shop.Framework.dll": {}
|
||||
}
|
||||
@@ -61,6 +63,13 @@
|
||||
"path": "fuzzysharp/2.0.2",
|
||||
"hashPath": "fuzzysharp.2.0.2.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Extensions.Logging.Abstractions/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-NxP6ahFcBnnSfwNBi2KH2Oz8Xl5Sm2krjId/jRR3I7teFphwiUoUeZPwTNA21EX+5PtjqmyAvKaOeBXcJjcH/w==",
|
||||
"path": "microsoft.extensions.logging.abstractions/5.0.0",
|
||||
"hashPath": "microsoft.extensions.logging.abstractions.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Newtonsoft.Json/13.0.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
@@ -68,13 +77,6 @@
|
||||
"path": "newtonsoft.json/13.0.1",
|
||||
"hashPath": "newtonsoft.json.13.0.1.nupkg.sha512"
|
||||
},
|
||||
"System.Linq.Async/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-cPtIuuH8TIjVHSi2ewwReWGW1PfChPE0LxPIDlfwVcLuTM9GANFTXiMB7k3aC4sk3f0cQU25LNKzx+jZMxijqw==",
|
||||
"path": "system.linq.async/5.0.0",
|
||||
"hashPath": "system.linq.async.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Props.Shop.Framework/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
|
Binary file not shown.
BIN
Props/shops/Props.Shop.Framework.dll
Normal file
BIN
Props/shops/Props.Shop.Framework.dll
Normal file
Binary file not shown.
Reference in New Issue
Block a user