Projects (GanjooRazor -> DiwanRazor, GanjoorService.sln -> DiwanService.sln), files, folders, classes, namespaces, settings, API routes (/api/diwan) and DB tables (Diwan*). External addresses (ganjoor.net, github.com/ganjoor) unchanged. Migrations renamed consistently (no pending model changes); requires a fresh database. Upstream RUNNING_LOCALLY/SEMANTIC_SEARCH docs archived unmodified under docs/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.8 KiB
C#
69 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
using RMuseum.Models.Diwan;
|
|
using RMuseum.Models.Diwan.ViewModels;
|
|
|
|
namespace DiwanRazor.Pages
|
|
{
|
|
/// <summary>
|
|
/// the "explore all characters" modal - the whole-site force-directed relationship graph
|
|
/// (formerly the standalone page PeopleGraph.cshtml) plus the family-tree-roots index
|
|
/// (formerly the standalone page People.cshtml), merged into one bare fragment (Layout = null)
|
|
/// and opened via PeopleExplorer.open() in personwindow.js. Neither of those two pages had an
|
|
/// entry point in the site's own navigation, so folding them together here loses nothing -
|
|
/// it's reachable from inside PersonWindow and from the category-scoped "شخصیتها" tab's
|
|
/// "نمایش شبکهٔ کامل شخصیتها" link.
|
|
/// </summary>
|
|
public class PeopleExplorerModel : LoginPartialEnabledPageModel
|
|
{
|
|
public PeopleExplorerModel(HttpClient httpClient, IConfiguration configuration) : base(httpClient, configuration)
|
|
{
|
|
}
|
|
|
|
public string LastError { get; set; }
|
|
|
|
public List<DiwanRelatedPerson> FamilyTreeRoots { get; set; }
|
|
|
|
public DiwanPersonGraphViewModel Graph { get; set; }
|
|
|
|
/// <summary>
|
|
/// Graph, re-serialized with an explicit camelCase contract (same convention
|
|
/// PeopleGraphModel/_PersonGraphPartialModel used) so peoplegraph.js has a predictable
|
|
/// shape to parse
|
|
/// </summary>
|
|
public string GraphDataJson =>
|
|
JsonConvert.SerializeObject(
|
|
Graph,
|
|
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
|
|
);
|
|
|
|
public async Task<IActionResult> OnGetAsync()
|
|
{
|
|
InitializeCommonPageState();
|
|
|
|
var treesResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/people/familytrees");
|
|
if (!treesResponse.IsSuccessStatusCode)
|
|
{
|
|
LastError = await ReadErrorMessageAsync(treesResponse);
|
|
return Page();
|
|
}
|
|
FamilyTreeRoots = JsonConvert.DeserializeObject<List<DiwanRelatedPerson>>(await treesResponse.Content.ReadAsStringAsync());
|
|
|
|
var graphResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/people/graph");
|
|
if (!graphResponse.IsSuccessStatusCode)
|
|
{
|
|
LastError = await ReadErrorMessageAsync(graphResponse);
|
|
return Page();
|
|
}
|
|
Graph = JsonConvert.DeserializeObject<DiwanPersonGraphViewModel>(await graphResponse.Content.ReadAsStringAsync());
|
|
|
|
return Page();
|
|
}
|
|
}
|
|
}
|