Added: Add and Remove User

This commit is contained in:
TheJoKlLa 2022-06-25 17:46:57 +02:00
parent b0597f944a
commit 3020024270
12 changed files with 228 additions and 14 deletions

View File

@ -47,6 +47,9 @@ namespace Borepin
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>();
containerRegistry.RegisterForNavigation<ScanURNPage, ScanURNPageModel>();
containerRegistry.RegisterForNavigation<UserListPage, UserListPageModel>();
containerRegistry.RegisterForNavigation<UserPage, UserPageModel>();
containerRegistry.RegisterForNavigation<AddUserPage, AddUserPageModel>();
#endregion

View File

@ -2,13 +2,14 @@
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Dialog.ConfirmDialog"
BackgroundColor="White">
BackgroundColor="White"
xmlns:resource_text="clr-namespace:Borepin.Resources.Text">
<ContentView.Content>
<StackLayout Background="{StaticResource EighthColor}" Padding="10">
<Label Text="{Binding Title}" Style="{StaticResource LabelStyle_Title}"/>
<Label Text="{Binding Message}" Style="{StaticResource Style_Label_Property_Text}"/>
<Button Text="Confirm" Command="{Binding ConfirmCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="Abort" Command="{Binding AbortCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="{x:Static resource_text:TextResource.CONFIRM}" Command="{Binding ConfirmCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="{x:Static resource_text:TextResource.CANCEL}" Command="{Binding AbortCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -2,11 +2,12 @@
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
x:Class="Borepin.Dialog.ScanDialog">
x:Class="Borepin.Dialog.ScanDialog"
xmlns:resource_text="clr-namespace:Borepin.Resources.Text">
<ContentView.Content>
<StackLayout IsVisible="{Binding IsVisible}">
<zxing:ZXingScannerView Result="{Binding ScanResult, Mode=TwoWay}" ScanResultCommand="{Binding ScannedCommand}" IsScanning="{Binding IsScanning}" WidthRequest="300" HeightRequest="500" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"/>
<Button Text="Abort" Command="{Binding AbortCommand}"/>
<Button Text="{x:Static resource_text:TextResource.CANCEL}" Command="{Binding AbortCommand}"/>
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -11,7 +11,11 @@
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}">
<Label Text="{x:Static resource_text:TextResource.USERNAME}" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Username}" Keyboard="Url" IsSpellCheckEnabled="false"/>
<Label Text="{x:Static resource_text:TextResource.PASSWORD}" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Password}" Keyboard="Url" IsSpellCheckEnabled="false"/>
<Button Text="{x:Static resource_text:TextResource.AddUserPage_AddUser}" Command="{Binding AddUserCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>

View File

@ -7,9 +7,12 @@
<ContentPage Title="FabAccess" BackgroundColor="{StaticResource SecondColor}">
<StackLayout>
<StackLayout Margin="0,50,0,0" VerticalOptions="FillAndExpand">
<Button Text="{x:Static resource_text:TextResource.MainPage_Machines}" Command="{Binding NavigateCommand}" CommandParameter="MachineListPage" VerticalOptions="Start" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
<Button Text="{x:Static resource_text:TextResource.MainPage_Users}" IsVisible="{Binding CanManageUsers}" Command="{Binding NavigateCommand}" CommandParameter="UserListPage" VerticalOptions="Start" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
<Button Text="{x:Static resource_text:TextResource.MainPage_Servers}" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" VerticalOptions="Start" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
<Button Text="{x:Static resource_text:TextResource.MainPage_Machines}" Command="{Binding NavigateCommand}" CommandParameter="MachineListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
<Button Text="{x:Static resource_text:TextResource.MainPage_Users}" IsVisible="{Binding CanManageUsers}" Command="{Binding NavigateCommand}" CommandParameter="UserListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
</StackLayout>
<StackLayout Margin="0,50,0,50">
<Button Text="{x:Static resource_text:TextResource.MainPage_Servers}" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" VerticalOptions="End"/>
<!--<Button Text="{x:Static resource_text:TextResource.MainPage_Profile}" Command="{Binding NavigateCommand}" CommandParameter="ProfilePage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" VerticalOptions="End"/>-->
</StackLayout>
<StackLayout Margin="0,0,0,10">
<Label Text="{Binding CurrentVersion, StringFormat='Version: {0}'}" VerticalOptions="End" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.ProfilePage"
xmlns:converters="clr-namespace:Borepin.Converter"
xmlns:views="clr-namespace:Borepin.View"
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
Title="{x:Static resource_text:TextResource.TITLE_Profile}">
<ContentPage.Content>
<StackLayout Padding="20">
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}">
<Label Text="{Binding UserItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
</StackLayout>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,15 @@

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ProfilePage : ContentPage
{
public ProfilePage()
{
InitializeComponent();
}
}
}

View File

@ -31,6 +31,7 @@
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>

View File

