public async Task <IActionResult> Index() { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRemoteInstances)) { return(Forbid()); } var remoteInstanceList = await _service.GetRemoteInstanceListAsync(); var model = new RemoteInstanceIndexViewModel { RemoteInstanceList = remoteInstanceList }; return(View(model)); }
public async Task <IActionResult> Index(ContentOptions options, PagerParameters pagerParameters) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageRemoteInstances)) { return(Forbid()); } var siteSettings = await _siteService.GetSiteSettingsAsync(); var pager = new Pager(pagerParameters, siteSettings.PageSize); var remoteInstances = (await _service.GetRemoteInstanceListAsync()).RemoteInstances; if (!string.IsNullOrWhiteSpace(options.Search)) { remoteInstances = remoteInstances.Where(x => x.Name.Contains(options.Search, StringComparison.OrdinalIgnoreCase)).ToList(); } var count = remoteInstances.Count(); var startIndex = pager.GetStartIndex(); var pageSize = pager.PageSize; // Maintain previous route data when generating page links var routeData = new RouteData(); routeData.Values.Add("Options.Search", options.Search); var pagerShape = (await New.Pager(pager)).TotalItemCount(count).RouteData(routeData); var model = new RemoteInstanceIndexViewModel { RemoteInstances = remoteInstances, Pager = pagerShape, Options = options }; model.Options.ContentsBulkAction = new List <SelectListItem>() { new SelectListItem() { Text = S["Delete"], Value = nameof(ContentsBulkAction.Remove) } }; return(View(model)); }
public ActionResult IndexFilterPOST(RemoteInstanceIndexViewModel model) { return(RedirectToAction(nameof(Index), new RouteValueDictionary { { "Options.Search", model.Options.Search } })); }