Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/CymaticLabs.InfluxDB.Studio/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.1.1.1" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand All @@ -27,13 +27,16 @@
<value />
</setting>
<setting name="AllowUntrustedSsl" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
<setting name="TimeFormat" serializeAs="String">
<value>hh:mm:ss tt</value>
<value>HH:mm:ss</value>
</setting>
<setting name="DateFormat" serializeAs="String">
<value>M/dd/yyyy</value>
<value>yyyy/M/d</value>
</setting>
<setting name="Precision" serializeAs="String">
<value>rfc3339</value>
</setting>
</CymaticLabs.InfluxDB.Studio.Properties.Settings>
</userSettings>
Expand Down
230 changes: 162 additions & 68 deletions src/CymaticLabs.InfluxDB.Studio/AppForm.Designer.cs

Large diffs are not rendered by default.

97 changes: 80 additions & 17 deletions src/CymaticLabs.InfluxDB.Studio/AppForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public AppForm()
// Setup container for active database connection clients
ActiveClients = new List<InfluxDbClient>();
InitializeComponent();
my_InitializeComponent();

// Create dialog windows
aboutDialog = new AboutDialog();
Expand Down Expand Up @@ -207,6 +208,48 @@ private async void showQueriesToolStripMenuItem_Click(object sender, EventArgs e
await ShowQueries(node);
}

private void hourToolStripMenuItem_Click(object sender, EventArgs e)
{
UncheckOtherToolStripMenuItems((ToolStripMenuItem)sender);
Settings.Precision = "h";
} // fin hourToolStripMenuItem_Click()

private void minuteToolStripMenuItem_Click(object sender, EventArgs e)
{
UncheckOtherToolStripMenuItems((ToolStripMenuItem)sender);
Settings.Precision = "m";
} // fin minuteToolStripMenuItem_Click()

private void secondToolStripMenuItem_Click(object sender, EventArgs e)
{
UncheckOtherToolStripMenuItems((ToolStripMenuItem)sender);
Settings.Precision = "s";
} // fin secondToolStripMenuItem_Click()

private void millisecondToolStripMenuItem_Click(object sender, EventArgs e)
{
UncheckOtherToolStripMenuItems((ToolStripMenuItem)sender);
Settings.Precision = "ms";
} // fin millisecondToolStripMenuItem_Click()

private void microsecondToolStripMenuItem_Click(object sender, EventArgs e)
{
UncheckOtherToolStripMenuItems((ToolStripMenuItem)sender);
Settings.Precision = "u";
} // fin microsecondToolStripMenuItem_Click()

private void nanosecondToolStripMenuItem_Click(object sender, EventArgs e)
{
UncheckOtherToolStripMenuItems((ToolStripMenuItem)sender);
Settings.Precision = "ns";
} // fin nanosecondToolStripMenuItem_Click()

private void rfc3339ToolStripMenuItem_Click(object sender, EventArgs e)
{
UncheckOtherToolStripMenuItems((ToolStripMenuItem)sender);
Settings.Precision = "rfc3339";
} // fin rfc3339ToolStripMenuItem_Click()

#endregion Query

#region Settings
Expand All @@ -228,7 +271,7 @@ private void timeFormatComboBox_SelectedIndexChanged(object sender, EventArgs e)
// Handles Settings -> Date Format -> change of date format
private void dateFormatComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
Settings.DateFormat = dateFormatComboBox.SelectedIndex == 0 ? AppSettings.DateFormatMonth : AppSettings.DateFormatDay;
Settings.DateFormat = (dateFormatComboBox.SelectedIndex == 0 ? AppSettings.DateFormatYear : (dateFormatComboBox.SelectedIndex == 1 ? AppSettings.DateFormatMonth : AppSettings.DateFormatDay));
}

#endregion Settings
Expand Down Expand Up @@ -846,7 +889,7 @@ async Task RefreshConnection(TreeNode node)
var client = GetClient(connection);

// Add a placeholder
var placeholderNode = CreateTreeNode("loading...", InfluxDbNodeTypes.LoadingPlacholder);
var placeholderNode = CreateTreeNode("Loading...", InfluxDbNodeTypes.LoadingPlacholder);
node.Nodes.Add(placeholderNode);

// Refresh and rerender
Expand Down Expand Up @@ -906,7 +949,7 @@ async Task CreateDatabase(TreeNode node)
newDatabaseNode.ContextMenuStrip = databaseContextMenu;

// Don't render measurement, instead include a loading place holder
var placeholderNode = CreateTreeNode("loading...", InfluxDbNodeTypes.LoadingPlacholder);
var placeholderNode = CreateTreeNode("Loading...", InfluxDbNodeTypes.LoadingPlacholder);
newDatabaseNode.Nodes.Add(placeholderNode);

