improvements to settings page
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\Subject.png" />
|
||||
<None Remove="Settings.xaml" />
|
||||
<None Remove="URLShortener.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
BIN
Assets/Subject.png
Normal file
BIN
Assets/Subject.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 375 KiB |
25
JSONClasses.cs
Normal file
25
JSONClasses.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace APIToolkit
|
||||
{
|
||||
public record class APIHeaders
|
||||
{
|
||||
[JsonPropertyName("user-agent")]
|
||||
public required string UserAgent { get; set; }
|
||||
|
||||
[JsonPropertyName("cf-connecting-ip")]
|
||||
public required string CfConnectingIp { get; set; }
|
||||
|
||||
[JsonPropertyName("cf-ipcountry")]
|
||||
public required string CfIpCountry { get; set; }
|
||||
|
||||
[JsonPropertyName("cf-ray")]
|
||||
public required string CfRay { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border x:Name="AppTitleBar" VerticalAlignment="Top" Grid.Column="0" Grid.Row="0">
|
||||
<TextBlock x:Name="AppTitle" Text="😺 Enstrayed API Toolkit" VerticalAlignment="Top" FontSize="18" Margin="10,8,8,8"/>
|
||||
<TextBlock x:Name="AppTitle" Text="Enstrayed API Toolkit" VerticalAlignment="Top" FontSize="18" Margin="10,8,8,8"/>
|
||||
</Border>
|
||||
|
||||
<NavigationView Grid.Column="0" Grid.Row="1" ItemInvoked="NavigationView_ItemInvoked">
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
@@ -28,6 +31,9 @@ namespace APIToolkit
|
||||
this.SetTitleBar(AppTitleBar);
|
||||
|
||||
ContentArea.Navigate(typeof(URLShortener)); // Set default page
|
||||
|
||||
GlobalMethods.WebRequest.BaseAddress = new Uri("https://enstrayed.com/api/"); // Set base address for web requests being made
|
||||
GlobalMethods.WebRequest.DefaultRequestHeaders.UserAgent.ParseAdd($"DotNet/{Environment.Version} APIToolkit/{GlobalMethods.Version}"); // Set user agent of client
|
||||
}
|
||||
|
||||
private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
|
||||
@@ -51,4 +57,10 @@ namespace APIToolkit
|
||||
}
|
||||
}
|
||||
|
||||
public static class GlobalMethods
|
||||
{
|
||||
public static HttpClient WebRequest = new();
|
||||
public static string Version = "1.0";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,90 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Button Content="Settings"/>
|
||||
<Grid Margin="36,36,36,36" x:Name="Settings_MainGrid">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--Margin: Left Top Right Bottom-->
|
||||
|
||||
<Expander Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" IsExpanded="True">
|
||||
<Expander.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<FontIcon Glyph="" Margin="0,0,12,0"/>
|
||||
<TextBlock Text="Authentication"/>
|
||||
</StackPanel>
|
||||
</Expander.Header>
|
||||
<Expander.Content>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
|
||||
<TextBlock Text="Token" Margin="0,0,12,0" VerticalAlignment="Center"/>
|
||||
<PasswordBox MinWidth="300" Margin="0,0,12,0"/>
|
||||
<Button Content="Save"/>
|
||||
</StackPanel>
|
||||
</Expander.Content>
|
||||
</Expander>
|
||||
|
||||
|
||||
<Expander Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left">
|
||||
<Expander.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<FontIcon Glyph="" Margin="0,0,12,0"/>
|
||||
<TextBlock Text="Diagnostics (HTTP Headers)"/>
|
||||
</StackPanel>
|
||||
</Expander.Header>
|
||||
<Expander.Content>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MinHeight="30"/>
|
||||
<RowDefinition MinHeight="30"/>
|
||||
<RowDefinition MinHeight="30"/>
|
||||
<RowDefinition MinHeight="30"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button Content="Refresh" Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" Margin="0,12,0,0" Click="SettingsHeadersRefresh"/>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Text="User Agent" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Text="Cloudflare Connecting IP" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="Cloudflare IP Country" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="3" Text="Cloudflare Ray ID" VerticalAlignment="Center"/>
|
||||
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Text="" Name="SettingsHeadersUserAgent" VerticalAlignment="Center" FontFamily="Consolas" IsTextSelectionEnabled="True" TextWrapping="Wrap"/>
|
||||
<TextBlock Grid.Column="1" Grid.Row="1" Text="" Name="SettingsHeadersConnectingIp" VerticalAlignment="Center" FontFamily="Consolas" IsTextSelectionEnabled="True"/>
|
||||
<TextBlock Grid.Column="1" Grid.Row="2" Text="" Name="SettingsHeadersIpCountry" VerticalAlignment="Center" FontFamily="Consolas" IsTextSelectionEnabled="True"/>
|
||||
<TextBlock Grid.Column="1" Grid.Row="3" Text="" Name="SettingsHeadersRayId" VerticalAlignment="Center" FontFamily="Consolas" IsTextSelectionEnabled="True"/>
|
||||
|
||||
</Grid>
|
||||
</Expander.Content>
|
||||
</Expander>
|
||||
|
||||
<Expander Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left">
|
||||
<Expander.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<FontIcon Glyph="" Margin="0,0,12,0"/>
|
||||
<TextBlock Text="Information"/>
|
||||
</StackPanel>
|
||||
</Expander.Header>
|
||||
<Expander.Content>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
|
||||
<Image Source="Assets/Subject.png" MaxWidth="300"/>
|
||||
<StackPanel VerticalAlignment="Center" Margin="36,0,0,0">
|
||||
<TextBlock Text="Enstrayed API Toolkit" FontSize="32" Margin="0,0,0,8"/>
|
||||
<TextBlock Name="SettingsVersionLabel" FontSize="16" Margin="0,0,0,12"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Expander.Content>
|
||||
</Expander>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using ABI.System;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
@@ -9,7 +10,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Json;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text.Json;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
|
||||
@@ -26,6 +30,27 @@ namespace APIToolkit
|
||||
public Settings()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
SettingsVersionLabel.Text = $"Version {GlobalMethods.Version}";
|
||||
}
|
||||
|
||||
private async void SettingsHeadersRefresh(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string SettingsHeadersResponseJSON = await GlobalMethods.WebRequest.GetStringAsync("headers");
|
||||
APIHeaders SettingsHeadersResponse = JsonSerializer.Deserialize<APIHeaders>(SettingsHeadersResponseJSON);
|
||||
|
||||
SettingsHeadersUserAgent.Text = SettingsHeadersResponse.UserAgent;
|
||||
SettingsHeadersConnectingIp.Text = SettingsHeadersResponse.CfConnectingIp;
|
||||
SettingsHeadersIpCountry.Text = SettingsHeadersResponse.CfIpCountry;
|
||||
SettingsHeadersRayId.Text = SettingsHeadersResponse.CfRay;
|
||||
}
|
||||
catch (System.Exception Error)
|
||||
{
|
||||
UIFunctions.ShowError(Settings_MainGrid.XamlRoot, Error.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user