// Binds the database drop down to the list of database for the current connection async Task BindDatabases() { // Clear current list of databases databaseComboBox.Items.Clear(); // Get the total list of databases var dbNames = await InfluxDbClient.GetDatabaseNamesAsync(); if (dbNames.Count() == 0) { return; } databaseComboBox.BeginUpdate(); foreach (var db in dbNames) { databaseComboBox.Items.Add(db); } databaseComboBox.EndUpdate(); // Select the first database databaseComboBox.SelectedIndex = 0; }
/// <summary> /// Runs the current query against the configured connection and database. /// </summary> public override async Task ExecuteRequestAsync(bool updateGrid = true) { if (InfluxDbClient == null) { throw new Exception("No InfluxDB client available."); } // Clear current listView.Items.Clear(); databaseComboBox.Items.Clear(); // If this connection specifies just one database, use it if (!string.IsNullOrWhiteSpace(InfluxDbClient.Connection.Database)) { databaseComboBox.Items.Add(InfluxDbClient.Connection.Database); } // Otherwise load the current list else { var databaseNames = await InfluxDbClient.GetDatabaseNamesAsync(); foreach (var dbName in databaseNames) { databaseComboBox.Items.Add(dbName); } } // Select default database if (SelectedDatabase == null) { databaseComboBox.SelectedIndex = 0; SelectedDatabase = databaseComboBox.Items[databaseComboBox.SelectedIndex].ToString(); } else { for (var i = 0; i < databaseComboBox.Items.Count; i++) { var database = databaseComboBox.Items[i].ToString(); if (database == SelectedDatabase) { databaseComboBox.SelectedIndex = i; break; } } } }