Skip to content

Commit

Permalink
Add fontsUrl support to AuthenticationManager
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPurdum committed Dec 5, 2024
1 parent c02421c commit d199507
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<CoreVersion>3.1.1</CoreVersion>
<CoreVersion>3.1.2-beta1</CoreVersion>
</PropertyGroup>
</Project>
30 changes: 26 additions & 4 deletions src/dymaptic.GeoBlazor.Core/Model/AuthenticationManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using dymaptic.GeoBlazor.Core.Components.Views;
using dymaptic.GeoBlazor.Core.Objects;
using Microsoft.Extensions.Configuration;
using Microsoft.JSInterop;

Expand Down Expand Up @@ -115,6 +114,29 @@ public List<string>? TrustedServers
}
}

/// <summary>
/// Get or set the ArcGIS Fonts URL. This would only be used in disconnected scenarios where you want to point to a local ArcGIS Portal.
/// </summary>
public string? FontsUrl
{
get
{
if (string.IsNullOrWhiteSpace(_fontsUrl))
{
_fontsUrl = _configuration["ArcGISFontsUrl"];
}

return _fontsUrl;
}
set
{
if (!string.IsNullOrWhiteSpace(value))
{
_fontsUrl = value;
}
}
}

/// <summary>
/// Initializes authentication based on either an OAuth App ID or an API Key. This is called automatically by <see cref="MapView" /> on first render, but can also be called manually for other actions such as rest calls.
/// </summary>
Expand All @@ -125,7 +147,8 @@ public async Task<bool> Initialize()
IJSObjectReference arcGisJsInterop = await GetArcGisJsInterop();

_module = await arcGisJsInterop.InvokeAsync<IJSObjectReference>("getAuthenticationManager",
_cancellationTokenSource.Token, DotNetObjectReference.Create(this), ApiKey, AppId, PortalUrl, TrustedServers);
_cancellationTokenSource.Token, DotNetObjectReference.Create(this), ApiKey, AppId, PortalUrl,
TrustedServers, FontsUrl);
}

return true;
Expand Down Expand Up @@ -186,8 +209,6 @@ public async Task EnsureLoggedIn()
/// </summary>
public async Task<IJSObjectReference> GetArcGisJsInterop()
{
LicenseType licenseType = Licensing.GetLicenseType();

var token = new CancellationToken();
IJSObjectReference? arcGisPro = await JsModuleManager.GetArcGisJsPro(_jsRuntime, token);
IJSObjectReference arcGisJsInterop = await JsModuleManager.GetArcGisJsCore(_jsRuntime, arcGisPro, token);
Expand All @@ -203,4 +224,5 @@ public async Task<IJSObjectReference> GetArcGisJsInterop()
private List<string>? _trustedServers;
private string? _portalUrl;
private IJSObjectReference? _module;
private string? _fontsUrl;
}
6 changes: 3 additions & 3 deletions src/dymaptic.GeoBlazor.Core/Scripts/arcGisJsInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export let dotNetRefs = {};
export let queryLayer: FeatureLayer;
export let blazorServer: boolean = false;
import normalizeUtils from "@arcgis/core/geometry/support/normalizeUtils";
export { projection, geometryEngine, Graphic, Color, Point, Polyline, Polygon, normalizeUtils };
export { projection, geometryEngine, Graphic, Color, Point, Polyline, Polygon, normalizeUtils, esriConfig };
let notifyExtentChanged: boolean = true;
let uploadingLayers: Array<string> = [];
let userChangedViewExtent: boolean = false;
Expand Down Expand Up @@ -3315,9 +3315,9 @@ function updateGeometryForProtobuf(geometry) {
let _authenticationManager: AuthenticationManager | null = null;

export function getAuthenticationManager(dotNetRef: any, apiKey: string | null, appId: string | null,
portalUrl: string | null, trustedServers: string[] | null): AuthenticationManager {
portalUrl: string | null, trustedServers: string[] | null, fontsUrl: string | null): AuthenticationManager {
if (_authenticationManager === null) {
_authenticationManager = new AuthenticationManager(dotNetRef, apiKey, appId, portalUrl, trustedServers);
_authenticationManager = new AuthenticationManager(dotNetRef, apiKey, appId, portalUrl, trustedServers, fontsUrl);
}
return _authenticationManager;
}
Expand Down
6 changes: 5 additions & 1 deletion src/dymaptic.GeoBlazor.Core/Scripts/authenticationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class AuthenticationManager {
private info: OAuthInfo | undefined;
private dotNetRef: any;

constructor(dotNetReference, apiKey, appId, portalUrl, trustedServers) {
constructor(dotNetReference, apiKey, appId, portalUrl, trustedServers, fontsUrl) {
if (appId !== null) {
this.appId = appId;
this.info = new OAuthInfo({
Expand All @@ -26,6 +26,10 @@ export default class AuthenticationManager {
if (trustedServers !== null) {
esriConfig.request.trustedServers = esriConfig.request.trustedServers !== undefined ? esriConfig.request.trustedServers.concat(trustedServers) : trustedServers;
}

if (fontsUrl !== null) {
esriConfig.fontsUrl = fontsUrl;
}

this.dotNetRef = dotNetReference;
}
Expand Down

0 comments on commit d199507

Please sign in to comment.