From ecf55f4193c0a7ab273c7e8243e446a2f2c32d51 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 16 Dec 2018 08:22:45 +0200 Subject: Working on PPC tech mode & logging module. Working on PPC date picker & calendar. Implemented no-permissions view. --- .../PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | 2 ++ .../PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs | 18 ++++++++++--- .../Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs | 30 ++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 281e54958..516349a18 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -20,6 +20,7 @@ using Tango.PPC.Common.Notifications.NotificationItems; using Tango.PPC.Jobs; using Tango.SharedUI; using System.Data.Entity; +using Tango.BL.Enumerations; namespace Tango.PPC.UI.ViewModels { @@ -79,6 +80,7 @@ namespace Tango.PPC.UI.ViewModels if (db.Users.Count() == 1 || machine.AutoLogin) { var user = await db.Users.FirstAsync(); + LogManager.Log($"Application started. Single user/Auto login detected ({user.Email}). Skipping LoginView..."); await AuthenticationProvider.Login(user.Email, user.Password, false); IsLoading = false; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs index 9d17a4a76..aa9689ef3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs @@ -11,6 +11,8 @@ using System.ComponentModel.DataAnnotations; using Tango.SharedUI.Helpers; using Tango.PPC.Common.Authentication; using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Logging; namespace Tango.PPC.UI.ViewModels { @@ -89,9 +91,19 @@ namespace Tango.PPC.UI.ViewModels base.OnApplicationReady(); await Task.Delay(500); - LogManager.Log("Application is ready! Navigating to home module..."); - await NavigationManager.NavigateTo(NavigationView.HomeModule); - IsLoading = false; + + if (AuthenticationProvider.CurrentUser != null && AuthenticationProvider.CurrentUser.HasPermission(Permissions.RunPPC)) + { + LogManager.Log("Application is ready! Navigating to home module..."); + await NavigationManager.NavigateTo(NavigationView.HomeModule); + IsLoading = false; + } + else + { + LogManager.Log("Application is ready! The logged in user does not have permission to run the application!", LogCategory.Warning); + await NavigationManager.NavigateTo(NavigationView.NoPermissionsView); + IsLoading = false; + } } #endregion diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs new file mode 100644 index 000000000..cea8a7d63 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.PPC.Common; + +namespace Tango.PPC.UI.ViewModels +{ + public class NoPermissionsViewVM : PPCViewModel + { + public RelayCommand RestartCommand { get; set; } + + public NoPermissionsViewVM() + { + RestartCommand = new RelayCommand(Restart); + } + + private void Restart() + { + ApplicationManager.Restart(); + } + + public override void OnApplicationStarted() + { + + } + } +} -- cgit v1.3.1