Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/fitzchak1/ravendb

  • Loading branch information...
commit dbf60eea2996720826a107346c9b6aee0bf9db68 2 parents 9a86da4 + 7dba4bb
Ayende Rahien ayende authored
117 Raven.Studio/Commands/DeleteDocumentsCommand.cs
View
@@ -1,59 +1,60 @@
-// -----------------------------------------------------------------------
-// <copyright file="DeleteDocumentsCommand.cs" company="Hibernating Rhinos LTD">
-// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
-// </copyright>
-// -----------------------------------------------------------------------
-using System.Collections.Generic;
-using System.Linq;
-using Raven.Abstractions.Commands;
-using Raven.Studio.Features.Documents;
-using Raven.Studio.Features.Input;
-using Raven.Studio.Infrastructure;
-using Raven.Studio.Messages;
-using Raven.Studio.Models;
-
-namespace Raven.Studio.Commands
-{
- public class DeleteDocumentsCommand : ListBoxCommand<ViewableDocument>
- {
- public override void Execute(object parameter)
- {
- var documentsIds = Items
- .Select(x => x.Id)
- .ToList();
-
- AskUser.ConfirmationAsync("Confirm Delete", documentsIds.Count > 1
- ? string.Format("Are you sure you want to delete these {0} documents?", documentsIds.Count)
- : string.Format("Are you sure that you want to delete this document? ({0})", documentsIds.First()))
- .ContinueWhenTrue(() => DeleteDocuments(documentsIds))
- .ContinueWhenTrueInTheUIThread(() =>
- {
- var model = (DocumentsModel)Context;
- foreach (var document in Items)
- {
- model.Documents.Remove(document);
- }
- });
- }
-
- private void DeleteDocuments(IList<string> documentIds)
- {
- var deleteCommandDatas = documentIds.Select(id => new DeleteCommandData
- {
- Key = id
- }).ToArray();
- ApplicationModel.Current.Server.Value.SelectedDatabase.Value.AsyncDatabaseCommands.BatchAsync(deleteCommandDatas)
- .ContinueOnSuccessInTheUIThread(() =>
- {
- View.UpdateAllFromServer();
- ApplicationModel.Current.AddNotification(new Notification(documentIds.Count > 1
- ? string.Format(
- "{0} documents were deleted",
- documentIds.Count)
- : string.Format(
- "Document {0} was deleted",
- documentIds.First())));
- });
- }
- }
+// -----------------------------------------------------------------------
+// <copyright file="DeleteDocumentsCommand.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+// -----------------------------------------------------------------------
+using System.Collections.Generic;
+using System.Linq;
+using Raven.Abstractions.Commands;
+using Raven.Studio.Features.Documents;
+using Raven.Studio.Features.Input;
+using Raven.Studio.Infrastructure;
+using Raven.Studio.Messages;
+using Raven.Studio.Models;
+
+namespace Raven.Studio.Commands
+{
+ public class DeleteDocumentsCommand : ListBoxCommand<ViewableDocument>
+ {
+ public override void Execute(object parameter)
+ {
+ var documentsIds = Items
+ .Select(x => x.Id)
+ .ToList();
+
+ AskUser.ConfirmationAsync("Confirm Delete", documentsIds.Count > 1
+ ? string.Format("Are you sure you want to delete these {0} documents?", documentsIds.Count)
+ : string.Format("Are you sure that you want to delete this document? ({0})", documentsIds.First()))
+ .ContinueWhenTrue(() => DeleteDocuments(documentsIds))
+ .ContinueWhenTrueInTheUIThread(() =>
+ {
+ var model = (DocumentsModel) Context;
+ foreach (var document in Items)
+ {
+ model.Documents.Remove(document);
+ }
+ });
+ }
+
+ private void DeleteDocuments(IList<string> documentIds)
+ {
+ var deleteCommandDatas = documentIds
+ .Select(id => new DeleteCommandData{Key = id})
+ .Cast<ICommandData>()
+ .ToArray();
+
+ DatabaseCommands.BatchAsync(deleteCommandDatas)
+ .ContinueOnSuccessInTheUIThread(() => DeleteDocumentSuccess(documentIds));
+ }
+
+ private void DeleteDocumentSuccess(IList<string> documentIds)
+ {
+ View.UpdateAllFromServer();
+
+ var notification = documentIds.Count > 1
+ ? string.Format("{0} documents were deleted", documentIds.Count)
+ : string.Format("Document {0} was deleted", documentIds.First());
+ ApplicationModel.Current.AddNotification(new Notification(notification));
+ }
+ }
}
4 Raven.Studio/Features/Logs/LogsModel.cs
View
@@ -10,8 +10,6 @@
using System.Threading.Tasks;
using Raven.Abstractions.Data;
using Raven.Studio.Infrastructure;
-using Raven.Studio.Messages;
-using Raven.Studio.Models;
namespace Raven.Studio.Features.Logs
{
@@ -38,7 +36,7 @@ protected override Task LoadedTimerTickedAsync()
})
.CatchIgnore<WebException>(LogsIsNotEnabled);
}
-
+
private void LogsIsNotEnabled()
{
IsLogsEnabled = false;
5 Raven.Studio/Features/Logs/LogsView.xaml
View
@@ -85,7 +85,6 @@
</Grid.RowDefinitions>
<data:DataGrid x:Name="LogsList"
- Grid.Row="1"
AutoGenerateColumns="False"
FrozenColumnCount="1"
IsReadOnly="True"
@@ -132,14 +131,14 @@
</data:DataGrid.Columns>
</data:DataGrid>
- <sdk:GridSplitter Grid.Row="2"
+ <sdk:GridSplitter Grid.Row="1"
HorizontalAlignment="Stretch"
Style="{StaticResource Style_GridSplitter_Transparent}" />
<Border BorderBrush="#FFEAE7E4"
Background="{StaticResource Brush_SubtleBackground2}"
BorderThickness="1"
- Grid.Row="3">
+ Grid.Row="2">
<Grid DataContext="{Binding ElementName=LogsList, Path=SelectedItem}"
Visibility="{Binding ElementName=LogsList, Path=SelectedItem, Converter={StaticResource HiddenWhenNull}}">
<Grid.ColumnDefinitions>
3  Raven.Studio/Infrastructure/ModelAttacher.cs
View
@@ -45,7 +45,8 @@ private static void AttachObservableModelCallback(DependencyObject source, Depen
{
var viewModel = model as ViewModel;
if (viewModel == null) return;
- viewModel.LoadModel(UrlUtil.Url);
+ viewModel.LoadModel(UrlUtil.Url);
+ modelModel.ForceTimerTicked();
};
}
catch (Exception ex)
198 Raven.Studio/Infrastructure/UrlParser.cs
View
@@ -1,100 +1,100 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Raven.Studio.Models;
-
-namespace Raven.Studio.Infrastructure
-{
- public class UrlParser
- {
- private readonly string url;
- private string Url
- {
- get { return url; }
- }
-
- private Dictionary<string, string> queryParams;
-
- public UrlParser(string url)
- {
- this.url = url;
- }
-
- public Dictionary<string, string> QueryParams
- {
- get
- {
- if (queryParams == null)
- {
- queryParams = new Dictionary<string, string>();
- var indexOf = Url.IndexOf('?');
- if (indexOf == -1)
- return queryParams;
-
- var options = Url.Substring(indexOf + 1).Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
- foreach (var option in options)
- {
- var param = option.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
- queryParams.Add(param[0], param[1]);
- }
- }
- return queryParams;
- }
- }
-
- private string path;
- public string Path
- {
- get
- {
- if (path == null)
- {
- var indexOf = Url.IndexOf('?');
- path = indexOf != -1 ? Url.Substring(0, indexOf) : Url;
- }
- return path;
- }
- }
-
- public string GetQueryParam(string name)
- {
- if (QueryParams.ContainsKey(name))
- return QueryParams[name];
- return null;
- }
-
- public void SetQueryParam(string name, object value)
- {
- if (value == null) return;
- QueryParams[name] = value.ToString();
- }
-
- public bool RemoveQueryParam(string name)
- {
- return QueryParams.Remove(name);
- }
-
- public string BuildUrl()
- {
- EnsureDatabaseParameterIncluded();
-
- var uri = Path;
- if (string.IsNullOrWhiteSpace(uri))
- uri = "/home";
- var query = string.Join("&", QueryParams.Select(x => string.Format("{0}={1}", x.Key, x.Value)));
- if (string.IsNullOrEmpty(query) == false)
- {
- uri += "?" + query;
- }
- return uri;
- }
-
- private void EnsureDatabaseParameterIncluded()
- {
- if (GetQueryParam("database") != null)
- return;
-
- SetQueryParam("database", ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Name);
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Raven.Studio.Models;
+
+namespace Raven.Studio.Infrastructure
+{
+ public class UrlParser
+ {
+ private readonly string url;
+ private string Url
+ {
+ get { return url; }
+ }
+
+ private Dictionary<string, string> queryParams;
+
+ public UrlParser(string url)
+ {
+ this.url = url;
+ }
+
+ public Dictionary<string, string> QueryParams
+ {
+ get
+ {
+ if (queryParams == null)
+ {
+ queryParams = new Dictionary<string, string>();
+ var indexOf = Url.IndexOf('?');
+ if (indexOf == -1)
+ return queryParams;
+
+ var options = Url.Substring(indexOf + 1).Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
+ foreach (var option in options)
+ {
+ var param = option.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
+ queryParams.Add(param[0], param[1]);
+ }
+ }
+ return queryParams;
+ }
+ }
+
+ private string path;
+ public string Path
+ {
+ get
+ {
+ if (path == null)
+ {
+ var indexOf = Url.IndexOf('?');
+ path = indexOf != -1 ? Url.Substring(0, indexOf) : Url;
+ }
+ return path;
+ }
+ }
+
+ public string GetQueryParam(string name)
+ {
+ if (QueryParams.ContainsKey(name))
+ return QueryParams[name];
+ return null;
+ }
+
+ public void SetQueryParam(string name, object value)
+ {
+ if (value == null) return;
+ QueryParams[name] = value.ToString();
+ }
+
+ public bool RemoveQueryParam(string name)
+ {
+ return QueryParams.Remove(name);
+ }
+
+ public string BuildUrl()
+ {
+ EnsureDatabaseParameterIncluded();
+
+ var uri = Path;
+ if (string.IsNullOrWhiteSpace(uri))
+ uri = "/home";
+ var query = string.Join("&", QueryParams.Select(x => string.Format("{0}={1}", x.Key, x.Value)));
+ if (string.IsNullOrEmpty(query) == false)
+ {
+ uri += "?" + query;
+ }
+ return uri;
+ }
+
+ private void EnsureDatabaseParameterIncluded()
+ {
+ if (GetQueryParam("database") != null)
+ return;
+
+ SetQueryParam("database", ApplicationModel.Database.Value.Name);
+ }
+ }
}
2  Raven.Studio/Infrastructure/ViewModel.cs
View
@@ -41,7 +41,7 @@ protected virtual Task LoadedTimerTickedAsync()
return null;
}
- public Observable<DatabaseModel> Database {get { return ApplicationModel.Current.Server.Value.SelectedDatabase; }}
+ public Observable<DatabaseModel> Database {get { return ApplicationModel.Database; }}
public IAsyncDatabaseCommands DatabaseCommands
{
2  Raven.Studio/Models/AllDocumentsModel.cs
View
@@ -10,7 +10,7 @@ static AllDocumentsModel()
Documents = new Observable<DocumentsModel>();
Documents.Value = new DocumentsModel();
SetTotalResults();
- ApplicationModel.Current.Server.Value.SelectedDatabase.PropertyChanged += (sender, args) => SetTotalResults();
+ ApplicationModel.Database.PropertyChanged += (sender, args) => SetTotalResults();
}
private static void SetTotalResults()
2  Raven.Studio/Models/DatabasesListModel.cs
View
@@ -23,7 +23,7 @@ public BindableCollection<DatabaseModel> Databases
private DatabaseModel selectedDatabase;
public DatabaseModel SelectedDatabase
{
- get { return selectedDatabase ?? (selectedDatabase = ApplicationModel.Current.Server.Value.SelectedDatabase.Value); }
+ get { return selectedDatabase ?? (selectedDatabase = ApplicationModel.Database.Value); }
set
{
selectedDatabase = value;
Please sign in to comment.
Something went wrong with that request. Please try again.