/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to html_server/templates/base.html

  • Committer: Vasilii Chernov
  • Date: 2016-02-25 16:02:35 UTC
  • mto: This revision was merged to the branch mainline in revision 367.
  • Revision ID: vchernov@inr.ru-20160225160235-g9zkhg8ngg2o12zj
Move html_server to separate folder. Update html server templates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
        <title>{% block title %}Device {{ device }}{% endblock %}</title>
5
5
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6
6
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
7
 
        <link rel="stylesheet" type="text/css" href="codebase/dhtmlx.css"/>
 
7
        <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='codebase/dhtmlx.css') }}"/>
8
8
   <script type=text/javascript src="{{ url_for('static', filename='jquery-2.2.1.js') }}"></script>
9
 
        <script src="codebase/dhtmlx.js"></script>
10
 
   <script src="pcilib_tree.js"></script>
 
9
        <script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script>
 
10
   <script src="{{ url_for('static', filename='check_err.js') }}"></script>
11
11
        <script>
12
12
      var propsTree
13
 
      
14
 
      function checkError(json)
15
 
      {
16
 
         if(json.error)
17
 
            alert('Error:\n' + json.error)
18
 
      }
19
 
      
20
 
      function createPropertyTree(branch, id)
21
 
      {
22
 
         function getPropertyItemsOnLevel(branch, id)
23
 
         {
 
13
      function createPropertyTree(branch, id) {
 
14
         
 
15
         function getPropertyItemsOnLevel(branch, id) {
24
16
            pathToProperties = "{{ url_for('get_property_list_json') }}"
25
17
            completePath = pathToProperties + '?branch=' + branch
26
18
            
27
19
            $.getJSON(completePath, 
28
20
                      function(json) {
29
 
                         checkError(json)
30
 
                         parsePropertyItems(json, branch, id)
 
21
                           checkError(json)
 
22
                           parsePropertyItems(json, branch, id)
31
23
                         });
32
24
         }
33
25
         
34
 
         function parsePropertyItems(json, branch, id)
35
 
         {
36
 
            function updatePropertyValue(id, path)
37
 
            {
38
 
               pathToGetProperty = "{{ url_for('get_property_json') }}"
39
 
               completePath = pathToGetProperty + '?prop=' + path
40
 
               
41
 
               $.getJSON(completePath, function(json){
42
 
                           checkError(json)
43
 
                           propsTree.updateItem(id, 'value: ' + json.value);
44
 
                        })
45
 
            }
46
 
         
47
 
            function writePropertyValue(id, path)
48
 
            {
49
 
               value = window.prompt("Enter new property value");
50
 
               
51
 
               if(value != null)
52
 
               {
53
 
                  pathToGetProperty = "{{ url_for('set_property_json') }}"
54
 
                  completePath = pathToGetProperty + '?prop=' + path +'&val=' + value
55
 
                  
56
 
                  $.getJSON(completePath, 
57
 
                            function(json) {
58
 
                              checkError(json)
59
 
                              updatePropertyValue(id, path)
60
 
                             })
61
 
               }
62
 
               else
63
 
                  updatePropertyValue(id, path)
64
 
            }
65
 
            
66
 
            function setCurrentValueField(id, path, mode)
67
 
            {
68
 
               var propValId = id + 'CurrVal'
69
 
               var func = 0
70
 
               
71
 
               if(mode)
72
 
                  func = function(){writePropertyValue(propValId, path)}
73
 
               else
74
 
                  func = function(){updatePropertyValue(propValId, path)}
75
 
                  
76
 
               propsTree.insertNewItem(id, propValId,
77
 
                                    'value: ', 
78
 
                                    func);
79
 
               
80
 
               updatePropertyValue(propValId, path)
81
 
            }
82
 
            
83
 
            for(var i = 0; i < json.length; i++)
84
 
            {
85
 
               propsTree.insertNewItem(id, json[i].path, json[i].name, 0);
86
 
               
 
26
         function parsePropertyItems(json, branch, id) {
 
27
            
 
28
            function loadPropertyInfo(branch) {
 
29
               
 
30
               var pathToProperties = "{{ url_for('get_property_list') }}"
 
31
               var completePath = pathToProperties + '?branch=' + branch
 
32
               
 
33
               $("#prop_info_place").load(completePath)
 
34
            }
 
35
            
 
36
            
 
37
            function setPropertyField(id, name, branch) {
 
38
               
 
39
               var func = function(){loadPropertyInfo(branch)}
 
40
               propsTree.insertNewItem(id, branch,
 
41
                                       name, 
 
42
                                       func);
 
43
               propsTree.closeAllItems()
 
44
            }
 
45
            
 
46
            for(var i = 0; i < json.length; i++) {
 
47
               
 
48
               setPropertyField(id, json[i].name, json[i].path)
87
49
               if(json[i].flags.indexOf("childs") != -1)
88
 
               {
89
50
                  getPropertyItemsOnLevel(json[i].path, json[i].path)
90
 
               }
91
 
               else
92
 
               {
93
 
                  if(json[i].mode.indexOf("R") != -1)
94
 
                  {
95
 
                     var mode = (json[i].mode.indexOf("W") != -1)
96
 
                     setCurrentValueField(json[i].path, json[i].path, mode)
97
 
                  }
98
 
               }
99
 
               
100
 
               //show aviable info
101
 
               if(json[i].description)
102
 
                  propsTree.insertNewItem(json[i].path, json[i].path + 'Desc',
103
 
                                       'description:\n' + json[i].description, 0);
104
 
               if(json[i].type)
105
 
                  propsTree.insertNewItem(json[i].path, json[i].path + 'Type',
106
 
                                       'type: ' + json[i].type, 0);
107
 
               if(json[i].unit)
108
 
                  propsTree.insertNewItem(json[i].path, json[i].path + 'Unit',
109
 
                                       'unit: ' + json[i].unit, 0);
110
 
                                       
111
 
               if(json[i].mode)
112
 
               {
113
 
                  var modeId = json[i].path + 'Mode'
114
 
                  propsTree.insertNewItem(json[i].path, modeId,
115
 
                                       'mode', 0);
116
 
                  
117
 
                  for(var j = 0; j < json[i].mode.length; j++)
118
 
                     propsTree.insertNewItem(modeId, modeId + j,
119
 
                                       json[i].mode[j], 0);
120
 
                  propsTree.closeItem(modeId)
121
 
               }
122
 
               
123
 
               if(json[i].path)
124
 
                  propsTree.insertNewItem(json[i].path, json[i].path + 'Path',
125
 
                                       'path: ' + json[i].path, 0);
126
 
                                       
127
 
               propsTree.closeItem(json[i].path);
128
51
            }  
129
 
      }
 
52
         }
130
53
         
131
54
         getPropertyItemsOnLevel(branch, id)
132
55
      }
133
56
      
134
57
      var regTree
135
 
      function createRegistersList()
136
 
      {
137
 
         function parseJsonRegisterList(json)
138
 
         {
 
58
      function createRegistersList() {
 
59
         function parseJsonRegisterList(json) {
 
60
            
139
61
            checkError(json)
 
62
            if(json.lenght <= 0)
 
63
               return
140
64
            
141
 
            function compareRegistersByBank(a,b) 
142
 
            {
 
65
            //sort registers by bank
 
66
            function compareRegistersByBank(a,b) {
143
67
               if (a.bank < b.bank)
144
68
                  return -1;
145
69
               else if (a.bank > b.bank)
147
71
               else 
148
72
                  return 0;
149
73
            }
150
 
            
151
 
            if(json.lenght <= 0)
152
 
               return
153
 
            
154
 
            //sort registers by bank
155
74
            json.sort(compareRegistersByBank)
156
75
            
 
76
            
157
77
            //create bank dirs
158
78
            var curBankName = json[0].bank
159
79
            var created = 0
160
 
            for(var i = 0; i < json.length; i++)
161
 
            {
 
80
            for(var i = 0; i < json.length; i++) {
 
81
               
162
82
               //create new bank tab if it has not created already
163
 
               if(json[i].bank != curBankName)
164
 
               {
 
83
               if(json[i].bank != curBankName) {
165
84
                  curBankName = json[i].bank
166
85
                  created = 0
167
86
               }
168
 
               if(!created)
169
 
               {
 
87
               
 
88
               if(!created) {
170
89
                  regTree.insertNewItem(0, json[i].bank, json[i].bank, 0);
171
90
                  created = 1
172
91
               }
173
92
               
 
93
               
174
94
               //insert register info to bank
175
 
               var itemId = json[i].bank + "_" + json[i].name
176
 
               regTree.insertNewItem(json[i].bank, itemId, json[i].name)
177
 
               
178
 
               function updateRegisterValue(id, bank, name)
179
 
               {
180
 
                  pathToGetProperty = "{{ url_for('read_register_json') }}"
181
 
                  completePath = pathToGetProperty + '?bank=' + bank +
 
95
               function loadRegisterInfo(bank, name) {
 
96
                  var pathToGetProperty = "{{ url_for('get_register_info') }}"
 
97
                  var completePath = pathToGetProperty + '?bank=' + bank +
182
98
                                 '&name=' + name
183
 
                  
184
 
                  $.getJSON(completePath, function(json){
185
 
                              checkError(json)
186
 
                              regTree.updateItem(id, 'value: ' + json.value);
187
 
                           })
188
 
               }
189
 
         
190
 
 
191
 
               function writeRegisterValue(id, bank, name)
192
 
               {
193
 
                  value = window.prompt("Enter new register value");
194
 
                  
195
 
                  if(value != null)
196
 
                  {
197
 
                     pathToGetProperty = "{{ url_for('write_register_json') }}"
198
 
                     completePath = pathToGetProperty + '?bank=' + bank +
199
 
                                    '&name=' + name + '&val=' + value;
200
 
                     
201
 
                     $.getJSON(completePath, 
202
 
                               function(json) {
203
 
                                 checkError(json)
204
 
                                 updateRegisterValue(id, bank, name)
205
 
                                })
206
 
                  }
207
 
                  else
208
 
                     updateRegisterValue(id, bank, name)
209
 
               }
210
 
 
211
 
               function setCurrentValueField(id, bank, name, mode)
212
 
               {
213
 
                  var regValId = id + 'CurrVal'
214
 
                  var func = 0
215
 
                  
216
 
                  if(mode)
217
 
                     func = function(){writeRegisterValue(regValId, bank, name)}
218
 
                  else
219
 
                     func = function(){updateRegisterValue(regValId, bank, name)}
220
 
                     
221
 
                  regTree.insertNewItem(id, regValId,
222
 
                                       'value: ', 
223
 
                                       func);
224
 
                  updateRegisterValue(regValId, bank, name)
225
 
               }
226
 
               
227
 
               if(json[i].mode.indexOf("R") != -1)
228
 
               {
229
 
                  var mode = (json[i].mode.indexOf("W") != -1)
230
 
                  setCurrentValueField(itemId, json[i].bank, json[i].name, mode)
231
 
               }
232
 
               
233
 
               //show aviable info
234
 
               if(json[i].description)
235
 
                  regTree.insertNewItem(itemId, itemId + 'Desc',
236
 
                                        'description:\n' + json[i].description, 0);
237
 
               if(json[i].defvalue)
238
 
                  regTree.insertNewItem(itemId, itemId + 'Defvalue',
239
 
                                       'defvalue: ' + json[i].defvalue, 0);
240
 
               
241
 
               if(json[i].mode)
242
 
               {
243
 
                  var modeId = itemId + 'Mode'
244
 
                  regTree.insertNewItem(itemId, modeId,
245
 
                                       'mode', 0);
246
 
                  
247
 
                  for(var j = 0; j < json[i].mode.length; j++)
248
 
                     regTree.insertNewItem(modeId, modeId + j,
249
 
                                       json[i].mode[j], 0);
250
 
                  regTree.closeItem(modeId)
251
 
               }
252
 
               
253
 
               if(json[i].range)
254
 
               {
255
 
                  var rangeId = itemId + 'Range'
256
 
                  regTree.insertNewItem(itemId, rangeId,
257
 
                                       'range', 0);
258
 
                  regTree.insertNewItem(rangeId, rangeId + 'Min',
259
 
                                       'min: ' + json[i].range.min, 0);
260
 
                  regTree.insertNewItem(rangeId, rangeId + 'Max',
261
 
                                       'max: ' + json[i].range.max, 0);
262
 
                  regTree.closeItem(rangeId)
263
 
               }
264
 
               
265
 
               if(json[i].values)
266
 
               {
267
 
                  var valuesId = itemId + 'Values'
268
 
                  regTree.insertNewItem(itemId, valuesId,
269
 
                                       'values', 0);
270
 
                                       
271
 
                  function addValueInfo(valuesId, value)
272
 
                  {
273
 
                     var valueId = valuesId + value.name
274
 
                     regTree.insertNewItem(valuesId, valueId, value.name, 0);
275
 
                     
276
 
                     if(value.description)
277
 
                        regTree.insertNewItem(valueId, valueId + 'Desc',
278
 
                                              'description: ' + value.description, 0);
279
 
                     if(value.value)
280
 
                        regTree.insertNewItem(valueId, valueId + 'Value',
281
 
                                              'value: ' + value.value, 0);
282
 
                     if(value.min)
283
 
                        regTree.insertNewItem(valueId, valueId + 'Min',
284
 
                                              'min: ' + value.min, 0);
285
 
                     if(value.max)
286
 
                        regTree.insertNewItem(valueId, valueId + 'Max',
287
 
                                              'max: ' + value.max, 0);   
288
 
                  }
289
 
                  
290
 
                  for(var j = 0; j < json[i].values.length; j++)
291
 
                  {
292
 
                     addValueInfo(valuesId, json[i].values[j])
293
 
                  }
294
 
                  regTree.closeItem(valuesId)
295
 
               }
296
 
                                       
297
 
               propsTree.closeItem(json[i].path);
298
 
               
299
 
               regTree.closeItem(itemId);
 
99
               
 
100
                  $("#reg_info_place").load(completePath)
 
101
               }
 
102
               
 
103
               function setRegisterField(id, bank, name) {
 
104
                  
 
105
                  var itemId = bank + "_" + name
 
106
                  var func = function(){loadRegisterInfo(bank, name)}
 
107
                  
 
108
                  regTree.insertNewItem(id, itemId, name, func)
 
109
                  regTree.closeAllItems()
 
110
               }
 
111
               
 
112
               setRegisterField(json[i].bank, json[i].bank, json[i].name)
300
113
            }
301
114
         }
302
115
         
320
133
</head>
321
134
<body onload="doOnLoad()">
322
135
        {% block info %}
323
 
      <h2>Device {{ device }} model={{ model }} control page </h2>
 
136
      <div class="block1" >
 
137
         <h2>Device {{ device }} model={{ model }} control page </h2>
 
138
      </div>
324
139
   {% endblock %}
325
140
   
 
141
   <style>
 
142
      .tabs > div, .tabs > input { display: none; }
 
143
 
 
144
      .tabs label {
 
145
               padding: 5px;
 
146
               border: 1px solid #aaa;
 
147
               line-height: 28px;
 
148
               cursor: pointer;
 
149
               position: relative;
 
150
               bottom: 1px;
 
151
               background: #fff;
 
152
            }
 
153
            
 
154
      .tabs input[type="radio"]:checked + label { border-bottom: 2px solid #fff; }
 
155
 
 
156
      .tabs > input:nth-of-type(1):checked ~ div:nth-of-type(1),
 
157
      .tabs > input:nth-of-type(2):checked ~ div:nth-of-type(2) {
 
158
                                                      display: block; 
 
159
                                                      padding: 5px; 
 
160
                                                      border: 
 
161
                                                      1px solid #aaa;
 
162
                                                   }
 
163
      .tree {
 
164
               height: 85vh;
 
165
               padding: 5px;
 
166
               border: 1px solid #aaa;
 
167
               line-height: 28px;
 
168
               cursor: pointer;
 
169
               position: relative;
 
170
               bottom: 1px;
 
171
               background: #fff;
 
172
               overflow:auto;
 
173
            }
 
174
            
 
175
      .infoTable {
 
176
               padding: 5px;
 
177
               
 
178
               border: 1px solid #aaa;
 
179
               line-height: 28px;
 
180
               cursor: pointer;
 
181
               position: relative;
 
182
               background: #fff;
 
183
               overflow:auto;
 
184
               bottom: 1px;
 
185
               
 
186
               text-align: left;
 
187
            }
 
188
   </style>
 
189
   
 
190
   <div class="tabs">
 
191
      <input type="radio" name="current" checked="checked" id="props_id"/>
 
192
      <label for="props_id">Properties</label>
 
193
      <input type="radio" name="current" id="labels_id"/>
 
194
      <label for="labels_id">Registers</label>
 
195
      <div>
 
196
         <table>
 
197
            <tr>
 
198
               <td valign="top">
 
199
                  <div id="treeboxbox_tree" class = "tree"></div>
 
200
               </td>
 
201
               <td valign="top" id="prop_info_place" />
 
202
            </tr>
 
203
         </table>         
 
204
      </div>
 
205
      <div>
 
206
         <table>
 
207
            <tr>
 
208
               <td valign="top">
 
209
                  <div id="treeboxbox_tree2" class="tree"></div>
 
210
               </td>
 
211
               <td valign="top" id="reg_info_place" />
 
212
            </tr>
 
213
         </table>
 
214
      </div>
 
215
   </div>
326
216
   {% block content %}
327
217
   {% endblock %}
328
 
        <table>
329
 
                <tr>
330
 
         <td>
331
 
            <h3>Properties Tree</h3>
332
 
         </td>
333
 
         <td>
334
 
            <h3>Registers Tree</h3>
335
 
         </td>
336
 
                </tr>
337
 
                <tr>
338
 
         <td valign="top">
339
 
                                <div id="treeboxbox_tree" style="background-color:#f5f5f5;border :1px solid Silver; overflow:auto;"></div>
340
 
                        </td>
341
 
                        <td valign="top">
342
 
                                <div id="treeboxbox_tree2" style="background-color:#f5f5f5;border :1px solid Silver; overflow:auto;"></div>
343
 
                        </td>
344
 
                </tr>
345
 
        </table>
346
218
</body>
347
219
</html>