// Binds to a user's privileges and displays them in the UI async Task BindToPrivileges(InfluxDbUser user) { grantsListView.Items.Clear(); grantsListView.BeginUpdate(); // No need for grants if this is an admin, so disable the panel if (user.IsAdmin) { grantsListView.Enabled = false; } // Otherwise render granted privileges for the user else { grantsListView.Enabled = true; var privileges = await InfluxDbClient.GetPrivilegesAsync(user.Name); if (privileges.Count() > 0) { foreach (var p in privileges) { //Console.WriteLine("{0} => read: {1}, write: {2}, all: {3}", p.Database, p.Read, p.Write, p.All); grantsListView.Items.Add(new ListViewItem(new string[] { p.Database, user.IsAdmin || p.Privilege == InfluxDbPrivileges.Read ? RequestControl.CheckMark : null, user.IsAdmin || p.Privilege == InfluxDbPrivileges.Write ? RequestControl.CheckMark : null, user.IsAdmin || p.Privilege == InfluxDbPrivileges.All ? RequestControl.CheckMark : null, }) { Tag = p }); // Assign the privilege as tag } } } // Restore any selected privilege if (SelectedPrivilegeGrant != null) { var database = selectedPrivilegeGrant.Database; foreach (ListViewItem li in grantsListView.Items) { if (li.Text == database) { li.Selected = true; break; } } } grantsListView.EndUpdate(); }