Debian Codegraph @

webapp/graphite/templates/composer.html

raw
1 <!-- Copyright 2008 Orbitz WorldWide
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at:
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License. -->
14 {% load static %}
15
16 <html>
17 <head>
18 <title>Graphite Composer</title>
19 <link rel="stylesheet" type="text/css" href="{% static "js/ext/resources/css/ext-all.css" %}"/>
20 </head>
21 <body onload="init();" data-static-root="{% get_static_prefix %}" data-base-url="{% url "browser" %}"{% if queryString %} data-query-string="{{ queryString }}"{% endif %}{% if showTarget %} data-show-target="{{ showTarget }}"{% endif %}>
22
23 {% if jsdebug %}
24 <script type="text/javascript" src="{% static "js/ext/adapter/ext/ext-base-debug.js" %}"></script>
25 <script type="text/javascript" src="{% static "js/ext/ext-all-debug.js" %}"></script>
26 {% else %}
27 <script type="text/javascript" src="{% static "js/ext/adapter/ext/ext-base.js" %}"></script>
28 <script type="text/javascript" src="{% static "js/ext/ext-all.js" %}"></script>
29 {% endif %}
30
31 <script type="text/javascript">
32 /* A global cache of current metadata about metrics the user selects */
33 var TargetRecord = new Ext.data.Record.create(['value']);
34
35 var TargetStore = new Ext.data.ArrayStore({
36 fields: TargetRecord.fields
37 });
38
39 function getTargetRecord(target) {
40 var index = indexOfTarget(target);
41 return (index == -1) ? null : TargetStore.getAt(index);
42 }
43
44 function addTarget(target) {
45 TargetStore.add([ new TargetRecord({value: target}) ]);
46 }
47
48 function removeTarget(target) {
49 var record = getTargetRecord(target);
50
51 if (record) {
52 TargetStore.remove(record);
53 }
54 }
55
56 function indexOfTarget(target) {
57 return TargetStore.findExact('value', target);
58 }
59
60 function insertTarget(index, target) {
61 TargetStore.insert(index, [ new TargetRecord({value: target}) ]);
62 }
63
64 function replaceTarget(oldTarget, newTarget) {
65 var oldRecord = getTargetRecord(oldTarget);
66 var newRecord = getTargetRecord(newRecord);
67
68 if (oldRecord && (!newRecord)) {
69 oldRecord.set('value', newTarget);
70 TargetStore.commitChanges();
71 }
72 }
73 </script>
74
75 <script type="text/javascript" src="{% static "js/browser.js" %}"></script>
76 <script type="text/javascript" src="{% static "js/composer_widgets.js" %}"></script>
77 <script type="text/javascript" src="{% static "js/composer.js" %}"></script>
78 <script type="text/javascript" src="{% static "js/completer.js" %}"></script>
79
80 <style type="text/css">
81 /* Hack to fix this bug http://extjs.net/forum/showthread.php?s=a570aba1bf2fc67a2287684c5d91c662&t=74230 */
82 .x-list-body {
83 height: 100%;
84 position: absolute;
85 }
86
87 /* More readable style for search results */
88 #searchResults a {
89 font-size: 8pt;
90 font-family: monospace;
91 }
92 </style>
93
94 <script type="text/javascript">
95 Ext.BLANK_IMAGE_URL = '{% static "js/ext/resources/images/default/s.gif" %}';
96
97 var Browser;
98 var Composer;
99 var GraphiteConfig = {
100 showMyGraphs: {{showMyGraphs}},
101 searchEnabled: {{searchEnabled}},
102 refreshInterval: {{refreshInterval}},
103 };
104
105 function init() {
106 Browser = new GraphiteBrowser();
107 Composer = new GraphiteComposer();
108
109 new Ext.Viewport({
110 layout: 'border',
111 items: [
112 Browser.panel,
113 { //Panel that holds the composer window
114 region: 'center',
115 items: [Composer.window]
116 }
117 ]
118 });
119
120 Composer.window.show();
121
122 /* Direct graph loading */
123 if (document.body.dataset.queryString) {
124 Composer.loadURL("?" + document.body.dataset.queryString);
125 }
126 /* Automatic tree expansion */
127 if (document.body.dataset.showTarget) {
128 var parts = document.body.dataset.showTarget.split('.');
129
130 if (parts[0] == "Graphite") {
131 parts.shift();
132 }
133
134 recursiveExpand.expand(Browser.trees.graphite, parts);
135
136 }
137 /* Enable forward / backward functionality */
138 Composer.enableHistory(window.top);
139 } // init
140
141 </script>
142
143 </head>
144 <body onload="init();">
145 </body>
146 </html>