/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<script type="text/javascript">
//<![CDATA[
    function doDrop() {
	var node = document.getElementById("action_input");
	if (node) node.value = "drop";
    }
    function doRewidth() {
	var node = document.getElementById("action_input");
	if (node) node.value = "rewidth";
    }
//]]>
</script>

<?php 

/*
function data_link(&$req, $grname, $format, $from, $to) {
    global $FORMATS;
    
    $props = array();
    $props["experiment"] = "$from-$to";
    $props["window"] = "0";
    $props["format"] = $format;    

    if ($FORMATS[$format]["title"]) $title = $FORMATS[$format]["title"];
    else $title = $format;
    if ($FORMATS[$format]["extension"]) $ext = $FORMATS[$format]["extension"];
    else $ext = $format;

    
//    $props["filename"] =  preg_replace("/[^\w\d]/", "_", $grname) . "__" . round($from) . "_" . round($to) . "." . $ext;
    
    $query = $req->GetQueryString($props);
    
    echo "<a href=\"services/getdata.php?$query\">" . $title . "</a>";
}

try {
    $req = new SOURCERequest();
} catch (ADEIException $e) {
    $req = new REQUEST();
    $nodata = 1;
}
*/

$flags = REQUEST::NEED_ITEMINFO|REQUEST::NEED_INFO|CACHE::TABLE_INFO|CACHE::NEED_REQUESTS|CACHE::FIND_BROKEN;

$cache = new CACHEDB();
$list = $cache->GetCacheList($flags);

?><br/><form action="index.php?page=do.php" method="post">
    <input type="hidden" name="action" id="action_input"/>
    <input type="submit" value="<?echo translate("Drop Selected");?>" onClick="javascript:doDrop()"/>
    <input type="submit" value="<?echo translate("Resize Selected");?>" onClick="javascript:doRewidth()"/>
<?
foreach ($list as &$info) {
    ?><div class="group">
	<h3>Tables: cache*<?echo $info["postfix"];?> (<a href="index.php?page=do.php&action=drop&postfix=<?echo urlencode(json_encode(array($info['postfix'])));?>"><?echo translate("Drop");?></a>)
	<input type="checkbox" name="postfix<?echo $info['postfix']?>" value="1"/>
	</h3>
	<?
	echo translate("SourceID: %s", $info['db_server'] . "__" . $info['db_name'] . "__" . $info['db_group']) . "<br/>";

	if ($info['incomplete']) {
	    echo translate("Status") . ": <b>" . translate("Broken") ."</b>" . "<br/>";
	}
	
	if ($info['req']) {
    	    echo translate("Active: yes") . "<br/>";
	    if ($info['disconnected']) {
		echo translate("Mode: disconnected") . "<br/>";
	    }
        } else if ($info['disconnected']) {
	    echo translate("Active: unknown");
	    echo " (" . translate("The data source is disconnected at the moment") . ")";
	    echo "<br/>";
	} else {
	    echo translate("Active: no");
	    if (($info['server'])&&($info['database'])&&($info['group'])) {
		// strange should not be	
	    } else if (($info['server'])&&($info['database'])) {
		echo " (" . translate("The loggroup is not present any more") . ")";
	    } else if ($info['server']) {
		echo " (" . translate("The database is not present any more") . ")";
	    } else {
		echo " (" . translate("The data source is not present in active configuration") . ")";
	    }
	    echo "<br/>";
	}
	
	if ($info['reader']) {
	    echo translate("Reader: %s", $info['reader']) . "<br/>";
	}
	
	if ($info['server']) {
	    echo translate("Server: %s", $info['server']) . "<br/>";
	}
	
	if ($info['database']) {
	    echo translate("Database: %s", $info['database']) . "<br/>";
	}

	if ($info['group']) {
	    echo translate("LogGroup: %s", $info['group']) . "<br/>";
	}
	
	echo "<br/>";

	if ($info['info']['dbsize']) {
	    echo translate("Database Size: %s", dsPrintSize($info['info']['dbsize'])) . "<br/>";
	}

	if ($info['info']['records']) {
	    echo translate("Number of records: %s", $info['info']['records']) . "<br/>";
	}

	if ($info['info']['width']) {
	    echo translate("Number of items: %s", $info['info']['width']);

	    if (is_array($info['info']['items'])) {
		$reader_width = sizeof($info['info']['items']);
		if (($reader_width)&&($reader_width != $info['info']['width'])) {
		    echo " (CACHE), $reader_width (READER)";
		    echo " <a href=\"index.php?page=do.php&action=rewidth&postfix=" . urlencode(json_encode(array($info['postfix']))) . "\">[ " . translate("Resize") . " ]</a>";
		}
	    }
	    
	    echo "<br/>";
	}
	
	if ($info['info']['outdated']) {
	    echo translate("Table version: outdated, needs update") . "<br/>";
	}
	
	if (isset($info['info']['ns'])) {
	    if ($info['info']['ns']) {
		echo translate("Subsecond precision: yes") . "<br/>";
	    } else {
		echo translate("Subsecond precision: no") . "<br/>";
	    }
	}

	if (($info['info']['first'])&&($info['info']['last'])) {
	    echo translate("First record: %s", date("r", $info['info']['first'])) . "<br/>";
	    echo translate("Last record: %s", date("r", $info['info']['last'])) . "<br/>";
	}
	
	if ($info['info']['tables']) {
	    echo translate("Resolutions:");
	    foreach (array_keys($info['info']['tables']) as $res) {
		echo " $res";
	    }
	    echo "<br/>";
	    
	    if (isset($_GET['table_info'])) {
	        echo "<br/>";
		
	        echo translate("Extended Table Info:") . "<br/><table>";
		foreach ($info['info']['tables'] as $res => $tblinfo) {
		    $output = false;
		    echo "<tr><td>&nbsp;" . sprintf("% 5u", $res) . ":</td><td>";
		
		    if ($tblinfo['dbsize']) {
			if ($output) echo ", ";
			else $output = true;

			echo dsPrintSize($tblinfo['dbsize']);
		    }

		    if ($tblinfo['records']) {
			if ($output) echo ", ";
			else $output = true;
		    
			echo translate("%s records", $tblinfo['records']);
		    }

		    if (($tblinfo['first'])&&($tblinfo['last'])) {
			if ($output) echo ", ";
			else $output = true;

			echo date("c", $tblinfo['first']) . ' - ' . date("c", $tblinfo['last']+$res);
			$output = true;
		    }
		    echo "</td></tr>";
	        }
		echo "</table>";
	    }

	    if ((isset($_GET['item_info']))&&(is_array($info['info']['items']))) {
	        echo "<br/>";
		
	        echo translate("Extended Item Info:") . "<br/><table>";
		foreach ($info['info']['items'] as $id => $iinfo) {
		    echo "<tr><td>&nbsp;" . sprintf("% 3u", $id) . ":</td><td>";
		    echo $iinfo['name'];
		    echo "</td></tr>";
		}
		echo "</table>";
	    }
	}
	

//	print_r($info);
	?>
	<br/><br/>
    </div><?
}
echo "</form>";
?>