mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 17:53:32 +00:00
Compare commits
No commits in common. "37b8c2c3e9e52bb6110beef9540845fd0d262900" and "ff74376ca2743fe92381ec18ad0bcc74029fcfec" have entirely different histories.
37b8c2c3e9
...
ff74376ca2
@ -33,7 +33,7 @@ public abstract class PluginEndPoint
|
||||
/// <summary>
|
||||
/// Gets the full URL of the end point
|
||||
/// </summary>
|
||||
public string Url => $"/{_pluginsHandler.BaseRoute}/{PluginFeature.Plugin.Guid}/{Name}";
|
||||
public string Url => $"{_pluginsHandler.ServerUrl}{_pluginsHandler.BaseRoute}/{PluginFeature.Plugin.Guid}/{Name}";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin the end point is associated with
|
||||
|
||||
@ -96,7 +96,9 @@ public class PluginsHandler : IHandler
|
||||
}
|
||||
|
||||
#region Overrides of WebModuleBase
|
||||
|
||||
|
||||
internal string? ServerUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read only collection containing all current plugin end points
|
||||
/// </summary>
|
||||
|
||||
@ -28,7 +28,6 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly PluginSetting<bool> _webServerEnabledSetting;
|
||||
private readonly PluginSetting<bool> _webServerRemoteAccessSetting;
|
||||
private readonly PluginSetting<int> _webServerPortSetting;
|
||||
private readonly SemaphoreSlim _webserverSemaphore = new(1, 1);
|
||||
|
||||
@ -46,11 +45,9 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
_controllers = new List<WebApiControllerRegistration>();
|
||||
|
||||
_webServerEnabledSetting = settingsService.GetSetting("WebServer.Enabled", true);
|
||||
_webServerRemoteAccessSetting = settingsService.GetSetting("WebServer.RemoteAccess", false);
|
||||
_webServerPortSetting = settingsService.GetSetting("WebServer.Port", 9696);
|
||||
_webServerEnabledSetting.SettingChanged += WebServerSettingsOnSettingChanged;
|
||||
_webServerRemoteAccessSetting.SettingChanged += WebServerSettingsOnSettingChanged;
|
||||
_webServerPortSetting.SettingChanged += WebServerSettingsOnSettingChanged;
|
||||
_webServerEnabledSetting.SettingChanged += WebServerEnabledSettingOnSettingChanged;
|
||||
_webServerPortSetting.SettingChanged += WebServerPortSettingOnSettingChanged;
|
||||
pluginManagementService.PluginFeatureDisabled += PluginManagementServiceOnPluginFeatureDisabled;
|
||||
|
||||
PluginsHandler = new PluginsHandler("plugins");
|
||||
@ -78,7 +75,12 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
WebServerStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void WebServerSettingsOnSettingChanged(object? sender, EventArgs e)
|
||||
private void WebServerEnabledSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
_ = StartWebServer();
|
||||
}
|
||||
|
||||
private void WebServerPortSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
_ = StartWebServer();
|
||||
}
|
||||
@ -100,6 +102,7 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
public void Dispose()
|
||||
{
|
||||
Server?.DisposeAsync();
|
||||
_webServerPortSetting.SettingChanged -= WebServerPortSettingOnSettingChanged;
|
||||
}
|
||||
|
||||
public IServer? Server { get; private set; }
|
||||
@ -117,6 +120,8 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
OnWebServerStopped();
|
||||
Server = null;
|
||||
}
|
||||
|
||||
PluginsHandler.ServerUrl = $"http://localhost:{_webServerPortSetting.Value}/";
|
||||
|
||||
LayoutBuilder serverLayout = Layout.Create()
|
||||
.Add(PluginsHandler)
|
||||
@ -133,12 +138,12 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
|
||||
IServer server = Host.Create()
|
||||
.Handler(serverLayout.Build())
|
||||
.Bind(_webServerRemoteAccessSetting.Value ? IPAddress.Any : IPAddress.Loopback, (ushort) _webServerPortSetting.Value)
|
||||
.Bind(IPAddress.Loopback, (ushort) _webServerPortSetting.Value)
|
||||
.Defaults()
|
||||
.Build();
|
||||
|
||||
// Store the URL in a webserver.txt file so that remote applications can find it
|
||||
await File.WriteAllTextAsync(Path.Combine(Constants.DataFolder, "webserver.txt"), $"http://localhost:{_webServerPortSetting.Value}/");
|
||||
await File.WriteAllTextAsync(Path.Combine(Constants.DataFolder, "webserver.txt"), PluginsHandler.ServerUrl);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Routing;
|
||||
@ -43,11 +42,14 @@ public partial class SettingsViewModel : RoutableHostScreen<RoutableScreen>, IMa
|
||||
public ViewModelBase? TitleBarViewModel => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
// Display tab change on navigate, if there is none forward to the first
|
||||
SelectedTab = SettingTabs.FirstOrDefault(t => t.Matches(args.Path)) ?? SettingTabs.FirstOrDefault();
|
||||
return Task.CompletedTask;
|
||||
// Display tab change on navigate
|
||||
SelectedTab = SettingTabs.FirstOrDefault(t => t.Matches(args.Path));
|
||||
|
||||
// Always show a tab, if there is none forward to the first
|
||||
if (SelectedTab == null)
|
||||
await _router.Navigate(SettingTabs.First().Path);
|
||||
}
|
||||
|
||||
public void GoBack()
|
||||
|
||||
@ -145,22 +145,6 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock>Enable remote access</TextBlock>
|
||||
<TextBlock Classes="subtitle" TextWrapping="Wrap">
|
||||
By default the web server can only be accessed by applications running on your own computer, e.g. supported games.
|
||||
</TextBlock>
|
||||
<TextBlock Classes="subtitle warning" TextWrapping="Wrap">
|
||||
Enabling remote access allows you to access Artemis from other devices on your network, depending on your router even the outside world.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleSwitch IsChecked="{CompiledBinding WebServerRemoteAccess.Value}" OnContent="Yes" OffContent="No" MinWidth="0" Margin="0 -10" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0">
|
||||
|
||||
@ -167,7 +167,6 @@ public class GeneralTabViewModel : RoutableScreen
|
||||
public PluginSetting<double> CoreRenderScale => _settingsService.GetSetting("Core.RenderScale", 0.5);
|
||||
public PluginSetting<int> CoreTargetFrameRate => _settingsService.GetSetting("Core.TargetFrameRate", 30);
|
||||
public PluginSetting<bool> WebServerEnabled => _settingsService.GetSetting("WebServer.Enabled", true);
|
||||
public PluginSetting<bool> WebServerRemoteAccess => _settingsService.GetSetting("WebServer.RemoteAccess", false);
|
||||
public PluginSetting<int> WebServerPort => _settingsService.GetSetting("WebServer.Port", 9696);
|
||||
|
||||
private void ExecuteShowLogs()
|
||||
|
||||
@ -62,7 +62,7 @@ public partial class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsVie
|
||||
|
||||
public ReadOnlyObservableCollection<ReleaseViewModel> ReleaseViewModels { get; }
|
||||
public string Channel { get; }
|
||||
|
||||
|
||||
public async Task GetReleases(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@ -97,7 +97,7 @@ public partial class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsVie
|
||||
Loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
@ -109,6 +109,10 @@ public partial class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsVie
|
||||
SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(vm => vm.Release.Id == releaseId);
|
||||
// Otherwise forward to the last release
|
||||
else
|
||||
SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(r => r.IsCurrentVersion) ?? ReleaseViewModels.FirstOrDefault();
|
||||
{
|
||||
ReleaseViewModel? lastRelease = ReleaseViewModels.FirstOrDefault(r => r.IsCurrentVersion) ?? ReleaseViewModels.FirstOrDefault();
|
||||
if (lastRelease != null)
|
||||
await _router.Navigate($"settings/releases/{lastRelease.Release.Id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.StartupWizard.Steps;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@ -12,13 +11,11 @@ namespace Artemis.UI.Screens.StartupWizard;
|
||||
public partial class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
{
|
||||
private readonly IContainer _container;
|
||||
private readonly ISettingsService _settingsService;
|
||||
[Notify] private WizardStepViewModel _screen;
|
||||
|
||||
public StartupWizardViewModel(IContainer container, IWindowService windowService, ISettingsService settingsService)
|
||||
public StartupWizardViewModel(IContainer container, IWindowService windowService)
|
||||
{
|
||||
_container = container;
|
||||
_settingsService = settingsService;
|
||||
_screen = _container.Resolve<WelcomeStepViewModel>();
|
||||
_screen.Wizard = this;
|
||||
|
||||
@ -44,10 +41,6 @@ public partial class StartupWizardViewModel : DialogViewModelBase<bool>
|
||||
|
||||
public void SkipOrFinishWizard()
|
||||
{
|
||||
PluginSetting<bool> setting = _settingsService.GetSetting("UI.SetupWizardCompleted", false);
|
||||
setting.Value = true;
|
||||
setting.Save();
|
||||
|
||||
Close(true);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user