mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-19 00:51:30 -07:00
Add easy exporting of diagnostic data
This commit is contained in:
parent
cac081eeb8
commit
fa7ebf4f9d
54
Bloxstrap/Resources/Strings.Designer.cs
generated
54
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -432,6 +432,15 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Export.
|
||||||
|
/// </summary>
|
||||||
|
public static string Common_Export {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Common.Export", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Help.
|
/// Looks up a localized string similar to Help.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1386,6 +1395,15 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Zip archive.
|
||||||
|
/// </summary>
|
||||||
|
public static string FileTypes_ZipArchive {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("FileTypes.ZipArchive", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Bloxstrap has been upgraded to v{0}.
|
/// Looks up a localized string similar to Bloxstrap has been upgraded to v{0}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -2103,6 +2121,42 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Gather information that can be uploaded online to troubleshoot a problem you're having..
|
||||||
|
/// </summary>
|
||||||
|
public static string Menu_Bloxstrap_ExportData_Description {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Menu.Bloxstrap.ExportData.Description", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Bloxstrap configuration.
|
||||||
|
/// </summary>
|
||||||
|
public static string Menu_Bloxstrap_ExportData_ExportConfig {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Menu.Bloxstrap.ExportData.ExportConfig", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to All Bloxstrap logs.
|
||||||
|
/// </summary>
|
||||||
|
public static string Menu_Bloxstrap_ExportData_ExportLogs {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Menu.Bloxstrap.ExportData.ExportLogs", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Export diagnostic data.
|
||||||
|
/// </summary>
|
||||||
|
public static string Menu_Bloxstrap_ExportData_Title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Menu.Bloxstrap.ExportData.Title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Add new.
|
/// Looks up a localized string similar to Add new.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -906,6 +906,7 @@ Selecting 'No' will ignore this warning and continue installation.</value>
|
|||||||
</data>
|
</data>
|
||||||
<data name="FileTypes.JSONFiles" xml:space="preserve">
|
<data name="FileTypes.JSONFiles" xml:space="preserve">
|
||||||
<value>JSON files</value>
|
<value>JSON files</value>
|
||||||
|
<comment>Shown in the open file dialog, where the file type selection dropdown is, e.g. "JSON files (*.json)"</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Menu.FastFlagEditor.InvalidBoolValue" xml:space="preserve">
|
<data name="Menu.FastFlagEditor.InvalidBoolValue" xml:space="preserve">
|
||||||
<value>The entry for '{0}' is not valid as the value must be a boolean (either 'True' or 'False')</value>
|
<value>The entry for '{0}' is not valid as the value must be a boolean (either 'True' or 'False')</value>
|
||||||
@ -1248,4 +1249,26 @@ Would you like to enable test mode?</value>
|
|||||||
Please close any applications that may be using Roblox's files, and relaunch.</value>
|
Please close any applications that may be using Roblox's files, and relaunch.</value>
|
||||||
<comment>This is *not* for when Roblox is still running when trying to upgrade. This applies to files being open (i.e. image assets)</comment>
|
<comment>This is *not* for when Roblox is still running when trying to upgrade. This applies to files being open (i.e. image assets)</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="FileTypes.ZipArchive" xml:space="preserve">
|
||||||
|
<value>Zip archive</value>
|
||||||
|
<comment>Shown in the save file dialog, where the file type selection dropdown is, e.g. "Zip archive (*.zip)"</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Common.Export" xml:space="preserve">
|
||||||
|
<value>Export</value>
|
||||||
|
<comment>Currently used under the "Bloxstrap" settings tab for the button to export diagnostic data</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Menu.Bloxstrap.ExportData.Title" xml:space="preserve">
|
||||||
|
<value>Export diagnostic data</value>
|
||||||
|
</data>
|
||||||
|
<data name="Menu.Bloxstrap.ExportData.Description" xml:space="preserve">
|
||||||
|
<value>Gather information that can be uploaded online to troubleshoot a problem you're having.</value>
|
||||||
|
</data>
|
||||||
|
<data name="Menu.Bloxstrap.ExportData.ExportConfig" xml:space="preserve">
|
||||||
|
<value>Bloxstrap configuration</value>
|
||||||
|
<comment>Label that appears next to a checkbox</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Menu.Bloxstrap.ExportData.ExportLogs" xml:space="preserve">
|
||||||
|
<value>All Bloxstrap logs</value>
|
||||||
|
<comment>Label that appears next to a checkbox</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -8,7 +8,7 @@
|
|||||||
xmlns:controls="clr-namespace:Bloxstrap.UI.Elements.Controls"
|
xmlns:controls="clr-namespace:Bloxstrap.UI.Elements.Controls"
|
||||||
xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels.Settings"
|
xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels.Settings"
|
||||||
xmlns:resources="clr-namespace:Bloxstrap.Resources"
|
xmlns:resources="clr-namespace:Bloxstrap.Resources"
|
||||||
d:DataContext="{d:DesignInstance Type=models:BehaviourViewModel}"
|
d:DataContext="{d:DesignInstance Type=models:BloxstrapViewModel}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="600" d:DesignWidth="800"
|
d:DesignHeight="600" d:DesignWidth="800"
|
||||||
Title="BehaviourPage"
|
Title="BehaviourPage"
|
||||||
@ -28,5 +28,44 @@
|
|||||||
Description="{Binding Source={x:Static resources:Strings.Menu_Bloxstrap_Analytics_Description}, Converter={StaticResource StringFormatConverter}, ConverterParameter='https://github.com/bloxstraplabs/bloxstrap/wiki/Privacy-Policy#analytical-functionality'}">
|
Description="{Binding Source={x:Static resources:Strings.Menu_Bloxstrap_Analytics_Description}, Converter={StaticResource StringFormatConverter}, ConverterParameter='https://github.com/bloxstraplabs/bloxstrap/wiki/Privacy-Policy#analytical-functionality'}">
|
||||||
<ui:ToggleSwitch IsChecked="{Binding AnalyticsEnabled, Mode=TwoWay}" />
|
<ui:ToggleSwitch IsChecked="{Binding AnalyticsEnabled, Mode=TwoWay}" />
|
||||||
</controls:OptionControl>
|
</controls:OptionControl>
|
||||||
|
|
||||||
|
<ui:CardExpander Margin="0,8,0,0" IsExpanded="True">
|
||||||
|
<ui:CardExpander.Header>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel Grid.Column="0">
|
||||||
|
<TextBlock FontSize="14" Text="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_Title}" />
|
||||||
|
<TextBlock FontSize="12" Text="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_Description}" Foreground="{DynamicResource TextFillColorTertiaryBrush}" TextWrapping="Wrap" />
|
||||||
|
</StackPanel>
|
||||||
|
<ui:Button Grid.Column="1" MinWidth="100" Margin="0,0,16,0" Icon="CopySelect20" Content="{x:Static resources:Strings.Common_Export}" Command="{Binding ExportDataCommand}">
|
||||||
|
<ui:Button.Style>
|
||||||
|
<Style TargetType="ui:Button" BasedOn="{StaticResource {x:Type ui:Button}}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<MultiDataTrigger>
|
||||||
|
<MultiDataTrigger.Conditions>
|
||||||
|
<Condition Binding="{Binding ElementName=ShouldExportConfig, Path=IsChecked}" Value="False" />
|
||||||
|
<Condition Binding="{Binding ElementName=ShouldExportLogs, Path=IsChecked}" Value="False" />
|
||||||
|
</MultiDataTrigger.Conditions>
|
||||||
|
<Setter Property="IsEnabled" Value="False" />
|
||||||
|
</MultiDataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
<Setter Property="IsEnabled" Value="True" />
|
||||||
|
</Style>
|
||||||
|
</ui:Button.Style>
|
||||||
|
</ui:Button>
|
||||||
|
</Grid>
|
||||||
|
</ui:CardExpander.Header>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<CheckBox Grid.Column="0" Name="ShouldExportConfig" Content="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_ExportConfig}" IsChecked="{Binding ShouldExportConfig}" />
|
||||||
|
<CheckBox Grid.Column="1" Name="ShouldExportLogs" Content="{x:Static resources:Strings.Menu_Bloxstrap_ExportData_ExportLogs}" IsChecked="{Binding ShouldExportLogs}" />
|
||||||
|
</Grid>
|
||||||
|
</ui:CardExpander>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ui:UiPage>
|
</ui:UiPage>
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
namespace Bloxstrap.UI.ViewModels.Settings
|
using System.Windows.Input;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
|
namespace Bloxstrap.UI.ViewModels.Settings
|
||||||
{
|
{
|
||||||
public class BloxstrapViewModel : NotifyPropertyChangedViewModel
|
public class BloxstrapViewModel : NotifyPropertyChangedViewModel
|
||||||
{
|
{
|
||||||
@ -13,5 +18,73 @@
|
|||||||
get => App.Settings.Prop.EnableAnalytics;
|
get => App.Settings.Prop.EnableAnalytics;
|
||||||
set => App.Settings.Prop.EnableAnalytics = value;
|
set => App.Settings.Prop.EnableAnalytics = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShouldExportConfig { get; set; } = true;
|
||||||
|
|
||||||
|
public bool ShouldExportLogs { get; set; } = true;
|
||||||
|
|
||||||
|
public ICommand ExportDataCommand => new RelayCommand(ExportData);
|
||||||
|
|
||||||
|
private void ExportData()
|
||||||
|
{
|
||||||
|
string timestamp = DateTime.UtcNow.ToString("yyyyMMdd'T'HHmmss'Z'");
|
||||||
|
|
||||||
|
var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
FileName = $"Bloxstrap-export-{timestamp}.zip",
|
||||||
|
Filter = $"{Strings.FileTypes_ZipArchive}|*.zip"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (dialog.ShowDialog() != true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
using var memStream = new MemoryStream();
|
||||||
|
using var zipStream = new ZipOutputStream(memStream);
|
||||||
|
|
||||||
|
if (ShouldExportConfig)
|
||||||
|
{
|
||||||
|
var files = new List<string>()
|
||||||
|
{
|
||||||
|
App.Settings.FileLocation,
|
||||||
|
App.State.FileLocation,
|
||||||
|
App.FastFlags.FileLocation
|
||||||
|
};
|
||||||
|
|
||||||
|
AddFilesToZipStream(zipStream, files, "Config/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ShouldExportLogs && Directory.Exists(Paths.Logs))
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(Paths.Logs)
|
||||||
|
.Where(x => !x.Equals(App.Logger.FileLocation, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
AddFilesToZipStream(zipStream, files, "Logs/");
|
||||||
|
}
|
||||||
|
|
||||||
|
zipStream.CloseEntry();
|
||||||
|
memStream.Position = 0;
|
||||||
|
|
||||||
|
using var outputStream = File.OpenWrite(dialog.FileName);
|
||||||
|
memStream.CopyTo(outputStream);
|
||||||
|
|
||||||
|
Process.Start("explorer.exe", $"/select,\"{dialog.FileName}\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddFilesToZipStream(ZipOutputStream zipStream, IEnumerable<string> files, string directory)
|
||||||
|
{
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
if (!File.Exists(file))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var entry = new ZipEntry(directory + Path.GetFileName(file));
|
||||||
|
entry.DateTime = DateTime.Now;
|
||||||
|
|
||||||
|
zipStream.PutNextEntry(entry);
|
||||||
|
|
||||||
|
using var fileStream = File.OpenRead(file);
|
||||||
|
fileStream.CopyTo(zipStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Windows;
|
using System.Windows.Input;
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user