Initial Commit

This commit is contained in:
2026-05-29 14:17:46 -04:00
commit b7d0676d5b
498 changed files with 30308 additions and 0 deletions
@@ -0,0 +1,45 @@
using Blazor.Analytics;
namespace Services.Website;
public class DataCollectionKeys
{
// Inputs people are using in the build calculator
public static string BuildCalcInput = "buildcalc-input";
public static string PageInitialized = "page-initialized";
public static string FirstPage = "first-page";
}
public class DataCollectionService : IDataCollectionService, IDisposable
{
private readonly IAnalytics _globalTracking;
private readonly IStorageService _storageService;
private bool _isEnabled;
public DataCollectionService(IAnalytics globalTracking,
IStorageService storageService)
{
_globalTracking = globalTracking;
_storageService = storageService;
_storageService.Subscribe(Refresh);
Refresh();
}
public void SendEvent<T>(string eventName, T eventData)
{
if (_isEnabled) _globalTracking.TrackEvent(eventName, eventData);
}
void IDisposable.Dispose()
{
_storageService.Unsubscribe(Refresh);
}
private void Refresh()
{
_isEnabled = _storageService.GetValue<bool>(StorageKeys.EnabledDataCollection);
}
}
@@ -0,0 +1,76 @@
namespace Services.Website;
//TODO Move to a database folder, with EntityService, EntityFilterService
public class EntityDialogService : IEntityDialogService
{
private readonly List<string> history = new();
private string? entityId;
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange += action;
}
public void AddDialog(string id)
{
entityId = id;
history.Add(id);
NotifyDataChanged();
}
public void CloseDialog()
{
entityId = null;
history.Clear();
NotifyDataChanged();
}
public void BackDialog()
{
if (history.Count > 1)
{
history.RemoveAt(history.Count - 1);
if (history.Count == 0)
{
entityId = null;
NotifyDataChanged();
return;
}
entityId = history.Last();
NotifyDataChanged();
}
}
public bool HasDialog()
{
return entityId != null;
}
public bool HasHistory()
{
return history.Count > 1;
}
public string? GetEntityId()
{
return entityId;
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
OnChange?.Invoke();
}
}
@@ -0,0 +1,56 @@
using Microsoft.AspNetCore.Components;
namespace Services.Website;
public class DialogContents
{
public string Title { get; set; }
public string Message { get; set; }
public string ConfirmButtonLabel { get; set; }
public EventCallback<EventArgs> OnConfirm { get; set; }
public EventCallback<EventArgs> OnCancel { get; set; }
}
public class MyDialogService : IMyDialogService
{
private DialogContents _dialogContents;
public bool IsVisible { get; set; }
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange += action;
}
public void Show(DialogContents dialogContents)
{
_dialogContents = dialogContents;
IsVisible = true;
NotifyDataChanged();
}
public DialogContents GetDialogContents()
{
return _dialogContents;
}
public void Hide()
{
IsVisible = false;
NotifyDataChanged();
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
OnChange();
}
}
@@ -0,0 +1,120 @@
using Model.Website.Enums;
namespace Services.Website;
public class NavigationService : INavigationService
{
private int navigationStateId = -1;
private string navigationStateType = NavigationStateType.Default;
private NavSelectionType navSelectionType = NavSelectionType.None;
private Type renderType = null!;
private int webPageType;
private int webSectionType;
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange += action;
}
public void ChangeNavigationSectionId(int newState)
{
navigationStateId = newState;
NotifyDataChanged();
}
public int GetNavigationSectionId()
{
return navigationStateId;
}
public void ChangeNavigationState(string newState)
{
if (newState.Equals(navigationStateType))
return;
navigationStateType = newState;
NotifyDataChanged();
}
public string GetNavigationState()
{
return navigationStateType;
}
public void SelectPage(int pageType, Type page)
{
if (renderType != page)
{
renderType = page;
webPageType = pageType;
navSelectionType = NavSelectionType.Page;
NotifyDataChanged();
}
}
public void SelectSection(int section)
{
if (section == webSectionType) return;
webSectionType = section;
navSelectionType = NavSelectionType.Section;
NotifyDataChanged();
}
public void Back()
{
if (navSelectionType == NavSelectionType.Page)
{
navSelectionType = NavSelectionType.Section;
webPageType = 0;
NotifyDataChanged();
return;
}
if (navSelectionType == NavSelectionType.Section)
{
navSelectionType = NavSelectionType.None;
webSectionType = 0;
webPageType = 0;
NotifyDataChanged();
}
}
public NavSelectionType GetNavSelectionType()
{
return navSelectionType;
}
public int GetWebPageId()
{
return webPageType;
}
public int GetWebSectionId()
{
return webSectionType;
}
public Type GetRenderType()
{
return renderType;
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
OnChange?.Invoke();
}
}
@@ -0,0 +1,63 @@
using Microsoft.JSInterop;
namespace Services.Website;
public class PermissionService : IPermissionService, IDisposable
{
private readonly IStorageService _storageService;
private IJSRuntime _jsRuntime;
private IToastService _toastService;
private bool isLoaded;
private bool isStorageEnabled = false;
public PermissionService(IJSRuntime jsRuntime, IToastService toastService, IStorageService storageService)
{
_jsRuntime = jsRuntime;
_toastService = toastService;
_storageService = storageService;
_storageService.Subscribe(NotifyDataChanged);
}
void IDisposable.Dispose()
{
_storageService.Unsubscribe(NotifyDataChanged);
}
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange += action;
}
public bool GetIsStorageEnabled()
{
return _storageService.GetValue<bool>(StorageKeys.EnabledStorage);
}
public bool GetIsDataCollectionEnabled()
{
return _storageService.GetValue<bool>(StorageKeys.EnabledDataCollection);
}
public void SetIsStorageEnabled(bool isEnabled)
{
_storageService.SetValue(StorageKeys.EnabledStorage, isEnabled);
}
public void SetIsDataCollectionEnabled(bool isEnabled)
{
_storageService.SetValue(StorageKeys.EnabledDataCollection, isEnabled);
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
OnChange();
}
}
+125
View File
@@ -0,0 +1,125 @@
using Model.Entity.Data;
using Model.Website;
using Model.Website.Data;
namespace Services.Website;
public class SearchService : ISearchService
{
private readonly INoteService noteService;
private bool isLoaded;
public SearchService(INoteService noteService)
{
this.noteService = noteService;
}
public List<SearchPointModel> SearchPoints { get; set; } = new();
public Dictionary<string, List<SearchPointModel>> Searches { get; set; } = new();
public bool IsVisible { get; set; }
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange += action;
}
public void Search(string entityId)
{
}
public async Task Load()
{
await noteService.Load();
Searches.Add("Pages", new List<SearchPointModel>());
Searches.Add("Notes", new List<SearchPointModel>());
Searches.Add("Entities", new List<SearchPointModel>());
foreach (var webPage in WebsiteData.GetPages())
{
SearchPoints.Add(new SearchPointModel
{
Title = webPage.Name,
PointType = "WebPage",
Summary = $"{webPage.Description}",
Href = webPage.Href
});
Searches["Pages"].Add(SearchPoints.Last());
}
foreach (var note in noteService.NoteContentModels)
{
SearchPoints.Add(new SearchPointModel
{
Title = note.Name,
PointType = "Note",
Href = note.GetNoteLink(),
Summary = note.Description
});
Searches["Notes"].Add(SearchPoints.Last());
}
foreach (var entity in EntityData.Get().Values)
{
var summary =
entity.Info().Description.Length > 35
? entity.Info().Description.Substring(0, 30).Trim() + "..."
: entity.Info().Description.Length > 0
? entity.Info().Description
: "";
SearchPoints.Add(new SearchPointModel
{
Title = entity.Info().Name,
Tags = $"{entity.EntityType},{entity.Descriptive}",
PointType = "Entity",
Summary = $"{entity.EntityType}, {summary}",
Href = $"database/{entity.Info().Name.ToLower()}"
});
Searches["Entities"].Add(SearchPoints.Last());
}
isLoaded = true;
NotifyDataChanged();
}
public bool IsLoaded()
{
return isLoaded;
}
public void Show()
{
IsVisible = true;
NotifyDataChanged();
}
public void Hide()
{
IsVisible = false;
NotifyDataChanged();
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
OnChange();
}
}
+101
View File
@@ -0,0 +1,101 @@
using Blazored.LocalStorage;
using Model.Feedback;
namespace Services.Website;
public class StorageKeys
{
public static string EnabledStorage = "StorageEnabled";
public static string EnabledDataCollection = "StorageDataCollection";
public static string IsPlainView { get; set; } = "IsPlainView";
public static string IsDynamicFormatting { get; set; } = "IsDynamicFormatting";
public static string AttackTime { get; set; } = "AttackTime";
public static string TravelTime { get; set; } = "TravelTime";
public static string SelectedFaction { get; set; } = "SelectedFaction";
public static string SelectedImmortal { get; set; } = "SelectedImmortal";
public static string BuildInputDelay { get; set; } = "BuildInputDelay";
public static string WaitTime { get; set; } = "WaitTime";
public static string WaitTo { get; set; } = "WaitTo";
}
public class StorageService : IStorageService
{
private readonly ISyncLocalStorageService _localStorageService;
private readonly IToastService _toastService;
private bool isLoaded;
public StorageService(IToastService toastService,
ISyncLocalStorageService localStorageService)
{
_toastService = toastService;
_localStorageService = localStorageService;
}
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange += action;
}
public T GetValue<T>(string forKey)
{
return _localStorageService.GetItem<T>(forKey);
}
public void SetValue<T>(string key, T value)
{
if (key.Equals(StorageKeys.EnabledStorage) && value.Equals(true))
{
_localStorageService.SetItem(key, value);
NotifyDataChanged();
return;
}
if (key.Equals(StorageKeys.EnabledStorage))
{
_localStorageService.Clear();
NotifyDataChanged();
return;
}
var isEnabled = GetValue<bool>(StorageKeys.EnabledStorage);
if (!isEnabled)
{
_toastService.AddToast(new ToastModel
{
Title = "Permission Error",
SeverityType = SeverityType.Error,
Message = "Storage must be enabled before Storage can be used."
});
NotifyDataChanged();
return;
}
_localStorageService.SetItem(key, value);
NotifyDataChanged();
}
public Task Load()
{
if (!isLoaded) return Task.CompletedTask;
isLoaded = true;
NotifyDataChanged();
return Task.CompletedTask;
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
OnChange();
}
}
+60
View File
@@ -0,0 +1,60 @@
using Model.Feedback;
namespace Services.Website;
public class ToastService : IToastService
{
private readonly List<ToastModel> toasts = new();
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action)
{
OnChange += action;
}
public void AddToast(ToastModel toast)
{
toasts.Insert(0, toast);
NotifyDataChanged();
}
public void RemoveToast(ToastModel toast)
{
toasts.Remove(toast);
}
public bool HasToasts()
{
return toasts.Count > 0;
}
public List<ToastModel> GetToasts()
{
return toasts;
}
public void AgeToasts()
{
foreach (var toast in toasts) toast.Age++;
NotifyDataChanged();
}
public void ClearAllToasts()
{
toasts.Clear();
NotifyDataChanged();
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
OnChange();
}
}