From 2701b59b7c5a6be580c8df7b551977c04a949c76 Mon Sep 17 00:00:00 2001 From: Jeremy Tellier - ROG Date: Wed, 15 Jul 2020 13:39:55 +0100 Subject: [PATCH 1/3] Organized UIs as we grow. Added Warning for overlapping services Switched from Minimize to hide to prevent improperly minimizing the UI Changed Mouse Down To Mouse Up --- DesktopEdge/Assets/Images/Warning.png | Bin 0 -> 2201 bytes DesktopEdge/IdentityDetails.xaml | 6 +- DesktopEdge/IdentityDetails.xaml.cs | 1 + DesktopEdge/MainMenu.xaml | 4 +- DesktopEdge/MainMenu.xaml.cs | 8 ++- DesktopEdge/MainWindow.xaml | 8 ++- DesktopEdge/MainWindow.xaml.cs | 61 +++++++++--------- DesktopEdge/Models/ZitiIdentity.cs | 8 +-- DesktopEdge/Models/ZitiService.cs | 4 +- .../ItemRenderers}/IdentityItem.xaml | 0 .../ItemRenderers}/IdentityItem.xaml.cs | 0 .../ItemRenderers}/MenuEditItem.xaml | 0 .../ItemRenderers}/MenuEditItem.xaml.cs | 0 .../{ => Views/ItemRenderers}/MenuItem.xaml | 0 .../ItemRenderers}/MenuItem.xaml.cs | 0 .../ItemRenderers}/ServiceInfo.xaml | 2 + .../ItemRenderers}/ServiceInfo.xaml.cs | 15 +++++ .../ItemRenderers}/SubMenuItem.xaml | 0 .../ItemRenderers}/SubMenuItem.xaml.cs | 0 DesktopEdge/ZitiDesktopEdge.csproj | 27 ++++---- 20 files changed, 88 insertions(+), 56 deletions(-) create mode 100644 DesktopEdge/Assets/Images/Warning.png rename DesktopEdge/{ => Views/ItemRenderers}/IdentityItem.xaml (100%) rename DesktopEdge/{ => Views/ItemRenderers}/IdentityItem.xaml.cs (100%) rename DesktopEdge/{ => Views/ItemRenderers}/MenuEditItem.xaml (100%) rename DesktopEdge/{ => Views/ItemRenderers}/MenuEditItem.xaml.cs (100%) rename DesktopEdge/{ => Views/ItemRenderers}/MenuItem.xaml (100%) rename DesktopEdge/{ => Views/ItemRenderers}/MenuItem.xaml.cs (100%) rename DesktopEdge/{ => Views/ItemRenderers}/ServiceInfo.xaml (87%) rename DesktopEdge/{ => Views/ItemRenderers}/ServiceInfo.xaml.cs (79%) rename DesktopEdge/{ => Views/ItemRenderers}/SubMenuItem.xaml (100%) rename DesktopEdge/{ => Views/ItemRenderers}/SubMenuItem.xaml.cs (100%) diff --git a/DesktopEdge/Assets/Images/Warning.png b/DesktopEdge/Assets/Images/Warning.png new file mode 100644 index 0000000000000000000000000000000000000000..35b012d92fd791dcece72b3c69975def853b9a3b GIT binary patch literal 2201 zcmV;K2xj+*P) zzfv4W5QlqJju9_Fl@z*2s7q`jLt-l=P&q}|$_3>IKz;y&b6e(=Vpqw^WGA3R;N(m~ zIYcVTImHXCYxa8a>ELd=XXj7%%zRZ6LfqZ%-TwG?cDA>-f{ds~um}Jv0I&uC_wnC` z_WXoy!H!(dpeN3iel^`nwhAaFyi5FXl>?RwPA zWh6&3yA0e_Tm)QXlDm$S3}HLhV9Q#HmPo=7Ogo&<2+uMAJOzLy#-fw6L@I%x&N-ad z0FMFSddANeDuBPtSH|MkQ<}+Czso>7P{MH85e9?#**oScgx*zoC515rb%X46grVhU z=JMC@D83;V%NU3u$cKFF^8RI})GM}d25?T$hO+0~RYloIS z=Ht~{Lfym^+Tnr_2xEuOdIrLLK&Q;v%V9Nutv<_)iAF<&vO`N&mQZDg&~|9a$r9QO z5!wzd*;qnNAkYq!8A0nKi-0wR7N}6H#XgErFogfva^EXbH~lNS!6b2cjM|gEI+s01QLYme61b zP63Q}@CYVZONb5x+JSOBAHohTNn1j?Aw=1sC1p#94TMlTv?OZ@$%YVVhZajqh@ZU_ z83^HaXtA<{ztwSrR73bGo^^_aB_3ed#Ud^c3_G0EWp)w`LH)qErSiVu zo;wk32~mN-tEs7W;FigI0mm@hP>8jJG(%{!LkssvN312p1On|q>9^p*4(2NFuPcD> z%va{s-nU4}5@Kp9>k%9g1M#>|AS!@I08Q(m$q<;q;V$eyi#b(RPoh#c(DqR|pD43Uc+ zT2xsgXdrU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Rx`3&4MQ*( z2gF++6!b8}a=G{O*7(*;CF Identity Name - + @@ -44,8 +44,8 @@ diff --git a/DesktopEdge/IdentityDetails.xaml.cs b/DesktopEdge/IdentityDetails.xaml.cs index 5aea08d9..fc47e1b0 100644 --- a/DesktopEdge/IdentityDetails.xaml.cs +++ b/DesktopEdge/IdentityDetails.xaml.cs @@ -74,6 +74,7 @@ namespace ZitiDesktopEdge { ServiceInfo editor = new ServiceInfo(); editor.Label = _identity.Services[i].Name; editor.Value = _identity.Services[i].Url; + editor.Warning = _identity.Services[i].Warning; editor.IsLocked = true; ServiceList.Children.Add(editor); } diff --git a/DesktopEdge/MainMenu.xaml b/DesktopEdge/MainMenu.xaml index 1c4c1677..59a1ed8f 100644 --- a/DesktopEdge/MainMenu.xaml +++ b/DesktopEdge/MainMenu.xaml @@ -39,7 +39,7 @@ - + @@ -71,7 +71,7 @@ - + diff --git a/DesktopEdge/MainMenu.xaml.cs b/DesktopEdge/MainMenu.xaml.cs index 4852156f..edd4f64c 100644 --- a/DesktopEdge/MainMenu.xaml.cs +++ b/DesktopEdge/MainMenu.xaml.cs @@ -6,6 +6,7 @@ using System; using System.Threading; using System.Management.Automation; using ZitiDesktopEdge.Models; +using System.Web; namespace ZitiDesktopEdge { @@ -18,7 +19,7 @@ namespace ZitiDesktopEdge public delegate void AttachementChanged(bool attached); public event AttachementChanged OnAttachmentChange; public string menuState = "Main"; - public string licenseData = "it's open source - someone motivated could track this down. we'll add this some day i'm sure"; + public string licenseData = "it's open source."; public MainMenu() { InitializeComponent(); @@ -92,7 +93,6 @@ namespace ZitiDesktopEdge LogsItems.Visibility = Visibility.Visible; BackArrow.Visibility = Visibility.Visible; } else if (menuState == "UILogs") { - ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"]; MenuTitle.Content = "Application Logs"; LogsItems.Text = UILog.GetLogs(); LogsItems.Visibility = Visibility.Visible; @@ -130,7 +130,9 @@ namespace ZitiDesktopEdge Process.Start(new ProcessStartInfo("https://netfoundry.io/terms") { UseShellExecute = true }); } private void ShowFeedback(object sender, MouseButtonEventArgs e) { - Process.Start(new ProcessStartInfo("mailto:ziti-support@netfoundry.io") { UseShellExecute = true }); + ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"]; + string body = HttpUtility.UrlEncode("\n\nService Logs\n\n" + client.GetLogs());// + "\n\nApplication Logs\n\n" + UILog.GetLogs()); + Process.Start(new ProcessStartInfo("mailto:ziti-support@netfoundry.io?subject=Ziti%20Support&body="+body) { UseShellExecute = true }); } private void ShowSupport(object sender, MouseButtonEventArgs e) { Process.Start(new ProcessStartInfo("https://openziti.discourse.group/") { UseShellExecute = true }); diff --git a/DesktopEdge/MainWindow.xaml b/DesktopEdge/MainWindow.xaml index d1c0d86a..de68398b 100644 --- a/DesktopEdge/MainWindow.xaml +++ b/DesktopEdge/MainWindow.xaml @@ -136,7 +136,7 @@ - + @@ -146,7 +146,11 @@ - + + + + + diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index 5d27d829..4d2fcb74 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -17,6 +17,7 @@ using System.Windows.Controls; using System.Threading.Tasks; using System.Threading; using System.Text; +using System.Runtime.InteropServices; namespace ZitiDesktopEdge { @@ -80,14 +81,12 @@ namespace ZitiDesktopEdge { private void MainWindow_Activated(object sender, EventArgs e) { this.Visibility = Visibility.Visible; + Debug.WriteLine("Activation"); + Placement(); } private void MainWindow_Deactivated(object sender, EventArgs e) { -#if DEBUG - Debug.WriteLine("debug is enabled - not minimizing window"); -#else this.Visibility = Visibility.Collapsed; -#endif } private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { @@ -120,9 +119,7 @@ namespace ZitiDesktopEdge { } private void MainWindow1_Loaded(object sender, RoutedEventArgs e) { - var desktopWorkingArea = System.Windows.SystemParameters.WorkArea; - this.Left = desktopWorkingArea.Right - this.Width - _right; - this.Top = desktopWorkingArea.Bottom - this.Height - _bottom; + Placement(); // add a new service client serviceClient = new Client(); serviceClient.OnClientConnected += ServiceClient_OnClientConnected; @@ -144,6 +141,7 @@ namespace ZitiDesktopEdge { } catch /*ignored for now (Exception ex) */{ SetCantDisplay(); } + Debug.WriteLine("App Loaded"); LoadIdentities(); IdentityMenu.OnForgot += IdentityForgotten; } @@ -177,6 +175,7 @@ namespace ZitiDesktopEdge { var found = identities.Find(i => i.Fingerprint == e.Id.FingerPrint); if (found == null) { identities.Add(zid); + LoadIdentities(); } else { //if we get here exit out so that LoadIdentities() doesn't get called found.IsEnabled = true; @@ -185,7 +184,6 @@ namespace ZitiDesktopEdge { } else { IdentityForgotten(ZitiIdentity.FromClient(e.Id)); } - LoadIdentities(); }); Debug.WriteLine($"IDENTITY EVENT. Action: {e.Action} fingerprint: {zid.Fingerprint}"); } @@ -195,7 +193,7 @@ namespace ZitiDesktopEdge { long totalUp = 0; long totalDown = 0; foreach (var id in ids) { - Debug.WriteLine($"==== MetricsEvent : id {id.Name} down: {id.Metrics.Down} up:{id.Metrics.Up}"); + //Debug.WriteLine($"==== MetricsEvent : id {id.Name} down: {id.Metrics.Down} up:{id.Metrics.Up}"); if (id?.Metrics != null) { totalDown += id.Metrics.Down; totalUp += id.Metrics.Up; @@ -231,7 +229,7 @@ namespace ZitiDesktopEdge { } if (e.Action == "added") { - ZitiService zs = new ZitiService(e.Service.Name, e.Service.HostName, e.Service.Port); + ZitiService zs = new ZitiService(e.Service.Name, e.Service.HostName, e.Service.Port, ""); // CLINT: Gimme an error var svc = found.Services.Find(s => s.Name == zs.Name); if (svc == null) found.Services.Add(zs); else Debug.WriteLine("the service named " + zs.Name + " is already accounted for on this identity."); @@ -268,17 +266,12 @@ namespace ZitiDesktopEdge { private void AttachmentChanged(bool attached) { _isAttached = attached; - if (_isAttached) { - Arrow.Visibility = Visibility.Visible; + if (!_isAttached) { var desktopWorkingArea = System.Windows.SystemParameters.WorkArea; - 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; - this.Left = desktopWorkingArea.Right-this.Width-75; - this.Top = desktopWorkingArea.Bottom-this.Height-75; + this.Left = desktopWorkingArea.Right - this.Width - 75; + this.Top = desktopWorkingArea.Bottom - this.Height - 75; } + Placement(); MainMenu.Visibility = Visibility.Collapsed; } @@ -314,6 +307,7 @@ namespace ZitiDesktopEdge { foreach (var id in status.Identities) { updateViewWithIdentity(id); } + Debug.WriteLine("Load From Service"); LoadIdentities(); } else { SetCantDisplay(); @@ -359,11 +353,21 @@ namespace ZitiDesktopEdge { IdList.Children.Add(id); IdList.Height += 60; } + Debug.WriteLine("Ids Loaded "+ ids.Length); + if (this._isAttached) Placement(); + } + + public void Placement() { var desktopWorkingArea = System.Windows.SystemParameters.WorkArea; - if (this._isAttached) { + if (_isAttached) { + Arrow.Visibility = Visibility.Visible; this.Left = desktopWorkingArea.Right - this.Width - _right; this.Top = desktopWorkingArea.Bottom - this.Height - _bottom; + } else { + Arrow.Visibility = Visibility.Collapsed; } + Debug.WriteLine("Placement: " + this.Left + " " + desktopWorkingArea.Right + " " + this.Width + " " + _right); + Debug.WriteLine("Place: " + this.Top + " " + desktopWorkingArea.Bottom + " " + this.Height + " " + _bottom); } private void OpenIdentity(ZitiIdentity identity) { @@ -391,7 +395,6 @@ namespace ZitiDesktopEdge { client.IdentityOnOff(createdId.FingerPrint, true); if (createdId != null) { identities.Add(ZitiIdentity.FromClient(createdId)); - LoadIdentities(); } else { ShowError("Identity Error", "Identity Id was null, please try again"); } @@ -518,18 +521,18 @@ namespace ZitiDesktopEdge { } private void MainUI_Deactivated(object sender, EventArgs e) { - if (UIModel.HideOnLostFocus) - { -#if DEBUG - Debug.WriteLine("debug is enabled - not minimizing window"); -#else - this.WindowState = WindowState.Minimized; -#endif + if (UIModel.HideOnLostFocus) { + this.Visibility = Visibility.Collapsed; } } private void MainUI_Activated(object sender, EventArgs e) { - this.WindowState = WindowState.Normal; + this.Visibility = Visibility.Visible; + //this.WindowState = WindowState.Normal; + } + + private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e) { + Placement(); } } } diff --git a/DesktopEdge/Models/ZitiIdentity.cs b/DesktopEdge/Models/ZitiIdentity.cs index 9af38425..fd3361fa 100644 --- a/DesktopEdge/Models/ZitiIdentity.cs +++ b/DesktopEdge/Models/ZitiIdentity.cs @@ -42,11 +42,9 @@ namespace ZitiDesktopEdge.Models { Status = id.Status, }; - if (id.Services != null) - { - foreach (var svc in id.Services) - { - var zsvc = new ZitiService(svc.Name, svc.HostName, svc.Port); + if (id.Services != null) { + foreach (var svc in id.Services) { + var zsvc = new ZitiService(svc.Name, svc.HostName, svc.Port, ""); // CLINT: Warning needed zid.Services.Add(zsvc); } } diff --git a/DesktopEdge/Models/ZitiService.cs b/DesktopEdge/Models/ZitiService.cs index f1f22583..4e7ba741 100644 --- a/DesktopEdge/Models/ZitiService.cs +++ b/DesktopEdge/Models/ZitiService.cs @@ -8,9 +8,11 @@ namespace ZitiDesktopEdge.Models { public class ZitiService { public string Name { get; set; } public string Url { get; set; } - public ZitiService(string Name, string hostname, int port) { + public string Warning { get; set; } + public ZitiService(string Name, string hostname, int port, string warning) { this.Name = Name; this.Url = hostname + ":" + port; + this.Warning = warning; } } } diff --git a/DesktopEdge/IdentityItem.xaml b/DesktopEdge/Views/ItemRenderers/IdentityItem.xaml similarity index 100% rename from DesktopEdge/IdentityItem.xaml rename to DesktopEdge/Views/ItemRenderers/IdentityItem.xaml diff --git a/DesktopEdge/IdentityItem.xaml.cs b/DesktopEdge/Views/ItemRenderers/IdentityItem.xaml.cs similarity index 100% rename from DesktopEdge/IdentityItem.xaml.cs rename to DesktopEdge/Views/ItemRenderers/IdentityItem.xaml.cs diff --git a/DesktopEdge/MenuEditItem.xaml b/DesktopEdge/Views/ItemRenderers/MenuEditItem.xaml similarity index 100% rename from DesktopEdge/MenuEditItem.xaml rename to DesktopEdge/Views/ItemRenderers/MenuEditItem.xaml diff --git a/DesktopEdge/MenuEditItem.xaml.cs b/DesktopEdge/Views/ItemRenderers/MenuEditItem.xaml.cs similarity index 100% rename from DesktopEdge/MenuEditItem.xaml.cs rename to DesktopEdge/Views/ItemRenderers/MenuEditItem.xaml.cs diff --git a/DesktopEdge/MenuItem.xaml b/DesktopEdge/Views/ItemRenderers/MenuItem.xaml similarity index 100% rename from DesktopEdge/MenuItem.xaml rename to DesktopEdge/Views/ItemRenderers/MenuItem.xaml diff --git a/DesktopEdge/MenuItem.xaml.cs b/DesktopEdge/Views/ItemRenderers/MenuItem.xaml.cs similarity index 100% rename from DesktopEdge/MenuItem.xaml.cs rename to DesktopEdge/Views/ItemRenderers/MenuItem.xaml.cs diff --git a/DesktopEdge/ServiceInfo.xaml b/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml similarity index 87% rename from DesktopEdge/ServiceInfo.xaml rename to DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml index 91e678bd..1fe5b1dd 100644 --- a/DesktopEdge/ServiceInfo.xaml +++ b/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml @@ -12,9 +12,11 @@ + + diff --git a/DesktopEdge/ServiceInfo.xaml.cs b/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml.cs similarity index 79% rename from DesktopEdge/ServiceInfo.xaml.cs rename to DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml.cs index dea597fb..a3cddebb 100644 --- a/DesktopEdge/ServiceInfo.xaml.cs +++ b/DesktopEdge/Views/ItemRenderers/ServiceInfo.xaml.cs @@ -20,6 +20,21 @@ namespace ZitiDesktopEdge { public partial class ServiceInfo: UserControl { private string _label = ""; + private string _warning = ""; + + public string Warning { + get { + return _warning; + } + set { + _warning = value; + if (_warning.Length>0) { + WarnIcon.ToolTip = _warning; + WarnIcon.Visibility = Visibility.Visible; + WarningColumn.Width = new GridLength(30); + } + } + } public string Label { get { diff --git a/DesktopEdge/SubMenuItem.xaml b/DesktopEdge/Views/ItemRenderers/SubMenuItem.xaml similarity index 100% rename from DesktopEdge/SubMenuItem.xaml rename to DesktopEdge/Views/ItemRenderers/SubMenuItem.xaml diff --git a/DesktopEdge/SubMenuItem.xaml.cs b/DesktopEdge/Views/ItemRenderers/SubMenuItem.xaml.cs similarity index 100% rename from DesktopEdge/SubMenuItem.xaml.cs rename to DesktopEdge/Views/ItemRenderers/SubMenuItem.xaml.cs diff --git a/DesktopEdge/ZitiDesktopEdge.csproj b/DesktopEdge/ZitiDesktopEdge.csproj index 765c2ef5..f7ef1ccf 100644 --- a/DesktopEdge/ZitiDesktopEdge.csproj +++ b/DesktopEdge/ZitiDesktopEdge.csproj @@ -104,6 +104,7 @@ True + @@ -134,10 +135,10 @@ - + ServiceInfo.xaml - + MenuEditItem.xaml @@ -145,10 +146,10 @@ RegistrationScreen.xaml - + SubMenuItem.xaml - + MenuItem.xaml @@ -164,7 +165,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -180,18 +181,18 @@ App.xaml Code - + IdentityItem.xaml MainWindow.xaml Code - + MSBuild:Compile Designer - + MSBuild:Compile Designer @@ -199,11 +200,11 @@ Designer MSBuild:Compile - + MSBuild:Compile Designer - + Designer MSBuild:Compile @@ -342,7 +343,11 @@ - + + + + + \ No newline at end of file From 2471dbbbaefef77185d240ca27580e0ea4b9b4ad Mon Sep 17 00:00:00 2001 From: ziti-ci Date: Wed, 15 Jul 2020 09:13:25 -0400 Subject: [PATCH 2/3] coming soon - when api version doesn't match show error --- DesktopEdge/MainWindow.xaml | 4 ++-- DesktopEdge/MainWindow.xaml.cs | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/DesktopEdge/MainWindow.xaml b/DesktopEdge/MainWindow.xaml index de68398b..8770cb5d 100644 --- a/DesktopEdge/MainWindow.xaml +++ b/DesktopEdge/MainWindow.xaml @@ -220,8 +220,8 @@ -