diff options
Diffstat (limited to 'Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs index 40548bd31..04fca66e1 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentLogStreamViewVM.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Windows; using Tango.AzureUtils.Environment; using Tango.AzureUtils.Logging; +using Tango.Core.Commands; using Tango.SharedUI.Components; namespace Tango.AzureUtils.UI.ViewModels @@ -27,7 +28,7 @@ namespace Tango.AzureUtils.UI.ViewModels public IWebAppBase SelectedDeploymentSlot { get { return _selectedDeploymentSlot; } - set { _selectedDeploymentSlot = value; RaisePropertyChangedAuto(); OnSelectedDeploymentSlotChanged(); } + set { _selectedDeploymentSlot = value; RaisePropertyChangedAuto(); } } private TextController _log; @@ -37,14 +38,32 @@ namespace Tango.AzureUtils.UI.ViewModels set { _log = value; RaisePropertyChangedAuto(); } } + private bool _isStarted; + public bool IsStarted + { + get { return _isStarted; } + set { _isStarted = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public RelayCommand StartCommand { get; set; } + + public RelayCommand StopCommand { get; set; } + + public RelayCommand ClearCommand { get; set; } + public EnvironmentLogStreamViewVM() { Log = new TextController(); + + StartCommand = new RelayCommand(Start,() => !IsStarted); + StopCommand = new RelayCommand(Stop, () => IsStarted); + ClearCommand = new RelayCommand(Clear); } public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps) { DeploymentSlots = apps.ToList(); + SelectedDeploymentSlot = DeploymentSlots.SingleOrDefault(x => x.Name.EndsWith("DEV")); _logStreamManager = new LogStreamManager(azure); _logStreamManager.ConfirmationRequired += ConfirmationHandler; @@ -57,11 +76,31 @@ namespace Tango.AzureUtils.UI.ViewModels Log.WriteLine(msg); } - private async void OnSelectedDeploymentSlotChanged() + private void Clear() + { + Log.Clear(); + } + + private void Stop() + { + IsStarted = false; + _logStreamManager.StopLogStreaming(); + } + + private async void Start() { if (SelectedDeploymentSlot != null && _logStreamManager != null) { - await _logStreamManager.StartLogStreamingAsync(SelectedDeploymentSlot); + try + { + IsStarted = true; + Log.Clear(); + await _logStreamManager.StartLogStreamingAsync(SelectedDeploymentSlot); + } + catch + { + IsStarted = false; + } } } } |
