-
-
-
-
@@ -239,140 +217,13 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
- @foreach (var serviceGroup in Model.reviewServices)
- {
- var serviceGroupTag = @serviceGroup.ServiceName.ToLower().Replace(" ","-");
- @serviceGroupTag = @Regex.Replace(@serviceGroupTag, "[^a-zA-Z0-9_-]+", "", RegexOptions.Compiled);
-
-
-
- @serviceGroup.ServiceName
- |
-
- @foreach (var packageGroup in serviceGroup.packages.Values)
- {
- var packageGroupTag = @serviceGroupTag + '_' + @packageGroup.PackageDisplayName.ToLower().Replace(" ","-");
- @packageGroupTag = @Regex.Replace(@packageGroupTag, "[^a-zA-Z0-9_-]+", "", RegexOptions.Compiled);
-
-
-
- @packageGroup.PackageDisplayName
- |
-
-
- @foreach (var reviewData in packageGroup.reviews)
- {
- var truncationIndex = @Math.Min(@reviewData.ReviewDisplayName.Length, 100);
-
-
- @if (reviewData.Language != null)
- {
- @switch (reviewData.Language.ToLower())
- {
- case "c#":
-
- break;
- case "javascript":
-
- break;
- case "python":
-
- break;
- case "c":
-
- break;
- case "c++":
-
- break;
- case "go":
-
- break;
- case "java":
-
- break;
- case "swift":
-
- break;
- default:
-
- break;
- }
- }
- @reviewData.ReviewDisplayName.Substring(0, @truncationIndex)
- @if (reviewData.IsApproved == true)
- {
- APPROVED
- }
- |
-
- @reviewData.Author
- |
-
-
- |
-
- @reviewData.FilterType.ToString()
- |
-
- @if (reviewData.Author == User.GetGitHubLogin())
- {
-
-
-
- }
- else
- {
-
-
-
- }
- |
-
- }
- }
- }
-
-
-
+
diff --git a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Index.cshtml.cs b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Index.cshtml.cs
index f868ee86fbb..df43fe68641 100644
--- a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Index.cshtml.cs
+++ b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Index.cshtml.cs
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Linq;
-using System.Text.Json;
+using System.Web;
using System.Threading.Tasks;
using APIViewWeb.Models;
using APIViewWeb.Repositories;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
+using Microsoft.Extensions.Azure;
namespace APIViewWeb.Pages.Assemblies
{
@@ -13,6 +14,8 @@ public class IndexPageModel : PageModel
{
private readonly ReviewManager _manager;
private readonly UserPreferenceCache _preferenceCache;
+ public const int _defaultPageSize = 50;
+ public const string _defaultSortField = "LastUpdated";
public IndexPageModel(ReviewManager manager, UserPreferenceCache preferenceCache)
{
@@ -26,28 +29,32 @@ public IndexPageModel(ReviewManager manager, UserPreferenceCache preferenceCache
[FromForm]
public string Label { get; set; }
- [BindProperty(SupportsGet = true)]
- public bool Closed { get; set; }
+ public ReviewsProperties ReviewsProperties { get; set; } = new ReviewsProperties();
- [BindProperty(SupportsGet = true)]
- public string Language { get; set; } = "All";
+ public (IEnumerable
Reviews, int TotalCount, int TotalPages,
+ int CurrentPage, int? PreviousPage, int? NextPage) PagedResults { get; set; }
- [BindProperty(SupportsGet = true)]
- public ReviewType FilterType { get; set; } = ReviewType.Automatic;
-
- public IEnumerable Assemblies { get; set; } = new List();
-
- public IEnumerable reviewServices { get; set; }
+ public async Task OnGetAsync(
+ List search = null, List languages=null, List state =null,
+ List status =null, List type =null, int pageNo=1, int pageSize=_defaultPageSize, string sortField=_defaultSortField)
+ {
+ await RunGetRequest(search, languages, state, status, type, pageNo, pageSize, sortField);
+ }
- public async Task OnGetAsync()
+ public async Task OnGetReviewsPartialAsync(
+ List search = null, List languages = null, List state = null,
+ List status = null, List type = null, int pageNo = 1, int pageSize=_defaultPageSize, string sortField=_defaultSortField)
{
- _preferenceCache.UpdateUserPreference(new UserPreferenceModel() {
- UserName = User.GetGitHubLogin(),
- FilterType = this.FilterType,
- Language = this.Language,
- });
+ await RunGetRequest(search, languages, state, status, type, pageNo, pageSize, sortField);
+ return Partial("_ReviewsPartial", PagedResults);
+ }
- reviewServices = await _manager.GetReviewsByServicesAsync(FilterType);
+ public async Task OnGetReviewsLanguagesAsync(List selectedLanguages = null)
+ {
+ ReviewsProperties.Languages.All = await _manager.GetReviewProprtiesAsync("Revisions[0].Files[0].Language");
+ selectedLanguages = selectedLanguages.Select(x => HttpUtility.UrlDecode(x)).ToList();
+ ReviewsProperties.Languages.Selected = selectedLanguages;
+ return Partial("_SelectPickerPartial", ReviewsProperties.Languages);
}
public async Task OnPostUploadAsync()
@@ -71,13 +78,88 @@ public async Task OnPostUploadAsync()
return RedirectToPage();
}
- public Dictionary GetRoutingData(string language = null, bool? closed = null, ReviewType filterType = ReviewType.Manual)
+ private async Task RunGetRequest(List search, List languages,
+ List state, List status, List type, int pageNo, int pageSize, string sortField)
{
- var routingData = new Dictionary();
- routingData["language"] = language ?? Language;
- routingData["closed"] = (closed ?? Closed) == true ? "true" : "false";
- routingData["filterType"] = filterType.ToString();
- return routingData;
+ search = search.Select(x => HttpUtility.UrlDecode(x)).ToList();
+ languages = languages.Select(x => HttpUtility.UrlDecode(x)).ToList();
+ state = state.Select(x => HttpUtility.UrlDecode(x)).ToList();
+ status = status.Select(x => HttpUtility.UrlDecode(x)).ToList();
+ type = type.Select(x => HttpUtility.UrlDecode(x)).ToList();
+
+ // Update selected properties
+ if (state.Count() > 0)
+ {
+ ReviewsProperties.State.Selected = state;
+ }
+ else
+ {
+ state = ReviewsProperties.State.Selected.ToList();
+ }
+
+ if (status.Count() > 0)
+ {
+ ReviewsProperties.Status.Selected = status;
+ }
+
+ if (type.Count() > 0)
+ {
+ ReviewsProperties.Type.Selected = type;
+ }
+
+ bool? isClosed = null;
+ // Resolve isClosed value
+ if (state.Contains("Open") && !state.Contains("Closed"))
+ {
+ isClosed = false;
+ }
+ else if (!state.Contains("Open") && state.Contains("Closed"))
+ {
+ isClosed = true;
+ }
+ else
+ {
+ isClosed = null;
+ }
+
+ // Resolve FilterType
+ List filterTypes = new List();
+ if (type.Contains("Manual")) { filterTypes.Add((int)ReviewType.Manual); }
+ if (type.Contains("Automatic")) { filterTypes.Add((int)ReviewType.Automatic); }
+ if (type.Contains("PullRequest")) { filterTypes.Add((int)ReviewType.PullRequest); }
+
+ _preferenceCache.UpdateUserPreference(new UserPreferenceModel()
+ {
+ UserName = User.GetGitHubLogin(),
+ FilterType = filterTypes.Cast().ToList(),
+ Language = languages
+ });
+
+ bool? isApproved = null;
+ // Resolve Approval State
+ if (status.Contains("Approved") && !status.Contains("Pending"))
+ {
+ isApproved = true;
+ }
+ else if (!status.Contains("Approved") && status.Contains("Pending"))
+ {
+ isApproved = false;
+ }
+ else
+ {
+ isApproved = null;
+ }
+ var offset = (pageNo - 1) * pageSize;
+
+ PagedResults = await _manager.GetPagedReviewsAsync(search, languages, isClosed, filterTypes, isApproved, offset, pageSize, sortField);
}
}
+
+ public class ReviewsProperties
+ {
+ public (IEnumerable All, IEnumerable Selected) Languages = (All: new List(), Selected: new List());
+ public (IEnumerable All, IEnumerable Selected) State = (All: new List { "Closed", "Open" }, Selected: new List { "Open" });
+ public (IEnumerable All, IEnumerable Selected) Status = (All: new List { "Approved", "Pending" }, Selected: new List());
+ public (IEnumerable All, IEnumerable Selected) Type = (All: new List { "Automatic", "Manual", "PullRequest" }, Selected: new List());
+ }
}
diff --git a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml
index cc70ae9fc43..c12e5510cad 100644
--- a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml
+++ b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml
@@ -43,6 +43,15 @@
case "swift":
break;
+ case "kotlin":
+
+ break;
+ case "json":
+
+ break;
+ case "swagger":
+
+ break;
default:
@Model.Review.Language
break;
@@ -85,7 +94,7 @@