From a6e6af346bf160b4a83163a6f1b268920cf2005c Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 7 Dec 2019 20:10:55 +0200 Subject: Implemented machine updates history on machine designer. Related Work Items: #1618 --- .../Tango.MachineStudio.MachineDesigner.csproj | 18 ++- .../ViewModels/MachineUpdateDetailsDialogVM.cs | 20 +++ .../ViewModels/MachineUpdatesViewVM.cs | 142 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 13 +- .../Views/MachineDetailsView.xaml | 3 + .../Views/MachineUpdateDetailsDialog.xaml | 85 ++++++++++++ .../Views/MachineUpdateDetailsDialog.xaml.cs | 28 ++++ .../Views/MachineUpdatesView.xaml | 98 ++++++++++++++ .../Views/MachineUpdatesView.xaml.cs | 28 ++++ 9 files changed, 433 insertions(+), 2 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index d80060831..6225bd7ad 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -89,6 +89,8 @@ + + @@ -97,6 +99,9 @@ HardwareConfigurationView.xaml + + MachineUpdateDetailsDialog.xaml + MachineCreationDialog.xaml @@ -122,6 +127,9 @@ MainView.xaml + + MachineUpdatesView.xaml + SpoolsView.xaml @@ -137,6 +145,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -169,6 +181,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -308,7 +324,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs new file mode 100644 index 000000000..49d410cdf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.ViewModels +{ + public class MachineUpdateDetailsDialogVM : DialogViewVM + { + private TangoUpdate _update; + public TangoUpdate Update + { + get { return _update; } + set { _update = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs new file mode 100644 index 000000000..7ff64c505 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.MachineDesigner.Views; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.ViewModels +{ + public class MachineUpdatesViewVM : ViewModel + { + private INotificationProvider _notification; + + #region Properties + + private Machine _machine; + public Machine Machine + { + get { return _machine; } + set { _machine = value; RaisePropertyChangedAuto(); } + } + + private List _updates; + public List Updates + { + get { return _updates; } + set { _updates = value; RaisePropertyChangedAuto(); } + } + + private ICollectionView _updatesView; + public ICollectionView UpdatesView + { + get { return _updatesView; } + set { _updatesView = value; RaisePropertyChangedAuto(); } + } + + + private TangoUpdate _selectedUpdate; + public TangoUpdate SelectedUpdate + { + get { return _selectedUpdate; } + set { _selectedUpdate = value; RaisePropertyChangedAuto(); OnSelectedUpdateChanged(); } + } + + private bool _displayMachineSetups; + public bool DisplayMachineSetups + { + get { return _displayMachineSetups; } + set { _displayMachineSetups = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private bool _displayApplicationUpdates; + public bool DisplayApplicationUpdates + { + get { return _displayApplicationUpdates; } + set { _displayApplicationUpdates = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private bool _displayDatabaseUpdates; + public bool DisplayDatabaseUpdates + { + get { return _displayDatabaseUpdates; } + set { _displayDatabaseUpdates = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + #endregion + + #region Constructors + + public MachineUpdatesViewVM() + { + DisplayApplicationUpdates = true; + DisplayMachineSetups = true; + DisplayDatabaseUpdates = true; + } + + public MachineUpdatesViewVM(INotificationProvider notificationProvider) : this() + { + _notification = notificationProvider; + } + + #endregion + + #region Public Methods + + public async Task Init(Machine machine, ObservablesContext context) + { + Machine = machine; + Updates = (await new TangoUpdatesCollectionBuilder(context).Set(x => x.MachineGuid == machine.Guid).BuildAsync()).OrderByDescending(x => x.StartDate).ToList(); + UpdatesView = CollectionViewSource.GetDefaultView(Updates); + UpdatesView.Filter = UpdatesFilter; + OnFilterChanged(); + } + + #endregion + + #region Private Methods + + private void OnFilterChanged() + { + if (UpdatesView != null) + { + UpdatesView.Refresh(); + } + } + + private bool UpdatesFilter(object obj) + { + TangoUpdate update = obj as TangoUpdate; + if (update != null) + { + if (!DisplayMachineSetups && update.IsSetup) return false; + if (!DisplayApplicationUpdates && update.IsUpdate) return false; + if (!DisplayDatabaseUpdates && update.IsDataBase) return false; + return true; + } + else + { + return false; + } + } + + private void OnSelectedUpdateChanged() + { + if (SelectedUpdate == null) return; + + var selectedUpdate = SelectedUpdate; + SelectedUpdate = null; + + _notification.ShowModalDialog(new MachineUpdateDetailsDialogVM() { Update = selectedUpdate }, (vm) => { }, () => { }); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 5fd086198..820950290 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -123,7 +123,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } private HardwareConfigurationViewVM _hardwareConfigurationViewVM; - public HardwareConfigurationViewVM HardwareConfigurationViewVM { get { return _hardwareConfigurationViewVM; } @@ -134,6 +133,13 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + private MachineUpdatesViewVM _machineUpdatesViewVM; + public MachineUpdatesViewVM MachineUpdatesViewVM + { + get { return _machineUpdatesViewVM; } + set { _machineUpdatesViewVM = value; RaisePropertyChangedAuto(); } + } + #endregion @@ -225,6 +231,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); CloneMachineCommand = new RelayCommand(CloneMachine, () => SelectedMachine != null); ResetDeviceRegistrationCommand = new RelayCommand(ResetDeviceRegistration); + + MachineUpdatesViewVM = new MachineUpdatesViewVM(_notification); } #endregion @@ -469,6 +477,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + await MachineUpdatesViewVM.Init(ActiveMachine, ActiveMachineAdapter.Context); + + ActiveMachine.Configuration.HardwareVersionChanged += Configuration_HardwareVersionChanged; View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml index 1f748fe9f..666a4ee4a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -61,6 +61,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml new file mode 100644 index 000000000..9d60d36f8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml.cs new file mode 100644 index 000000000..8bb051c51 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.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.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for MachineCreationDialog.xaml + /// + public partial class MachineUpdateDetailsDialog : UserControl + { + public MachineUpdateDetailsDialog() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml new file mode 100644 index 000000000..d9ea2cb44 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Machine Setups + Software Updates + Database Updates + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml.cs new file mode 100644 index 000000000..d13ef2d0e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.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.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for SpoolsView.xaml + /// + public partial class MachineUpdatesView : UserControl + { + public MachineUpdatesView() + { + InitializeComponent(); + } + } +} -- cgit v1.3.1