Fixes
This commit is contained in:
parent
28e5b078e4
commit
580edfb232
@ -1 +0,0 @@
|
||||
PSCHelpdesk
|
||||
@ -11,26 +11,29 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="95257dc5-08bd-4c50-8726-85956b3c2c92" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/avalonia.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/avalonia.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/.name" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/HetznerServer.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/HetznerServer.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/HetznerServer.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/HetznerServer.csproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/HetznerServerBootstrap.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/HetznerServerBootstrap.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/Models/Settings.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Models/Settings.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/ViewModels/HetznerSettingsViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/ViewModels/HetznerSettingsViewModel.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/Views/HetznerSettingsView.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Views/HetznerSettingsView.axaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/HetznerServer/Views/HetznerSettingsView.axaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Views/HetznerSettingsView.axaml.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk.sln.DotSettings.user" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk.sln.DotSettings.user" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Models/GlobalSetting.cs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Services/MenuService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Services/MenuService.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Models/LocalSetting.cs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/PSCHelpdesk.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/PSCHelpdesk.csproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Services/PluginService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Services/PluginService.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Startup.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Startup.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewLocator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewLocator.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/MainWindowViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/MainWindowViewModel.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/PluginListViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/PluginListViewModel.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsGlobalViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsGlobalViewModel.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/ContentDisplay.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/ContentDisplay.axaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/ContentDisplay.axaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/ContentDisplay.axaml.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/MainWindow.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/MainWindow.axaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsGlobalView.axaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsGlobalView.axaml.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsView.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsView.axaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsView.axaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsView.axaml.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Shared/Menu/Item.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Shared/Menu/Item.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Shared/Plugin/Contract.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Shared/Plugin/Contract.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Shared/Shared.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/Shared/Shared.csproj" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -44,19 +47,13 @@
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/1b81cb3be224213a6a73519b6e340a628d9a1fb8629c351a186a26f6376669/List.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/2e6883f773fb7c69a15db509adac9a0c068e4ca54fa119e835fd2324311c3b/Ioc.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/5cde391207de75962d7bacb899ca2bd3985c86911b152d185b58999a422bf0/Type.CoreCLR.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/9cf5f68d759deefc91b9c48c5ac3dd27708bb7dc38d0c485661fff5ce15b82/SafeFileHandle.Unix.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/9d4f4ac7db6d2c5d183ab2d92602280ed4349fd6e6a1b6313546b3d01fdab5/ServiceProvider.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/c7102cd0ffb8973777e61b1942c3fffac7e14016a511d055c3adf73ff91748/ThrowHelper.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/e6a62e457eaef3f1f68c2a3e51b1b1351d3f2a3cef1a7379c6248f38bb8d64e8/File.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/HetznerServer/Views/ServerView.axaml" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/HetznerServer/Views/ServerView.axaml.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/info/RiderProjects/pschelpdesk/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/info/RiderProjects/pschelpdesk/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/info/RiderProjects/pschelpdesk/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/info/RiderProjects/pschelpdesk/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/info/RiderProjects/pschelpdesk/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Vendor/Prise/AssemblyScanning/DefaultAssemblyResolver.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Vendor/Prise/DefaultPluginLoader.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Vendor/Prise/DependencyInjection/ServiceCollectionExtensions.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
@ -200,6 +197,7 @@
|
||||
<workItem from="1730716176795" duration="11704000" />
|
||||
<workItem from="1730749692901" duration="5980000" />
|
||||
<workItem from="1730887536949" duration="12370000" />
|
||||
<workItem from="1730923358764" duration="8836000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -239,30 +237,56 @@
|
||||
<option name="timeStamp" value="92" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs</url>
|
||||
<line>38</line>
|
||||
<properties documentPath="C:\Users\info\RiderProjects\pschelpdesk\PSCHelpdesk\PSCHelpdesk\ViewModels\SettingsViewModel.cs" containingFunctionPresentation="Constructor 'SettingsViewModel'">
|
||||
<url>file://$PROJECT_DIR$/Shared/Setting/SettingsManager.cs</url>
|
||||
<line>85</line>
|
||||
<properties documentPath="$PROJECT_DIR$/Shared/Setting/SettingsManager.cs" containingFunctionPresentation="Method 'SavePluginSettings'">
|
||||
<startOffsets>
|
||||
<option value="1051" />
|
||||
<option value="2568" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="1136" />
|
||||
<option value="2611" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="146" />
|
||||
<option name="timeStamp" value="154" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/SettingsViewModel.cs</url>
|
||||
<line>36</line>
|
||||
<properties documentPath="C:\Users\info\RiderProjects\pschelpdesk\PSCHelpdesk\PSCHelpdesk\ViewModels\SettingsViewModel.cs" containingFunctionPresentation="Constructor 'SettingsViewModel'">
|
||||
<url>file://$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsGlobalView.axaml.cs</url>
|
||||
<line>29</line>
|
||||
<properties documentPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsGlobalView.axaml.cs" containingFunctionPresentation="Method 'ChooseGlobalSettingsFile_OnClick'">
|
||||
<startOffsets>
|
||||
<option value="979" />
|
||||
<option value="815" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="1028" />
|
||||
<option value="854" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="147" />
|
||||
<option name="timeStamp" value="157" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsGlobalView.axaml.cs</url>
|
||||
<line>32</line>
|
||||
<properties documentPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/SettingsGlobalView.axaml.cs" containingFunctionPresentation="Method 'ChooseGlobalSettingsFile_OnClick'">
|
||||
<startOffsets>
|
||||
<option value="964" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="1019" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="159" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs</url>
|
||||
<line>77</line>
|
||||
<properties documentPath="$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs" containingFunctionPresentation="Method 'OpenSSH'">
|
||||
<startOffsets>
|
||||
<option value="2296" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="2443" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="160" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
|
||||
@ -11,13 +11,6 @@
|
||||
<DebugType>portable</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Views\ServerView.axaml.cs">
|
||||
<DependentUpon>ServerView.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\Shared.csproj" Private="false" />
|
||||
</ItemGroup>
|
||||
|
||||
13
HetznerServer/Models/ServerSetting.cs
Normal file
13
HetznerServer/Models/ServerSetting.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace PSCHelpdesk.Plugins.HetznerServer.Models;
|
||||
|
||||
public class ServerSetting
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
public ServerSetting()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString();
|
||||
ApiKey = string.Empty;
|
||||
}
|
||||
}
|
||||
@ -2,5 +2,12 @@
|
||||
|
||||
public class Settings
|
||||
{
|
||||
|
||||
public string HetznerApiKey { get; set; }
|
||||
public List<ServerSetting> ServerSettings { get; set; }
|
||||
|
||||
public Settings()
|
||||
{
|
||||
HetznerApiKey = "";
|
||||
ServerSettings = new List<ServerSetting>();
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,12 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using HetznerCloudApi;
|
||||
using PSCHelpdesk.Plugins.HetznerServer.Models;
|
||||
using PSCHelpdesk.Plugins.HetznerServer.Views;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
using PSCHelpdesk.Shared.Setting;
|
||||
using PSCHelpdesk.Shared.ViewModels;
|
||||
|
||||
namespace PSCHelpdesk.Plugins.HetznerServer.ViewModels;
|
||||
@ -13,9 +16,12 @@ public partial class HetznerSettingsViewModel : ViewModelBase, IViewModelBase
|
||||
private string _apiKey;
|
||||
public HetznerSettingsViewModel()
|
||||
{
|
||||
LocalSetting settings = new LocalSetting();
|
||||
settings.Load();
|
||||
|
||||
var settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
|
||||
var settings = new Settings();
|
||||
settingsManager.LoadPluginSettings("HetznerSettings", settings);
|
||||
|
||||
ApiKey = settings.HetznerApiKey;
|
||||
}
|
||||
|
||||
public string ApiKey
|
||||
|
||||
@ -1,19 +1,25 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using HetznerCloudApi;
|
||||
using PSCHelpdesk.Plugins.HetznerServer.Models;
|
||||
using PSCHelpdesk.Plugins.HetznerServer.Views;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
using PSCHelpdesk.Shared.Setting;
|
||||
using PSCHelpdesk.Shared.ViewModels;
|
||||
|
||||
namespace PSCHelpdesk.Plugins.HetznerServer.ViewModels;
|
||||
|
||||
public partial class ServerViewModel : ViewModelBase, IViewModelBase
|
||||
{
|
||||
private SettingsManager _settingsManager;
|
||||
public ServerViewModel()
|
||||
{
|
||||
Server = new ObservableCollection<Server>();
|
||||
SelectedServer = new Server(1,"","","","","");
|
||||
_settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
|
||||
loadServers();
|
||||
|
||||
}
|
||||
@ -41,7 +47,9 @@ public partial class ServerViewModel : ViewModelBase, IViewModelBase
|
||||
|
||||
private async void loadServers()
|
||||
{
|
||||
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("kcsTOjNw7YxiOGVaIrk33gIYIHmLRov9Ap6BgWxQZVJyzSsmeNpClMhpJZUYCL0k");
|
||||
var settings = new Settings();
|
||||
_settingsManager.LoadPluginSettings("HetznerSettings", settings);
|
||||
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient(settings.HetznerApiKey);
|
||||
|
||||
List<HetznerCloudApi.Object.Server.Server> list = await hetznerCloudClient.Server.Get();
|
||||
foreach (var server in list)
|
||||
@ -67,8 +75,7 @@ public partial class ServerViewModel : ViewModelBase, IViewModelBase
|
||||
[RelayCommand]
|
||||
public void OpenSSH(Server server)
|
||||
{
|
||||
/*LocalSetting setting = JsonSettings.Load<LocalSetting>();
|
||||
Process.Start(string.Format(setting.SSHClientExecutable, server.Ipv4));*/
|
||||
Process.Start(_settingsManager.CoreSettings.SSHClientExecutable,string.Format(_settingsManager.CoreSettings.SSHClientExecutableArgs, server.Ipv4));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
@ -2,7 +2,18 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="clr-namespace:PSCHelpdesk.Plugins.HetznerServer.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="PSCHelpdesk.Plugins.HetznerServer.Views.HetznerSettingsView">
|
||||
Welcome to settings hetzner!
|
||||
x:Class="PSCHelpdesk.Plugins.HetznerServer.Views.HetznerSettingsView"
|
||||
x:DataType="vm:HetznerSettingsViewModel">
|
||||
<Design.DataContext>
|
||||
<vm:HetznerSettingsViewModel></vm:HetznerSettingsViewModel>
|
||||
</Design.DataContext>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0 5" >Hetzner ApiKey</TextBlock>
|
||||
<StackPanel Orientation="Horizontal" Spacing="1">
|
||||
<TextBox Text="{Binding ApiKey }" Width="400"></TextBox>
|
||||
</StackPanel>
|
||||
<Button Margin="0 5" Content="Save Settings" Click="SaveSettings_OnClick"></Button>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@ -1,13 +1,32 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using PSCHelpdesk.Plugins.HetznerServer.Models;
|
||||
using PSCHelpdesk.Plugins.HetznerServer.ViewModels;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
using PSCHelpdesk.Shared.Setting;
|
||||
|
||||
namespace PSCHelpdesk.Plugins.HetznerServer.Views;
|
||||
|
||||
public partial class HetznerSettingsView : UserControl
|
||||
{
|
||||
private SettingsManager settingsManager;
|
||||
private Settings settings;
|
||||
public HetznerSettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
|
||||
settings = new Settings();
|
||||
settingsManager.LoadPluginSettings("HetznerSettings", settings);
|
||||
|
||||
}
|
||||
|
||||
private void SaveSettings_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
settings.HetznerApiKey = ((HetznerSettingsViewModel)this.DataContext).ApiKey;
|
||||
settingsManager.SavePluginSettings("HetznerSettings", settings);
|
||||
}
|
||||
}
|
||||
@ -15,6 +15,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADefaultPluginLoader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F667004c0a83e47158c9865f6d54f01d91ac00_003F34_003F243c7c7d_003FDefaultPluginLoader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbd1d5c50194fea68ff3559c160230b0ab50f5acf4ce3061bffd6d62958e2182_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbf9021a960b74107a7e141aa06bc9d8a0a53c929178c2fb95b1597be8af8dc_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFile_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe6a62e457eaef3f1f68c2a3e51b1b1351d3f2a3cef1a7379c6248f38bb8d64e8_003FFile_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFirst_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc9f1e78ef04f5214281bc448c6a251bb5f9a3135b662f76745bbfb39b14150_003FFirst_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHeaderedSelectingItemsControl_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F16a25d89779ca224b34f189688787a4b4f091751ee7706b8b396a5e88aa225_003FHeaderedSelectingItemsControl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIoc_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F2e6883f773fb7c69a15db509adac9a0c068e4ca54fa119e835fd2324311c3b_003FIoc_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
@ -37,6 +38,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fad1d58b8dd22123dfae3f2cf5d8b199992465c9c344d032f93a826d8e5539ff_003FRuntimeType_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbaf2eef7c7bbea3742b74ee71fe7168c3a8c2269a1ce22d51333175656840_003FRuntimeType_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbc57ab3db8ad1c2d647f4171d82a80762571212ac42bb1eac4ed63162acdc4ed_003FRuntimeType_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASafeFileHandle_002EUnix_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F9cf5f68d759deefc91b9c48c5ac3dd27708bb7dc38d0c485661fff5ce15b82_003FSafeFileHandle_002EUnix_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASelectMany_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Ff93d3944f37777fd1f922d0d91e96fb77c2f83024101cb4b92f8d9b68080da_003FSelectMany_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AServiceCollection_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F33fa97197c7d5dc2e649bd1e13ca25ad6fd7928c626fa7796267b9434bd4ba_003FServiceCollection_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AServiceDescriptor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Ff53745e7f6e85d65317047eeae9af151fe9aca1cb284d27e5c83962a50be46_003FServiceDescriptor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using Nucs.JsonSettings;
|
||||
|
||||
namespace PSCHelpdesk.Models;
|
||||
|
||||
public class LocalSetting: JsonSettings
|
||||
{
|
||||
public string GlobalConfigFilePath { get; set; }
|
||||
|
||||
public string SSHClientExecutable { get; set; }
|
||||
|
||||
public string SCPClientExecutable { get; set; }
|
||||
|
||||
public string SSHClientExecutableArgs { get; set; }
|
||||
|
||||
public string SCPClientExecutableArgs { get; set; }
|
||||
|
||||
public string PrivateSSHKeyPath { get; set; }
|
||||
public override string FileName { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
|
||||
@"\PSCHelpDesk\config.json";
|
||||
}
|
||||
@ -21,7 +21,6 @@
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Nucs.JsonSettings2" Version="2.0.3" />
|
||||
<PackageReference Include="Prise" Version="6.0.0" />
|
||||
<PackageReference Include="Prise.Proxy" Version="6.1.0" />
|
||||
</ItemGroup>
|
||||
@ -48,4 +47,8 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -63,6 +63,7 @@ public class PluginService
|
||||
var pluginLoader = Ioc.Default.GetService(typeof(IPluginLoader)) as IPluginLoader;
|
||||
var menuService = Ioc.Default.GetRequiredService<IMenuService>();
|
||||
var settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
|
||||
var settingsManager = Ioc.Default.GetRequiredService<ISettingsManager>();
|
||||
var testService = Ioc.Default.GetRequiredService<ITestService>();
|
||||
var appService = Ioc.Default.GetService(typeof(AppService)) as AppService;
|
||||
|
||||
@ -78,6 +79,7 @@ public class PluginService
|
||||
.AddRemoteTypes(new []{typeof(Item)})
|
||||
.AddHostService<IMenuService>(menuService)
|
||||
.AddHostService<ISettingsService>(settingsService)
|
||||
.AddHostService<ISettingsManager>(settingsManager)
|
||||
.AddHostService<ITestService>(testService)
|
||||
//.AddHostService<SettingsManager>(settingsService)
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ using Prise.Proxy;
|
||||
using PSCHelpdesk.Converter;
|
||||
using PSCHelpdesk.Services;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
using PSCHelpdesk.Shared.Setting;
|
||||
using PSCHelpdesk.ViewModels;
|
||||
|
||||
namespace PSCHelpdesk;
|
||||
@ -14,12 +15,14 @@ class Startup
|
||||
public static void RegisterServices()
|
||||
{
|
||||
var menuService = new MenuService();
|
||||
var settingsManager = new SettingsManager();
|
||||
var settingsService = new SettingsService();
|
||||
|
||||
var te = new ServiceCollection()
|
||||
.AddPrise()
|
||||
.AddFactory<IResultConverter>(()=> new AvaloniaPluginResultConverter())
|
||||
.AddSingleton<AppService>()
|
||||
.AddSingleton<ISettingsManager>(settingsManager)
|
||||
.AddSingleton<IMenuService>(menuService)
|
||||
.AddSingleton<ISettingsService>(settingsService)
|
||||
.AddSingleton<ITestService>(new TestService())
|
||||
|
||||
@ -2,11 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Nucs.JsonSettings;
|
||||
using PSCHelpdesk.Services;
|
||||
using PSCHelpdesk.Shared.Menu;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Nucs.JsonSettings;
|
||||
using PSCHelpdesk.Models;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
using PSCHelpdesk.Shared.Setting;
|
||||
using PSCHelpdesk.Shared.ViewModels;
|
||||
|
||||
namespace PSCHelpdesk.ViewModels;
|
||||
@ -58,12 +51,13 @@ public partial class SettingsGlobalViewModel : ViewModelBase, IViewModelBase
|
||||
|
||||
public SettingsGlobalViewModel()
|
||||
{
|
||||
LocalSetting settings = new LocalSetting();
|
||||
settings.Load();
|
||||
this.GlobalConfigFilePath = settings.GlobalConfigFilePath;
|
||||
this.PrivateSSHKeyPath = settings.PrivateSSHKeyPath;
|
||||
this.ScpClientPath = settings.SCPClientExecutable;
|
||||
this.SshClientPath = settings.SSHClientExecutable;
|
||||
var settingsManager = new SettingsManager();
|
||||
this.GlobalConfigFilePath = settingsManager.CoreSettings.GlobalConfigFilePath;
|
||||
this.PrivateSSHKeyPath = settingsManager.CoreSettings.PrivateSSHKeyPath;
|
||||
this.ScpClientPath = settingsManager.CoreSettings.SCPClientExecutable;
|
||||
this.SshClientPath = settingsManager.CoreSettings.SSHClientExecutable;
|
||||
this.SshClientPathArgs = settingsManager.CoreSettings.SSHClientExecutableArgs;
|
||||
this.ScpClientPathArgs = settingsManager.CoreSettings.SCPClientExecutableArgs;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,16 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using DynamicData;
|
||||
using Nucs.JsonSettings;
|
||||
using PSCHelpdesk.Models;
|
||||
using PSCHelpdesk.Services;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
using PSCHelpdesk.Shared.ViewModels;
|
||||
@ -30,10 +19,9 @@ public partial class SettingsViewModel : ViewModelBase
|
||||
|
||||
public SettingsViewModel()
|
||||
{
|
||||
var settingsService = (SettingsService)Ioc.Default.GetService<ISettingsService>();
|
||||
|
||||
this.TabItems = new List<SettingsTabItemViewModel>();
|
||||
|
||||
|
||||
var settingsService = (SettingsService)Ioc.Default.GetService<ISettingsService>();
|
||||
foreach (var setting in settingsService.Settings)
|
||||
{
|
||||
TabItems.Add(new SettingsTabItemViewModel(setting.Header, setting.CommandParameter));
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<ContentPresenter
|
||||
Width="400" Height="400"
|
||||
Name="PartSelectedContentHost"
|
||||
Content="{TemplateBinding SelectedContent}">
|
||||
</ContentPresenter>
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Nucs.JsonSettings;
|
||||
using PSCHelpdesk.Shared.Menu;
|
||||
|
||||
namespace PSCHelpdesk.Views;
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
</MenuItem.Styles>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<ContentControl Content="{Binding ContentDisplay}"></ContentControl>
|
||||
<TextBlock Text="{Binding SelectedItem.Header}"></TextBlock>
|
||||
<views:ContentDisplay SelectedOption="{Binding SelectedItem}"></views:ContentDisplay>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
using System.IO;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Platform.Storage;
|
||||
using PSCHelpdesk.Models;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
using PSCHelpdesk.Shared.Setting;
|
||||
using PSCHelpdesk.ViewModels;
|
||||
|
||||
namespace PSCHelpdesk.Views;
|
||||
@ -14,6 +13,7 @@ public partial class SettingsGlobalView : UserControl
|
||||
public SettingsGlobalView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private async void ChooseGlobalSettingsFile_OnClick(object? sender, RoutedEventArgs e)
|
||||
@ -30,22 +30,21 @@ public partial class SettingsGlobalView : UserControl
|
||||
if (file is not null && file.Count > 0)
|
||||
{
|
||||
SettingsGlobalViewModel model = (SettingsGlobalViewModel)this.DataContext;
|
||||
model.GlobalConfigFilePath = file[0].Path.ToString();
|
||||
model.GlobalConfigFilePath = file[0].Path.AbsolutePath;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveSettings_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
LocalSetting settings = new LocalSetting();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(settings.FileName));
|
||||
SettingsManager settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
|
||||
SettingsGlobalViewModel model = (SettingsGlobalViewModel)this.DataContext;
|
||||
settings.GlobalConfigFilePath = model.GlobalConfigFilePath;
|
||||
settings.SCPClientExecutable = model.ScpClientPath;
|
||||
settings.SSHClientExecutable = model.SshClientPath;
|
||||
settings.SCPClientExecutableArgs = model.ScpClientPathArgs;
|
||||
settings.SSHClientExecutableArgs = model.SshClientPathArgs;
|
||||
settings.PrivateSSHKeyPath = model.PrivateSSHKeyPath;
|
||||
settings.Save();
|
||||
settingsManager.CoreSettings.GlobalConfigFilePath = model.GlobalConfigFilePath;
|
||||
settingsManager.CoreSettings.SCPClientExecutable = model.ScpClientPath;
|
||||
settingsManager.CoreSettings.SSHClientExecutable = model.SshClientPath;
|
||||
settingsManager.CoreSettings.SCPClientExecutableArgs = model.ScpClientPathArgs;
|
||||
settingsManager.CoreSettings.SSHClientExecutableArgs = model.SshClientPathArgs;
|
||||
settingsManager.CoreSettings.PrivateSSHKeyPath = model.PrivateSSHKeyPath;
|
||||
settingsManager.SaveSettings();
|
||||
}
|
||||
|
||||
private async void ChooseSshClientFile_OnClick(object? sender, RoutedEventArgs e)
|
||||
@ -62,7 +61,7 @@ public partial class SettingsGlobalView : UserControl
|
||||
if (file is not null && file.Count > 0)
|
||||
{
|
||||
SettingsGlobalViewModel model = (SettingsGlobalViewModel)this.DataContext;
|
||||
model.SshClientPath = file[0].Path.ToString();
|
||||
model.SshClientPath = file[0].Path.AbsolutePath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +79,7 @@ public partial class SettingsGlobalView : UserControl
|
||||
if (file is not null && file.Count > 0)
|
||||
{
|
||||
SettingsGlobalViewModel model = (SettingsGlobalViewModel)this.DataContext;
|
||||
model.ScpClientPath = file[0].Path.ToString();
|
||||
model.ScpClientPath = file[0].Path.AbsolutePath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +97,7 @@ public partial class SettingsGlobalView : UserControl
|
||||
if (file is not null && file.Count > 0)
|
||||
{
|
||||
SettingsGlobalViewModel model = (SettingsGlobalViewModel)this.DataContext;
|
||||
model.PrivateSSHKeyPath = file[0].Path.ToString();
|
||||
model.PrivateSSHKeyPath = file[0].Path.AbsolutePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@
|
||||
<Design.DataContext>
|
||||
<vm:SettingsViewModel />
|
||||
</Design.DataContext>
|
||||
<Panel Margin="10">
|
||||
<StackPanel Margin="10">
|
||||
<TabControl ItemsSource="{Binding TabItems}">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate DataType="vm:SettingsTabItemViewModel">
|
||||
@ -24,5 +24,5 @@
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</Panel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@ -1,13 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Nucs.JsonSettings;
|
||||
using PSCHelpdesk.Models;
|
||||
using PSCHelpdesk.ViewModels;
|
||||
|
||||
namespace PSCHelpdesk.Views;
|
||||
|
||||
|
||||
6
Shared/Service/ISettingsManager.cs
Normal file
6
Shared/Service/ISettingsManager.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace PSCHelpdesk.Shared.Service;
|
||||
|
||||
public interface ISettingsManager
|
||||
{
|
||||
|
||||
}
|
||||
27
Shared/Setting/CoreSettings.cs
Normal file
27
Shared/Setting/CoreSettings.cs
Normal file
@ -0,0 +1,27 @@
|
||||
namespace PSCHelpdesk.Shared.Setting;
|
||||
|
||||
public class CoreSettings
|
||||
{
|
||||
public string GlobalConfigFilePath { get; set; }
|
||||
|
||||
public string SSHClientExecutable { get; set; }
|
||||
|
||||
public string SCPClientExecutable { get; set; }
|
||||
|
||||
public string SSHClientExecutableArgs { get; set; }
|
||||
|
||||
public string SCPClientExecutableArgs { get; set; }
|
||||
|
||||
public string PrivateSSHKeyPath { get; set; }
|
||||
|
||||
public CoreSettings()
|
||||
{
|
||||
GlobalConfigFilePath = string.Empty;
|
||||
SSHClientExecutable = string.Empty;
|
||||
SCPClientExecutable = string.Empty;
|
||||
SSHClientExecutableArgs = string.Empty;
|
||||
SCPClientExecutableArgs = string.Empty;
|
||||
PrivateSSHKeyPath = string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
89
Shared/Setting/SettingsManager.cs
Normal file
89
Shared/Setting/SettingsManager.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using Newtonsoft.Json;
|
||||
using PSCHelpdesk.Shared.Service;
|
||||
|
||||
namespace PSCHelpdesk.Shared.Setting;
|
||||
|
||||
public class SettingsManager: ISettingsManager
|
||||
{
|
||||
private string DataRoot => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PSC", "PSCHelpDesk");
|
||||
|
||||
private string SettingsPath => Path.Combine(this.DataRoot, "settings.json");
|
||||
|
||||
public SettingsManager()
|
||||
{
|
||||
Directory.CreateDirectory(this.DataRoot);
|
||||
this.LoadSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the core settings instance.
|
||||
/// </summary>
|
||||
public CoreSettings CoreSettings { get; set; } = new CoreSettings();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the UI Settings instance.
|
||||
/// </summary>
|
||||
// public UISettings UISettings { get; set; } = new UISettings();
|
||||
|
||||
private string SettingsFile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reads the configuration file.
|
||||
/// </summary>
|
||||
public void LoadSettings()
|
||||
{
|
||||
if (File.Exists(this.SettingsPath))
|
||||
{
|
||||
string json = File.ReadAllText(this.SettingsPath);
|
||||
JsonConvert.PopulateObject(json, this.CoreSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CoreSettings = new CoreSettings();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the configuration file.
|
||||
/// </summary>
|
||||
public void SaveSettings()
|
||||
{
|
||||
// serialize JSON directly to a file
|
||||
using (StreamWriter file = File.CreateText(this.SettingsPath))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer()
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
};
|
||||
|
||||
serializer.Serialize(file, this.CoreSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadPluginSettings(string pluginName, object? settingsObject)
|
||||
{
|
||||
|
||||
var pluginSettingsPath = Path.Combine(this.CoreSettings.GlobalConfigFilePath, pluginName + "_settings.json");
|
||||
|
||||
if (File.Exists(pluginSettingsPath))
|
||||
{
|
||||
string json = File.ReadAllText(pluginSettingsPath);
|
||||
JsonConvert.PopulateObject(json, settingsObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePluginSettings(string pluginName, object? settingsObject)
|
||||
{
|
||||
var pluginSettingsPath = Path.Combine(this.CoreSettings.GlobalConfigFilePath, pluginName + "_settings.json");
|
||||
|
||||
using (StreamWriter file = File.CreateText(pluginSettingsPath))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer()
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
};
|
||||
|
||||
serializer.Serialize(file, settingsObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,9 @@
|
||||
<Reference Include="Avalonia.Markup.Xaml">
|
||||
<HintPath>..\..\..\.nuget\packages\avalonia\11.1.0\ref\net8.0\Avalonia.Markup.Xaml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\..\.nuget\packages\newtonsoft.json\13.0.3\lib\net6.0\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user