Skip to content

Commit

Permalink
Preparing v0.7-beta (#19)
Browse files Browse the repository at this point in the history
* Show Query Metrics per partition

* Better memory management

* Start the application maximized

* Handle exceptions on CollectionMetrics not loading correctly

* Renamed project folder

* Index editor (#17)

* Add UI Editor for Indexing Policy

* Execute storeproc (#18)

Fix #5 Execute Stored Procedure

* Fix issue with new Asset Node creating in multiple collection

* Fix issue with Reset Query Options

* Add more information to Metrics

* Close Tab when deleting on the treeview
  • Loading branch information
sachabruttin committed Apr 23, 2018
1 parent 1609d60 commit ec81606
Show file tree
Hide file tree
Showing 185 changed files with 2,717 additions and 702 deletions.
2 changes: 1 addition & 1 deletion src/CosmosDbExplorer.sln
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CosmosDbExplorer", "DocumentDbExplorer\CosmosDbExplorer.csproj", "{5AF0B2F1-B905-46CF-B493-71B1950A96A4}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CosmosDbExplorer", "CosmosDbExplorer\CosmosDbExplorer.csproj", "{5AF0B2F1-B905-46CF-B493-71B1950A96A4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{14B2F32C-93E0-4831-8D9B-79E59F5AD256}"
ProjectSection(SolutionItems) = preProject
Expand Down
File renamed without changes.
File renamed without changes.
162 changes: 143 additions & 19 deletions src/DocumentDbExplorer/App.xaml → src/CosmosDbExplorer/App.xaml

Large diffs are not rendered by default.

File renamed without changes.
Expand Up @@ -40,6 +40,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -52,7 +53,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>cosmos-db.ico</ApplicationIcon>
<ApplicationIcon>astronaut.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>9F62A3926A5B227285B516DBEC4075DCACB56EC9</ManifestCertificateThumbprint>
Expand Down Expand Up @@ -127,6 +128,22 @@
<HintPath>..\packages\System.ComponentModel.Primitives.4.3.0\lib\net45\System.ComponentModel.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Reactive.Core, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Linq, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.PlatformServices, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Windows.Threading, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -183,6 +200,8 @@
<Compile Include="Infrastructure\Converters\BytesToGigaBytesConverter.cs" />
<Compile Include="Infrastructure\Converters\ColorToBrushConverter.cs" />
<Compile Include="Infrastructure\Converters\NullToEnabledConverter.cs" />
<Compile Include="Infrastructure\Converters\QueryMetricsToDocumentConverter.cs" />
<Compile Include="Infrastructure\Converters\QueryMetricsToStringConverter.cs" />
<Compile Include="Infrastructure\Extensions\ListExtensions.cs" />
<Compile Include="Infrastructure\JsonHelpers\DocumentDbWithoutSystemPropertyResolver.cs" />
<Compile Include="Infrastructure\JsonHelpers\OrderedDictionaryConverter.cs" />
Expand All @@ -195,6 +214,7 @@
<Compile Include="Infrastructure\Models\Author.cs" />
<Compile Include="Infrastructure\Models\CollectionMetrics.cs" />
<Compile Include="Infrastructure\Models\UIViewModelBase.cs" />
<Compile Include="Infrastructure\RadioButtonEx.cs" />
<Compile Include="Infrastructure\TemplateSelectors\DocumentDescriptionTemplateSelector.cs" />
<Compile Include="Infrastructure\Extensions\DocumentClientExceptionExtension.cs" />
<Compile Include="Infrastructure\Extensions\NameValueCollectionExtensions.cs" />
Expand All @@ -204,7 +224,9 @@
<Compile Include="Infrastructure\Models\PaneViewModel.cs" />
<Compile Include="Infrastructure\Models\StatusBarItemType.cs" />
<Compile Include="Infrastructure\TemplateSelectors\StatusBarItemTemplateSelector.cs" />
<Compile Include="Infrastructure\ValidationTemplate.cs" />
<Compile Include="Infrastructure\TemplateSelectors\StoredProcParameterTemplateSelector.cs" />
<Compile Include="Infrastructure\Validar\ValidationFactory.cs" />
<Compile Include="Infrastructure\Validar\ValidationTemplate.cs" />
<Compile Include="Infrastructure\Models\WindowViewModelBase.cs" />
<Compile Include="Infrastructure\RelayCommand.cs" />
<Compile Include="Infrastructure\TemplateSelectors\TabContentTemplateSelector.cs" />
Expand Down Expand Up @@ -260,6 +282,10 @@
<Compile Include="ViewModel\DatabaseViewModel.cs" />
<Compile Include="ViewModel\DatabaseNodes\DocumentNodeViewModel.cs" />
<Compile Include="ViewModel\DocumentsTabViewModel.cs" />
<Compile Include="ViewModel\Indexes\ExcludedPathViewModel.cs" />
<Compile Include="ViewModel\Indexes\IncludedPathViewModel.cs" />
<Compile Include="ViewModel\Indexes\IndexingPolicyViewModel.cs" />
<Compile Include="ViewModel\Indexes\IndexViewModel.cs" />
<Compile Include="ViewModel\Interfaces\IAssetTabCommand.cs" />
<Compile Include="ViewModel\Interfaces\ICanRefreshTab.cs" />
<Compile Include="ViewModel\Interfaces\IHaveQuerySettings.cs" />
Expand All @@ -276,6 +302,7 @@
<Compile Include="ViewModel\Assets\TriggerTabViewModel.cs" />
<Compile Include="ViewModel\Assets\UserDefFuncTabViewModel.cs" />
<Compile Include="ViewModel\PermissionEditViewModel.cs" />
<Compile Include="ViewModel\Assets\StoredProcParameterViewModel.cs" />
<Compile Include="ViewModel\UserEditViewModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="Views\AboutView.xaml.cs">
Expand Down Expand Up @@ -450,9 +477,6 @@
<ItemGroup>
<Resource Include="Images\loading.gif" />
</ItemGroup>
<ItemGroup>
<Resource Include="DocumentDB.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7">
<Visible>False</Visible>
Expand All @@ -466,7 +490,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="cosmos-db.ico" />
<Resource Include="astronaut.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
Expand Up @@ -16,5 +16,10 @@ public static class Default
public const string Trigger = "function trigger(){}";
public const string UserDefiniedFunction = "function userDefinedFunction(){}";
}

public static class Validation
{
public const string PathRegex = @"^\/[\*]?$|^\/(\w*\/|\[\]\/)+[\*\?]$";
}
}
}
@@ -0,0 +1,26 @@
using System;
using System.Globalization;
using System.Windows.Data;
using ICSharpCode.AvalonEdit.Document;
using Microsoft.Azure.Documents;

namespace CosmosDbExplorer.Infrastructure.Converters
{
public class QueryMetricsToDocumentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is QueryMetrics metrics)
{
return new TextDocument(metrics.ToString());
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,25 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Microsoft.Azure.Documents;

namespace CosmosDbExplorer.Infrastructure.Converters
{
public class QueryMetricsToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is QueryMetrics metrics)
{
return metrics.ToString();
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Expand Up @@ -37,9 +37,13 @@ public EnumBindingSourceExtension(Type enumType)

public override object ProvideValue(IServiceProvider serviceProvider)
{
//if (_enumType == null)
//{
// throw new InvalidOperationException("The EnumType must be specified.");
//}
if (_enumType == null)
{
throw new InvalidOperationException("The EnumType must be specified.");
return null;
}

var actualEnumType = Nullable.GetUnderlyingType(_enumType) ?? _enumType;
Expand Down
50 changes: 50 additions & 0 deletions src/CosmosDbExplorer/Infrastructure/Models/CollectionMetrics.cs
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;

namespace CosmosDbExplorer.Infrastructure.Models
{
public class CollectionMetric
{
public CollectionMetric(ResourceResponse<DocumentCollection> documentCollection)
{
var quotaUsage = documentCollection.CurrentResourceQuotaUsage
.Split(';')
.Select(item => new { Key = item.Split('=')[0], Value = item.Split('=')[1] })
.ToDictionary(d => d.Key, d => d.Value);

RequestCharge = documentCollection.RequestCharge;
PartitionCount = documentCollection.Resource.PartitionKeyRangeStatistics.Count;
DocumentSize = long.Parse(quotaUsage["documentsSize"]);
DocumentCount = long.Parse(quotaUsage["documentsCount"]);
PartitionMetrics = documentCollection.Resource.PartitionKeyRangeStatistics.ToList();
CollectionSizeQuota = documentCollection.CollectionSizeQuota;
CollectionSizeUsage = documentCollection.CollectionSizeUsage;
StoredProceduresQuota = documentCollection.StoredProceduresQuota;
StoredProceduresUsage = documentCollection.StoredProceduresUsage;
TriggersQuota = documentCollection.TriggersQuota;
TriggersUsage = documentCollection.TriggersUsage;
UserDefinedFunctionsQuota = documentCollection.UserDefinedFunctionsQuota;
UserDefinedFunctionsUsage = documentCollection.UserDefinedFunctionsUsage;
}

public double RequestCharge { get; }
public int PartitionCount { get; }
public long DocumentCount { get; }
public long DocumentSize { get; }
public List<PartitionKeyRangeStatistics> PartitionMetrics { get; }
public long CollectionSizeQuota { get; }
public long CollectionSizeUsage { get; }
public long StoredProceduresQuota { get; }
public long StoredProceduresUsage { get; }
public long TriggersQuota { get; }
public long TriggersUsage { get; }
public long UserDefinedFunctionsQuota { get; }
public long UserDefinedFunctionsUsage { get; }
public bool HasPartitionKey { get; }
}
}
Expand Up @@ -5,10 +5,11 @@
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Threading;
using Microsoft.Azure.Documents;
using PropertyChanged;

namespace CosmosDbExplorer.Infrastructure.Models
{
public abstract class PaneViewModelBase: UIViewModelBase
public abstract class PaneViewModelBase : UIViewModelBase
{
private RelayCommand _closeCommand;
private readonly StatusBarItem _pathStatusBarItem;
Expand All @@ -22,32 +23,44 @@ protected PaneViewModelBase(IMessenger messenger, IUIServices uiServices)
_uiServices = uiServices;
}

[DoNotSetChanged]
public string Title { get; set; }

[DoNotSetChanged]
public string ToolTip { get; set; }

public virtual void OnToolTipChanged()
{
_pathStatusBarItem.DataContext.Value = ToolTip;
}

[DoNotSetChanged]
public string Header { get; set; }

[DoNotSetChanged]
public string ContentId { get; protected set; }

[DoNotSetChanged]
public bool IsSelected { get; set; }

[DoNotSetChanged]
public bool IsActive { get; set; }

[DoNotSetChanged]
public bool IsClosed { get; set; }

public virtual void OnIsActiveChanged()
{
DispatcherHelper.RunAsync(() => MessengerInstance.Send(new ActivePaneChangedMessage(this)));
}

[DoNotSetChanged]
public ObservableCollection<StatusBarItem> StatusBarItems { get; protected set; } = new ObservableCollection<StatusBarItem>();

[DoNotSetChanged]
public object IconSource { get; set; }

[DoNotSetChanged]
public Color? AccentColor { get; set; }

public RelayCommand CloseCommand
Expand All @@ -61,12 +74,14 @@ public RelayCommand CloseCommand

protected virtual bool CanClose()
{
return true;
return !IsClosed;
}

protected virtual void OnClose()
{
MessengerInstance.Send(new CloseDocumentMessage(this));
Cleanup();
IsClosed = true;
}
}

Expand All @@ -91,6 +106,7 @@ protected PaneWithZoomViewModel(IMessenger messenger, IUIServices uiServices)
StatusBarItems.Add(new StatusBarItem(new StatusBarItemContext { Value = this, IsVisible = true }, StatusBarItemType.Zoom, "Zoom", System.Windows.Controls.Dock.Right));
}

[DoNotSetChanged]
public double Zoom { get; set; } = 0.5;
}

Expand All @@ -101,6 +117,7 @@ protected ToolViewModel(IMessenger messenger, IUIServices uiServices)
{
}

[DoNotSetChanged]
public bool IsVisible { get; set; }
}
}
Expand Up @@ -2,6 +2,7 @@
using CosmosDbExplorer.Services;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using PropertyChanged;

namespace CosmosDbExplorer.Infrastructure.Models
{
Expand All @@ -10,15 +11,16 @@ public abstract class UIViewModelBase : ViewModelBase
{
private readonly IUIServices _uiServices;

protected UIViewModelBase(IMessenger messenger, IUIServices uiServices)
protected UIViewModelBase(IMessenger messenger, IUIServices uiServices)
: base(messenger)
{
_uiServices = uiServices;
}

[DoNotSetChanged]
public bool IsBusy { get; set; }

protected void OnIsBusyChanged()
protected virtual void OnIsBusyChanged()
{
_uiServices.SetBusyState(IsBusy);
}
Expand Down

0 comments on commit ec81606

Please sign in to comment.