mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 14:51:44 +01:00
Added: Connection failed Message
This commit is contained in:
parent
aab362b2c0
commit
aba074c263
@ -1,16 +1,27 @@
|
||||
<?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.AddServerProcess.HostSelectPage">
|
||||
x:Class="Borepin.Page.AddServerProcess.HostSelectPage"
|
||||
xmlns:converters="clr-namespace:Borepin.Converter">
|
||||
<NavigationPage.TitleView>
|
||||
<Label Text="FabAccess" Style="{StaticResource Style_Label_Header}"/>
|
||||
<Label Text="FabAccess" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
|
||||
</NavigationPage.TitleView>
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ContentPage.Content>
|
||||
<StackLayout Padding="20">
|
||||
<Label Text="Host" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Entry Text="{Binding Host}"/>
|
||||
<Button Text="Detect local host" Command="{Binding DetectHostCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Button Text="Select Host" Command="{Binding UseHostCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<StackLayout IsVisible="{Binding IsBusy}">
|
||||
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
||||
<Label Text="Host" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Entry Text="{Binding Host}"/>
|
||||
<Button Text="Demo Host Address" Command="{Binding DetectHostCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Button Text="Select Host" Command="{Binding UseHostCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
@ -1,19 +1,30 @@
|
||||
<?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.AddServerProcess.LoginChoosePage">
|
||||
x:Class="Borepin.Page.AddServerProcess.LoginChoosePage"
|
||||
xmlns:converters="clr-namespace:Borepin.Converter">
|
||||
<NavigationPage.TitleView>
|
||||
<Label Text="FabAccess" FontAttributes="Bold" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" VerticalOptions="FillAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
|
||||
<Label Text="FabAccess" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
|
||||
</NavigationPage.TitleView>
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ContentPage.Content>
|
||||
<StackLayout Padding="20">
|
||||
<Label Text="Sign In:" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Button Text="Login with Password" Command="{Binding LoginPasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Label Text="or" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Button Text="Login with Card" Style="{StaticResource Style_Button_Primary}" IsEnabled="False"/>
|
||||
<StackLayout IsVisible="{Binding IsBusy}">
|
||||
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
||||
<Label Text="Sign In:" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Button Text="Login with Password" Command="{Binding LoginPasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Label Text="or" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Button Text="Login with Card" Style="{StaticResource Style_Button_Primary}" IsEnabled="False"/>
|
||||
|
||||
<Label Text="Sign Up:" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Button Text="Register" Style="{StaticResource Style_Button_Primary}" IsEnabled="False"/>
|
||||
<Label Text="Sign Up:" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Button Text="Register" Style="{StaticResource Style_Button_Primary}" IsEnabled="False"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
@ -1,19 +1,30 @@
|
||||
<?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.AddServerProcess.LoginPasswordPage">
|
||||
x:Class="Borepin.Page.AddServerProcess.LoginPasswordPage"
|
||||
xmlns:converters="clr-namespace:Borepin.Converter">
|
||||
<NavigationPage.TitleView>
|
||||
<Label Text="FabAccess" FontAttributes="Bold" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" VerticalOptions="FillAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
|
||||
<Label Text="FabAccess" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
|
||||
</NavigationPage.TitleView>
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ContentPage.Content>
|
||||
<StackLayout Padding="20">
|
||||
<Label Text="Username" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Entry Text="{Binding Username}"/>
|
||||
<StackLayout IsVisible="{Binding IsBusy}">
|
||||
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
||||
<Label Text="Username" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Entry Text="{Binding Username}"/>
|
||||
|
||||
<Label Text="Password" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Entry Text="{Binding Password}" IsPassword="True"/>
|
||||
<Label Text="Password" Style="{StaticResource Style_Label_Property_Title}"></Label>
|
||||
<Entry Text="{Binding Password}" IsPassword="True"/>
|
||||
|
||||
<Button Text="Login" Command="{Binding AuthenticateCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Button Text="Login" Command="{Binding AuthenticateCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
@ -1,6 +1,7 @@
|
||||
using Borepin.Service.BFFH;
|
||||
using Prism.Mvvm;
|
||||
using Borepin.Base;
|
||||
using Borepin.Service.BFFH;
|
||||
using Prism.Navigation;
|
||||
using Prism.Services;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
@ -9,27 +10,36 @@ using Xamarin.Forms;
|
||||
|
||||
namespace Borepin.PageModel.AddServerProcess
|
||||
{
|
||||
public class HostSelectPageModel : BindableBase
|
||||
public class HostSelectPageModel : PageModelBase
|
||||
{
|
||||
private readonly INavigationService _NavigationService;
|
||||
#region Private Properties
|
||||
private readonly IBFFHService _BFFHService;
|
||||
private readonly IPageDialogService _PageDialogService;
|
||||
#endregion
|
||||
|
||||
public HostSelectPageModel(INavigationService navigationService, IBFFHService bffhService)
|
||||
#region Constructors
|
||||
public HostSelectPageModel(INavigationService navigationService, IBFFHService bffhService, IPageDialogService pageDialogService) : base(navigationService)
|
||||
{
|
||||
_NavigationService = navigationService;
|
||||
_BFFHService = bffhService;
|
||||
_PageDialogService = pageDialogService;
|
||||
|
||||
UseHostCommand = new Command(UseHostCommandExecuted);
|
||||
DetectHostCommand = new Command(DetectHostCommandExecuted);
|
||||
|
||||
Task.Run(LoadData);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void LoadData()
|
||||
#region LoadData
|
||||
public override Task LoadData()
|
||||
{
|
||||
IsBusy = false;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private string _Host;
|
||||
public string Host
|
||||
{
|
||||
@ -43,7 +53,9 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
get => _KnownHost_List;
|
||||
set => SetProperty(ref _KnownHost_List, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
private ICommand _UseHostCommand;
|
||||
public ICommand UseHostCommand
|
||||
{
|
||||
@ -53,6 +65,8 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
|
||||
private async void UseHostCommandExecuted()
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
UriBuilder builder = new UriBuilder(Host);
|
||||
if(builder.Port == 80)
|
||||
{
|
||||
@ -68,9 +82,18 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
{
|
||||
await _BFFHService.Disconnect();
|
||||
}
|
||||
await _BFFHService.Connect(connection);
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
await _BFFHService.Connect(connection);
|
||||
}
|
||||
catch (Capnp.Rpc.RpcException exception) when (exception.Message == "TcpRpcClient is unable to connect")
|
||||
{
|
||||
await _PageDialogService.DisplayAlertAsync("Connection failed", "Unable to connect to server.", "Ok");
|
||||
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("AddServerProcess_LoginChoosePage");
|
||||
if(!result.Success)
|
||||
@ -91,5 +114,18 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
// Use Demo Host
|
||||
Host = "127.0.0.1:59661";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INavigationAware
|
||||
public override void OnNavigatedFrom(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,30 @@
|
||||
using Prism.Mvvm;
|
||||
using Borepin.Base;
|
||||
using Prism.Navigation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Borepin.PageModel.AddServerProcess
|
||||
{
|
||||
public class LoginChoosePageModel : BindableBase
|
||||
public class LoginChoosePageModel : PageModelBase
|
||||
{
|
||||
private INavigationService _NavigationService;
|
||||
|
||||
public LoginChoosePageModel(INavigationService navigationService)
|
||||
#region Contructors
|
||||
public LoginChoosePageModel(INavigationService navigationService) : base(navigationService)
|
||||
{
|
||||
_NavigationService = navigationService;
|
||||
|
||||
LoginPasswordCommand = new Command(LoginPasswordCommandExecuted);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LoadData
|
||||
public override Task LoadData()
|
||||
{
|
||||
IsBusy = false;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
private ICommand _LoginPasswordCommand;
|
||||
public ICommand LoginPasswordCommand
|
||||
{
|
||||
@ -31,5 +40,18 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INavigationAware
|
||||
public override void OnNavigatedFrom(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using Borepin.Model;
|
||||
using Borepin.Base;
|
||||
using Borepin.Model;
|
||||
using Borepin.Service.BFFH;
|
||||
using Borepin.Service.Connections;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Navigation;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,15 +10,16 @@ using System.Windows.Input;
|
||||
|
||||
namespace Borepin.PageModel.AddServerProcess
|
||||
{
|
||||
public class LoginPasswordPageModel : BindableBase
|
||||
public class LoginPasswordPageModel : PageModelBase
|
||||
{
|
||||
private readonly INavigationService _NavigationService;
|
||||
#region Private Properties
|
||||
private readonly IBFFHService _BFFHService;
|
||||
private readonly IConnectionService _ConnectionService;
|
||||
#endregion
|
||||
|
||||
public LoginPasswordPageModel(INavigationService navigationService, IBFFHService bffhService, IConnectionService connectionService)
|
||||
#region Constructors
|
||||
public LoginPasswordPageModel(INavigationService navigationService, IBFFHService bffhService, IConnectionService connectionService) : base(navigationService)
|
||||
{
|
||||
_NavigationService = navigationService;
|
||||
_BFFHService = bffhService;
|
||||
_ConnectionService = connectionService;
|
||||
|
||||
@ -26,12 +27,18 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
|
||||
Task.Run(LoadData);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void LoadData()
|
||||
#region LoadData
|
||||
public override Task LoadData()
|
||||
{
|
||||
IsBusy = false;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private string _Username;
|
||||
public string Username
|
||||
{
|
||||
@ -45,7 +52,9 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
get => _Password;
|
||||
set => SetProperty(ref _Password, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
private ICommand _AuthenticateCommand;
|
||||
public ICommand AuthenticateCommand
|
||||
{
|
||||
@ -79,5 +88,18 @@ namespace Borepin.PageModel.AddServerProcess
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INavigationAware
|
||||
public override void OnNavigatedFrom(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ using Borepin.Service.Connections;
|
||||
using Borepin.Service.Credentials;
|
||||
using Prism.Commands;
|
||||
using Prism.Navigation;
|
||||
using Prism.Services;
|
||||
using Prism.Services.Dialogs;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
@ -18,16 +19,18 @@ namespace Borepin.PageModel
|
||||
private readonly IConnectionService _ConnectionService;
|
||||
private readonly IBFFHService _BFFHService;
|
||||
private readonly ICredentialService _CredentialService;
|
||||
private readonly IPageDialogService _PageDialogService;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public ServerPageModel(INavigationService navigationService, IDialogService dialogService, IConnectionService connectionService, IBFFHService bffhService, ICredentialService credentialService) : base(navigationService)
|
||||
public ServerPageModel(INavigationService navigationService, IDialogService dialogService, IConnectionService connectionService, IBFFHService bffhService, ICredentialService credentialService, IPageDialogService pageDialogService) : base(navigationService)
|
||||
{
|
||||
_DialogService = dialogService;
|
||||
|
||||
_ConnectionService = connectionService;
|
||||
_BFFHService = bffhService;
|
||||
_CredentialService = credentialService;
|
||||
_PageDialogService = pageDialogService;
|
||||
|
||||
ConnectCommand = new DelegateCommand(async () => await ConnectCommandExecuted());
|
||||
DeleteCommand = new DelegateCommand(DeleteCommandExecuted);
|
||||
@ -77,7 +80,17 @@ namespace Borepin.PageModel
|
||||
}
|
||||
else
|
||||
{
|
||||
await _BFFHService.Connect(Connection_Item);
|
||||
try
|
||||
{
|
||||
await _BFFHService.Connect(Connection_Item);
|
||||
}
|
||||
catch(Capnp.Rpc.RpcException exception) when (exception.Message == "TcpRpcClient is unable to connect")
|
||||
{
|
||||
await _PageDialogService.DisplayAlertAsync("Connection failed", "Unable to connect to server.", "Ok");
|
||||
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
await _BFFHService.Authenticate();
|
||||
|
||||
IsConnected = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user