@ -201,8 +201,8 @@ namespace Borepin.PageModel
{
DialogParameters parameters = new DialogParameters
{
{ "title", "Delete Server" },
{ "message", "Do you really want to delete this Server?" },
{ "title", Resources.Text.TextResource.DIALOG_DeleteServer },
{ "message", Resources.Text.TextResource.DIALOG_DeleteServerConfirm },
{ "instance", Connection_Item },
};

View File

@ -14,6 +14,8 @@ using Borepin.ViewModel;
using System.Collections.Generic;
using NaturalSort.Extension;
using System.Linq;
using Prism.Services.Dialogs;
using Xamarin.Forms;
namespace Borepin.PageModel
{
@ -22,12 +24,14 @@ namespace Borepin.PageModel
#region Private Fields
private string _ID;
private User _User;
private bool IsDialog = false;
private IDialogService _DialogService;
#endregion
#region Contructors
public UserPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService)
public UserPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IDialogService dialogService) : base(navigationService, pageDialogService, apiService)
{
_DialogService = dialogService;
}
#endregion
@ -72,6 +76,9 @@ namespace Borepin.PageModel
viewmodel_list.OrderBy(x => x.RoleName, StringComparison.OrdinalIgnoreCase.WithNaturalSort());
PermissionSelectViewModel_List = viewmodel_list;
CanAdmin = !((UserSystem.ManageInterface_Proxy)_API.Session.UserSystem.Manage).IsNull;
CanManage = !((User.AdminInterface_Proxy)_User.Manage).IsNull;
}
#endregion
@ -89,10 +96,69 @@ namespace Borepin.PageModel
get => _UserItem;
set => SetProperty(ref _UserItem, value);
}
private bool _CanAdmin;
public bool CanAdmin
{
get => _CanAdmin;
set => SetProperty(ref _CanAdmin, value);
}
private bool _CanManage;
public bool CanManage
{
get => _CanManage;
set => SetProperty(ref _CanManage, value);
}
#endregion
#region Commands
private ICommand _DeleteCommand;
public ICommand DeleteCommand
{
get => _DeleteCommand;
set => SetProperty(ref _DeleteCommand, value);
}
public void DeleteCommandExecute()
{
DialogParameters parameters = new DialogParameters
{
{ "title", Resources.Text.TextResource.DIALOG_DeleteUser },
{ "message", Resources.Text.TextResource.DIALOG_DeleteUserConfirm },
{ "instance", _User },
};
IsDialog = true;
_DialogService.ShowDialog("ConfirmDialog", parameters, DeleteCommandExecute_Dialog);
}
public async void DeleteCommandExecute_Dialog(IDialogResult result)
{
if (string.Equals(result.Parameters.GetValue<string>("result"), "confirm", StringComparison.Ordinal))
{
if(_API.IsConnected)
{
try
{
await _API.Session.UserSystem.Manage.RemoveUser(_User).ConfigureAwait(false);
Device.BeginInvokeOnMainThread(async () =>
{
INavigationResult result_nav = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/UserListPage").ConfigureAwait(false);
if (result_nav.Exception != null)
{
Log.Fatal(result.Exception, "Navigating failed");
}
});
}
catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))
{
Log.Debug("RPC Connection Loss");
}
}
}
}
#endregion
}
}

View File

@ -132,6 +132,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to Add User.
/// </summary>
internal static string AddUserPage_AddUser {
get {
return ResourceManager.GetString("AddUserPage_AddUser", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Alert.
/// </summary>
@ -222,6 +231,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to Confirm.
/// </summary>
internal static string CONFIRM {
get {
return ResourceManager.GetString("CONFIRM", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete.
/// </summary>
@ -231,6 +249,42 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to Delete Server.
/// </summary>
internal static string DIALOG_DeleteServer {
get {
return ResourceManager.GetString("DIALOG_DeleteServer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &quot;Do you really want to delete this Server?&quot;.
/// </summary>
internal static string DIALOG_DeleteServerConfirm {
get {
return ResourceManager.GetString("DIALOG_DeleteServerConfirm", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete User.
/// </summary>
internal static string DIALOG_DeleteUser {
get {
return ResourceManager.GetString("DIALOG_DeleteUser", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Do you really want to delete this User?.
/// </summary>
internal static string DIALOG_DeleteUserConfirm {
get {
return ResourceManager.GetString("DIALOG_DeleteUserConfirm", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to FabAccess.
/// </summary>
@ -330,6 +384,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to My Profile.
/// </summary>
internal static string MainPage_Profile {
get {
return ResourceManager.GetString("MainPage_Profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Servers.
/// </summary>
@ -564,6 +627,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Looks up a localized string similar to My Profile.
/// </summary>
internal static string TITLE_Profile {
get {
return ResourceManager.GetString("TITLE_Profile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Server.
/// </summary>

View File

@ -142,6 +142,9 @@
<value>PLACEHOLDER</value>
<comment>Server Struktur erklären, auf QR-Code hinweisen, ansonsten im Space fragen</comment>
</data>
<data name="AddUserPage_AddUser" xml:space="preserve">
<value>Add User</value>
</data>
<data name="ALERT" xml:space="preserve">
<value>Alert</value>
</data>
@ -172,9 +175,24 @@
<data name="CANCEL" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="CONFIRM" xml:space="preserve">
<value>Confirm</value>
</data>
<data name="DELETE" xml:space="preserve">
<value>Delete</value>
</data>
<data name="DIALOG_DeleteServer" xml:space="preserve">
<value>Delete Server</value>
</data>
<data name="DIALOG_DeleteServerConfirm" xml:space="preserve">
<value>"Do you really want to delete this Server?"</value>
</data>
<data name="DIALOG_DeleteUser" xml:space="preserve">
<value>Delete User</value>
</data>
<data name="DIALOG_DeleteUserConfirm" xml:space="preserve">
<value>Do you really want to delete this User?</value>
</data>
<data name="FABACCESS" xml:space="preserve">
<value>FabAccess</value>
</data>
@ -209,6 +227,9 @@
<data name="MainPage_Machines" xml:space="preserve">
<value>Machines</value>
</data>
<data name="MainPage_Profile" xml:space="preserve">
<value>My Profile</value>
</data>
<data name="MainPage_Servers" xml:space="preserve">
<value>Servers</value>
</data>
@ -287,6 +308,9 @@
<data name="TITLE_Machines" xml:space="preserve">
<value>Machines</value>
</data>
<data name="TITLE_Profile" xml:space="preserve">
<value>My Profile</value>
</data>
<data name="TITLE_Server" xml:space="preserve">
<value>Server</value>
</data>