mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 08:39:55 +00:00
Service List Size, Window Position faked for Demo, Remove Ids when Removed and properly only show one when loaded.
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
<local:MenuEditItem x:Name="IdentityEnrollment" HorizontalAlignment="Stretch" Label="Enrollment Status" IsLocked="True"></local:MenuEditItem>
|
||||
<Label Content="SERVICES" Foreground="Gray" FontWeight="SemiBold" />
|
||||
<StackPanel Name="ServiceList" Orientation="Vertical"></StackPanel>
|
||||
<Label Name="ForgetIdentityButton" Margin="0,10,0,10" Content="Forget This Identity" Cursor="Hand" Foreground="#F4044D" HorizontalAlignment="Center" MouseUp="ForgetIdentity"></Label>
|
||||
<Label Name="ForgetIdentityButton" Margin="0,10,0,10" Content="Forget This Identity" Cursor="Hand" Foreground="#F4044D" HorizontalAlignment="Center" Mouse.MouseDown="ForgetIdentity"></Label>
|
||||
<Image Source="/Assets/Images/identity.png" Height="100" Width="100" HorizontalAlignment="Stretch">
|
||||
</Image>
|
||||
</StackPanel>
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace ZitiTunneler {
|
||||
public partial class IdentityDetails:UserControl {
|
||||
|
||||
private bool _isAttached = true;
|
||||
public delegate void Forgot(ZitiIdentity forgotten);
|
||||
public event Forgot OnForgot;
|
||||
|
||||
private List<ZitiIdentity> identities {
|
||||
get {
|
||||
@@ -63,7 +65,7 @@ namespace ZitiTunneler {
|
||||
IdentityStatus.Value = _identity.Status;
|
||||
ServiceList.Children.Clear();
|
||||
for (int i=0; i<_identity.Services.Count; i++) {
|
||||
MenuEditItem editor = new MenuEditItem();
|
||||
ServiceInfo editor = new ServiceInfo();
|
||||
editor.Label = _identity.Services[i].Name;
|
||||
editor.Value = _identity.Services[i].Url;
|
||||
editor.IsLocked = true;
|
||||
@@ -86,21 +88,30 @@ namespace ZitiTunneler {
|
||||
|
||||
private void ForgetIdentity(object sender, MouseButtonEventArgs e) {
|
||||
// Jeremy - this works now as long as you pass a fingerprint that's valid!
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"];
|
||||
try {
|
||||
client.RemoveIdentity(_identity.Fingerprint);
|
||||
MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to forget this identity?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);
|
||||
if (messageBoxResult == MessageBoxResult.Yes) {
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"];
|
||||
try {
|
||||
client.RemoveIdentity(_identity.Fingerprint);
|
||||
|
||||
foreach (var id in identities) {
|
||||
if (id.Fingerprint == _identity.Fingerprint) {
|
||||
identities.Remove(id);
|
||||
break;
|
||||
ZitiIdentity forgotten = new ZitiIdentity();
|
||||
foreach (var id in identities) {
|
||||
if (id.Fingerprint == _identity.Fingerprint) {
|
||||
forgotten = id;
|
||||
identities.Remove(id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (OnForgot != null) {
|
||||
OnForgot(forgotten);
|
||||
}
|
||||
} catch (ServiceClient.ServiceException se) {
|
||||
MessageBox.Show(se.AdditionalInfo, se.Message);
|
||||
} catch (Exception ex) {
|
||||
MessageBox.Show("Unexpected error 1", ex.Message);
|
||||
}
|
||||
} catch (ServiceClient.ServiceException se) {
|
||||
MessageBox.Show(se.AdditionalInfo, se.Message);
|
||||
} catch (Exception ex) {
|
||||
MessageBox.Show("Unexpected error 1", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Vertical" Margin="20,20,20,20">
|
||||
<StackPanel Name="MainStack" Grid.Column="0" Grid.Row="0" Orientation="Vertical" Margin="20,20,20,20">
|
||||
<Grid Margin="0,0,0,20">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="70"/>
|
||||
@@ -78,9 +78,9 @@
|
||||
<local:MenuEditItem x:Name="ConfigMtu" HorizontalAlignment="Stretch" Width="Auto" Label="MTU:"></local:MenuEditItem>
|
||||
<local:MenuEditItem x:Name="ConfigDns" HorizontalAlignment="Stretch" Width="Auto" Label="DNS Servers:"></local:MenuEditItem>
|
||||
</StackPanel>
|
||||
<TextBox Name="LicensesItems" Width="380" Height="400" Visibility="Collapsed"></TextBox>
|
||||
<TextBox Name="LogsItems" Width="380" Height="400" Visibility="Collapsed"></TextBox>
|
||||
|
||||
<TextBox Name="LicensesItems" Height="400" Width="{Binding ActualWidth, ElementName=MainStack}" TextWrapping="Wrap" Visibility="Collapsed"></TextBox>
|
||||
<TextBox Name="LogsItems" Height="400" Width="{Binding ActualWidth, ElementName=MainStack}" TextWrapping="Wrap" Visibility="Collapsed"></TextBox>
|
||||
|
||||
<Button Name="ConfigSaveButton" Cursor="Hand" Click="SaveConfig" Visibility="Collapsed" Content="SAVE" FontSize="10" FontWeight="SemiBold" Padding="20,7,20,7" Background="#0069FF" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="White"></Button>
|
||||
<StackPanel Name="AboutItemsButton" Orientation="Vertical" HorizontalAlignment="Stretch" Visibility="Collapsed">
|
||||
<Image Grid.Column="0" Source="/Assets/Images/logo.png" Height="60" Width="240"></Image>
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace ZitiTunneler {
|
||||
private System.Windows.Forms.Timer _timer;
|
||||
private Client serviceClient = null;
|
||||
private bool _isAttached = true;
|
||||
private int _right = 75;
|
||||
private int _bottom = -10;
|
||||
|
||||
private List<ZitiIdentity> identities {
|
||||
get {
|
||||
@@ -64,8 +66,8 @@ namespace ZitiTunneler {
|
||||
|
||||
private void MainWindow1_Loaded(object sender, RoutedEventArgs e) {
|
||||
var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
|
||||
this.Left = desktopWorkingArea.Right-this.Width-25;
|
||||
this.Top = desktopWorkingArea.Bottom-this.Height-50;
|
||||
this.Left = desktopWorkingArea.Right-this.Width-_right;
|
||||
this.Top = desktopWorkingArea.Bottom-this.Height-_bottom;
|
||||
|
||||
// add a new service client
|
||||
serviceClient = new Client();
|
||||
@@ -80,6 +82,17 @@ namespace ZitiTunneler {
|
||||
// MessageBox.Show("oh my goodness - problem with the service. Almost certainly means the service is NOT RUNNING... Jeremy make this pretty.\n" + ex.Message);
|
||||
}
|
||||
LoadIdentities();
|
||||
IdentityMenu.OnForgot += IdentityForgotten;
|
||||
}
|
||||
|
||||
private void IdentityForgotten(ZitiIdentity forgotten) {
|
||||
ZitiTunnelStatus status = serviceClient.GetStatus();
|
||||
identities.Clear();
|
||||
foreach (var id in status.Identities) {
|
||||
var zid = ZitiIdentity.FromClient(id);
|
||||
identities.Add(zid);
|
||||
}
|
||||
LoadIdentities();
|
||||
}
|
||||
|
||||
private void AttachmentChanged(bool attached) {
|
||||
@@ -87,8 +100,8 @@ namespace ZitiTunneler {
|
||||
if (_isAttached) {
|
||||
Arrow.Visibility = Visibility.Visible;
|
||||
var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
|
||||
this.Left = desktopWorkingArea.Right-this.Width-25;
|
||||
this.Top = desktopWorkingArea.Bottom-this.Height-50;
|
||||
this.Left = desktopWorkingArea.Right-this.Width-_right;
|
||||
this.Top = desktopWorkingArea.Bottom-this.Height-_bottom;
|
||||
} else {
|
||||
Arrow.Visibility = Visibility.Collapsed;
|
||||
var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
|
||||
@@ -144,8 +157,8 @@ namespace ZitiTunneler {
|
||||
IdList.Children.Add(id);
|
||||
}
|
||||
var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
|
||||
this.Left = desktopWorkingArea.Right-this.Width-25;
|
||||
this.Top = desktopWorkingArea.Bottom-this.Height-50;
|
||||
this.Left = desktopWorkingArea.Right-this.Width-_right;
|
||||
this.Top = desktopWorkingArea.Bottom-this.Height-_bottom;
|
||||
}
|
||||
|
||||
private void OpenIdentity(ZitiIdentity identity) {
|
||||
@@ -165,10 +178,13 @@ namespace ZitiTunneler {
|
||||
|
||||
try {
|
||||
Identity createdId = serviceClient.AddIdentity(System.IO.Path.GetFileName(jwtDialog.FileName), false, fileContent);
|
||||
ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"];
|
||||
client.IdentityOnOff(createdId.FingerPrint, true);
|
||||
if (createdId != null) {
|
||||
identities.Add(ZitiIdentity.FromClient(createdId));
|
||||
MessageBox.Show("New identity added with fingerprint: " + createdId.FingerPrint);
|
||||
updateViewWithIdentity(createdId);
|
||||
LoadIdentities();
|
||||
//MessageBox.Show("New identity added with fingerprint: " + createdId.FingerPrint);
|
||||
//updateViewWithIdentity(createdId);
|
||||
} else {
|
||||
// Jeremy buddy - error popup here
|
||||
MessageBox.Show("created id was null - wtf jeremy. your fault, um nope your fault clint, or probably Andrews");
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<UserControl x:Class="ZitiTunneler.ServiceInfo"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ZitiTunneler"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="36" HorizontalAlignment="Stretch" d:DesignWidth="350" Cursor="Hand">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid Height="35">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Name="MainLabel" MaxWidth="150" BorderThickness="0" Background="White" ClipToBounds="True" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="Black"></TextBox>
|
||||
<TextBox Name="MainEdit" MaxWidth="150" BorderThickness="0" Background="White" ClipToBounds="True" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="12" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="Black"></TextBox>
|
||||
</Grid>
|
||||
<Rectangle HorizontalAlignment="Stretch" Height="1" Fill="#7d8faf" Opacity="0.2"></Rectangle>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ZitiTunneler {
|
||||
/// <summary>
|
||||
/// Interaction logic for MenuItem.xaml
|
||||
/// </summary>
|
||||
public partial class ServiceInfo: UserControl {
|
||||
|
||||
private string _label = "";
|
||||
|
||||
public string Label {
|
||||
get {
|
||||
return _label;
|
||||
}
|
||||
set {
|
||||
this._label = value;
|
||||
MainLabel.Text = this._label;
|
||||
}
|
||||
}
|
||||
public string Value {
|
||||
get {
|
||||
return MainEdit.Text;
|
||||
}
|
||||
set {
|
||||
MainEdit.Text = value;
|
||||
}
|
||||
}
|
||||
public bool IsLocked {
|
||||
get {
|
||||
return MainEdit.IsReadOnly;
|
||||
}
|
||||
set {
|
||||
MainEdit.IsReadOnly = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ServiceInfo() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void MainEdit_GotFocus(object sender, RoutedEventArgs e) {
|
||||
var textbox = (sender as TextBox);
|
||||
textbox.SelectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,9 @@
|
||||
<Compile Include="MainMenu.xaml.cs">
|
||||
<DependentUpon>MainMenu.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ServiceInfo.xaml.cs">
|
||||
<DependentUpon>ServiceInfo.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MenuEditItem.xaml.cs">
|
||||
<DependentUpon>MenuEditItem.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -120,6 +123,10 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="ServiceInfo.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="MenuEditItem.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
Reference in New Issue
Block a user