Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added, that a warning is displayed when elasticsearch appears to be down

  • Loading branch information...
commit 0edd7b9e8c6247f34e621f22c248bfaea5e3f9ff 1 parent f478476
@karmi authored
Showing with 41 additions and 3 deletions.
  1. +21 −0 example/app.css
  2. +10 −2 example/app.js
  3. +10 −1 example/index.html
View
21 example/app.css
@@ -5,6 +5,10 @@ body {
padding: 2em 4em;
}
+a {
+ color: #222;
+}
+
h1 {
color: #d33850;
font-size: 3em;
@@ -80,6 +84,20 @@ li.task.completed {
text-decoration: line-through;
}
+p.error {
+ color: #222;
+ background: #e0e0e0;
+ padding: 1em;
+ border-radius: 0.75em;
+ width: 40em;
+}
+p.error * {
+ color: #222;
+}
+p.error [class^="icon-"] {
+ margin-top: 2px;
+}
+
/* Lifted from Twitter bootstrap */
[class^="icon-"], [class*=" icon-"] {
display: inline-block;
@@ -102,3 +120,6 @@ li.task.completed {
.icon-remove {
background-position: -312px 0;
}
+.icon-exclamation-sign {
+ background-position: 0 -120px;
+}
View
12 example/app.js
@@ -15,12 +15,20 @@ var App = Em.Application.create({
ready: function() {
var index_url = [App.store.adapter.url, "tasks"].join('/');
- // Let's check if the `tasks` index exists and create it otherwise.
+ // Let's check if the `tasks` index exists...
//
jQuery.ajax({
url: index_url,
type: 'HEAD',
- error: function() { jQuery.post(index_url, {}, function(data) {}) }
+ error: function(xhr, textStatus, error) {
+ // ... elasticsearch appears to be down (no response)
+ //
+ if ( "" == error ) App.set("elasticsearch_unavailable", true);
+ //
+ // ... elasticsearch is up but the index is missing, let's create it
+ //
+ if ( "Not Found" == error ) jQuery.post(index_url, {}, function(data) {});
+ }
});
}
});
View
11 example/index.html
@@ -19,6 +19,16 @@
</script>
<script type="text/x-handlebars">
+ {{#if App.elasticsearch_unavailable}}
+ <p class="error">
+ <span class="icon-exclamation-sign"></span>
+ It seems that elasticsearch is not running on this machine
+ (<a href="http://localhost:9200">localhost:9200</a>)?
+ </p>
+ {{/if}}
+ </script>
+
+ <script type="text/x-handlebars">
<ul id="tasks">
{{#each App.Controllers.tasks}}
@@ -34,7 +44,6 @@
</ul>
</script>
-
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-1.0.pre.min.js"></script>
Please sign in to comment.
Something went wrong with that request. Please try again.