ui adjustments for groups

This commit is contained in:
Stanley Dimant
2022-10-03 00:20:49 +02:00
parent fd23a977ac
commit fcb0b17a56
4 changed files with 42 additions and 31 deletions

Submodule MareAPI updated: bab758f173...a2a4d07c04

View File

@@ -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);

View File

@@ -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)

View File

@@ -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;