Index: trunk/extensions/DataCenter/DataCenter.css |
— | — | @@ -412,20 +412,20 @@ |
413 | 413 | border: solid 1px silver; |
414 | 414 | width: 100%; |
415 | 415 | } |
416 | | -div.datacenter-ui div.widget-difference td.field { |
| 416 | +div.datacenter-ui div.widget-difference td.label { |
417 | 417 | width: 20%; |
418 | 418 | padding-left: 8px; |
419 | 419 | padding-right: 8px; |
420 | 420 | color: gray; |
421 | 421 | } |
422 | | -div.datacenter-ui div.widget-difference td.value-a { |
| 422 | +div.datacenter-ui div.widget-difference td.previous { |
423 | 423 | width: 40%; |
424 | 424 | padding-left: 8px; |
425 | 425 | padding-right: 8px; |
426 | 426 | color: green; |
427 | 427 | background-color: #DDFFDD; |
428 | 428 | } |
429 | | -div.datacenter-ui div.widget-difference td.value-b { |
| 429 | +div.datacenter-ui div.widget-difference td.current { |
430 | 430 | width: 40%; |
431 | 431 | padding-left: 8px; |
432 | 432 | padding-right: 8px; |
Index: trunk/extensions/DataCenter/DataCenter.db.php |
— | — | @@ -1475,6 +1475,13 @@ |
1476 | 1476 | } |
1477 | 1477 | |
1478 | 1478 | /** |
| 1479 | + * Determines whether a row is present in the database |
| 1480 | + */ |
| 1481 | + public function exists() { |
| 1482 | + return DataCenterDB::rowExists( $this ); |
| 1483 | + } |
| 1484 | + |
| 1485 | + /** |
1479 | 1486 | * Automatically inserts or updates row |
1480 | 1487 | */ |
1481 | 1488 | public function save() { |
— | — | @@ -1514,9 +1521,12 @@ |
1515 | 1522 | /** |
1516 | 1523 | * Gets changes that reference this object by category, type, and ID |
1517 | 1524 | */ |
1518 | | - public function getChanges() { |
| 1525 | + public function getChanges( |
| 1526 | + array $options = array() |
| 1527 | + ) { |
1519 | 1528 | return DataCenterDB::getChanges( |
1520 | 1529 | array_merge_recursive( |
| 1530 | + $options, |
1521 | 1531 | DataCenterDB::buildCondition( |
1522 | 1532 | 'meta', 'change', 'component_category', $this->category |
1523 | 1533 | ), |
— | — | @@ -1976,7 +1986,8 @@ |
1977 | 1987 | $type = null, |
1978 | 1988 | $note = null |
1979 | 1989 | ) { |
1980 | | - if ( !is_string( $type ) ) { |
| 1990 | + global $wgUser; |
| 1991 | + if ( $type !== null && !is_string( $type ) ) { |
1981 | 1992 | throw new MWException( |
1982 | 1993 | $type . ' is not a valid type of change' |
1983 | 1994 | ); |
— | — | @@ -1986,7 +1997,6 @@ |
1987 | 1998 | $type . ' is not a valid change note' |
1988 | 1999 | ); |
1989 | 2000 | } |
1990 | | - global $wgUser; |
1991 | 2001 | return self::newFromValues( |
1992 | 2002 | array( |
1993 | 2003 | 'timestamp' => wfTimestampNow(), |
Index: trunk/extensions/DataCenter/Controllers/Facilities.php |
— | — | @@ -49,14 +49,18 @@ |
50 | 50 | ) { |
51 | 51 | switch ( $type ) { |
52 | 52 | case 'location': |
53 | | - $location = DataCenterDBLocation::newFromValues( $data ); |
54 | | - $location->save(); |
55 | | - return true; |
| 53 | + $component = DataCenterDBLocation::newFromValues( $data ); |
| 54 | + break; |
56 | 55 | case 'space': |
57 | | - $space = DataCenterDBSpace::newFromValues( $data ); |
58 | | - $space->save(); |
59 | | - return true; |
| 56 | + $component = DataCenterDBSpace::newFromValues( $data ); |
| 57 | + break; |
60 | 58 | } |
| 59 | + if ( isset( $component ) ) { |
| 60 | + $component->save(); |
| 61 | + $change = DataCenterDBChange::newFromComponent( $component ); |
| 62 | + $change->save(); |
| 63 | + return true; |
| 64 | + } |
61 | 65 | return false; |
62 | 66 | } |
63 | 67 | } |
\ No newline at end of file |
Index: trunk/extensions/DataCenter/Controllers/Assets.php |
— | — | @@ -47,9 +47,10 @@ |
48 | 48 | array $data, |
49 | 49 | $type |
50 | 50 | ) { |
51 | | - $asset = DataCenterAsset::newFromType( $type, $data ); |
| 51 | + $asset = DataCenterDBAsset::newFromType( $type, $data ); |
52 | 52 | $asset->save(); |
| 53 | + $change = DataCenterDBChange::newFromComponent( $asset ); |
| 54 | + $change->save(); |
53 | 55 | return true; |
54 | 56 | } |
55 | | - |
56 | 57 | } |
\ No newline at end of file |
Index: trunk/extensions/DataCenter/Controllers/Models.php |
— | — | @@ -50,6 +50,8 @@ |
51 | 51 | ) { |
52 | 52 | $model = DataCenterDBModel::newFromType( $type, $data ); |
53 | 53 | $model->save(); |
| 54 | + $change = DataCenterDBChange::newFromComponent( $model ); |
| 55 | + $change->save(); |
54 | 56 | return true; |
55 | 57 | } |
56 | 58 | |
Index: trunk/extensions/DataCenter/DataCenter.sql |
— | — | @@ -199,8 +199,7 @@ |
200 | 200 | PRIMARY KEY (mta_pln_id) |
201 | 201 | ) /*$wgDBTableOptions*/; |
202 | 202 | -- |
| 203 | +-- Table of changes made to targets (facilities, assets and models) |
203 | 204 | DROP TABLE IF EXISTS dc_meta_changes; |
204 | 205 | CREATE TABLE /*$wgDBPrefix*/dc_meta_changes ( |
205 | 206 | -- Unique ID of dc_meta_changes |
— | — | @@ -390,8 +389,8 @@ |
391 | 390 | fcl_loc_longitude |
392 | 391 | ) |
393 | 392 | VALUES |
394 | | - ( 'present', 'PMTPA', 'Tampa, FL', 27.949036, -82.457306 ), |
395 | | - ( 'present', 'SFO', 'San Francisco, CA', 37.782792, -122.394810 ); |
| 393 | + ( 'present', 'PMTPA', 'Tampa, FL', 27.98141, -82.451141 ), |
| 394 | + ( 'present', 'SFO', 'San Francisco, CA', 37.775196, -122.419204 ); |
396 | 395 | -- |
397 | 396 | INSERT INTO dc_facility_spaces |
398 | 397 | ( |
Index: trunk/extensions/DataCenter/UI/Widgets/Difference.php |
— | — | @@ -31,11 +31,6 @@ |
32 | 32 | * @datatype DataCenterDBRow |
33 | 33 | */ |
34 | 34 | 'current' => null, |
35 | | - /** |
36 | | - * Fields to display |
37 | | - * @datatype array |
38 | | - */ |
39 | | - 'fields' => null, |
40 | 35 | ); |
41 | 36 | |
42 | 37 | /* Functions */ |
— | — | @@ -51,12 +46,13 @@ |
52 | 47 | $xmlOutput .= DataCenterXml::open( 'table' ); |
53 | 48 | // Checks that an array of fields and valid rows were given |
54 | 49 | if ( |
55 | | - is_array( $parameters['fields'] ) && |
56 | | - ( $parameters['previous'] instanceof DataCenterDBRow ) && |
57 | | - ( $parameters['current'] instanceof DataCenterDBRow ) |
| 50 | + is_array( $parameters['previous'] ) && |
| 51 | + is_array( $parameters['current'] ) |
58 | 52 | ) { |
59 | 53 | // Loops over each field |
60 | | - foreach ( $parameters['fields'] as $field ) { |
| 54 | + foreach ( $parameters['current'] as $field => $value ) { |
| 55 | + // Detects changed field |
| 56 | + $different = ( $value !== $parameters['previous'][$field] ); |
61 | 57 | // Adds row |
62 | 58 | $xmlOutput .= DataCenterXml::row( |
63 | 59 | DataCenterXml::cell( |
— | — | @@ -65,11 +61,21 @@ |
66 | 62 | ), |
67 | 63 | DataCenterXml::cell( |
68 | 64 | array( 'class' => 'previous' ), |
69 | | - $parameters['previous']->get( $field ) |
| 65 | + DataCenterXml::span( |
| 66 | + array( |
| 67 | + 'class' => $different ? 'different' : 'same' |
| 68 | + ), |
| 69 | + $parameters['previous'][$field] |
| 70 | + ) |
70 | 71 | ), |
71 | 72 | DataCenterXml::cell( |
72 | 73 | array( 'class' => 'current' ), |
73 | | - $parameters['current']->get( $field ) |
| 74 | + DataCenterXml::span( |
| 75 | + array( |
| 76 | + 'class' => $different ? 'different' : 'same' |
| 77 | + ), |
| 78 | + $value |
| 79 | + ) |
74 | 80 | ) |
75 | 81 | ); |
76 | 82 | } |
Index: trunk/extensions/DataCenter/Views/Facilities.php |
— | — | @@ -10,15 +10,4 @@ |
11 | 11 | |
12 | 12 | /* Functions */ |
13 | 13 | |
14 | | - public function main( |
15 | | - $path |
16 | | - ) { |
17 | | - return DataCenterUI::renderLayout( |
18 | | - 'columns', |
19 | | - array( |
20 | | - __CLASS__, |
21 | | - __METHOD__ |
22 | | - ) |
23 | | - ); |
24 | | - } |
25 | 14 | } |
\ No newline at end of file |
Index: trunk/extensions/DataCenter/Views/History.php |
— | — | @@ -40,7 +40,8 @@ |
41 | 41 | 'link' => array( |
42 | 42 | 'page' => 'history', |
43 | 43 | 'type' => 'change', |
44 | | - 'action' => 'view' |
| 44 | + 'action' => 'view', |
| 45 | + 'id' => '#id', |
45 | 46 | ) |
46 | 47 | ) |
47 | 48 | ) |
— | — | @@ -58,7 +59,7 @@ |
59 | 60 | } |
60 | 61 | $change = DataCenterDB::getChange( $path['id'] ); |
61 | 62 | $component = DataCenterDB::getRow( |
62 | | - 'DataCenterComponent', |
| 63 | + 'DataCenterDBComponent', |
63 | 64 | $change->get( 'component_category' ), |
64 | 65 | $change->get( 'component_type' ), |
65 | 66 | $change->get( 'component_id' ) |
— | — | @@ -66,13 +67,24 @@ |
67 | 68 | return DataCenterUI::renderLayout( |
68 | 69 | 'columns', |
69 | 70 | array( |
70 | | - DataCenterUI::renderWidget( |
71 | | - 'difference', |
| 71 | + DataCenterUI::renderLayout( |
| 72 | + 'rows', |
72 | 73 | array( |
73 | | - 'row-a' => $component->get(), |
74 | | - 'row-b' => unserialize( $change->get( 'state' ) ) |
| 74 | + DataCenterUI::renderWidget( |
| 75 | + 'heading', |
| 76 | + array( 'message' => 'difference' ) |
| 77 | + ), |
| 78 | + DataCenterUI::renderWidget( |
| 79 | + 'difference', |
| 80 | + array( |
| 81 | + 'current' => $component->get(), |
| 82 | + 'previous' => unserialize( |
| 83 | + $change->get( 'state' ) |
| 84 | + ) |
| 85 | + ) |
| 86 | + ) |
75 | 87 | ) |
76 | | - ) |
| 88 | + ), |
77 | 89 | ) |
78 | 90 | ); |
79 | 91 | } |
— | — | @@ -83,7 +95,11 @@ |
84 | 96 | $path, |
85 | 97 | $component |
86 | 98 | ) { |
87 | | - $changes = $component->getChanges(); |
| 99 | + $changes = $component->getChanges( |
| 100 | + DataCenterDB::buildSort( |
| 101 | + 'meta', 'change', 'timestamp DESC' |
| 102 | + ) |
| 103 | + ); |
88 | 104 | return DataCenterUI::renderWidget( 'table', |
89 | 105 | array( |
90 | 106 | 'rows' => $changes, |
— | — | @@ -99,7 +115,8 @@ |
100 | 116 | 'link' => array( |
101 | 117 | 'page' => 'history', |
102 | 118 | 'type' => 'change', |
103 | | - 'action' => 'view' |
| 119 | + 'action' => 'view', |
| 120 | + 'id' => '#id', |
104 | 121 | ) |
105 | 122 | ) |
106 | 123 | ); |
Index: trunk/extensions/DataCenter/Views/Models.php |
— | — | @@ -198,6 +198,18 @@ |
199 | 199 | ); |
200 | 200 | } |
201 | 201 | |
| 202 | + public function history( |
| 203 | + $path |
| 204 | + ) { |
| 205 | + $asset = DataCenterDB::getAsset( $path['type'], $path['id'] ); |
| 206 | + return DataCenterUI::renderLayout( |
| 207 | + 'columns', |
| 208 | + array( |
| 209 | + DataCenterViewHistory::typeHistory( $path, $asset ) |
| 210 | + ) |
| 211 | + ); |
| 212 | + } |
| 213 | + |
202 | 214 | public function view( |
203 | 215 | $path |
204 | 216 | ) { |
Index: trunk/extensions/DataCenter/Views/Facilities/Space.php |
— | — | @@ -73,6 +73,18 @@ |
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
| 77 | + public function history( |
| 78 | + $path |
| 79 | + ) { |
| 80 | + $asset = DataCenterDB::getSpace( $path['id'] ); |
| 81 | + return DataCenterUI::renderLayout( |
| 82 | + 'columns', |
| 83 | + array( |
| 84 | + DataCenterViewHistory::typeHistory( $path, $asset ) |
| 85 | + ) |
| 86 | + ); |
| 87 | + } |
| 88 | + |
77 | 89 | public function view( |
78 | 90 | $path |
79 | 91 | ) { |
Index: trunk/extensions/DataCenter/Views/Facilities/Location.php |
— | — | @@ -77,6 +77,18 @@ |
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
| 81 | + public function history( |
| 82 | + $path |
| 83 | + ) { |
| 84 | + $asset = DataCenterDB::getLocation( $path['id'] ); |
| 85 | + return DataCenterUI::renderLayout( |
| 86 | + 'columns', |
| 87 | + array( |
| 88 | + DataCenterViewHistory::typeHistory( $path, $asset ) |
| 89 | + ) |
| 90 | + ); |
| 91 | + } |
| 92 | + |
81 | 93 | public function view( |
82 | 94 | $path |
83 | 95 | ) { |
Index: trunk/extensions/DataCenter/DataCenter.i18n.php |
— | — | @@ -166,6 +166,7 @@ |
167 | 167 | 'datacenter-ui-heading-models-type' => '$1 Assets', |
168 | 168 | 'datacenter-ui-heading-attaching-type' => 'Attaching $1', |
169 | 169 | 'datacenter-ui-heading-configuring-type' => 'Configuring $1', |
| 170 | + 'datacenter-ui-heading-difference' => 'Difference', |
170 | 171 | // Bodies |
171 | 172 | 'datacenter-ui-body-confirm-remove-type' => 'Removing this $1 will result in the removal of the following links and cannot be recovered from. Do you want to continue with the removal?', |
172 | 173 | 'datacenter-ui-body-invalid-request' => 'You have requested a page with an invalid path.', |