Fixed MainPage Grid

This commit is contained in:
TheJoKlLa 2022-07-18 17:06:27 +02:00
parent 5ca2e66443
commit 50e614047a
10 changed files with 54 additions and 43 deletions

View File

@ -5,22 +5,27 @@
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"> xmlns:resource_text="clr-namespace:Borepin.Resources.Text">
<FlyoutPage.Flyout> <FlyoutPage.Flyout>
<ContentPage Title="FabAccess" BackgroundColor="{StaticResource SecondColor}"> <ContentPage Title="FabAccess" BackgroundColor="{StaticResource SecondColor}">
<StackLayout> <Grid>
<StackLayout Margin="0,50,0,0" VerticalOptions="FillAndExpand"> <Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" IsVisible="{Binding IsConnected}" Margin="0, 50, 0, 0">
<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_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}"/> <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>
<StackLayout Margin="0,50,0,50"> <StackLayout Grid.Row="1" VerticalOptions="End" Margin="0, 0, 0, 50">
<Button Text="{x:Static resource_text:TextResource.MainPage_Servers}" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" VerticalOptions="End"/>
<StackLayout IsVisible="{Binding IsConnected}"> <StackLayout IsVisible="{Binding IsConnected}">
<Button Text="{x:Static resource_text:TextResource.MainPage_Profile}" Command="{Binding NavigateCommand}" CommandParameter="ProfilePage" 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}"/>
</StackLayout> </StackLayout>
<Button Text="{x:Static resource_text:TextResource.MainPage_Servers}" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}"/>
</StackLayout> </StackLayout>
<StackLayout Margin="0,0,0,10"> <StackLayout Grid.Row="2" Margin="10, 0, 0, 10" VerticalOptions="End">
<Label Text="{Binding CurrentVersion, StringFormat='Version: {0}'}" VerticalOptions="End" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/> <Label Text="{Binding CurrentVersion, StringFormat='Version: {0}'}" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/>
<Label Text="{Binding CurrentBuild, StringFormat='Build: {0}'}" VerticalOptions="End" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/> <Label Text="{Binding CurrentBuild, StringFormat='Build: {0}'}" Margin="10,0,0,0" TextColor="{StaticResource FirstColor}"/>
</StackLayout> </StackLayout>
</StackLayout> </Grid>
</ContentPage> </ContentPage>
</FlyoutPage.Flyout> </FlyoutPage.Flyout>
</FlyoutPage> </FlyoutPage>

View File

@ -17,11 +17,13 @@
</StackLayout> </StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}"> <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}"> <StackLayout IsVisible="{Binding IsConnected}">
<Label Text="{Binding UserItem.Username}" Style="{StaticResource LabelStyle_Title}"/> <Label Text="{Binding Username}" Style="{StaticResource LabelStyle_Title}"/>
<Label Text="{x:Static resource_text:TextResource.ProfilePage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/> <StackLayout IsVisible="{Binding CanManage}">
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_OldPassword}" Text="{Binding OldPassword}"/> <Label Text="{x:Static resource_text:TextResource.ProfilePage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_NewPassword}" Text="{Binding NewPassword}"/> <Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_OldPassword}" Text="{Binding OldPassword}"/>
<Button Text="{x:Static resource_text:TextResource.ProfilePage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/> <Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_NewPassword}" Text="{Binding NewPassword}"/>
<Button Text="{x:Static resource_text:TextResource.ProfilePage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
</StackLayout> </StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}"> <StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/> <Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>

View File

@ -31,11 +31,13 @@
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView> </ListView>
<Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/> <StackLayout IsVisible="{Binding CanAdmin}">
<Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/> <Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
<Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/> <Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/>
<Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
<Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/> <Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
</StackLayout> </StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}"> <StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/> <Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
</StackLayout> </StackLayout>

View File

@ -6,7 +6,6 @@ using Borepin.Base;
using Borepin.Base.Exceptions; using Borepin.Base.Exceptions;
using Borepin.Service; using Borepin.Service;
using Borepin.Service.Storage; using Borepin.Service.Storage;
using Borepin.Service.Storage.Exceptions;
using FabAccessAPI; using FabAccessAPI;
using FabAccessAPI.Exceptions; using FabAccessAPI.Exceptions;
using Prism.Commands; using Prism.Commands;
@ -47,6 +46,11 @@ namespace Borepin.PageModel.AddServerProcess
return Task.CompletedTask; return Task.CompletedTask;
} }
public override Task<object> CreateInstance()
{
return Task.FromResult<object>(_ConnectionData);
}
#endregion #endregion
#region Fields #region Fields

