Skip to content

Commit

Permalink
Persist search parameters in the web ui.
Browse files Browse the repository at this point in the history
  • Loading branch information
Emzi0767 committed Jul 6, 2019
1 parent 765a508 commit 541cc22
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/SlimGet/Controllers/GalleryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task<IActionResult> Packages([FromQuery] int skip, CancellationToke
var count = await dbpackages.CountAsync(cancellationToken);
var next = skip + 20 <= count ? skip + 20 : -1;

return this.View("Packages", new GallerySearchListingModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20)), next, skip - 20, null));
return this.View("Packages", new GallerySearchListModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20)), next, skip - 20, null));
}

[HttpGet, SlimGetRoute(Routing.GalleryPackageRouteName)]
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<IActionResult> Search([FromQuery] GallerySearchModel search, C
var count = await dbpackages.CountAsync(cancellationToken);
var next = skip + 20 <= count ? skip + 20 : -1;

return this.View("Packages", new GallerySearchListingModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20), prerelease), next, skip - 20, search));
return this.View("Packages", new GallerySearchListModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20), prerelease), next, skip - 20, search));
}

[HttpGet, SlimGetRoute(Routing.GalleryAboutRouteName)]
Expand Down
4 changes: 2 additions & 2 deletions src/SlimGet/Models/GalleryModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public sealed class GalleryPackageListItemModel
public string Description { get; set; }
}

public sealed class GallerySearchListingModel
public sealed class GallerySearchListModel
{
public int TotalCount { get; }
public IEnumerable<GalleryPackageListItemModel> Items { get; }
Expand All @@ -89,7 +89,7 @@ public sealed class GallerySearchListingModel
public bool IncludePrerelease => this.SearchQuery.Prerelease;
public GallerySearchModel SearchQuery { get; }

public GallerySearchListingModel(int total, IEnumerable<GalleryPackageListItemModel> items, int next, int prev, GallerySearchModel searchQuery)
public GallerySearchListModel(int total, IEnumerable<GalleryPackageListItemModel> items, int next, int prev, GallerySearchModel searchQuery)
{
this.TotalCount = total;
this.Items = items;
Expand Down
2 changes: 1 addition & 1 deletion src/SlimGet/Views/Gallery/Packages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
limitations under the License.
*@

@model GallerySearchListingModel
@model GallerySearchListModel
@{
ViewData["Title"] = string.IsNullOrWhiteSpace(this.Model.Query) ? "Packages hosted in this feed" : "Package search results";
}
Expand Down
4 changes: 2 additions & 2 deletions src/SlimGet/Views/Gallery/SearchForm.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<div class="search-form">
<form method="get" asp-route="@Routing.GallerySearchRouteName">
<div class="search-group search-query-group">
<input type="text" name="q" placeholder="Search packages" />
<input type="text" name="q" placeholder="Search packages" value="@this.Model?.Query" />
<button type="submit"><i class="fas fa-search"></i></button>
</div>

<div class="search-group search-prerelease-group">
<input type="checkbox" name="pre" value="true" id="form-input-prerelease" />
<input type="checkbox" name="pre" value="true" id="form-input-prerelease" @if (this.Model?.Prerelease == true) { <text>checked="checked"</text> } />
<label for="form-input-prerelease"><i class="fas fa-check"></i></label>
<label for="form-input-prerelease">Include prerelease packages</label>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/SlimGet/wwwroot/css/slimget.css
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ p.navigation > .navigation-pipe
{
font-size: 14pt;
display: flex;
flex-direction: row;
}

.search-form > form > .search-query-group > input,
Expand All @@ -454,7 +455,7 @@ p.navigation > .navigation-pipe
line-height: 28pt;

vertical-align: top;
flex-direction: row;
border-radius: 0;

transition: all 0.2s;
}
Expand Down
Loading

0 comments on commit 541cc22

Please sign in to comment.