Skip to content

Commit

Permalink
Collect logs feature
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperJMN committed May 16, 2019
1 parent f28cca6 commit fdffc57
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 37 deletions.
30 changes: 29 additions & 1 deletion Source/Deployer.Lumia.Gui/ViewModels/AdvancedViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
Expand All @@ -17,8 +19,10 @@ namespace Deployer.Lumia.Gui.ViewModels
[Metadata("Order", 2)]
public class AdvancedViewModel : ReactiveObject, ISection, IDisposable
{
private const string LogsZipName = "PhoneLogs.zip";
private readonly IDeploymentContext context;
private readonly IWindowsDeployer deployer;
private readonly ILogCollector logCollector;
private readonly IDisposable preparerUpdater;
private readonly IOperationProgress progress;
private readonly ILumiaSettingsService lumiaSettingsService;
Expand All @@ -30,12 +34,14 @@ public AdvancedViewModel(ILumiaSettingsService lumiaSettingsService, IFileSystem
UIServices uiServices, IDeploymentContext context, IOperationContext operationContext,
IList<Meta<IDiskLayoutPreparer>> diskPreparers,
IWindowsDeployer deployer,
ILogCollector logCollector,
IOperationProgress progress)
{
this.lumiaSettingsService = lumiaSettingsService;
this.uiServices = uiServices;
this.context = context;
this.deployer = deployer;
this.logCollector = logCollector;
this.progress = progress;

DiskPreparers = diskPreparers;
Expand All @@ -52,9 +58,12 @@ public AdvancedViewModel(ILumiaSettingsService lumiaSettingsService, IFileSystem
RestoreCommandWrapper =
new CommandWrapper<Unit, Unit>(this, ReactiveCommand.CreateFromTask(Restore), uiServices.ContextDialog, operationContext);

CollectLogsCommmandWrapper = new CommandWrapper<Unit, Unit>(this, ReactiveCommand.CreateFromTask(CollectLogs), uiServices.ContextDialog, operationContext);

IsBusyObservable = Observable.Merge(DeleteDownloadedWrapper.Command.IsExecuting,
BackupCommandWrapper.Command.IsExecuting, RestoreCommandWrapper.Command.IsExecuting,
ForceDualBootWrapper.Command.IsExecuting, ForceSingleBootWrapper.Command.IsExecuting);
ForceDualBootWrapper.Command.IsExecuting, ForceSingleBootWrapper.Command.IsExecuting,
CollectLogsCommmandWrapper.Command.IsExecuting);

preparerUpdater = this.WhenAnyValue(x => x.SelectedPreparer)
.Where(x => x != null)
Expand All @@ -67,6 +76,23 @@ public AdvancedViewModel(ILumiaSettingsService lumiaSettingsService, IFileSystem
SelectedPreparer = GetInitialDiskPreparer();
}

private async Task CollectLogs()
{
await logCollector.Collect(context.Device, LogsZipName);
var fileInfo = new FileInfo(LogsZipName);
ExploreFile(fileInfo.FullName);
}

private void ExploreFile(string filePath)
{
if (!File.Exists(filePath))
{
return;
}
//Clean up file path so it can be navigated OK
Process.Start("explorer.exe", $"/select,\"{filePath}\"");
}

private Meta<IDiskLayoutPreparer> GetInitialDiskPreparer()
{
var fromSettings = DiskPreparers.FirstOrDefault(x => (string)x.Metadata["Name"] == lumiaSettingsService.DiskPreparer);
Expand Down Expand Up @@ -115,6 +141,8 @@ public bool CleanDownloadedBeforeDeployment
}
}

public CommandWrapper<Unit, Unit> CollectLogsCommmandWrapper { get; }

public CommandWrapper<Unit, Unit> ForceDualBootWrapper { get; }

public CommandWrapper<Unit, Unit> ForceSingleBootWrapper { get; }
Expand Down
72 changes: 38 additions & 34 deletions Source/Deployer.Lumia.Gui/Views/Parts/Advanced/AdvancedPart.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,44 +70,48 @@
</mah:MetroProgressBar>
</Grid>
<GroupBox Header="Misc" Padding="10" Margin="0 20 0 0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<ui:IconButton HorizontalAlignment="Center" Height="50"
Command="{Binding DeleteDownloadedWrapper.Command}"
Content="Delete 'Downloaded' folder"
IsBusy="{Binding DeleteDownloadedWrapper.IsExecuting}">
<UniformGrid>
<UniformGrid.Resources>
<Style TargetType="ui:IconButton">
<Setter Property="Height" Value="50" />
<Setter Property="Margin" Value="3"></Setter>
</Style>
</UniformGrid.Resources>
<ui:IconButton Command="{Binding DeleteDownloadedWrapper.Command}"
Content="Delete 'Downloaded' folder"
IsBusy="{Binding DeleteDownloadedWrapper.IsExecuting}">
<ui:IconButton.Icon>
<iconPacks:MaterialLight Kind="Delete" Height="30" />
</ui:IconButton.Icon>
</ui:IconButton>
<WrapPanel Grid.Column="1" HorizontalAlignment="Center" Margin="15 0 0 0">
<ui:IconButton Height="50"
Margin="4,0"
Command="{Binding ForceDualBootWrapper.Command}"
IsBusy="{Binding ForceDualBootWrapper.IsExecuting}">
<ui:IconButton.Content>
<TextBlock>Force Dual Boot</TextBlock>
</ui:IconButton.Content>
<ui:IconButton.Icon>
<iconPacks:PackIconMaterial Kind="Cogs" Height="30" />
</ui:IconButton.Icon>
</ui:IconButton>
<ui:IconButton HorizontalAlignment="Center" Height="50"
Margin="4,0"
Command="{Binding ForceSingleBootWrapper.Command}"
IsBusy="{Binding ForceSingleBootWrapper.IsExecuting}">
<ui:IconButton.Content>
<TextBlock TextWrapping="Wrap">Force Single Boot</TextBlock>
</ui:IconButton.Content>
<ui:IconButton.Icon>
<iconPacks:PackIconFontAwesome Kind="CogSolid" Height="30" />
</ui:IconButton.Icon>
</ui:IconButton>
</WrapPanel>
</Grid>
<ui:IconButton Command="{Binding ForceDualBootWrapper.Command}"
IsBusy="{Binding ForceDualBootWrapper.IsExecuting}">
<ui:IconButton.Content>
<TextBlock>Force Dual Boot</TextBlock>
</ui:IconButton.Content>
<ui:IconButton.Icon>
<iconPacks:PackIconMaterial Kind="Cogs" Height="30" />
</ui:IconButton.Icon>
</ui:IconButton>
<ui:IconButton Command="{Binding CollectLogsCommmandWrapper.Command}"
IsBusy="{Binding CollectLogsCommmandWrapper.IsExecuting}">
<ui:IconButton.Content>
<TextBlock TextWrapping="Wrap">Collect phone logs</TextBlock>
</ui:IconButton.Content>
<ui:IconButton.Icon>
<iconPacks:PackIconOcticons Kind="Package" Height="30" />
</ui:IconButton.Icon>
</ui:IconButton>
<ui:IconButton Command="{Binding ForceSingleBootWrapper.Command}"
IsBusy="{Binding ForceSingleBootWrapper.IsExecuting}">
<ui:IconButton.Content>
<TextBlock>Force Single Boot</TextBlock>
</ui:IconButton.Content>
<ui:IconButton.Icon>
<iconPacks:PackIconFontAwesome Kind="CogSolid" Height="30" />
</ui:IconButton.Icon>
</ui:IconButton>
</UniformGrid>
</GroupBox>
</StackPanel>
</UserControl>
1 change: 1 addition & 0 deletions Source/Deployer.Lumia.NetFx/ContainerConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ where type.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IDeploymentTask))
block.Export<PhoneModelInfoInfoReader>().As<IPhoneModelInfoReader>().Lifestyle.Singleton();
block.Export<Phone>().As<IPhone>().Lifestyle.Singleton();
block.Export<DismImageService>().As<IWindowsImageService>().Lifestyle.Singleton();
block.Export<LogCollector>().As<ILogCollector>().Lifestyle.Singleton();

return block;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.5.3")]
[assembly: AssemblyVersion("2.5.4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion Source/DeployerPlatform

0 comments on commit fdffc57

Please sign in to comment.