View File

@ -4,18 +4,10 @@ using Prism.Navigation;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
using FabAccessAPI.Schema; using FabAccessAPI.Schema;
using Borepin.Model;
using Prism.Services; using Prism.Services;
using Borepin.Service; using Borepin.Service;
using Borepin.Base.Exceptions;
using Capnp.Rpc; using Capnp.Rpc;
using System; using System;
using Borepin.ViewModel;
using System.Collections.Generic;
using NaturalSort.Extension;
using System.Linq;
using Prism.Services.Dialogs;
using Xamarin.Forms;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
@ -29,25 +21,22 @@ namespace Borepin.PageModel
#endregion #endregion
#region Data #region Data
public override Task LoadInstance(object instance)
{
return Task.CompletedTask;
}
public override async Task LoadAPIData() public override async Task LoadAPIData()
{ {
_UserItem = new UserVisualize(await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false)); User self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
_UserItem.LoadData(); Username = self.Username;
CanManage = !((User.ManageInterface_Proxy)self.Manage).IsNull;
} }
#endregion #endregion
#region Fields #region Fields
private UserVisualize _UserItem; private string _Username;
public UserVisualize UserItem public string Username
{ {
get => _UserItem; get => _Username;
set => SetProperty(ref _UserItem, value); set => SetProperty(ref _Username, value);
} }
private string _OldPassword = null; private string _OldPassword = null;
@ -63,6 +52,13 @@ namespace Borepin.PageModel
get => _NewPassword; get => _NewPassword;
set => SetProperty(ref _NewPassword, value); set => SetProperty(ref _NewPassword, value);
} }
private bool _CanManage;
public bool CanManage
{
get => _CanManage;
set => SetProperty(ref _CanManage, value);
}
#endregion #endregion
#region Commands #region Commands
@ -84,6 +80,8 @@ namespace Borepin.PageModel
{ {
User self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); User self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
await self.Manage.Pwd(OldPassword, NewPassword).ConfigureAwait(false); await self.Manage.Pwd(OldPassword, NewPassword).ConfigureAwait(false);
OldPassword = string.Empty;
NewPassword = string.Empty;
} }
} }
catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal)) catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))

View File

@ -194,7 +194,7 @@ namespace Borepin.PageModel
public void UpdatePasswordCommandExecute() public void UpdatePasswordCommandExecute()
{ {
_User.Manage.Pwd(null, NewPassword); _User.Admin.Pwd(NewPassword);
} }
#endregion #endregion
} }

View File

@ -48,7 +48,7 @@ namespace Borepin.ViewModel
Device.BeginInvokeOnMainThread(async () => Device.BeginInvokeOnMainThread(async () =>
{ {
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage/MachinePage", parameters).ConfigureAwait(false); INavigationResult result = await _NavigationService.NavigateAsync("MachinePage", parameters).ConfigureAwait(false);
if (result.Exception != null) if (result.Exception != null)
{ {
Log.Fatal(result.Exception, "Navigating failed"); Log.Fatal(result.Exception, "Navigating failed");

View File

@ -58,7 +58,7 @@ namespace Borepin.ViewModel
Device.BeginInvokeOnMainThread(async () => Device.BeginInvokeOnMainThread(async () =>
{ {
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage/ServerPage", parameters).ConfigureAwait(false); INavigationResult result = await _NavigationService.NavigateAsync("ServerPage", parameters).ConfigureAwait(false);
if (result.Exception != null) if (result.Exception != null)
{ {
Log.Fatal(result.Exception, "Navigating failed"); Log.Fatal(result.Exception, "Navigating failed");

View File

@ -59,7 +59,7 @@ namespace Borepin.ViewModel
Device.BeginInvokeOnMainThread(async () => Device.BeginInvokeOnMainThread(async () =>
{ {
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/UserListPage/UserPage", parameters).ConfigureAwait(false); INavigationResult result = await _NavigationService.NavigateAsync("UserPage", parameters).ConfigureAwait(false);
if (result.Exception != null) if (result.Exception != null)
{ {
Log.Fatal(result.Exception, "Navigating failed"); Log.Fatal(result.Exception, "Navigating failed");

@ -1 +1 @@
Subproject commit 63e63853c1d5ca9f223aa3627ad391ce434a0683 Subproject commit 086bbc2497785d2cc63e9252df6f6d3ee7599579