-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add page for uploading json files from tenor to configure persons and…
… orgs (#61) * Add page for uploading json files from tenor to configure persons and orgs Now you can open a separate tab on the localtest site and upload tenor kildedata to localtest internal storage. If there are relevant tenor files in storage, those will replace Ola Nordmann and Sofie Salt as the localtest users. You can also select a subset of the files to downoad testData.json to be used as app local users. In addtition to the user management page, I have included the following changes. * Cleanup of login page and use the menu on top instead of links scattered all over the login screen * Use latest bootstrap (from CDN, per getboostrap.com instructions) * Split HomeController into multiple smaller controllers. * Move `Reauthenticate` button besides the login button and make it a less visible color. * Loadbalancer redirects "/" and /Home/* to localtest, so all new controllers got a `/Home/[controller]/[action]` prefix * use only spaces (not mixed with tabs) in nginx.conf.conf * Fix wrong JsonPropertyName * Small UI improvments * Fix code review issues The main fix is that `GetTenorStorageDirectory` will create the directory if it does not exist. * Improve Iframe behaviour of LocalPlatformStorage * Don't let dotnet watch run add script to /LocalPlatformStorage * Mark user adminsitration as preview fix table layout
- Loading branch information
Showing
21 changed files
with
1,445 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#nullable enable | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
|
||
using LocalTest.Configuration; | ||
|
||
using LocalTest.Services.TestData; | ||
using Microsoft.AspNetCore.Authorization; | ||
|
||
namespace LocalTest.Controllers; | ||
|
||
[Route("Home/[controller]/[action]")] | ||
public class DebugUsersController : Controller | ||
{ | ||
private readonly LocalPlatformSettings _localPlatformSettings; | ||
private readonly TenorDataRepository _tenorDataRepository; | ||
|
||
public DebugUsersController( | ||
IOptions<LocalPlatformSettings> localPlatformSettings, | ||
TenorDataRepository tenorDataRepository) | ||
{ | ||
_localPlatformSettings = localPlatformSettings.Value; | ||
_tenorDataRepository = tenorDataRepository; | ||
} | ||
|
||
// Debugging endpoint | ||
[AllowAnonymous] | ||
public async Task<IActionResult> LocalTestUsersRaw() | ||
{ | ||
var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); | ||
|
||
return Json(localData); | ||
} | ||
|
||
//Debugging endpoint | ||
[AllowAnonymous] | ||
public async Task<IActionResult> LocalTestUsers() | ||
{ | ||
var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); | ||
var constructedAppData = AppTestDataModel.FromTestDataModel(localData); | ||
|
||
return Json(constructedAppData); | ||
} | ||
|
||
// Debugging endpoint | ||
[AllowAnonymous] | ||
public async Task<IActionResult> LocalTestUsersRoundTrip() | ||
{ | ||
var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); | ||
var constructedAppData = AppTestDataModel.FromTestDataModel(localData); | ||
|
||
return Json(constructedAppData.GetTestDataModel()); | ||
} | ||
|
||
// Debugging endpoint | ||
[AllowAnonymous] | ||
public async Task<IActionResult> ShowTenorUsers() | ||
{ | ||
var localData = await _tenorDataRepository.GetAppTestDataModel(); | ||
|
||
return Json(localData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#nullable enable | ||
using System.Text.Json; | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
using LocalTest.Configuration; | ||
using LocalTest.Models; | ||
using LocalTest.Services.LocalApp.Interface; | ||
|
||
using LocalTest.Services.TestData; | ||
using Microsoft.AspNetCore.Authentication.Cookies; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
|
||
namespace LocalTest.Controllers; | ||
|
||
[Route("Home/[controller]/[action]")] | ||
public class FrontendVersionController : Controller | ||
{ | ||
/// <summary> | ||
/// See src\development\loadbalancer\nginx.conf | ||
/// </summary> | ||
public static readonly string FRONTEND_URL_COOKIE_NAME = "frontendVersion"; | ||
|
||
[HttpGet] | ||
public async Task<ActionResult> Index([FromServices] HttpClient client) | ||
{ | ||
var versionFromCookie = HttpContext.Request.Cookies[FRONTEND_URL_COOKIE_NAME]; | ||
|
||
var frontendVersion = new FrontendVersion() | ||
{ | ||
Version = versionFromCookie, | ||
Versions = new List<SelectListItem>() | ||
{ | ||
new () | ||
{ | ||
Text = "Keep as is", | ||
Value = "", | ||
}, | ||
new () | ||
{ | ||
Text = "localhost:8080 (local dev)", | ||
Value = "http://localhost:8080/" | ||
} | ||
} | ||
}; | ||
var cdnVersionsString = await client.GetStringAsync("https://altinncdn.no/toolkits/altinn-app-frontend/index.json"); | ||
var groupCdnVersions = new SelectListGroup() { Name = "Specific version from cdn" }; | ||
var versions = JsonSerializer.Deserialize<List<string>>(cdnVersionsString)!; | ||
versions.Reverse(); | ||
versions.ForEach(version => | ||
{ | ||
frontendVersion.Versions.Add(new() | ||
{ | ||
Text = version, | ||
Value = $"https://altinncdn.no/toolkits/altinn-app-frontend/{version}/", | ||
Group = groupCdnVersions | ||
}); | ||
}); | ||
|
||
return View(frontendVersion); | ||
} | ||
public ActionResult Index(FrontendVersion frontendVersion) | ||
{ | ||
var options = new CookieOptions | ||
{ | ||
Expires = DateTime.MaxValue, | ||
HttpOnly = true, | ||
}; | ||
ICookieManager cookieManager = new ChunkingCookieManager(); | ||
if (string.IsNullOrWhiteSpace(frontendVersion.Version)) | ||
{ | ||
cookieManager.DeleteCookie(HttpContext, FRONTEND_URL_COOKIE_NAME, options); | ||
} | ||
else | ||
{ | ||
cookieManager.AppendResponseCookie( | ||
HttpContext, | ||
FRONTEND_URL_COOKIE_NAME, | ||
frontendVersion.Version, | ||
options | ||
); | ||
} | ||
|
||
return RedirectToAction("Index", "Home"); | ||
} | ||
} |
Oops, something went wrong.