connectionsTreeView.SelectedNode = newDatabaseNode;
Expand Down Expand Up @@ -1093,7 +1136,7 @@ async Task RefreshDatabase(TreeNode node)
var client = GetClient(connection);

// Add a placeholder
var placeholderNode = new TreeNode("loading...", 4, 4);
var placeholderNode = new TreeNode("Loading...", 4, 4);
node.Nodes.Add(placeholderNode);

// Refresh and rerender
Expand Down Expand Up @@ -1484,7 +1527,7 @@ void NewQuery(TreeNode node)
var queryControl = new QueryControl();
queryControl.InfluxDbClient = client;
queryControl.Database = database;
queryControl.EditorText = string.Format("SELECT * FROM \"{0}\" WHERE time > now() - 5m", measurement);
queryControl.EditorText = string.Format("SELECT * FROM \"{0}\" WHERE time > now() - 30m", measurement);

// Add a tab with a query control in it
tabControl.AddTabWithControl(connection.Name + "." + database, queryControl, Properties.Resources.RunQuery);
Expand Down Expand Up @@ -1580,16 +1623,7 @@ void ApplySettings()
}

// Set date format
if (Settings.DateFormat == AppSettings.DateFormatMonth)
{
// month-first
dateFormatComboBox.SelectedIndex = 0;
}
else
{
// day-first
dateFormatComboBox.SelectedIndex = 1;
}
dateFormatComboBox.SelectedIndex = (Settings.DateFormat == AppSettings.DateFormatYear ? 0 : (Settings.DateFormat == AppSettings.DateFormatMonth ? 1 : 2));

// Apply untrusted SSL
allowUntrustedSSLToolStripMenuItem.Checked = Settings.AllowUntrustedSsl;
Expand Down Expand Up @@ -1694,6 +1728,35 @@ bool CanRunQuery()
return tabControl.SelectedTab != null && tabControl.SelectedTab.Controls.Count > 0 && tabControl.SelectedTab.Controls[0] is RequestControl;
}

private void UncheckOtherToolStripMenuItems(ToolStripMenuItem selectedMenuItem)
{ // https://stackoverflow.com/a/13604433
selectedMenuItem.Checked = true;

// Select the other MenuItens from the ParentMenu(OwnerItens) and unchecked this,
// The current Linq Expression verify if the item is a real ToolStripMenuItem
// and if the item is a another ToolStripMenuItem to uncheck this.
foreach (var ltoolStripMenuItem in (from object
item in selectedMenuItem.Owner.Items
let ltoolStripMenuItem = item as ToolStripMenuItem
where ltoolStripMenuItem != null
where !item.Equals(selectedMenuItem)
select ltoolStripMenuItem))
(ltoolStripMenuItem).Checked = false;
} // fin UncheckOtherToolStripMenuItems()

private void my_InitializeComponent()
{
this.timeFormatComboBox.Items.AddRange(new object[] {
DateTime.Now.ToString(AppSettings.TimeFormat12Hour)+" (12 Hr)",
DateTime.Now.ToString(AppSettings.TimeFormat24Hour)+" (24 Hr)"
});
this.dateFormatComboBox.Items.AddRange(new object[] {
DateTime.Now.ToString(AppSettings.DateFormatYear)+" ("+AppSettings.DateFormatYear+")",
DateTime.Now.ToString(AppSettings.DateFormatMonth)+" ("+AppSettings.DateFormatMonth+")",
DateTime.Now.ToString(AppSettings.DateFormatDay)+" ("+AppSettings.DateFormatDay+")"
});
} // fin my_InitializeComponent()

#endregion User Interface

#region Connections
Expand Down Expand Up @@ -1797,7 +1860,7 @@ async Task RenderConnectionDetails(TreeNode connectionNode, InfluxDbConnection c
else
{
// Don't render databses, instead include a loading place holder
var placeholderNode = CreateTreeNode("loading...", InfluxDbNodeTypes.LoadingPlacholder);
var placeholderNode = CreateTreeNode("Loading...", InfluxDbNodeTypes.LoadingPlacholder);
connectionNode.Nodes.Add(placeholderNode);
}
}
Expand Down Expand Up @@ -1843,7 +1906,7 @@ async Task RenderDatabases(TreeNode connectionNode, InfluxDbClient client)
connectionNode.Nodes.Add(dbNode);

// Don't render measurement, instead include a loading place holder
var placeholderNode = CreateTreeNode("loading...", InfluxDbNodeTypes.LoadingPlacholder);
var placeholderNode = CreateTreeNode("Loading...", InfluxDbNodeTypes.LoadingPlacholder);
dbNode.Nodes.Add(placeholderNode);
}
}
Expand Down
Loading