aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2019-12-22 11:24:00 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2019-12-22 11:24:00 +0200
commitd0ad477ecc3b4de354aee900e1b5335bc31ab103 (patch)
treef4cb8027da60e785b80b1817d494891a2802089a /Software/Visual_Studio/MachineStudio/Modules
parent2eaca7740df614d8fdef798410d2969a87d9d98c (diff)
downloadTango-d0ad477ecc3b4de354aee900e1b5335bc31ab103.tar.gz
Tango-d0ad477ecc3b4de354aee900e1b5335bc31ab103.zip
Working on ActionLogs module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs87
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml103
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs2
4 files changed, 191 insertions, 2 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs
index 48f243c1b..a550a1911 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs
@@ -1,18 +1,105 @@

using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Builders;
+using Tango.BL.Entities;
+using Tango.BL.Enumerations;
+using Tango.Core.Commands;
using Tango.MachineStudio.Common;
+using Tango.SharedUI.Components;
namespace Tango.MachineStudio.ActionLogs.ViewModels
{
public class MainViewVM : StudioViewModel
{
+ private DateTime _startSelectedDate;
+ public DateTime StartSelectedDate
+ {
+ get { return _startSelectedDate; }
+ set { _startSelectedDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _endSelectedDate;
+ public DateTime EndSelectedDate
+ {
+ get { return _endSelectedDate; }
+ set { _endSelectedDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ private string _searchFilter;
+ public string SearchFilter
+ {
+ get { return _searchFilter; }
+ set { _searchFilter = value; RaisePropertyChangedAuto(); }
+ }
+
+ private ObservableCollection<ActionLog> _actionLogs;
+ public ObservableCollection<ActionLog> ActionLogs
+ {
+ get { return _actionLogs; }
+ set { _actionLogs = value; RaisePropertyChanged(nameof(ActionLogs)); }
+ }
+
+ private SelectedObjectCollection<ActionLogType> _selectedActionLogTypes;
+ public SelectedObjectCollection<ActionLogType> SelectedActionLogTypes
+ {
+ get { return _selectedActionLogTypes; }
+ set { _selectedActionLogTypes = value; RaisePropertyChanged(nameof(SelectedActionLogTypes)); }
+ }
+
+ public RelayCommand SearchCommand { get; set; }
+ public RelayCommand CopyToClipBoardCommand { get; set; }
+
+ public MainViewVM()
+ {
+ ActionLogs = new ObservableCollection<ActionLog>();
+ SearchCommand = new RelayCommand(Search);
+ CopyToClipBoardCommand = new RelayCommand(CopyToClipBoard);
+ DateTime now = DateTime.Now; ;
+ StartSelectedDate = now.AddMonths(-1);
+ EndSelectedDate = now;
+
+ var source = Enum.GetValues(typeof(ActionLogType)).Cast<ActionLogType>().ToObservableCollection();
+ var syncedSource = Enum.GetValues(typeof(ActionLogType)).Cast<ActionLogType>().ToObservableCollection();
+
+ SelectedActionLogTypes = new SelectedObjectCollection<ActionLogType>(source, syncedSource);
+
+ //SelectedActionLogTypes.ToList().ForEach(x => x.IsSelected = true);
+ }
+
public override void OnApplicationReady()
{
}
+
+ private void Search()
+ {
+ GetActionLogs();
+ }
+ private void CopyToClipBoard()
+ {
+ }
+ private async void GetActionLogs()
+ {
+ string filter = SearchFilter?.ToLower();
+
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated < EndSelectedDate && x.LastUpdated >= StartSelectedDate)
+ .WithUsers()
+ .WithActionType(SelectedActionLogTypes.SynchedSource.ToArray())
+ .Query(y => y.Where
+ (x => filter == null ||
+ (x.ID.ToString().ToLower().StartsWith(filter)
+ || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter))
+ || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter)))))
+ .BuildAsync();
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml
index e6c200fbe..53db8c11d 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml
@@ -4,12 +4,113 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Tango.MachineStudio.ActionLogs.Views"
+ xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
xmlns:vm="clr-namespace:Tango.MachineStudio.ActionLogs.ViewModels"
xmlns:global="clr-namespace:Tango.MachineStudio.ActionLogs"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:localConverters="clr-namespace:Tango.MachineStudio.ActionLogs.Converters"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
+ <UserControl.Resources>
+
+ <sharedConverters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
+ <localConverters:ActionLogTypesToStringConverter x:Key="ActionLogTypesToStringConverter"/>
+ </UserControl.Resources>
<Grid IsEnabled="{Binding IsFree}">
- <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="70">Action Logs</TextBlock>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="300"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+ <TextBlock Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="70"></TextBlock>
+ <Grid Grid.Row="1" Margin="20 0 10 20">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="60"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width ="6*"/>
+ <ColumnDefinition Width ="4*"/>
+ </Grid.ColumnDefinitions >
+
+ <DockPanel x:Name ="SearchButtons" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch">
+ <StackPanel DockPanel.Dock="Left">
+ <TextBlock FontSize="10">Start Date:</TextBlock>
+ <DatePicker x:Name="startdatePicker" SelectedDate="{Binding StartSelectedDate}" materialDesign:HintAssist.Hint="Pick start date" Width="160" VerticalAlignment="Center" FontSize="16" />
+ </StackPanel>
+ <StackPanel DockPanel.Dock="Left" Margin="40 0 0 0">
+ <TextBlock FontSize="10">End Date:</TextBlock>
+ <DatePicker x:Name="endDatePicker" SelectedDate="{Binding EndSelectedDate}" materialDesign:HintAssist.Hint="Pick end date" Width="160" VerticalAlignment="Center" FontSize="16"/>
+ </StackPanel>
+ <DockPanel DockPanel.Dock="Left" Margin="50 0 0 0" >
+ <TextBlock DockPanel.Dock="Top" Text="Action Log Type:" VerticalAlignment="Center" FontSize="10"></TextBlock>
+ <ToggleButton Width="200" Margin="0 5 0 0">
+ <ToggleButton.Template>
+ <ControlTemplate>
+ <Grid>
+ <Border CornerRadius="3" BorderBrush="{StaticResource BorderBrushGainsboro}" BorderThickness="1">
+ <DockPanel>
+ <materialDesign:PackIcon Width="16" Height="16" DockPanel.Dock="Right" Kind="ChevronDown" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" />
+ <TextBlock>Select Actions</TextBlock>
+ </DockPanel>
+ </Border>
+ <Popup IsOpen="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=IsChecked}">
+ <Border Padding="5">
+ <ItemsControl ItemsSource="{Binding SelectedActionLogTypes}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <DockPanel Margin="2">
+ <CheckBox VerticalAlignment="Center" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}" />
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data,Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock>
+ </DockPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </Border>
+ </Popup>
+ </Grid>
+ </ControlTemplate>
+ </ToggleButton.Template>
+ </ToggleButton>
+ </DockPanel>
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="50 0 0 0">
+ <materialDesign:PackIcon Kind="Magnify" Width="26" Height="26"/>
+ <TextBox Width="210" materialDesign:HintAssist.Hint="Search by ID, user, related object name" Text="{Binding SearchFilter,UpdateSourceTrigger=PropertyChanged}" />
+ </StackPanel>
+ <Button Width="120" Padding="5" HorizontalAlignment="Right" DockPanel.Dock="Right" Command="{Binding SearchCommand}">Search</Button>
+ </DockPanel>
+
+ <Grid IsEnabled="{Binding IsFree}" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch">
+ <DataGrid Margin="0 0 0 10" SelectionMode="Single" SelectionUnit="FullRow"
+ BorderBrush="{StaticResource borderBrush}" IsReadOnly="True" BorderThickness="1"
+ Background="{StaticResource TransparentBackgroundBrush}"
+ AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False"
+ CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding ActionLogs}"
+ SelectedItem="{Binding SelectedActionLog}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
+ <DataGrid.CellStyle>
+ <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
+ <Setter Property="BorderThickness" Value="0"/>
+ <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
+ <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+ </Style>
+ </DataGrid.CellStyle>
+
+ <DataGrid.Columns>
+ <DataGridTextColumn Header="ID" Binding="{Binding ID}" Width="Auto" />
+ <DataGridTextColumn Header="ACTION" Binding="{Binding Type, Converter={StaticResource EnumToDescriptionConverter}}" Width="Auto" MinWidth="100"/>
+ <DataGridTextColumn Header="USER" Binding="{Binding UserGuid}" Width="Auto" MinWidth="100"/>
+ <DataGridTextColumn Header="RELATED OBJECT NAME" Binding="{Binding RelatedObjectName}" Width="Auto" />
+ <DataGridTextColumn Header="GUID" Binding="{Binding RelatedObjectGuid}" Width="Auto" />
+ <DataGridTextColumn Header="MESSAGE" Binding="{Binding Message}" Width="Auto" />
+ </DataGrid.Columns>
+ </DataGrid>
+ </Grid>
+ <DockPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch">
+ <Button Width="Auto" Padding="5" HorizontalAlignment="Right" DockPanel.Dock="Right" Command="{Binding SearchCommand}">COPY TO CLIPBOARD</Button>
+ </DockPanel>
+ <Grid Grid.Row="1" Grid.Column="1" Margin="20 0 10 20" IsEnabled="{Binding IsFree}" HorizontalAlignment="Stretch" >
+ </Grid>
+
+ </Grid>
</Grid>
</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml.cs
index e87e3e55a..76ab27d30 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml.cs
@@ -24,5 +24,6 @@ namespace Tango.MachineStudio.ActionLogs.Views
{
InitializeComponent();
}
+
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs
index ae763167b..507dbdd6a 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs
@@ -322,7 +322,7 @@ namespace Tango.MachineStudio.Catalogs.ViewModels
await _activeCatalogContext.SaveChangesAsync();
var activeCatalogDTO = ColorCatalogDTO.FromObservable(ActiveCatalog);
- _actionLogManager.InsertLog(ActionLogType.CatalogSaved, _authentication.CurrentUser, ActiveCatalog.Name, _catalogBeforeSave, activeCatalogDTO, "Catalog created using Machine Studio.");
+ _actionLogManager.InsertLog(ActionLogType.CatalogSaved, _authentication.CurrentUser, ActiveCatalog.Name, _catalogBeforeSave, activeCatalogDTO, "Catalog saved using Machine Studio.");
_catalogBeforeSave = activeCatalogDTO;
await LoadCatalogs();