This commit is contained in:
Thomas Peterson 2024-11-18 19:53:49 +01:00
parent e29a9a92b2
commit 89c47a0766
14 changed files with 232 additions and 66 deletions

View File

@ -0,0 +1 @@
PSCHelpdesk

View File

@ -11,21 +11,13 @@
</component>
<component name="ChangeListManager">
<list default="true" id="95257dc5-08bd-4c50-8726-85956b3c2c92" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/FastBill/Views/CustomerView.axaml.cs" 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$/FastBill/FastBill.cs" beforeDir="false" afterPath="$PROJECT_DIR$/FastBill/FastBill.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/FastBill/FastBill.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/FastBill/FastBill.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/HetznerServer.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/HetznerServer.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/FastBill/Api/Customers.cs" beforeDir="false" afterPath="$PROJECT_DIR$/FastBill/Api/Customers.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/FastBill/ViewModels/CustomerViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/FastBill/ViewModels/CustomerViewModel.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/FastBill/Views/CustomerView.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/FastBill/Views/CustomerView.axaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/Models/Server.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Models/Server.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/Models/ServerSetting.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Models/ServerSetting.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/Service/ServerService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Service/ServerService.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/ServerDetailView.axaml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/Views/ServerDetailView.axaml.cs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/Views/ServerView.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Views/ServerView.axaml" 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$/_dist/hetzner/HetznerServer.deps.json" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.deps.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/Views/ServerDetailView.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/Views/ServerDetailView.axaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.dll" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.dll" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.dll" afterDir="false" />
@ -85,7 +77,7 @@
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
".NET Project.PSCHelpdesk.Desktop ohne plugin.executor": "Run",
".NET Project.PSCHelpdesk.Desktop.executor": "Debug",
".NET Project.PSCHelpdesk.Desktop.executor": "Run",
"Publish to folder.Build HetznerServer Plugin Debug.executor": "Run",
"Publish to folder.Copy Fastbill.executor": "Run",
"Publish to folder.Copy Hetzner Target.executor": "Run",
@ -107,7 +99,7 @@
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.lookFeel",
"settings.editor.selected.configurable": "preferences.pluginManager",
"vue.rearranger.settings.migration": "true"
},
"keyToStringList": {
@ -215,6 +207,7 @@
<item itemvalue=".NET Project.PSCHelpdesk.Browser" />
<item itemvalue=".NET Project.PSCHelpdesk.Desktop" />
<item itemvalue=".NET Project.PSCHelpdesk.Desktop ohne plugin" />
<item itemvalue="Android.PSCHelpdesk.Android" />
<item itemvalue="iOS.PSCHelpdesk.iOS" />
<item itemvalue="Publish to folder.Copy NextCloud" />
<item itemvalue="Publish to folder.Copy Fastbill" />
@ -250,6 +243,9 @@
<workItem from="1731775118011" duration="3650000" />
<workItem from="1731831383500" duration="6829000" />
<workItem from="1731872471713" duration="6104000" />
<workItem from="1731920010371" duration="2837000" />
<workItem from="1731924310645" duration="5978000" />
<workItem from="1731934744692" duration="8712000" />
</task>
<servers />
</component>
@ -372,19 +368,6 @@
</properties>
<option name="timeStamp" value="195" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/MainWindowViewModel.cs</url>
<line>125</line>
<properties documentPath="C:\Users\info\RiderProjects\pschelpdesk\PSCHelpdesk\PSCHelpdesk\ViewModels\MainWindowViewModel.cs" containingFunctionPresentation="Method 'openPlugins'">
<startOffsets>
<option value="4256" />
</startOffsets>
<endOffsets>
<option value="4384" />
</endOffsets>
</properties>
<option name="timeStamp" value="196" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs</url>
<line>99</line>
@ -398,44 +381,44 @@
</properties>
<option name="timeStamp" value="204" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/FastBill/Api/Customers.cs</url>
<line>20</line>
<properties documentPath="C:\Users\boonkerz\RiderProjects\PSCHelpDesk\FastBill\Api\Customers.cs" containingFunctionPresentation="Method 'SearchCustomer'">
<startOffsets>
<option value="781" />
</startOffsets>
<endOffsets>
<option value="802" />
</endOffsets>
</properties>
<option name="timeStamp" value="208" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/FastBill/ViewModels/CustomerViewModel.cs</url>
<line>28</line>
<properties documentPath="C:\Users\boonkerz\RiderProjects\PSCHelpDesk\FastBill\ViewModels\CustomerViewModel.cs" containingFunctionPresentation="Method 'SearchTerm'">
<line>29</line>
<properties documentPath="C:\Users\info\RiderProjects\pschelpdesk\FastBill\ViewModels\CustomerViewModel.cs" containingFunctionPresentation="Method 'searchTerm'">
<startOffsets>
<option value="689" />
<option value="709" />
</startOffsets>
<endOffsets>
<option value="744" />
<option value="764" />
</endOffsets>
</properties>
<option name="timeStamp" value="209" />
<option name="timeStamp" value="211" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/FastBill/Api/Customers.cs</url>
<line>18</line>
<properties documentPath="C:\Users\boonkerz\RiderProjects\PSCHelpDesk\FastBill\Api\Customers.cs" containingFunctionPresentation="Method 'SearchCustomer'">
<properties documentPath="C:\Users\info\RiderProjects\pschelpdesk\FastBill\Api\Customers.cs" containingFunctionPresentation="Method 'SearchCustomer'">
<startOffsets>
<option value="702" />
<option value="659" />
</startOffsets>
<endOffsets>
<option value="758" />
<option value="715" />
</endOffsets>
</properties>
<option name="timeStamp" value="210" />
<option name="timeStamp" value="212" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DotNet Breakpoints">
<url>file://$PROJECT_DIR$/FastBill/Api/Customers.cs</url>
<line>20</line>
<properties documentPath="C:\Users\info\RiderProjects\pschelpdesk\FastBill\Api\Customers.cs" containingFunctionPresentation="Method 'SearchCustomer'">
<startOffsets>
<option value="738" />
</startOffsets>
<endOffsets>
<option value="759" />
</endOffsets>
</properties>
<option name="timeStamp" value="213" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>

View File

@ -11,9 +11,9 @@ public class Customers
var customers = new List<Customer>();
var client = new RestClient("https://my.fastbill.com/");
var request = new RestRequest("api/1.0/api.php");
request.Authenticator = new HttpBasicAuthenticator(settings.EMail, settings.ApiKey);
request.RequestFormat = DataFormat.Json;
var request = new RestRequest("api/1.0/api.php"){
Authenticator = new HttpBasicAuthenticator(settings.EMail, settings.ApiKey)
};
request.AddJsonBody(new { SERVICE = "customer.get", FILTER = new { TERM = term } });
var response = await client.ExecuteAsync<List<Customer>>(request);
if (response.StatusCode == System.Net.HttpStatusCode.OK)

View File

@ -7,7 +7,7 @@ namespace FastBill.ViewModels;
public class CustomerViewModel: ViewModelBase, IViewModelBase
{
public string _term;
private string _term;
public string Term
{
@ -21,6 +21,7 @@ public class CustomerViewModel: ViewModelBase, IViewModelBase
public CustomerViewModel(CustomerService customerService)
{
Term = "";
_customerService = customerService;
SearchCustomer = ReactiveCommand.Create(searchTerm);
}

View File

@ -6,7 +6,9 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="vm:CustomerViewModel"
x:Class="FastBill.Views.CustomerView">
<Design.DataContext><vm:CustomerViewModel></vm:CustomerViewModel></Design.DataContext>
<Design.DataContext>
<vm:CustomerViewModel></vm:CustomerViewModel>
</Design.DataContext>
<StackPanel>
<TextBox Text="{Binding Term}"></TextBox>
<Button Content="Search" Command="{Binding SearchCustomer}"></Button>

View File

@ -0,0 +1,37 @@
using Material.Icons;
using ReactiveUI;
namespace PSCHelpdesk.Plugins.HetznerServer.Models;
public class Instance : ReactiveObject
{
private string _sftpUserName;
private string _sftpPassword;
private string _sftpHostName;
private bool _smtpOwn;
public bool SmtpOwn
{
get => _smtpOwn;
set => this.RaiseAndSetIfChanged(ref _smtpOwn, value);
}
public string SftpUserName
{
get => _sftpUserName;
set => this.RaiseAndSetIfChanged(ref _sftpUserName, value);
}
public string SftpPassword
{
get => _sftpPassword;
set => this.RaiseAndSetIfChanged(ref _sftpPassword, value);
}
public string SftpHostName
{
get => _sftpHostName;
set => this.RaiseAndSetIfChanged(ref _sftpHostName, value);
}
}

View File

@ -0,0 +1,36 @@
using Material.Icons;
using ReactiveUI;
namespace PSCHelpdesk.Plugins.HetznerServer.Models;
public class Plugin : ReactiveObject
{
public string Title { get; set; }
private bool _installed;
public bool Installed
{
get => _installed;
set
{
this.RaiseAndSetIfChanged(ref _installed, value);
}
}
private MaterialIconKind _icon;
public MaterialIconKind Icon
{
get => Installed==true? MaterialIconKind.Check:MaterialIconKind.Delete;
set => this.RaiseAndSetIfChanged(ref _icon, value);
}
public string Uuid { get; set; }
public Plugin()
{
Installed = false;
Icon = MaterialIconKind.Remove;
}
}

View File

@ -14,7 +14,22 @@ public class Server : ReactiveObject
{
public long ServerId { get; set; }
public string Name { get; set; }
private Instance _instance;
public Instance Instance
{
get => _instance;
set => this.RaiseAndSetIfChanged(ref _instance, value);
}
private List<Plugin> _plugins;
public List<Plugin> Plugins
{
get => _plugins;
set => this.RaiseAndSetIfChanged(ref _plugins, value);
}
private string _pscApiKey;
public string PscApiKey
@ -101,7 +116,9 @@ public class Server : ReactiveObject
Status = status;
Ipv4 = ipv4;
Ipv6 = ipv6;
this.Domains = new List<Domain>();
Domains = new List<Domain>();
Plugins = new List<Plugin>();
Instance = new Instance();
}
private List<Domain> _domains;

View File

@ -23,7 +23,6 @@ public class ServerService: IServerService
private SettingsManager _settingsManager;
private readonly DispatcherTimer _reloadTimer = new DispatcherTimer();
private string _searchText = string.Empty;
private static readonly HttpClient httpClient = new HttpClient();
private ITaskManager _taskManager;
private readonly IToastManager? _toastManager;
@ -157,30 +156,91 @@ public class ServerService: IServerService
{
serv.Domains.Add(new Domain(dom));
}
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/ld+json"));
httpClient.DefaultRequestHeaders.Add("User-Agent", "PSC Client");
try
{
var stringTask = httpClient.GetStringAsync("https://" + webHosts[0] + "/apps/api/system/version");
var stringTask = httpClient.GetStringAsync("https://" + webHosts[0] + "/apps/api/system/version");
var msg = await stringTask;
JObject versionMSg = JObject.Parse(msg);
serv.Datum = versionMSg["datum"].ToString();
serv.Release = float.Parse(versionMSg["release"].ToString());
var msg = await stringTask;
JObject versionMSg = JObject.Parse(msg);
serv.Datum = versionMSg["datum"].ToString();
serv.Release = float.Parse(versionMSg["release"].ToString());
}
catch (Exception ex)
{
_toastManager.DisplayNewToast("Server " + serv.Name + " error" + Environment.NewLine + ex.Message);
}
}
}
}
if (serv.PscApiKey != "" && serv.Domains.Count > 0)
{
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/ld+json"));
httpClient.DefaultRequestHeaders.Add("User-Agent", "PSC Client");
httpClient.DefaultRequestHeaders.Add("apiKey", serv.PscApiKey);
try
{
var stringPlugins =
httpClient.GetStringAsync("https://" + serv.Domains.First().Name + "/apps/api/plugins");
var msg = await stringPlugins;
JObject pluginMsg = JObject.Parse(msg);
foreach (var plugin in pluginMsg["data"])
{
serv.Plugins.Add(new Plugin()
{
Installed = bool.Parse(plugin["installed"].ToString()),
Title = plugin["title"].ToString(),
Uuid = plugin["uuid"].ToString()
});
}
}
catch (Exception ex)
{
_toastManager.DisplayNewToast("Server " + serv.Name + " error" + Environment.NewLine + ex.Message);
}
}
if (serv.PscApiKey != "" && serv.Domains.Count > 0)
{
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/ld+json"));
httpClient.DefaultRequestHeaders.Add("User-Agent", "PSC Client");
httpClient.DefaultRequestHeaders.Add("apiKey", serv.PscApiKey);
try
{
var stringPlugins =
httpClient.GetStringAsync("https://" + serv.Domains.First().Name + "/apps/api/system/info");
var msg = await stringPlugins;
JObject systemInfo = JObject.Parse(msg);
serv.Instance.SftpUserName = systemInfo["sftpUserName"].ToString();
serv.Instance.SftpPassword = systemInfo["sftpPassword"].ToString();
serv.Instance.SftpHostName = systemInfo["sftpHost"].ToString();
serv.Instance.SmtpOwn = bool.Parse(systemInfo["smtpOwn"].ToString());
}
catch (Exception ex)
{
_toastManager.DisplayNewToast("Server " + serv.Name + " error" + Environment.NewLine + ex.Message);
}
}
serv.IsGoodIcon = MaterialIconKind.Check;
serv.IsGoodColor = Brushes.Green;
client.Disconnect();
_toastManager.DisplayNewToast("Server " + serv.Name + " finished");
}
catch (Exception ex)
{

View File

@ -2,6 +2,7 @@
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:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:vm="clr-namespace:PSCHelpdesk.Plugins.HetznerServer.ViewModels"
xmlns:views="clr-namespace:PSCHelpdesk.Plugins.HetznerServer.Views"
@ -20,7 +21,6 @@
<ListBox.ItemTemplate>
<DataTemplate>
<Border Padding="1" Margin="0">
<!--<TextBox Text="{Binding Name}" DoubleTapped="InputElement_OnDoubleTapped"></TextBox>-->
<HyperlinkButton Content="{Binding LinkDomain}" NavigateUri="{Binding LinkDomain}"></HyperlinkButton>
</Border>
</DataTemplate>
@ -28,6 +28,35 @@
</ListBox>
</StackPanel>
</TabItem>
<TabItem Header="Info">
<StackPanel>
<TextBox Text="{Binding SelectedServer.Instance.SftpUserName}"></TextBox>
<TextBox Text="{Binding SelectedServer.Instance.SftpPassword}"></TextBox>
<TextBox Text="{Binding SelectedServer.Instance.SftpHostName}"></TextBox>
<TextBox Text="{Binding SelectedServer.Instance.SmtpOwn}"></TextBox>
</StackPanel>
</TabItem>
<TabItem Header="Plugins">
<StackPanel>
<ListBox ItemsSource="{Binding SelectedServer.Plugins}" Margin="0" Padding="0">
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Padding" Value="0" />
</Style>
</ListBox.Styles>
<ListBox.ItemTemplate>
<DataTemplate>
<Border Padding="1" Margin="0">
<Grid ColumnDefinitions="Auto,*">
<materialIcons:MaterialIcon Grid.Column="0" Kind="{Binding Icon }" Margin="5 0"></materialIcons:MaterialIcon>
<TextBox Grid.Column="1" Text="{Binding Title}"></TextBox>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</TabItem>
<TabItem Header="Settings">
<StackPanel>
<TextBlock Text="PSC ApiKey" Margin="0 5"></TextBlock>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.