Changeset cee63b89dc83bf064bb88917ccaf822b60c77660
- Timestamp:
- 11/22/08 01:45:08
(5 years ago)
- Author:
- Umar Farooq <umar@omniti.com>
- git-committer:
- Umar Farooq <umar@omniti.com> 1227318308 +0000
- git-parent:
[e13f962a493538e54cf6984e35513d9844300044]
- git-author:
- Umar Farooq <umar@omniti.com> 1227318308 +0000
- Message:
cranking out some more template stuff
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re13f962 |
rcee63b8 |
|
| 3 | 3 | RewriteRule ^json/ds/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ datapoint_browse_json.php?l1=$1&l2=$2&l3=$3&l4=$4 [PT,QSA] |
|---|
| 4 | 4 | RewriteRule ^json/ds/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ datapoint_browse_json.php?l1=$1&l2=$2&l3=$3&l4=$4&l5=$5 [PT,QSA] |
|---|
| 5 | | RewriteRule ^json/templates/([^/]+)/([^/]+)$ template_browse_json.php?l1=$1&l2=$2 [PT,QSA] |
|---|
| | 5 | RewriteRule ^json/templates/([^/]+)/([^/]+)/([^/]+)$ template_browse_json.php?l1=$1&l2=$2&l3=$3 [PT,QSA] |
|---|
| 6 | 6 | RewriteRule ^json/worksheet/info/([^/]*)$ worksheet_info.php?id=$1 [PT,QSA] |
|---|
| 7 | 7 | RewriteRule ^json/worksheet/store$ worksheet_store.php [PT,QSA] |
|---|
| re13f962 |
rcee63b8 |
|
| 75 | 75 | jQuery(document).ready(function(){ |
|---|
| 76 | 76 | $("#templates").treeview({ |
|---|
| 77 | | url: "json/templates/templateid/metric_name", |
|---|
| | 77 | url: "json/templates/templateid/targetname/sid", |
|---|
| 78 | 78 | params: {} |
|---|
| 79 | 79 | }) |
|---|
| re13f962 |
rcee63b8 |
|
| 4 | 4 | require_once 'Reconnoiter_GraphTemplate.php'; |
|---|
| 5 | 5 | |
|---|
| 6 | | |
|---|
| 7 | 6 | $db = Reconnoiter_DB::getDB(); |
|---|
| 8 | 7 | |
|---|
| 9 | | //these are the names of the parameters , one of templateid or metric_name |
|---|
| | 8 | //these are the names of the parameters , one of templateid, targetname, or sid |
|---|
| 10 | 9 | $l1 = $_GET['l1']; |
|---|
| 11 | 10 | $l2 = $_GET['l2']; |
|---|
| | 11 | $l3 = $_GET['l3']; |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | error_log("------"); |
|---|
| … | … | |
| 16 | 16 | error_log($l1."=".$_REQUEST[$l1]); |
|---|
| 17 | 17 | error_log($l2."=".$_REQUEST[$l2]); |
|---|
| | 18 | error_log($l3."=".$_REQUEST[$l3]); |
|---|
| 18 | 19 | |
|---|
| 19 | 20 | if ($_REQUEST['root'] == 'source'){ |
|---|
| … | … | |
| 23 | 24 | $want = $l2; |
|---|
| 24 | 25 | } |
|---|
| | 26 | else if($_REQUEST[$l2]) { |
|---|
| | 27 | $want = $l3; |
|---|
| | 28 | } |
|---|
| 25 | 29 | else { |
|---|
| 26 | | $want = 'got screwed'; |
|---|
| | 30 | $want = "we are screwed"; |
|---|
| 27 | 31 | } |
|---|
| 28 | 32 | |
|---|
| … | … | |
| 49 | 53 | } |
|---|
| 50 | 54 | |
|---|
| 51 | | else if($want == 'metric_name') { |
|---|
| | 55 | else if($want == 'targetname') { |
|---|
| 52 | 56 | $templateid = $_REQUEST[$l1]; |
|---|
| 53 | 57 | error_log("retreive template = $templateid"); |
|---|
| 54 | 58 | $template = new Reconnoiter_GraphTemplate($templateid); |
|---|
| 55 | 59 | |
|---|
| 56 | | $select = "<form><select name='sids' multiple>"; |
|---|
| 57 | | foreach ($template->sids() as $item) { |
|---|
| | 60 | $target_sid_map = array(); |
|---|
| | 61 | |
|---|
| | 62 | foreach ($template->sids() as $item) { |
|---|
| 58 | 63 | foreach ($item as $match) { |
|---|
| 59 | | $select.="<option value='$match[sid]'>$match[sid]"; |
|---|
| | 64 | if(!isset($target_sid_map[$match[target]])) { |
|---|
| | 65 | $target_sid_map[$match[target]] = array(); |
|---|
| 60 | 66 | } |
|---|
| 61 | | } |
|---|
| 62 | | $select.="</select></form>"; |
|---|
| | 67 | $target_sid_map[$match[target]][] = $match[sid]; |
|---|
| | 68 | } |
|---|
| | 69 | } |
|---|
| | 70 | |
|---|
| | 71 | foreach ($target_sid_map as $target_name => $sid_list) { |
|---|
| | 72 | $sidlist = implode(",", $sid_list); |
|---|
| | 73 | $jitem = array ('id' => $target_name, |
|---|
| | 74 | 'text' => $target_name, |
|---|
| | 75 | 'hasChildren' => true, |
|---|
| | 76 | 'classes' => $want, |
|---|
| | 77 | 'params' => array('targetname' => $sidlist) |
|---|
| | 78 | ); |
|---|
| | 79 | $bag[] = $jitem; |
|---|
| | 80 | } |
|---|
| | 81 | } |
|---|
| | 82 | else if($want == 'sid') { |
|---|
| | 83 | $sid_list = explode (",", $_REQUEST[$l2]); |
|---|
| | 84 | |
|---|
| | 85 | foreach($sid_list as $sid) { |
|---|
| | 86 | $sname = $db->get_sid_name($sid); |
|---|
| | 87 | error_log("got $name as the sid name"); |
|---|
| | 88 | $jitem = array ('id' => $sname, |
|---|
| | 89 | 'text' => $sname, |
|---|
| | 90 | 'hasChildren' => false, |
|---|
| | 91 | 'classes' => $want, |
|---|
| | 92 | 'params' => array(), |
|---|
| | 93 | ); |
|---|
| | 94 | $bag[] = $jitem; |
|---|
| | 95 | } |
|---|
| 63 | 96 | |
|---|
| 64 | | $jitem = array ('id' => "34", |
|---|
| 65 | | 'text' => $select, |
|---|
| 66 | | 'classes' => $want, |
|---|
| 67 | | 'hasChildren' => false, |
|---|
| 68 | | 'params' => array() |
|---|
| 69 | | ); |
|---|
| 70 | | $bag[] = $jitem; |
|---|
| 71 | | |
|---|
| | 97 | } |
|---|
| | 98 | |
|---|
| | 99 | |
|---|
| 72 | 100 | |
|---|
| 73 | 101 | /* |
|---|
| … | … | |
| 84 | 112 | //error_log("saved to graph id = $graph_id"); |
|---|
| 85 | 113 | */ |
|---|
| 86 | | } |
|---|
| 87 | 114 | |
|---|
| 88 | 115 | echo json_encode($bag); |
|---|
| re13f962 |
rcee63b8 |
|
| 461 | 461 | return $id; |
|---|
| 462 | 462 | } |
|---|
| | 463 | |
|---|
| | 464 | public function get_sid_name($sid) { |
|---|
| | 465 | $sql = "select m.name from stratcon.mv_loading_dock_check_s m where m.sid = ?"; |
|---|
| | 466 | $binds = array(); |
|---|
| | 467 | if($sid) { |
|---|
| | 468 | $binds[] = $sid; |
|---|
| | 469 | $sth = $this->db->prepare($sql); |
|---|
| | 470 | $sth->execute($binds); |
|---|
| | 471 | $row = $sth->fetch(); |
|---|
| | 472 | } |
|---|
| | 473 | return $row['name']; |
|---|
| | 474 | } |
|---|
| 463 | 475 | } |
|---|
| 464 | 476 | |
|---|