diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-09 00:15:09 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-09 00:15:09 +0200 |
| commit | c9597d3b4a053b7a1246419cb31517dd9f530543 (patch) | |
| tree | 0ff985015cc4c6a6bf0b5bdefa6ff9726d5de422 /Software/Visual_Studio/Azure/Tango.AzureUtils.UI | |
| parent | af1c7bd1b6122c1387fe6e2749f9847f4be84b16 (diff) | |
| download | Tango-c9597d3b4a053b7a1246419cb31517dd9f530543.tar.gz Tango-c9597d3b4a053b7a1246419cb31517dd9f530543.zip | |
Working on azure utils...
Fixed issue with TangoWebApplication logging.
Diffstat (limited to 'Software/Visual_Studio/Azure/Tango.AzureUtils.UI')
18 files changed, 674 insertions, 26 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/AzureDashboardViewModel.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/AzureDashboardViewModel.cs index 80431db3b..3c6a95ebf 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/AzureDashboardViewModel.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/AzureDashboardViewModel.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using Tango.AzureUtils.UI.Managers; using Tango.Core.DI; using Tango.SharedUI; @@ -25,5 +26,22 @@ namespace Tango.AzureUtils.UI { } + + protected void ConfirmationHandler(object sender, AzureUtilsConfirmationEventArgs e) + { + if (MessageBox.Show(e.Message, "Confirmation Required", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK) + { + e.Confirm(); + } + else + { + e.Cancel(); + } + } + + public void ProgressHandler(object sender, AzureUtilsProgressEventArgs e) + { + StatusManager.UpdateStatus(e); + } } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml index 54293c7d8..5adec916a 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml @@ -52,6 +52,15 @@ <TextBlock FontWeight="SemiBold">TANGO_VERSIONS_CONTAINER:</TextBlock> <TextBlock Text="{Binding ElementName=control,Path=Settings.TANGO_VERSIONS_CONTAINER}"></TextBlock> + + <TextBlock FontWeight="SemiBold">Machine Studio Version:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=MachineStudioVersion.Version}"></TextBlock> + + <TextBlock FontWeight="SemiBold">Tango Application Version:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=TangoVersion.Version}"></TextBlock> + + <TextBlock FontWeight="SemiBold">Tango Firmware Version::</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=TangoVersion.FirmwareVersion}"></TextBlock> </controls:TableGrid> </StackPanel> </Grid> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs index f046546f7..f71f236c7 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs @@ -13,6 +13,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.AzureUtils.Database; +using Tango.BL.Entities; namespace Tango.AzureUtils.UI.Controls { @@ -37,6 +39,22 @@ namespace Tango.AzureUtils.UI.Controls public static readonly DependencyProperty HostNamesProperty = DependencyProperty.Register("HostNames", typeof(List<String>), typeof(WebAppPropertiesControl), new PropertyMetadata(null)); + public TangoVersion TangoVersion + { + get { return (TangoVersion)GetValue(TangoVersionProperty); } + set { SetValue(TangoVersionProperty, value); } + } + public static readonly DependencyProperty TangoVersionProperty = + DependencyProperty.Register("TangoVersion", typeof(TangoVersion), typeof(WebAppPropertiesControl), new PropertyMetadata(null)); + + public MachineStudioVersion MachineStudioVersion + { + get { return (MachineStudioVersion)GetValue(MachineStudioVersionProperty); } + set { SetValue(MachineStudioVersionProperty, value); } + } + public static readonly DependencyProperty MachineStudioVersionProperty = + DependencyProperty.Register("MachineStudioVersion", typeof(MachineStudioVersion), typeof(WebAppPropertiesControl), new PropertyMetadata(null)); + public WebAppPropertiesControl() { @@ -56,6 +74,11 @@ namespace Tango.AzureUtils.UI.Controls HostNames = app.HostNames.Select(x => x).ToList(); Settings = await app.GetMachineServiceSettingsAsync(false); + + var azure = await AzureUtilsAuthenticationFactory.AuthenticateOrGetAsync(); + var databaseManager = new DatabaseManager(azure); + TangoVersion = await databaseManager.GetLatestPPCVersion(app); + MachineStudioVersion = await databaseManager.GetLatestMachineStudioVersion(app); } catch { } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Managers/DefaultStatusManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Managers/DefaultStatusManager.cs index 59c2cdc40..712c6507b 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Managers/DefaultStatusManager.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Managers/DefaultStatusManager.cs @@ -4,10 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; +using Tango.Core; namespace Tango.AzureUtils.UI.Managers { - public class DefaultStatusManager : IStatusManager + public class DefaultStatusManager : ExtendedObject, IStatusManager { public event EventHandler<AzureUtilsProgressEventArgs> StatusUpdated; @@ -25,16 +26,19 @@ namespace Tango.AzureUtils.UI.Managers public void UpdateStatus(AzureUtilsProgressEventArgs progress) { - if (progress.IsIndeterminate || (progress.Maximum == 0 && progress.Progress == 0)) + InvokeUI(() => { - Mouse.OverrideCursor = Cursors.Wait; - } - else - { - Mouse.OverrideCursor = null; - } + if (progress.IsIndeterminate || (progress.Progress > 0 && progress.Progress != progress.Maximum)) + { + Mouse.OverrideCursor = Cursors.Wait; + } + else + { + Mouse.OverrideCursor = null; + } - StatusUpdated?.Invoke(this, progress); + StatusUpdated?.Invoke(this, progress); + }); } public void UpdateStatus(Exception ex) diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj index 6812a5695..8f0546bfa 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Tango.AzureUtils.UI.csproj @@ -203,11 +203,23 @@ <Compile Include="Managers\IStatusManager.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\EnvironmentCreationViewVM.cs" /> + <Compile Include="ViewModels\EnvironmentLogStreamViewVM.cs" /> + <Compile Include="ViewModels\EnvironmentRemovalViewVM.cs" /> <Compile Include="ViewModels\EnvironmentUpgradeViewVM.cs" /> + <Compile Include="ViewModels\EnvironmentFirmwareUpgradeViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="Views\EnvironmentCreationView.xaml.cs"> <DependentUpon>EnvironmentCreationView.xaml</DependentUpon> </Compile> + <Compile Include="Views\EnvironmentLogStreamView.xaml.cs"> + <DependentUpon>EnvironmentLogStreamView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\EnvironmentFirmwareUpgradeView.xaml.cs"> + <DependentUpon>EnvironmentFirmwareUpgradeView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\EnvironmentRemovalView.xaml.cs"> + <DependentUpon>EnvironmentRemovalView.xaml</DependentUpon> + </Compile> <Compile Include="Views\EnvironmentUpgradeView.xaml.cs"> <DependentUpon>EnvironmentUpgradeView.xaml</DependentUpon> </Compile> @@ -242,6 +254,18 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\EnvironmentLogStreamView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\EnvironmentFirmwareUpgradeView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\EnvironmentRemovalView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\EnvironmentUpgradeView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -279,6 +303,10 @@ <None Include="App.config" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj"> + <Project>{F441FEEE-322A-4943-B566-110E12FD3B72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModelLocator.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModelLocator.cs index 196848e95..4fd7293c9 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModelLocator.cs @@ -21,6 +21,9 @@ namespace Tango.AzureUtils.UI TangoIOC.Default.Register<MainViewVM>(); TangoIOC.Default.Register<EnvironmentUpgradeViewVM>(); TangoIOC.Default.Register<EnvironmentCreationViewVM>(); + TangoIOC.Default.Register<EnvironmentRemovalViewVM>(); + TangoIOC.Default.Register<EnvironmentFirmwareUpgradeViewVM>(); + TangoIOC.Default.Register<EnvironmentLogStreamViewVM>(); TangoIOC.Default.Register<IStatusManager, DefaultStatusManager>(); } @@ -49,5 +52,29 @@ namespace Tango.AzureUtils.UI return TangoIOC.Default.GetInstance<EnvironmentCreationViewVM>(); } } + + public static EnvironmentRemovalViewVM EnvironmentRemovalViewVM + { + get + { + return TangoIOC.Default.GetInstance<EnvironmentRemovalViewVM>(); + } + } + + public static EnvironmentFirmwareUpgradeViewVM EnvironmentFirmwareUpgradeViewVM + { + get + { + return TangoIOC.Default.GetInstance<EnvironmentFirmwareUpgradeViewVM>(); + } + } + + public static EnvironmentLogStreamViewVM EnvironmentLogStreamViewVM + { + get + { + return TangoIOC.Default.GetInstance<EnvironmentLogStreamViewVM>(); + } + } } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs index d51cfb3bd..163565699 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentCreationViewVM.cs @@ -87,20 +87,8 @@ namespace Tango.AzureUtils.UI.ViewModels SelectedDeploymentSlot = DeploymentSlots.FirstOrDefault(); _environmentManager = new EnvironmentManager(azure); - _environmentManager.ConfirmationRequired += _environmentManager_ConfirmationRequired; - _environmentManager.Progress += (x, e) => StatusManager.UpdateStatus(e); - } - - private void _environmentManager_ConfirmationRequired(object sender, AzureUtilsConfirmationEventArgs e) - { - if (MessageBox.Show(e.Message, "Confirmation Required", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK) - { - e.Confirm(); - } - else - { - e.Cancel(); - } + _environmentManager.ConfirmationRequired += ConfirmationHandler; + _environmentManager.Progress += ProgressHandler; } private async void CreateEnvironment() diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs new file mode 100644 index 000000000..54576cda7 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentFirmwareUpgradeViewVM.cs @@ -0,0 +1,112 @@ +using Microsoft.Azure.Management.AppService.Fluent; +using Microsoft.Azure.Management.Fluent; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.AzureUtils.Environment; +using Tango.AzureUtils.Firmware; +using Tango.Core.Commands; + +namespace Tango.AzureUtils.UI.ViewModels +{ + public class EnvironmentFirmwareUpgradeViewVM : AzureDashboardViewModel + { + private FirmwareManager _firmwareManager; + + private List<IWebAppBase> _deploymentSlots; + public List<IWebAppBase> DeploymentSlots + { + get { return _deploymentSlots; } + set { _deploymentSlots = value; RaisePropertyChangedAuto(); } + } + + private IWebAppBase _selectedDeploymentSlot; + public IWebAppBase SelectedDeploymentSlot + { + get { return _selectedDeploymentSlot; } + set { _selectedDeploymentSlot = value; RaisePropertyChangedAuto(); } + } + + private String _filePath; + public String FilePath + { + get { return _filePath; } + set { _filePath = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private String _firmwareVersion; + public String FirmwareVersion + { + get { return _firmwareVersion; } + set { _firmwareVersion = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand UpgradeFirmwareCommand { get; set; } + public RelayCommand BrowseFileCommand { get; set; } + + public EnvironmentFirmwareUpgradeViewVM() + { + UpgradeFirmwareCommand = new RelayCommand(UpgradeFirmware,() => FilePath != null); + BrowseFileCommand = new RelayCommand(BrowseFile); + } + + public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps) + { + DeploymentSlots = apps.Where(x => x.Name.Contains("MachineService")).ToList(); + SelectedDeploymentSlot = DeploymentSlots.FirstOrDefault(x => x.Name.EndsWith("DEV")); + + _firmwareManager = new FirmwareManager(azure); + _firmwareManager.ConfirmationRequired += ConfirmationHandler; + _firmwareManager.Progress += ProgressHandler; + } + + private async void BrowseFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select Tango Firmware Package"; + dlg.Filter = "Tango Firmware Package Files|*.tfp"; + if (dlg.ShowDialog().Value) + { + FilePath = dlg.FileName; + try + { + FirmwareVersion = await _firmwareManager.GetFirmwareVersion(FilePath); + } + catch (Exception ex) + { + FilePath = null; + StatusManager.UpdateStatus(ex); + } + } + } + + private async void UpgradeFirmware() + { + try + { + if (!Validate()) return; + + IsFree = false; + + await _firmwareManager.InjectFirmwarePackage(SelectedDeploymentSlot, FilePath); + + var old = SelectedDeploymentSlot; + SelectedDeploymentSlot = null; + SelectedDeploymentSlot = old; + } + catch (Exception ex) + { + StatusManager.UpdateStatus(ex); + } + finally + { + IsFree = true; + } + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs new file mode 100644 index 000000000..40548bd31 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs @@ -0,0 +1,68 @@ +using Microsoft.Azure.Management.AppService.Fluent; +using Microsoft.Azure.Management.Fluent; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.AzureUtils.Environment; +using Tango.AzureUtils.Logging; +using Tango.SharedUI.Components; + +namespace Tango.AzureUtils.UI.ViewModels +{ + public class EnvironmentLogStreamViewVM : AzureDashboardViewModel + { + private LogStreamManager _logStreamManager; + + private List<IWebAppBase> _deploymentSlots; + public List<IWebAppBase> DeploymentSlots + { + get { return _deploymentSlots; } + set { _deploymentSlots = value; RaisePropertyChangedAuto(); } + } + + private IWebAppBase _selectedDeploymentSlot; + public IWebAppBase SelectedDeploymentSlot + { + get { return _selectedDeploymentSlot; } + set { _selectedDeploymentSlot = value; RaisePropertyChangedAuto(); OnSelectedDeploymentSlotChanged(); } + } + + private TextController _log; + public TextController Log + { + get { return _log; } + set { _log = value; RaisePropertyChangedAuto(); } + } + + public EnvironmentLogStreamViewVM() + { + Log = new TextController(); + } + + public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps) + { + DeploymentSlots = apps.ToList(); + + _logStreamManager = new LogStreamManager(azure); + _logStreamManager.ConfirmationRequired += ConfirmationHandler; + _logStreamManager.Progress += ProgressHandler; + _logStreamManager.LogAvailable += _logStreamManager_LogAvailable; + } + + private void _logStreamManager_LogAvailable(object sender, string msg) + { + Log.WriteLine(msg); + } + + private async void OnSelectedDeploymentSlotChanged() + { + if (SelectedDeploymentSlot != null && _logStreamManager != null) + { + await _logStreamManager.StartLogStreamingAsync(SelectedDeploymentSlot); + } + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentRemovalViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentRemovalViewVM.cs new file mode 100644 index 000000000..e8d966158 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentRemovalViewVM.cs @@ -0,0 +1,116 @@ +using Microsoft.Azure.Management.AppService.Fluent; +using Microsoft.Azure.Management.Fluent; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.AzureUtils.Environment; +using Tango.Core.Commands; + +namespace Tango.AzureUtils.UI.ViewModels +{ + public class EnvironmentRemovalViewVM : AzureDashboardViewModel + { + private IWebAppBase _machineServiceApp; + private EnvironmentManager _environmentManager; + + private List<IDeploymentSlot> _deploymentSlots; + public List<IDeploymentSlot> DeploymentSlots + { + get { return _deploymentSlots; } + set { _deploymentSlots = value; RaisePropertyChangedAuto(); } + } + + private IDeploymentSlot _selectedDeploymentSlot; + public IDeploymentSlot SelectedDeploymentSlot + { + get { return _selectedDeploymentSlot; } + set { _selectedDeploymentSlot = value; RaisePropertyChangedAuto(); } + } + + private String _slotName; + [Required(ErrorMessage = "Deployment slot name confirmation is required.")] + public String SlotName + { + get { return _slotName; } + set { _slotName = value; RaisePropertyChangedAuto(); } + } + + private String _email; + [Required(ErrorMessage = "Active directory email is required.")] + [EmailAddress(ErrorMessage = "Please enter a valid email.")] + public String Email + { + get { return _email; } + set { _email = value; RaisePropertyChangedAuto(); } + } + + private String _password; + [Required(ErrorMessage = "Password is required.")] + public String Password + { + get { return _password; } + set { _password = value; RaisePropertyChangedAuto(); } + } + + private RemoveEnvironmentConfiguration _config; + public RemoveEnvironmentConfiguration Config + { + get { return _config; } + set { _config = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand RemoveEnvironmentCommand { get; set; } + + public EnvironmentRemovalViewVM() + { + RemoveEnvironmentCommand = new RelayCommand(RemoveEnvironment); + Config = new RemoveEnvironmentConfiguration(); + } + + public override void OnApplicationReady() + { + Email = "roy@twine-s.com"; + Password = "1Creativity"; + } + + public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps) + { + _machineServiceApp = apps.SingleOrDefault(x => x.Name == "MachineService"); + DeploymentSlots = apps.OfType<IDeploymentSlot>().Where(x => x.Parent == _machineServiceApp).ToList(); + SelectedDeploymentSlot = DeploymentSlots.FirstOrDefault(); + + _environmentManager = new EnvironmentManager(azure); + _environmentManager.ConfirmationRequired += ConfirmationHandler; + _environmentManager.Progress += ProgressHandler; + } + + private async void RemoveEnvironment() + { + try + { + if (!Validate()) return; + + IsFree = false; + + Config.Email = Email; + Config.Password = Password; + + await _environmentManager.RemoveEnvironment(SelectedDeploymentSlot, SlotName, Config); + + SelectedDeploymentSlot = null; + } + catch (Exception ex) + { + StatusManager.UpdateStatus(ex); + } + finally + { + IsFree = true; + } + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs index 695ef9d4f..14e4bf196 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs @@ -76,7 +76,8 @@ namespace Tango.AzureUtils.UI.ViewModels SelectedTargetApp = Apps.FirstOrDefault(); EnvironmentManager = new EnvironmentManager(azure); - EnvironmentManager.Progress += (x, e) => StatusManager.UpdateStatus(e); + _environmentManager.ConfirmationRequired += ConfirmationHandler; + _environmentManager.Progress += ProgressHandler; } private async void ValidateUpgrade() @@ -111,6 +112,13 @@ namespace Tango.AzureUtils.UI.ViewModels { IsFree = false; await EnvironmentManager.UpgradeEnvironment(SelectedSourceApp, SelectedTargetApp, Config); + + var oldSource = SelectedSourceApp; + var oldTarget = SelectedTargetApp; + SelectedSourceApp = null; + SelectedTargetApp = null; + SelectedSourceApp = oldSource; + SelectedTargetApp = oldTarget; } catch (Exception ex) { diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml new file mode 100644 index 000000000..9d122ab06 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml @@ -0,0 +1,53 @@ +<UserControl x:Class="Tango.AzureUtils.UI.Views.EnvironmentFirmwareUpgradeView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.AzureUtils.UI.ViewModels" + xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.AzureUtils.UI" + xmlns:localControls="clr-namespace:Tango.AzureUtils.UI.Controls" + xmlns:local="clr-namespace:Tango.AzureUtils.UI.Views" + mc:Ignorable="d" + d:DesignHeight="700" + d:DesignWidth="1100" + d:DataContext="{d:DesignInstance Type=vm:EnvironmentFirmwareUpgradeViewVM, IsDesignTimeCreatable=False}" + DataContext="{x:Static global:ViewModelLocator.EnvironmentFirmwareUpgradeViewVM}" + Background="{StaticResource PrimaryBackgroundBrush}" + Foreground="{StaticResource PrimaryForegroundBrush}"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="50*"/> + <ColumnDefinition Width="60*"/> + </Grid.ColumnDefinitions> + + <GroupBox Header="Source Deployment Slot" Padding="5" Margin="10"> + <DockPanel> + <ComboBox DockPanel.Dock="Top" ItemsSource="{Binding DeploymentSlots}" SelectedItem="{Binding SelectedDeploymentSlot}" DisplayMemberPath="Name"></ComboBox> + + <localControls:WebAppPropertiesControl VerticalAlignment="Top" Margin="0 20 0 0" DataContext="{Binding SelectedDeploymentSlot}" /> + </DockPanel> + </GroupBox> + + <Grid Grid.Column="1"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="300"> + <GroupBox Header="Firmware Package Selection" Padding="30" Width="500"> + <StackPanel> + <TextBlock>Browse for .tfp file and press upgrade.</TextBlock> + <DockPanel Margin="0 10 0 0"> + <Button Command="{Binding BrowseFileCommand}" Padding="10 0" Margin="5 0 0 0" DockPanel.Dock="Right">Browse</Button> + <TextBox Text="{Binding FilePath}" VerticalAlignment="Center" IsReadOnly="True" /> + </DockPanel> + </StackPanel> + </GroupBox> + + <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" FontSize="14" FontWeight="SemiBold"> + <Run>Selected Firmware Version:</Run> + <Run Text="{Binding FirmwareVersion,TargetNullValue='N/A',FallbackValue='N/A'}"></Run> + </TextBlock> + + <Button Padding="20" Margin="0 80 0 0" MaxWidth="300" Command="{Binding UpgradeFirmwareCommand}">UPGRADE FIRMWARE</Button> + </StackPanel> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml.cs new file mode 100644 index 000000000..ed2d4c56f --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentFirmwareUpgradeView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.AzureUtils.UI.Views +{ + /// <summary> + /// Interaction logic for EnvironmentRemovalView.xaml + /// </summary> + public partial class EnvironmentFirmwareUpgradeView : UserControl + { + public EnvironmentFirmwareUpgradeView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentLogStreamView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentLogStreamView.xaml new file mode 100644 index 000000000..168e0b546 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentLogStreamView.xaml @@ -0,0 +1,39 @@ +<UserControl x:Class="Tango.AzureUtils.UI.Views.EnvironmentLogStreamView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.AzureUtils.UI.ViewModels" + xmlns:components="clr-namespace:Tango.SharedUI.Components;assembly=Tango.SharedUI" + xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.AzureUtils.UI" + xmlns:localControls="clr-namespace:Tango.AzureUtils.UI.Controls" + xmlns:local="clr-namespace:Tango.AzureUtils.UI.Views" + mc:Ignorable="d" + d:DesignHeight="700" + d:DesignWidth="1100" + d:DataContext="{d:DesignInstance Type=vm:EnvironmentLogStreamViewVM, IsDesignTimeCreatable=False}" + DataContext="{x:Static global:ViewModelLocator.EnvironmentLogStreamViewVM}" + Background="{StaticResource PrimaryBackgroundBrush}" + Foreground="{StaticResource PrimaryForegroundBrush}"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="50*"/> + <ColumnDefinition Width="60*"/> + </Grid.ColumnDefinitions> + + <GroupBox Header="Source Deployment Slot" Padding="5" Margin="10"> + <DockPanel> + <ComboBox DockPanel.Dock="Top" ItemsSource="{Binding DeploymentSlots}" SelectedItem="{Binding SelectedDeploymentSlot}" DisplayMemberPath="Name"></ComboBox> + + <localControls:WebAppPropertiesControl VerticalAlignment="Top" Margin="0 20 0 0" DataContext="{Binding SelectedDeploymentSlot}" /> + </DockPanel> + </GroupBox> + + <Grid Grid.Column="1"> + <GroupBox Header="Logs" Margin="10" Padding="10"> + <TextBox components:TextController.Controller="{Binding Log}" AcceptsReturn="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" IsReadOnlyCaretVisible="True" BorderThickness="0"></TextBox> + </GroupBox> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentLogStreamView.xaml.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentLogStreamView.xaml.cs new file mode 100644 index 000000000..77918c796 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentLogStreamView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.AzureUtils.UI.Views +{ + /// <summary> + /// Interaction logic for EnvironmentRemovalView.xaml + /// </summary> + public partial class EnvironmentLogStreamView : UserControl + { + public EnvironmentLogStreamView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentRemovalView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentRemovalView.xaml new file mode 100644 index 000000000..2175aaaf3 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentRemovalView.xaml @@ -0,0 +1,62 @@ +<UserControl x:Class="Tango.AzureUtils.UI.Views.EnvironmentRemovalView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.AzureUtils.UI.ViewModels" + xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.AzureUtils.UI" + xmlns:localControls="clr-namespace:Tango.AzureUtils.UI.Controls" + xmlns:local="clr-namespace:Tango.AzureUtils.UI.Views" + mc:Ignorable="d" + d:DesignHeight="700" + d:DesignWidth="1100" + d:DataContext="{d:DesignInstance Type=vm:EnvironmentRemovalViewVM, IsDesignTimeCreatable=False}" + DataContext="{x:Static global:ViewModelLocator.EnvironmentRemovalViewVM}" + Background="{StaticResource PrimaryBackgroundBrush}" + Foreground="{StaticResource PrimaryForegroundBrush}"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="50*"/> + <ColumnDefinition Width="60*"/> + </Grid.ColumnDefinitions> + + <GroupBox Header="Source Deployment Slot" Padding="5" Margin="10"> + <DockPanel> + <ComboBox DockPanel.Dock="Top" ItemsSource="{Binding DeploymentSlots}" SelectedItem="{Binding SelectedDeploymentSlot}" DisplayMemberPath="Name"></ComboBox> + + <localControls:WebAppPropertiesControl VerticalAlignment="Top" Margin="0 20 0 0" DataContext="{Binding SelectedDeploymentSlot}" /> + </DockPanel> + </GroupBox> + + <Grid Grid.Column="1"> + <DockPanel> + <GroupBox DockPanel.Dock="Top" HorizontalAlignment="Left" Margin="50 10 10 10" Header="Removal Configuration" Padding="10 10 100 10"> + <StackPanel> + <CheckBox IsChecked="{Binding Config.RemoveEnvironmentGroup}" >Remove Environment Group</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.RemoveDeploymentSlot}" >Remove Deployment Slot</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.RemoveStorageContainers}" >Remove Storage Containers</CheckBox> + <CheckBox Margin="0 5 0 0" IsChecked="{Binding Config.RemoveDatabase}" >Remove Database</CheckBox> + </StackPanel> + </GroupBox> + + <StackPanel> + <GroupBox HorizontalAlignment="Left" Margin="50 10 10 10" Header="Environment Credentials" Padding="10 10 90 10"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="300"> + <TextBlock FontSize="10">Environment Name (e.g DEV)</TextBlock> + <TextBox Margin="0 2 0 0" Text="{Binding SlotName}"></TextBox> + + <TextBlock FontSize="10" Margin="0 10 0 0">Active Directory Administrator Email</TextBlock> + <TextBox Margin="0 2 0 0" Text="{Binding Email}"></TextBox> + + <TextBlock Margin="0 10 0 0" FontSize="10">Password</TextBlock> + <PasswordBox Margin="0 2 0 0" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding Password,Mode=TwoWay}"></PasswordBox> + </StackPanel> + </GroupBox> + + <Button HorizontalAlignment="Left" Width="410" Margin="50 20 0 0" Padding="20" Command="{Binding RemoveEnvironmentCommand}">REMOVE ENVIRONMENT</Button> + </StackPanel> + </DockPanel> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentRemovalView.xaml.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentRemovalView.xaml.cs new file mode 100644 index 000000000..f5abf0b66 --- /dev/null +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentRemovalView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.AzureUtils.UI.Views +{ + /// <summary> + /// Interaction logic for EnvironmentRemovalView.xaml + /// </summary> + public partial class EnvironmentRemovalView : UserControl + { + public EnvironmentRemovalView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml index 11749207e..40d431be1 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/MainView.xaml @@ -28,12 +28,21 @@ <Grid Grid.Row="1" IsEnabled="{Binding IsInitialized}"> <TabControl Margin="10"> - <TabItem Header="Environment Upgrade Dashboard" Padding="5"> + <TabItem Header="Environment Upgrade" Padding="5"> <views:EnvironmentUpgradeView/> </TabItem> - <TabItem Header="Environment Creation Wizard" Padding="5"> + <TabItem Header="Environment Creation" Padding="5"> <views:EnvironmentCreationView/> </TabItem> + <TabItem Header="Environment Removal" Padding="5"> + <views:EnvironmentRemovalView/> + </TabItem> + <TabItem Header="Environment Firmware Injection" Padding="5"> + <views:EnvironmentFirmwareUpgradeView/> + </TabItem> + <TabItem Header="Environment Log Stream" Padding="5"> + <views:EnvironmentLogStreamView/> + </TabItem> </TabControl> </Grid> |
