mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
Compare commits
2 Commits
ff74376ca2
...
37b8c2c3e9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37b8c2c3e9 | ||
|
|
3367280576 |
@ -33,7 +33,7 @@ public abstract class PluginEndPoint
|
||||
/// <summary>
|
||||
/// Gets the full URL of the end point
|
||||
/// </summary>
|
||||
public string Url => $"{_pluginsHandler.ServerUrl}{_pluginsHandler.BaseRoute}/{PluginFeature.Plugin.Guid}/{Name}";
|
||||
public string Url => $"/{_pluginsHandler.BaseRoute}/{PluginFeature.Plugin.Guid}/{Name}";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin the end point is associated with
|
||||
|
||||
@ -96,9 +96,7 @@ 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,6 +28,7 @@ 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);
|
||||
|
||||
@ -45,9 +46,11 @@ 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 += WebServerEnabledSettingOnSettingChanged;
|
||||
_webServerPortSetting.SettingChanged += WebServerPortSettingOnSettingChanged;
|
||||
_webServerEnabledSetting.SettingChanged += WebServerSettingsOnSettingChanged;
|
||||
_webServerRemoteAccessSetting.SettingChanged += WebServerSettingsOnSettingChanged;
|
||||
_webServerPortSetting.SettingChanged += WebServerSettingsOnSettingChanged;
|
||||
pluginManagementService.PluginFeatureDisabled += PluginManagementServiceOnPluginFeatureDisabled;
|
||||
|
||||
PluginsHandler = new PluginsHandler("plugins");
|
||||
@ -75,12 +78,7 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
WebServerStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void WebServerEnabledSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
_ = StartWebServer();
|
||||
}
|
||||
|
||||
private void WebServerPortSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
private void WebServerSettingsOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
_ = StartWebServer();
|
||||
}
|
||||
@ -102,7 +100,6 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
public void Dispose()
|
||||
{
|
||||
Server?.DisposeAsync();
|
||||
_webServerPortSetting.SettingChanged -= WebServerPortSettingOnSettingChanged;
|
||||
}
|
||||
|
||||
public IServer? Server { get; private set; }
|
||||
@ -120,8 +117,6 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
OnWebServerStopped();
|
||||
Server = null;
|
||||
}
|
||||
|
||||
PluginsHandler.ServerUrl = $"http://localhost:{_webServerPortSetting.Value}/";
|
||||
|
||||
LayoutBuilder serverLayout = Layout.Create()
|
||||
.Add(PluginsHandler)
|
||||
@ -138,12 +133,12 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
|
||||
IServer server = Host.Create()
|
||||
.Handler(serverLayout.Build())
|
||||
.Bind(IPAddress.Loopback, (ushort) _webServerPortSetting.Value)
|
||||
.Bind(_webServerRemoteAccessSetting.Value ? IPAddress.Any : 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"), PluginsHandler.ServerUrl);
|
||||
await File.WriteAllTextAsync(Path.Combine(Constants.DataFolder, "webserver.txt"), $"http://localhost:{_webServerPortSetting.Value}/");
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
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;
|
||||
@ -42,14 +43,11 @@ public partial class SettingsViewModel : RoutableHostScreen<RoutableScreen>, IMa
|
||||
public ViewModelBase? TitleBarViewModel => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
public override Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
// 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);
|
||||
// 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;
|
||||
}
|
||||
|
||||
public void GoBack()
|
||||
|
||||
@ -145,6 +145,22 @@
|
||||
</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,6 +167,7 @@ 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,10 +109,6 @@ public partial class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsVie
|
||||
SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(vm => vm.Release.Id == releaseId);
|
||||
// Otherwise forward to the last release
|
||||
else
|
||||
{
|
||||
ReleaseViewModel? lastRelease = ReleaseViewModels.FirstOrDefault(r => r.IsCurrentVersion) ?? ReleaseViewModels.FirstOrDefault();
|
||||
if (lastRelease != null)
|
||||
await _router.Navigate($"settings/releases/{lastRelease.Release.Id}");
|
||||
}
|
||||
SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(r => r.IsCurrentVersion) ?? ReleaseViewModels.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.StartupWizard.Steps;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@ -11,11 +12,13 @@ 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)
|
||||
public StartupWizardViewModel(IContainer container, IWindowService windowService, ISettingsService settingsService)
|
||||
{
|
||||
_container = container;
|
||||
_settingsService = settingsService;
|
||||
_screen = _container.Resolve<WelcomeStepViewModel>();
|
||||
_screen.Wizard = this;
|
||||
|
||||
@ -41,6 +44,10 @@ 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