Mercurial > piecrust2
annotate piecrust/resources/server/piecrust-debug-info.js @ 273:d70a4adb61dd
themes: Add the `chef themes` command
The `themes` command lets the user create or override a theme easily.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Sun, 01 Mar 2015 09:07:36 -0800 |
| parents | d7a548ebcd58 |
| children | 9612cfc6455a |
| rev | line source |
|---|---|
|
219
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 var eventSource = new EventSource("/__piecrust_debug/pipeline_status"); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 //window.onbeforeunload = function(e) { |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 // console.log("Disconnecting SSE.", e); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 // eventSource.close(); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 //}; |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 eventSource.onerror = function(e) { |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 console.log("Error with SSE, closing.", e); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 eventSource.close(); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 }; |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 eventSource.addEventListener('pipeline_success', function(e) { |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 var placeholder = document.getElementById('piecrust-debug-info-pipeline-status'); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 //if (placeholder.firstChild !== null) |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 placeholder.removeChild(placeholder.firstChild); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 }); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 eventSource.addEventListener('pipeline_error', function(e) { |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 var obj = JSON.parse(e.data); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 var outer = document.createElement('div'); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 outer.style = 'padding: 1em;'; |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 for (var i = 0; i < obj.assets.length; ++i) { |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 var item = obj.assets[i]; |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 var markup = ( |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 '<p>Error processing: <span style="font-family: monospace;">' + |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 item.path + '</span></p>\n' + |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 '<ul>'); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 for (var j = 0; j < item.errors.length; ++j) { |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
31 markup += ( |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 '<li style="font-family: monospace;">' + |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 item.errors[j] + |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
34 '</li>\n'); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 } |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 markup += '</ul>\n'; |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 var entry = document.createElement('div'); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 entry.innerHTML = markup; |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 outer.appendChild(entry); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 } |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
41 |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
42 var placeholder = document.getElementById('piecrust-debug-info-pipeline-status'); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 placeholder.appendChild(outer); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 }); |
|
d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
45 |
