/// <summary>
        /// Binds the dialog to a user.
        /// </summary>
        /// <param name="user">The user to bind to.</param>
        public async Task BindToUser(InfluxDbUser user)
        {
            // Bind user details
            User = user;
            usernameValue.Text = user.Name;

            // Bind the database list
            await BindDatabases();
        }
        // 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();
        }
예제 #3
0
 /// <summary>
 /// Binds the dialog to a user.
 /// </summary>
 /// <param name="user">The user to bind to.</param>
 public void BindToUser(InfluxDbUser user)
 {
     usernameValue.Text    = user.Name;
     adminCheckBox.Checked = user.IsAdmin;
 }
예제 #4
0
 /// <summary>
 /// Binds the dialog to a user.
 /// </summary>
 /// <param name="user">The user to bind to.</param>
 public void BindToUser(InfluxDbUser user)
 {
     usernameValue.Text = user.Name;
     password.Text      = null;
 }