Browse files

Merge branch 'dev' of github.com:/EventStore/EventStore into dev

  • Loading branch information...
2 parents 94666cf + 67e303f commit 0ad4298031e711b8b67e05c119fde399a6786389 @TarasRoshko TarasRoshko committed Nov 13, 2012
View
125 src/EventStore/EventStore.SingleNode.Web/singlenode-web/delete-projection.htm
@@ -20,29 +20,28 @@
</div>
</div>
<div class="control-group">
- <label class="control-label" for="raw_state">
+ <label class="control-label" for="projection-state">
<strong>State</strong></label>
<div class="controls">
- <div id="raw_state">
+ <div id="projection-state">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="source">
<strong>Source</strong></label>
<div class="controls">
- <pre id="source" style="font-family: consolas, 'courier new'; width: 400px; height: 200px;"
- class="span5"></pre>
+ <textarea disabled="disabled" id="source" ></textarea>
</div>
</div>
<div class="control-group">
<div class="controls" id="delete-container">
- <div>
+ <label class="checkbox">
<input type="checkbox" id="delete-checkpoint-stream-checkbox" disabled="disabled">Delete Checkpoint Stream
- </div>
- <div>
+ </label>
+ <label class="checkbox">
<input type="checkbox" id="delete-state-stream-checkbox" disabled="disabled">Delete State Stream
- </div>
+ </label>
<div>
<button id="delete-button" class="btn btn-success">
Confirm Delete</button>
@@ -58,59 +57,43 @@
<script type="text/javascript">
- (function () {
+ (function() {
var projectionStatusUrl = "";
- function success(data, status, xhr) {
- var projection = data.projections[0];
- }
-
- function successDeleteProjection(data, status, xhr) {
- window.location = "view-projection.htm#" + projectionStatusUrl;
- }
-
- function error(xhr, status) {
- delayedRequestProjection();
- }
-
- function successState(data, status, xhr) {
- $("#raw_state").text(JSON.stringify(data));
- }
+ $(function() {
+ $.templates("editSourceTemplate", "#editSourceTemplate");
+ projectionStatusUrl = location.hash.substr(1);
- function errorState(xhr, status) {
- delayedRequestProjectionState();
- }
+ $('#delete-button').click(function() {
- function successSource(data, status, xhr) {
- $("#source").text(data);
- }
-
- function errorSource(xhr, status) {
- delayedRequestProjectionSource();
- }
+ var params = $.param({
+ deleteCheckpointStream: $("#delete-checkpoint-stream-checkbox").attr("checked") ? "yes" : "no",
+ deleteStateStream: $("#delete-state-stream-checkbox").attr("checked") ? "yes" : "no",
+ });
+ var url = projectionStatusUrl + "?" + params;
- function delayedRequestProjection() {
- setTimeout(requestProjection, 1000);
- }
+ $.ajax(url, {
+ headers: {
+ Accept: "application/json",
+ },
+ type: "DELETE",
+ success: successDeleteProjection,
+ error: function(xhr) {
+ var msg = es.util.formatError("Couldn't delete projection", xhr);
+ alert(msg);
+ }
+ });
+ });
- function delayedRequestProjectionState() {
- setTimeout(requestProjectionState, 1000);
- }
+ requestProjectionState();
+ requestProjectionSource();
- function delayedRequestProjectionSource() {
- setTimeout(requestProjectionSource, 1000);
- }
+ function successDeleteProjection(data, status, xhr) {
+ window.document.location = "projections.htm";
+ }
+ });
- function requestProjection() {
- $.ajax(projectionStatusUrl + "/statistics", {
- headers: {
- Accept: "application/json",
- },
- success: success,
- error: error
- });
- }
function requestProjectionState() {
$.ajax(projectionStatusUrl + "/state", {
@@ -120,6 +103,14 @@
success: successState,
error: errorState
});
+
+ function successState(data, status, xhr) {
+ $("#projection-state").text(JSON.stringify(data));
+ }
+
+ function errorState(xhr, status) {
+ setTimeout(requestProjectionState, 1000);
+ }
}
function requestProjectionSource() {
@@ -131,32 +122,16 @@
success: successSource,
error: errorSource
});
- }
- $(function () {
- $.templates("editSourceTemplate", "#editSourceTemplate");
- projectionStatusUrl = location.hash.substr(1);
+ function successSource(data, status, xhr) {
+ $("#source").text(data);
+ }
- $('#delete-button').click(function () {
- $.ajax(projectionStatusUrl + "?" + $.param({
- deleteCheckpointStream: $("#delete-checkpoint-stream-checkbox").attr("checked") ? "yes" : "no",
- deleteStateStream: $("#delete-state-stream-checkbox").attr("checked") ? "yes" : "no",
- }), {
- headers: {
- Accept: "application/json",
- },
-
-
- type: "DELETE",
- success: successDeleteProjection,
- error: function () { alert("Failed!"); }
- });
- });
+ function errorSource(xhr, status) {
+ setTimeout(requestProjectionSource, 1000);
+ }
+ }
- requestProjection();
- requestProjectionState();
- requestProjectionSource();
- });
})();
</script>
View
129 src/EventStore/EventStore.SingleNode.Web/singlenode-web/edit-projection-source.htm
@@ -14,26 +14,19 @@
<h1>
Edit Projection Source</h1>
<div class="form-horizontal">
- <div class="row">
- <div class="span12">
- <div id="projection-status">
- </div>
- </div>
- </div>
<div class="control-group">
- <label class="control-label" for="raw_state">
+ <label class="control-label" for="projection-state">
<strong>State</strong></label>
<div class="controls">
- <div id="raw_state">
+ <div id="projection-state">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="source">
<strong>Source</strong></label>
<div class="controls">
- <textarea rows="20" cols="100" id="source" style="font-family: consolas, 'courier new';"
- class="span5"></textarea>
+ <textarea id="source" ></textarea>
</div>
</div>
<div class="control-group">
@@ -42,16 +35,6 @@
Update</button>
</div>
</div>
- <div class="control-group">
- <label class="control-label" for="raw_data">
- <strong>Log:</strong></label>
- <div class="controls">
- <div id="raw_data" style="display: none; font-family: consolas, 'courier new';">
- </div>
- <div id="debug" style="display: none;">
- </div>
- </div>
- </div>
</div>
<script id="r-body">
@@ -65,55 +48,29 @@
var projectionStatusUrl = "";
- function success(data, status, xhr) {
- var projection = data.projections[0];
- }
-
- function successUpdateSource(data, status, xhr) {
- window.location = "view-projection.htm#" + projectionStatusUrl;
- }
-
- function error(xhr, status) {
- delayedRequestProjection();
- }
-
- function successState(data, status, xhr) {
- $("#raw_state").text(JSON.stringify(data));
- }
-
- function errorState(xhr, status) {
- delayedRequestProjectionState();
- }
-
- function successSource(data, status, xhr) {
- $("#source").text(data);
- }
-
- function errorSource(xhr, status) {
- delayedRequestProjectionSource();
- }
-
- function delayedRequestProjection() {
- setTimeout(requestProjection, 1000);
- }
-
- function delayedRequestProjectionState() {
- setTimeout(requestProjectionState, 1000);
- }
+ $(function() {
+ $.templates("editSourceTemplate", "#editSourceTemplate");
+ projectionStatusUrl = location.hash.substr(1);
- function delayedRequestProjectionSource() {
- setTimeout(requestProjectionSource, 1000);
- }
+ $('#update-button').click(function(ev) {
+ $.ajax(projectionStatusUrl + "/query", {
+ headers: {
+ Accept: "application/json",
+ },
- function requestProjection() {
- $.ajax(projectionStatusUrl + "/statistics", {
- headers: {
- Accept: "application/json",
- },
- success: success,
- error: error
+ type: "PUT",
+ data: $("#source").val(),
+ success: successUpdateSource,
+ error: function(xhr) {
+ var msg = es.util.formatError("Couldn't delete projection", xhr);
+ alert(msg);
+ }
+ });
});
- }
+
+ requestProjectionState();
+ requestProjectionSource();
+ });
function requestProjectionState() {
$.ajax(projectionStatusUrl + "/state", {
@@ -123,6 +80,15 @@
success: successState,
error: errorState
});
+
+ function successState(data, status, xhr) {
+ var state = JSON.stringify(data);
+ $("#projection-state").text(state);
+ }
+
+ function errorState(xhr, status) {
+ setTimeout(requestProjectionState, 1000);
+ }
}
function requestProjectionSource() {
@@ -134,29 +100,20 @@
success: successSource,
error: errorSource
});
- }
- $(function() {
- $.templates("editSourceTemplate", "#editSourceTemplate");
- projectionStatusUrl = location.hash.substr(1);
+ function successSource(data, status, xhr) {
+ $("#source").text(data);
+ }
- $('#update-button').click(function() {
- $.ajax(projectionStatusUrl + "/query", {
- headers: {
- Accept: "application/json",
- },
-
- type: "PUT",
- data: $("#source").val(),
- success: successUpdateSource,
- error: function() { alert("Failed!"); }
- });
- });
+ function errorSource(xhr, status) {
+ setTimeout(requestProjectionSource, 1000);
+ }
+ }
- requestProjection();
- requestProjectionState();
- requestProjectionSource();
- });
+ function successUpdateSource(data, status, xhr) {
+ window.location = "view-projection.htm#" + projectionStatusUrl;
+ }
+
})();
</script>
View
14 src/EventStore/EventStore.SingleNode.Web/singlenode-web/js/es.chartsSetup.js
@@ -28,12 +28,7 @@ $(function () {
function error(xhr, status, err) {
if (unloading)
return;
- var msg;
-
- if (xhr.status === 0)
- msg = "cannot connect to server";
- else
- msg = "error: " + err;
+ var msg = es.util.formatError("Couldn't build charts.", xhr);
$(".error").text(msg).show();
};
@@ -130,6 +125,13 @@ $(function () {
$(".error").hide();
publishNewStat(data);
}
+
+ function error(xhr, status, err) {
+ if (unloading)
+ return;
+ var msg = es.util.formatError("Couldn't update charts.", xhr);
+ $(".error").text(msg).show();
+ }
function publishNewStat(stat) {
$(document).trigger(newDataEvent, [stat]);
View
2 src/EventStore/EventStore.SingleNode.Web/singlenode-web/js/es.menu.js
@@ -1,4 +1,4 @@
-es.utils.loadMenu([
+es.util.loadMenu([
{ "name": "Home", "link": "home.htm", "class": "" },
{ "name": "Projections", "link": "projections.htm", "class": "" },
{ "name": "New Projection", "link": "new-projection.htm", "class": "" },
View
28 src/EventStore/EventStore.SingleNode.Web/singlenode-web/new-projection.htm
@@ -18,14 +18,14 @@
<label class="control-label" for="name">
<strong>Name</strong></label>
<div class="controls">
- <input id="name" type="text" class="span4" />
+ <input id="name" type="text" />
</div>
</div>
<div class="control-group">
- <label class="control-label" for="query">
+ <label class="control-label" for="source">
<strong>Source</strong></label>
<div class="controls">
- <textarea id="query" cols="80" rows="20" class="span5">
+ <textarea id="source">
fromAll().whenAny(function(state,event) { return state; });
</textarea>
</div>
@@ -34,7 +34,7 @@
<label class="control-label" for="mode">
<strong>Select Mode</strong></label>
<div class="controls">
- <select id="mode" class="span4">
+ <select id="mode" >
<option selected="selected" value="onetime">One-Time</option>
<option value="adhoc">Ad-Hoc</option>
<option value="continuous">Continuous</option>
@@ -48,8 +48,6 @@
Post</button>
</div>
</div>
- <div id="log">
- </div>
</div>
<div>
@@ -67,21 +65,25 @@
<script type="text/javascript">
$(function(){
$("#post").click(function () {
- function on_posted(data, textStatus, jqXHR) {
- var statusUrl = jqXHR.getResponseHeader('Location');
- $('#log').append("<a href='" + statusUrl + "'>" + statusUrl + "</a>");
- window.location = "view-projection.htm#" + statusUrl;
- }
+
var name = $("#name").val();
$.ajax("/projections/" + $("#mode").val() + (name == "" ? "" : "?name=" + name), {
headers: {
Accept: "application/json",
},
- data: $('#query').val(),
+ data: $('#source').val(),
type: 'POST',
success: on_posted,
- error: function () { alert('error'); }
+ error: function (xhr) {
+ var msg = es.util.formatError("Couldn't create new projection.", xhr);
+ alert(msg);
+ }
});
+
+ function on_posted(data, textStatus, jqXHR) {
+ var statusUrl = jqXHR.getResponseHeader('Location');
+ window.location = "view-projection.htm#" + statusUrl;
+ }
});
});
</script>
View
34 src/EventStore/EventStore.SingleNode.Web/singlenode-web/post-standard-projection.htm
@@ -18,14 +18,14 @@
<label class="control-label" for="name">
<strong>Name</strong></label>
<div class="controls">
- <input id="name" type="text" class="span4" />
+ <input id="name" type="text" />
</div>
</div>
<div class="control-group">
- <label class="control-label" for="query">
+ <label class="control-label" for="source">
<strong>Source</strong></label>
<div class="controls">
- <textarea id="query" cols="80" rows="20" class="span5"></textarea>
+ <textarea id="source" ></textarea>
</div>
</div>
<div class="control-group">
@@ -60,22 +60,26 @@
<script>
$(function(){
$('#post').click(function () {
+
+ var name = $("#name").val();
+ $.ajax("/projections/persistent?name=" + name + "&type=" + encodeURIComponent($("#type").val()), {
+ headers: {
+ Accept: "application/json",
+ "Content-Type": "text/plain",
+ },
+ data: $('#source').val(),
+ type: 'POST',
+ success: on_posted,
+ error: function(xhr) {
+ var msg = es.util.formatError("Couldn't create new projection.", xhr);
+ alert(msg);
+ }
+ });
+
function on_posted(data, textStatus, jqXHR) {
var statusUrl = jqXHR.getResponseHeader('Location');
- $('#log').append("<a href='" + statusUrl + "'>" + statusUrl + "</a>");
window.location = "view-projection.htm#" + statusUrl;
}
- var name = $("#name").val();
- $.ajax("/projections/persistent?name=" + name + "&type=" + encodeURIComponent($("#type").val()), {
- headers: {
- Accept: "application/json",
- "Content-Type": "text/plain",
- },
- data: $('#query').val(),
- type: 'POST',
- success: on_posted,
- error: function () { alert('error'); }
- });
});
});
</script>
View
129 src/EventStore/EventStore.SingleNode.Web/singlenode-web/projections.htm
@@ -33,6 +33,20 @@
<div id="content">
<h1>
Projections</h1>
+ <div class="row">
+ <div class="span12">
+ <div id="commands-container">
+ <ul style="display: inline;">
+ <li><a id="command-disable-all">
+ <img src="/web/es/img/stop_btn.png" title="Disable & Stop All" alt="Disable & Stop All" /> Disable & Stop All
+ </a></li>
+ <li><a id="command-enable-all">
+ <img src="/web/es/img/start_btn.png" title="Enable & Start All" alt="Enable & Start All" /> Enable & Start All</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
<table class="table table-bordered table-striped">
<thead>
<tr>
@@ -102,37 +116,88 @@
es.tmpl.renderBody();
</script>
</div>
-
-
-
<script type="text/javascript">
(function() {
- function success(data, status, xhr) {
+ $(function() {
- data.projections.sort(function(a, b) {
- return a.name.localeCompare(b.name);
- });
+ requestList();
- /*$("#raw_data").text(JSON.stringify(data));*/
- $.templates("projectionTemplate", "#projectionTemplate");
+ $("#command-disable-all").click(onDisableAll);
+ $("#command-enable-all").click(onEnableAll);
+
+ function onDisableAll(ev) {
+ ev.preventDefault();
- $("#projections").html(
- $.render.projectionTemplate(data.projections, {})
- );
+ postToEachProjection("/command/disable");
- delayedRequestList();
- }
+ return false;
+ }
+
+ function onEnableAll(ev) {
+ ev.preventDefault();
- function error(xhr, status) {
- delayedRequestList();
- }
+ postToEachProjection("/command/enable");
- function delayedRequestList() {
- setTimeout(requestList, 1000);
- }
+ return false;
+ }
+
+ function postToEachProjection(relativeUrl) {
+ $.ajax("/projections/any", {
+ headers: {
+ Accept: "application/json",
+ },
+ success: success,
+ error: error
+ });
+
+ function success(data, status, xhr) {
+
+ var errors = [];
+ var ajaxes = [];
+
+ $.each(data.projections, function(i,projection) {
+ ajaxes.push(disableProjection(projection, errors));
+ });
+ $.when.apply($, ajaxes)
+ .then(function() {
+ if (errors.length === 0)
+ return;
+
+ var errorText = "There was some errors:\r\n" + errors.join('\r\n');
+ alert(errorText);
+ });
+
+ function disableProjection(projection, errors) {
+ var ajax = $.ajax(projection.statusUrl + relativeUrl, {
+ headers: {
+ Accept: "application/json",
+ },
+ type: "POST",
+ success: function() {
+ },
+ error: function(xhr, status, error) {
+ var err = es.util.formatError("Error when posting to projection '" + projection.name + "'", xhr);
+ errors.push(err);
+ }
+ });
+
+ // make fails look like success to wait for them and show all errors at once
+ var newDfd = $.Deferred();
+ ajax.always(newDfd.resolve);
+ return newDfd.promise();
+ }
+ }
+
+ function error(xhr) {
+ var msg = es.util.formatError("Couldn't get projections list.", xhr);
+ alert(msg);
+ }
+ }
+ });
+
function requestList() {
$.ajax("/projections/any", {
headers: {
@@ -141,12 +206,28 @@
success: success,
error: error
});
- }
- $(function() {
- requestList();
- });
+ function success(data, status, xhr) {
+
+ data.projections.sort(function(a, b) {
+ return a.name.localeCompare(b.name);
+ });
+
+ $.templates("projectionTemplate", "#projectionTemplate");
+ $("#projections").html(
+ $.render.projectionTemplate(data.projections, {
+ encode: window.encodeURIComponent
+ })
+ );
+
+ setTimeout(requestList, 1000);
+ }
+
+ function error(xhr, status) {
+ setTimeout(requestList, 1000);
+ }
+ }
})();
</script>
</body>
View
328 src/EventStore/EventStore.SingleNode.Web/singlenode-web/view-projection.htm
@@ -17,42 +17,54 @@
<div class="span12">
<div id="commands-container">
<ul style="display: inline;">
- <li style="display: inline;" id="edit-source-container-top"></li>
- <li style="display: inline;"><a href="#" id="commandDisable">
- <img src="/web/es/img/stop_btn.png" title="Disable" alt="Disable" /></a> </li>
- <li style="display: inline;"><a href="#" id="commandEnable">
- <img src="/web/es/img/start_btn.png" title="Enable" alt="Enable" /></a> </li>
- <li style="display: inline;" id="delete-projection-container"></li>
+ <li id="edit-source-btn-container"></li>
+ <li id="delete-projection-btn-container"></li>
+ <li id="command-disable-container"><a id="command-disable">
+ <img src="/web/es/img/stop_btn.png" title="Disable & Stop" alt="Disable & Stop" /></a> </li>
+ <li id="command-enable-container"><a id="command-enable">
+ <img src="/web/es/img/start_btn.png" title="Enable & Start" alt="Enable & Start" /></a> </li>
</ul>
</div>
</div>
</div>
<div id="projection-status">
</div>
- <script id="projectionTemplate" type="text/x-jsrender">
- <div class="row">
- <div class="span12">
- <ul class="breadcrumb">
- <li><strong> {{>name}}</strong> <span class="divider">/</span></li>
- <li><strong>Mode:</strong> {{>mode}} <span class="divider">/</span></li>
- <li><strong>Status:</strong> {{>status}} <span class="divider">/</span></li>
- </ul>
- </div>
- </div>
- </script>
<h4>
State</h4>
<div class="row ">
<div class="span12">
<div class="well">
- <div id="raw_state">
+ <div id="projection-state">
</div>
- <div id="projection-status-button">
+ <div id="projection-statistics">
</div>
</div>
</div>
</div>
- <script id="projectionTemplateButton" type="text/x-jsrender">
+ <div class="row">
+ <div class="span12">
+ <h4>
+ Source: <span id="edit-source-container"></span>
+ </h4>
+ <pre id="source" style="font-family: consolas, 'courier new';"></pre>
+ </div>
+ </div>
+ <div class="row">
+ <div class="span12" id="projection-reason">
+ </div>
+ </div>
+ <script id="statusTemplate" type="text/x-jsrender">
+ <div class="row">
+ <div class="span12">
+ <ul class="breadcrumb">
+ <li><strong> {{>name}}</strong> <span class="divider">/</span></li>
+ <li><strong>Mode:</strong> {{>mode}} <span class="divider">/</span></li>
+ <li><strong>Status:</strong> {{>status}} <span class="divider">/</span></li>
+ </ul>
+ </div>
+ </div>
+ </script>
+ <script id="statisticsTemplate" type="text/x-jsrender">
<table class="table 1table-bordered 1table-striped table-thin">
<tbody>
<tr>
@@ -73,34 +85,22 @@
</tbody>
</table>
</script>
- <div class="row">
- <div class="span12">
- <h4>
- Source: <span id="edit-source-container"></span>
- </h4>
- <pre id="source" style="font-family: consolas, 'courier new';"></pre>
- </div>
- </div>
- <div class="row">
- <div class="span12" id="projection-reason">
- </div>
- </div>
- <script id="projectionTemplateReason" type="text/x-jsrender">
+ <script id="reasonTemplate" type="text/x-jsrender">
- <h4>Reason:<h4>
+ <h4>Failure Reason:<h4>
<div class="projection-reason-data">
<pre>{{>stateReason}}</pre>
</div>
</script>
<script id="editSourceTemplate" type="text/x-jsrender">
<a href="{{>'edit-projection-source.htm#'+statusUrl}}" class="btn btn-success"><i class="icon-pencil"></i> Edit</a>
- </script>
+ </script>
<script id="deleteProjectionTemplate" type="text/x-jsrender">
- <a href="{{>'delete-projection.htm#'+statusUrl}}">[Delete]</a>
- </script>
+ <a href="{{>'delete-projection.htm#'+statusUrl}}" class="btn btn-danger"><i class="icon-remove"></i> Delete</a>
+ </script>
<script id="r-body">
- es.tmpl.renderBody();
+ es.tmpl.renderBody();
</script>
</div>
<script type="text/javascript">
@@ -109,73 +109,99 @@
var projectionStatusUrl = "";
- function success(data, status, xhr) {
- var projection = data.projections[0];
- document.title = projection.name + " - Projection Status";
- $("#raw_data").text(JSON.stringify(projection));
-
- $("#projection-status").html(
- $.render.projectionTemplate(projection, {})
- );
-
- $("#projection-status-button").html(
- $.render.projectionTemplateButton(projection, {})
- );
-
- $("#projection-reason").html(
- $.render.projectionTemplateReason(projection, {})
- );
-
-
- $("#edit-source-container").html(
- $.render.editSourceTemplate(projection)
- );
- $("#edit-source-container-top").html(
- $.render.editSourceTemplate(projection)
- );
- $("#delete-projection-container").html(
- $.render.deleteProjectionTemplate(projection)
- );
- delayedRequestProjection();
- }
+ $(function() {
+ $.templates("statusTemplate", "#statusTemplate");
+ $.templates("statisticsTemplate", "#statisticsTemplate");
+ $.templates("reasonTemplate", "#reasonTemplate");
+ $.templates("editSourceTemplate", "#editSourceTemplate");
+ $.templates("deleteProjectionTemplate", "#deleteProjectionTemplate");
- function error(xhr, status) {
- delayedRequestProjection();
- }
+ projectionStatusUrl = document.location.hash.substring(1);
- function successState(data, status, xhr) {
- if (data) {
- $("#raw_state").text(JSON.stringify(data));
+ init();
+ requestProjectionStats();
+ requestProjectionState();
+ requestProjectionSource();
+
+ $('#command-disable').click(onDisable);
+ $("#command-enable").click(onEnable);
+
+
+ function onDisable(ev) {
+ ev.preventDefault();
+
+ $.ajax(projectionStatusUrl + "/command/disable", {
+ headers: {
+ Accept: "application/json",
+ },
+ type: "POST",
+ success: successPostCommand,
+ error: function(xhr, status, error) {
+ var err = es.util.formatError("Couldn't disable projection.", xhr);
+ alert(err);
+ }
+ });
+
+ return false;
}
- delayedRequestProjectionState();
- }
- function errorState(xhr, status) {
- delayedRequestProjectionState();
- }
+ function onEnable(ev) {
+ ev.preventDefault();
- function successSource(data, status, xhr) {
- $("#source").text(data);
- delayedRequestProjectionSource();
- }
+ $.ajax(projectionStatusUrl + "/command/enable", {
+ headers: {
+ Accept: "application/json",
+ },
+ type: "POST",
+ success: successPostCommand,
+ error: function(xhr) {
+ var err = es.util.formatError("Couldn't enable projection.", xhr);
+ alert(err);
+ }
+ });
- function errorSource(xhr, status) {
- delayedRequestProjectionSource();
- }
+ return false;
+ }
+
+ function successPostCommand(data, status, xhr) {
- function delayedRequestProjection() {
- setTimeout(requestProjection, 1000);
- }
+ }
+ });
+
+ function init() {
+
+ $.ajax(projectionStatusUrl + "/statistics", {
+ cache: false,
+ headers: {
+ Accept: "application/json",
+ },
+ success: success,
+ error: error
+ });
- function delayedRequestProjectionState() {
- setTimeout(requestProjectionState, 1000);
- }
+ function success(data, status, xhr) {
+ var projection = data.projections[0];
+ document.title = projection.name + " - Projection Status";
+
+ $("#edit-source-btn-container").html(
+ $.render.editSourceTemplate(projection)
+ );
+ $("#delete-projection-btn-container").html(
+ $.render.deleteProjectionTemplate(projection)
+ );
+
+ }
- function delayedRequestProjectionSource() {
- setTimeout(requestProjectionSource, 5000);
+ function error(xhr, status) {
+ delayedRequestProjection();
+ }
+
+ function delayedRequestProjection() {
+ setTimeout(requestProjectionStats, 1000);
+ }
}
- function requestProjection() {
+ function requestProjectionStats() {
$.ajax(projectionStatusUrl + "/statistics", {
cache: false,
headers: {
@@ -184,6 +210,36 @@
success: success,
error: error
});
+
+ function success(data, status, xhr) {
+ var projection = data.projections[0];
+
+ $("#projection-status").html(
+ $.render.statusTemplate(projection)
+ );
+
+ $("#projection-statistics").html(
+ $.render.statisticsTemplate(projection)
+ );
+
+ var html = !!projection.stateReason // on disabled its undefined, on enabled its ''
+ ? $.render.reasonTemplate(projection)
+ : '';
+ $("#projection-reason").html(html);
+
+ $("#edit-source-container").html(
+ $.render.editSourceTemplate(projection)
+ );
+ delayedRequestProjection();
+ }
+
+ function error(xhr, status) {
+ delayedRequestProjection();
+ }
+
+ function delayedRequestProjection() {
+ setTimeout(requestProjectionStats, 1000);
+ }
}
function requestProjectionState() {
@@ -194,6 +250,22 @@
success: successState,
error: errorState
});
+
+ function successState(data, status, xhr) {
+ if (data) {
+ $("#projection-state").text(JSON.stringify(data));
+ }
+ delayedRequestProjectionState();
+ }
+
+ function errorState(xhr, status) {
+ delayedRequestProjectionState();
+ }
+
+ function delayedRequestProjectionState() {
+ setTimeout(requestProjectionState, 1000);
+ }
+
}
function requestProjectionSource() {
@@ -205,56 +277,32 @@
success: successSource,
error: errorSource
});
- }
-
- function successPostCommand(data, status, xhr) {
- window.location = "view-projection.htm#" + projectionStatusUrl;
- }
+ function successSource(data, status, xhr) {
+ $("#source").text(data);
+ delayedRequestProjectionSource();
+ }
- function onDisable() {
- $.ajax(projectionStatusUrl + "/command/disable", {
- headers: {
- Accept: "application/json",
- },
- type: "POST",
- success: successPostCommand,
- error: function() { alert("Failed!"); }
- });
- }
+ function errorSource(xhr, status) {
+ delayedRequestProjectionSource();
+ }
- function onEnable() {
- $.ajax(projectionStatusUrl + "/command/enable", {
- headers: {
- Accept: "application/json",
- },
- type: "POST",
- success: successPostCommand,
- error: function() { alert("Failed!"); }
- });
+ function delayedRequestProjectionSource() {
+ setTimeout(requestProjectionSource, 5000);
+ }
}
-
- $(function() {
- $.templates("projectionTemplate", "#projectionTemplate");
- $.templates("projectionTemplateButton", "#projectionTemplateButton");
- $.templates("projectionTemplateReason", "#projectionTemplateReason");
- $.templates("editSourceTemplate", "#editSourceTemplate");
- $.templates("deleteProjectionTemplate", "#deleteProjectionTemplate");
-
- projectionStatusUrl = location.hash.substr(1);
- requestProjection();
- requestProjectionState();
- requestProjectionSource();
-
- $('#commandDisable').click(onDisable);
- $("#commandEnable").click(onEnable);
-
- /* $("#projectiontab a").click(function (e) {
- e.preventDefault();
- $(this).tab('show');
- });*/
- });
-
+
+ function getUrlParam(name) {
+ name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
+ var regexS = "[\\?&]" + name + "=([^&#]*)";
+ var regex = new RegExp(regexS);
+ var results = regex.exec(window.location.search);
+ if (results == null)
+ return "";
+ else
+ return decodeURIComponent(results[1].replace(/\+/g, " "));
+ };
+
})();
</script>
</body>
View
6 src/EventStore/EventStore.Web/EventStore.Web.csproj
@@ -46,6 +46,9 @@
<Content Include="es-common-web\js\controls\es.Zoomer.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+ <Content Include="es-common-web\js\es.util.js">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
<Content Include="es-common-web\lib\bootstrap\css\bootstrap-responsive.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
@@ -103,9 +106,6 @@
<Content Include="es-common-web\js\controls\es.TimeSeries.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
- <Content Include="es-common-web\js\es.loadmenu.js">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
<Content Include="es-common-web\js\projections\es.api.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
View
118 src/EventStore/EventStore.Web/es-common-web/css/es.sitelayout.css
@@ -1,4 +1,35 @@
+body {
+ /*padding: 0;*/
+}
+
+.navbar
+{
+ /*note MM: fixes extra blank space at page bottom problem, but with small side effects*/
+ position: static !important;
+}
+
+.control_btn_wrapper {
+ display: block;
+}
+
+.control_btn_list {
+ display: inline;
+}
+
+footer {
+ width: 100%;
+ background: #d6d6d6;
+}
+
+footer p {
+ font-family: Arial;
+ font-size: 13px;
+ color: #363636;
+ margin-top: 15px;
+}
+
+
/* Typography */
h1,h2,h3,h4,h5,h6 { font-weight: normal; color: #000000; }
@@ -25,15 +56,26 @@ h6 { font-size: 1em; font-weight: bold; }
padding: 2px 8px;
}
-#projection-status-button {
+#projection-statistics {
margin-top: 10px;
margin-bottom: -30px;
}
-#projection-reason > .projection-reason-data, #source{
+#projection-reason > .projection-reason-data{
max-height: 250px;
- *height: 250px;
- overflow-y: scroll;
+ height: 250px;
+ overflow-y: auto;
+}
+#source {
+ height: 250px;
+ overflow-y: auto;
+ font-family: consolas, 'courier new';
+}
+#source, #name {
+ min-width: 500px;
+}
+#mode {
+ min-width: 515px; /*width of #source + 15px - todo: find out why*/
}
.error {
min-width: 40%;
@@ -48,6 +90,33 @@ h6 { font-size: 1em; font-weight: bold; }
white-space: normal;
text-shadow: none;
}
+
+#commands-container {
+ margin-left: -25px;
+}
+
+#commands-container li {
+ display: inline;
+}
+#commands-container a {
+ cursor: pointer;
+}
+#commands-container i.icon-remove {
+ margin-top: 2px;
+ margin-bottom: 2px;
+ margin-left: -3px;
+}
+
+.form-horizontal .control-label {
+ padding-top: 0;
+}
+textarea[disabled='disabled'] {
+ cursor: default;
+}
+#projection-state {
+ word-wrap: break-word;
+}
+
/*===================================== charts =================================*/
.dropdown {
margin-left: 10px;
@@ -114,47 +183,6 @@ h6 { font-size: 1em; font-weight: bold; }
overflow-x: hidden!important;
}
-
-/* ==========================================================================
- Author's custom styles
- ========================================================================== */
-
-body {
- /*padding: 0;*/
-
-
-}
-
-.navbar
-{
- /*note MM: fixes extra blank space at page bottom problem, but with small side effects*/
- position: static !important;
-}
-
-
-.control_btn_wrapper {
- display: block;
-}
-
-.control_btn_list {
- display: inline;
-}
-
-footer {
- width: 100%;
- background: #d6d6d6;
-}
-
-footer p {
- font-family: Arial;
- font-size: 13px;
- color: #363636;
- margin-top: 15px;
-}
-
-#commands-container {
- margin-left: -25px;
-}
/* ==========================================================================
Footer Stick to the Bottom
========================================================================== */
View
17 ...Store.Web/es-common-web/js/es.loadmenu.js → ...ventStore.Web/es-common-web/js/es.util.js
@@ -1,8 +1,11 @@
if (!window.es) { window.es = {}; };
-if (!es.utils) { es.utils = {}; };
+if (es.util)
+ throw 'es.util is already declared.';
+
+es.util = {};
+
+es.util.loadMenu = function (pages) {
-es.utils.loadMenu = function(pages) {
-
var tmplStr = '<li class="{{>class}}"> <a href="{{>link}}"> {{>name}} </a> </li>';
var tmpl = $.templates(tmplStr);
var htmlString = tmpl.render(pages);
@@ -18,4 +21,12 @@ es.utils.loadMenu = function(pages) {
if (active.length == 1)
active.parent().addClass("active");
}
+};
+
+es.util.formatError = function (text, xhr) {
+ var reason = xhr.responseText
+ || (xhr.status === 0 ? "Couldn't connect to server." : null)
+ || xhr.statusText
+ || '(unknown)';
+ return [text, "\r\nReason: ", reason].join('');
};
View
9 src/EventStore/EventStore.Web/es-common-web/js/projections/es.api.js
@@ -1,17 +1,18 @@
if (!window.es) { window.es = {}; };
es.postEvent = function (settings) {
+ var eventType = settings.eventType || (function () { throw "eventType is required"; })();
+ var stream = settings.stream || (function () { throw "stream is required"; })();
+ var data = settings.data || (function () { throw "data is required"; })();
+
var expectedVersion = settings.expectedVersion || -2;
var eventId = settings.eventId || guid();
var correlationId = settings.correlationId || guid();
var metadata = settings.metadata || "";
var onError = settings.error || function() {};
var onSuccess = settings.success || function() {};
-
- var eventType = settings.eventType || (function() { throw "eventType is required"; })();
- var stream = settings.stream || (function() { throw "stream is required"; })();
- var data = settings.data || (function() { throw "data is required"; })();
+
var dataStr = null;
if (typeof data === "object") {
View
8 src/EventStore/EventStore.Web/es-common-web/tmpl/_body.tmpl.html
@@ -4,8 +4,10 @@
<div class="navbar-inner">
<div class="container">
<!-- ==== show menu for device ====-->
- <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span
- class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
</a>
<!-- ==== site logo ====-->
<a class="brand" href="/">
@@ -17,7 +19,7 @@
</ul>
</div>
<!--/.nav-collapse -->
- <script src="/web/es/js/es.loadmenu.js"></script>
+ <script src="/web/es/js/es.util.js"></script>
<script src="/web/js/es.menu.js"></script> <!--we expect that each project keep file in this location in which loads menu-->
</div>
</div>

0 comments on commit 0ad4298

Please sign in to comment.