blob: 6298146bd2aac5c3ba9f7576f890b2304177ce95 [file] [log] [blame]
Clement Escoffier3cdc5f72010-07-12 17:40:19 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17function renderHandlersData(handlers) {
18 $(".statline").html(getHandlersStatLine(handlers));
19 tableBody.empty();
20 for ( var idx in handlers.data ) {
21 handlersEntry( handlers.data[idx] );
22 }
23 $("#plugin_table").trigger("update");
24}
25
26function getHandlersStatLine(handlers) {
27 return handlers.count + " handlers in total, "
28 + handlers.valid_count + " valid handlers, "
29 + handlers.invalid_count + " invalid handlers.";
30}
31
32function handlersEntry(handler) {
33 var name = handler.name;
34 var state = handler.state;
35 var bundle = handler.bundle;
36 var type = handler.type;
37
38 console.log("Create entry : " + handler);
39
40 var _ = tableEntryTemplate.clone().appendTo(tableBody).attr('id', 'handler-' + handler.name);
41
42 _.find('td.name').text(name);
43 _.find('td.type').text(type);
44 _.find('td.bundle').text(bundle);
45 _.find('td.state').text(state);
46 if (handler.missing) {
47 _.find('td.missing').html(handler.missing);
48 } else {
49 _.find('td.missing').html('<i>No missing handlers</i>');
50 }
51
52}
53
54
55function loadHandlersData() {
56 console.log("Load handlers data");
57 $.get(pluginRoot + "/handlers.json", null, function(data) {
58 renderHandlersData(data);
59 }, "json");
60}
61
62function loadInstancesData() {
Clement Escoffierd430a1d2010-07-12 17:42:03 +000063 window.location = instances_url;
Clement Escoffier3cdc5f72010-07-12 17:40:19 +000064}
65
66function loadFactoriesData() {
Clement Escoffierd430a1d2010-07-12 17:42:03 +000067 window.location = factories_url;
Clement Escoffier3cdc5f72010-07-12 17:40:19 +000068}
69
70var tableBody = false;
71var tableEntryTemplate = false;
72
73$(document).ready(function(){
74 tableBody = $('#plugin_table tbody');
75 tableEntryTemplate = tableBody.find('tr').clone();
76
77 loadHandlersData();
78
79 $(".instancesButton").click(loadInstancesData);
80 $(".factoriesButton").click(loadFactoriesData);
81 $(".handlersButton").click(loadHandlersData);
82
83 var extractMethod = function(node) {
84 var link = node.getElementsByTagName("a");
85 if ( link && link.length == 1 ) {
86 return link[0].innerHTML;
87 }
88 return node.innerHTML;
89 };
90 $("#plugin_table").tablesorter({
91 sortList: [[1,0]],
92 textExtraction:extractMethod
93 });
94});
95