props/Props/Pages/Search.cshtml
Harrison Deng 38ffb3c7e1 Added logging to module framework
Implemented logging to Adafruit and changed database loading behavior.
2021-08-07 17:20:46 -05:00

262 lines
13 KiB
Plaintext

@page
@using Props.Services.Content
@model SearchModel
@inject ITextualManager<SearchModel> ContentManager
@{
ViewData["Title"] = "Search";
ViewData["Specific"] = "Search";
}
<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" 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="submit" id="search-btn">Search</button>
</div>
</div>
<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"
data-bs-target="#configuration"><i class="bi bi-x-lg"></i></button>
</div>
<div class="row justify-content-md-center">
<section class="col-lg px-4">
<h3>Price</h3>
<div class="mb-3">
<label for="max-price" class="form-label">Maximum Price</label>
<div class="input-group">
<div class="input-group-text">
<input class="form-check-input mt-0" type="checkbox" id="max-price-enabled"
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"
value="@Model.ActiveSearchOutline.Filters.UpperPrice"
name="ActiveSearchOutline.Filters.UpperPrice">
<span class="input-group-text">.00</span>
</div>
</div>
<div class="mb-3">
<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"
value="@Model.ActiveSearchOutline.Filters.LowerPrice"
name="ActiveSearchOutline.Filters.LowerPrice">
<span class="input-group-text">.00</span>
</div>
</div>
<div class="mb-3">
<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"
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"
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"
checked="@Model.ActiveSearchOutline.Filters.KeepUnknownShipping"
name="ActiveSearchOutline.Filters.KeepUnknownShipping">
<label class="form-check-label" for="keep-unknown-shipping">Keep Unknown Shipping</label>
</div>
</div>
</section>
<section class="col-lg px-4">
<h3>Metrics</h3>
<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"
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"
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"
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"
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>
</div>
<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"
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"
checked="@Model.ActiveSearchOutline.Filters.KeepUnrated"
name="ActiveSearchOutline.Filters.KeepUnrated">
<label class="form-check-label" for="keep-unrated">Keep Unrated Items</label>
</div>
</div>
</section>
<section class="col-lg px-4">
<h3>Shops Enabled</h3>
<div class="mb-3 px-3" id="shop-checkboxes">
@foreach (string shopName in Model.SearchManager.ShopManager.GetAllShopNames())
{
<div class="form-check">
<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>
}
</div>
</section>
</div>
</div>
</div>
</form>
<div id="content-pages" class="multipage mt-3 invisible">
<ul class="nav nav-pills selectors">
<li class="nav-item" role="presentation">
<button type="button" data-bs-toggle="pill" data-bs-target="#quick-picks-slide"><i
class="bi bi-stopwatch"></i></button>
</li>
<li class="nav-item" role="presentation">
<button type="button" data-bs-toggle="pill" data-bs-target="#results-slide"><i
class="bi bi-view-list"></i></button>
</li>
<li class="nav-item" role="presentation">
<button type="button" data-bs-toggle="pill" data-bs-target="#info-slide"><i
class="bi bi-info-lg"></i></button>
</li>
</ul>
<div class="multipage-slides tab-content">
<div class="multipage-slide tab-pane fade" id="quick-picks-slide">
<div class="multipage-title">
<h1 class="display-2"><i class="bi bi-stopwatch"></i> Quick Picks</h1>
@if (Model.SearchResults != null)
{
<p>@ContentManager.Json.quickPicks.searched</p>
}
else
{
<p>@ContentManager.Json.quickPicks.prompt</p>
}
<hr class="less-concise">
</div>
<div class="multipage-content">
@if (Model.SearchResults != null)
{
@if (Model.BestRatingPriceRatio != null)
{
<p>We found this product to have the best rating to price ratio.</p>
}
@if (Model.TopRated != null)
{
<p>This listing was the one that had the highest rating.</p>
}
@if (Model.MostPurchases != null)
{
<p>This listing has the most purchases.</p>
}
@if (Model.MostReviews != null)
{
<p>This listing had the most reviews.</p>
}
@if (Model.BestPrice != null)
{
<p>Here's the listing with the lowest price.</p>
<div>
@Model.BestPrice.Name
</div>
}
@* TODO: Add display for top results. *@
}
else
{
<div class="text-center less-concise text-muted flex-grow-1 justify-content-center d-flex flex-column">
<h2>@ContentManager.Json.notSearched</h2>
</div>
}
</div>
</div>
<div class="multipage-slide tab-pane fade" id="results-slide" x-data>
<div class="multipage-title">
<h2><i class="bi bi-view-list"></i> Results</h2>
@if (Model.SearchResults != null)
{
<p>@ContentManager.Json.results.searched</p>
}
else
{
<p>@ContentManager.Json.results.prompt</p>
}
<hr class="less-concise">
</div>
<div class="multipage-content">
@if (Model.SearchResults != null)
{
@* TODO: Display results with UI for sorting and changing views. *@
}
else
{
<div class="text-center less-concise text-muted flex-grow-1 justify-content-center d-flex flex-column">
<h2>@ContentManager.Json.notSearched</h2>
</div>
}
</div>
</div>
<div class="multipage-slide tab-pane fade" id="info-slide">
<div class="multipage-content">
<div class="less-concise text-muted flex-grow-1 justify-content-center d-flex flex-column">
<h1 class="display-3"><i class="bi bi-info-circle"></i> Get Started!</h1>
<ol>
@foreach (string instruction in ContentManager.Json.instructions)
{
<li>@instruction</li>
}
</ol>
</div>
</div>
</div>
</div>
</div>