From fcb0b17a5654ce89610fc896df60edfd2513ad2a Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Mon, 3 Oct 2022 00:20:49 +0200 Subject: [PATCH] ui adjustments for groups --- MareAPI | 2 +- MareSynchronos/UI/CompactUI.cs | 6 +-- MareSynchronos/UI/GroupPanel.cs | 63 +++++++++++++++----------- MareSynchronos/WebAPI/ApiController.cs | 2 +- 4 files changed, 42 insertions(+), 31 deletions(-) diff --git a/MareAPI b/MareAPI index bab758f..a2a4d07 160000 --- a/MareAPI +++ b/MareAPI @@ -1 +1 @@ -Subproject commit bab758f1736e266a392a7a93a47357b03b7b3e01 +Subproject commit a2a4d07c046e0dc5ea5a871dda551f866760d5f6 diff --git a/MareSynchronos/UI/CompactUI.cs b/MareSynchronos/UI/CompactUI.cs index 897fd88..7a02838 100644 --- a/MareSynchronos/UI/CompactUI.cs +++ b/MareSynchronos/UI/CompactUI.cs @@ -59,7 +59,7 @@ public class CompactUi : Window, IDisposable this.WindowName = "Mare Synchronos " + dateTime + "###MareSynchronosMainUI"; Toggle(); #else - this.WindowName = "Mare Synchronos " + Assembly.GetExecutingAssembly().GetName().Version; + this.WindowName = "Mare Synchronos " + Assembly.GetExecutingAssembly().GetName().Version + "###MareSynchronosMainUI"; #endif Logger.Verbose("Creating " + nameof(CompactUi)); @@ -72,8 +72,8 @@ public class CompactUi : Window, IDisposable SizeConstraints = new WindowSizeConstraints() { - MinimumSize = new Vector2(300, 400), - MaximumSize = new Vector2(300, 2000), + MinimumSize = new Vector2(350, 400), + MaximumSize = new Vector2(350, 2000), }; windowSystem.AddWindow(this); diff --git a/MareSynchronos/UI/GroupPanel.cs b/MareSynchronos/UI/GroupPanel.cs index d31a52f..0059ed9 100644 --- a/MareSynchronos/UI/GroupPanel.cs +++ b/MareSynchronos/UI/GroupPanel.cs @@ -113,6 +113,7 @@ namespace MareSynchronos.UI } catch { + _lastCreatedGroup = null; _errorGroupCreate = true; } } @@ -175,7 +176,7 @@ namespace MareSynchronos.UI ExpandedGroupState[group.GID] = !ExpandedGroupState[group.GID]; } ImGui.PopStyleColor(2); - ImGui.SameLine(); + ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + collapseButton.X); var pauseIcon = (group.IsPaused ?? false) ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; if (ImGuiComponents.IconButton(pauseIcon)) { @@ -186,6 +187,16 @@ namespace MareSynchronos.UI var groupName = group.Alias ?? group.GID; var textIsGid = true; + + if (group.OwnedBy == _apiController.UID) + { + ImGui.PushFont(UiBuilder.IconFont); + ImGui.Text(FontAwesomeIcon.Crown.ToIconString()); + ImGui.PopFont(); + UiShared.AttachToolTip("You are the owner of Syncshell " + groupName); + ImGui.SameLine(); + } + _showGidForEntry.TryGetValue(group.GID, out var showGidInsteadOfName); if (!showGidInsteadOfName && _configuration.GetCurrentServerGidComments().TryGetValue(group.GID, out var groupComment)) { @@ -244,21 +255,21 @@ namespace MareSynchronos.UI UiShared.DrawWithID(group.GID + "settings", () => DrawSyncShellButtons(group, name)); - ImGui.Indent(collapseButton.X + ImGui.GetStyle().ItemSpacing.X); + ImGui.Indent(collapseButton.X); if (ExpandedGroupState[group.GID]) { pairsInGroup = pairsInGroup.OrderBy(p => p.UserUID == group.OwnedBy ? 0 : 1).ThenBy(p => p.IsPinned ?? false).ThenBy(p => p.UserAlias ?? p.UserUID).ToList(); ImGui.Indent(ImGui.GetStyle().ItemSpacing.X / 2); - ImGui.Separator(); - foreach (var pair in pairsInGroup) { UiShared.DrawWithID(group.GID + pair.UserUID, () => DrawSyncshellPairedClient(pair, group.OwnedBy == _apiController.UID, group?.IsPaused ?? false)); } + + ImGui.Separator(); ImGui.Unindent(ImGui.GetStyle().ItemSpacing.X / 2); } - ImGui.Unindent(collapseButton.X + ImGui.GetStyle().ItemSpacing.X); + ImGui.Unindent(collapseButton.X); } private void DrawSyncShellButtons(GroupDto entry, string name) @@ -315,6 +326,27 @@ namespace MareSynchronos.UI } UiShared.AttachToolTip("Change Syncshell Password"); + if (ImGui.BeginPopupModal("Change Syncshell Password", ref _showModalChangePassword, ImGuiWindowFlags.AlwaysAutoResize)) + { + UiShared.TextWrapped("Enter the new Syncshell password for Syncshell " + name + " here."); + UiShared.TextWrapped("This action is irreversible"); + ImGui.InputTextWithHint("##changepw", "New password for " + name, ref _newSyncShellPassword, 255); + if (ImGui.Button("Change password")) + { + var pw = _newSyncShellPassword; + _isPasswordValid = _apiController.ChangeGroupPassword(entry.GID, pw).Result; + _newSyncShellPassword = string.Empty; + if (_isPasswordValid) _showModalChangePassword = false; + } + + if (!_isPasswordValid) + { + UiShared.ColorTextWrapped("The selected password is too short. It must be at least 10 characters.", new Vector4(1, 0, 0, 1)); + } + + ImGui.EndPopup(); + } + if (UiShared.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell")) { if (UiShared.CtrlPressed()) @@ -337,27 +369,6 @@ namespace MareSynchronos.UI ImGui.EndPopup(); } - - if (ImGui.BeginPopupModal("Change Syncshell Password", ref _showModalChangePassword, ImGuiWindowFlags.AlwaysAutoResize)) - { - UiShared.TextWrapped("Enter the new Syncshell password for Syncshell " + name + " here."); - UiShared.TextWrapped("This action is irreversible"); - ImGui.InputTextWithHint("##changepw", "New password for " + name, ref _newSyncShellPassword, 255); - if (ImGui.Button("Change password")) - { - var pw = _newSyncShellPassword; - _isPasswordValid = _apiController.ChangeGroupPassword(entry.GID, pw).Result; - _newSyncShellPassword = string.Empty; - if (_isPasswordValid) _showModalChangePassword = false; - } - - if (!_isPasswordValid) - { - UiShared.ColorTextWrapped("The selected password is too short. It must be at least 10 characters.", new Vector4(1, 0, 0, 1)); - } - - ImGui.EndPopup(); - } } private void DrawSyncshellPairedClient(GroupPairDto entry, bool isOwner, bool isPausedByYou) diff --git a/MareSynchronos/WebAPI/ApiController.cs b/MareSynchronos/WebAPI/ApiController.cs index ba22b0f..ac508cc 100644 --- a/MareSynchronos/WebAPI/ApiController.cs +++ b/MareSynchronos/WebAPI/ApiController.cs @@ -114,7 +114,7 @@ public partial class ApiController : IDisposable .ToDictionary(k => k.Key, k => k.Value); public string UID => _connectionDto?.UID ?? string.Empty; - public string DisplayName => string.IsNullOrEmpty(_connectionDto?.Alias) ? (_connectionDto?.UID ?? string.Empty) : _connectionDto.Alias; + public string DisplayName => _connectionDto?.UID ?? string.Empty; private string ApiUri => _pluginConfiguration.ApiUri; public int OnlineUsers => SystemInfoDto.OnlineUsers;