public function history($path) { if ($path['type'] == 'location') { $facility = DataCenterDB::getLocation($path['id']); } elseif ($path['type'] == 'space') { $facility = DataCenterDB::getSpace($path['id']); } else { return null; } return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'history-type', 'subject' => DataCenterUI::message('type', $path['type']))), DataCenterUI::renderWidget('history', array('component' => $facility)))))); }
public function configure($path) { // Detects mode if (!$path['id']) { // Creates new component $field = DataCenterDBMetaField::newFromValues(); // Sets 'do' specific parameters $formParameters = array('label' => 'add', 'success' => array('page' => 'settings', 'type' => 'field')); $rows = array(DataCenterUI::renderWidget('heading', array('message' => 'adding-type', 'type' => 'field'))); } else { // Gets component from database $field = DataCenterDB::getMetaField($path['id']); // Sets 'do' specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'settings', 'type' => 'field', 'action' => 'view', 'id' => $path['id'])); $rows = array(DataCenterUI::renderWidget('heading', array('message' => 'configuring-type', 'type' => 'field')), DataCenterUI::renderWidget('body', array('message' => 'important-configuring-field', 'style' => 'important'))); } // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array_merge($rows, array(DataCenterUI::renderWidget('form', array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'settings', 'type' => 'field'), 'row' => $field, 'fields' => array('name' => array('type' => 'string'), 'format' => array('type' => 'list', 'enum' => array('category' => 'meta', 'type' => 'field', 'field' => 'format'))))))))), ' ')); }
public function edit($path) { // Checks if... if (!$path['id'] && is_array($path['parameter']) && count($path['parameter'] >= 2) && $path['parameter'][0] == 'location') { // Creates new facility with default parameters $space = DataCenterDBSpace::newFromValues(array('location' => $path['parameter'][1], 'tense' => 'present', 'name' => DataCenterUI::message('default', 'new-type', DataCenterUI::message('type', 'space')))); // Sets 'do' specific parameters $formParameters = array('label' => 'add', 'hidden' => array($path['parameter'][0]), 'success' => array('page' => 'facilities', 'type' => $path['parameter'][0], 'action' => 'view', 'id' => $path['parameter'][1]), 'type' => 'add'); $headingParameters = array('message' => 'adding-type', 'subject' => DataCenterUI::message('type', $path['type'])); } else { // Gets facility from database $space = DataCenterDB::getSpace($path['id']); // Sets 'do' specific parameters $formParameters = array('label' => 'save', 'hidden' => array('location', 'id'), 'success' => array('page' => 'facilities', 'type' => 'space', 'action' => 'view', 'id' => $path['id']), 'type' => 'edit'); $headingParameters = array('message' => 'editing-type', 'subject' => DataCenterUI::message('type', $path['type'])); } // Builds JavaScript to access renderable facility $jsTarget = DataCenterJs::chain(array("dataCenter.renderer.getTarget" => DataCenterJs::toScalar('space'), 'getModule'), false); // Complete form parameters $formParameters = array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'facilities', 'type' => 'space'), 'row' => $space, 'fields' => array('tense' => array('type' => 'tense', 'disable' => array('past')), 'name' => array('type' => 'string'), 'width' => array('type' => 'number', 'effect' => $jsTarget . '.setWidth( {this}.value, true );'), 'height' => array('type' => 'number', 'effect' => $jsTarget . '.setHeight( {this}.value, true );'), 'depth' => array('type' => 'number', 'effect' => $jsTarget . '.setDepth( {this}.value, true );'), 'power' => array('type' => 'number', 'min' => 0, 'max' => 100000, 'step' => 100)))); // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', $formParameters))), DataCenterUI::renderWidget('space', array('space' => $space)))); }
public function edit($path) { // Detects mode if (!$path['id']) { // Creates a new facility location $location = DataCenterDBLocation::newFromValues(array('tense' => 'present', 'name' => DataCenterUI::message('default', 'new-type', DataCenterUI::message('type', 'location')))); // Sets 'do' specific parameters $formParameters = array('label' => 'add', 'success' => array('page' => 'facilities', 'type' => 'location'), 'type' => 'add'); $headingParameters = array('message' => 'adding-type', 'subject' => DataCenterUI::message('type', $path['type'])); } else { // Gets facility location from database $location = DataCenterDB::getLocation($path['id']); // Sets 'do' specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'facilities', 'type' => 'location', 'action' => 'view', 'id' => $path['id']), 'type' => 'edit'); $headingParameters = array('message' => 'editing-type', 'subject' => DataCenterUI::message('type', $path['type'])); } // Builds JavaScript that hooks the button into the geocoder $jsForm = 'document.form_save'; $jsOut = DataCenterJs::callFunction('addHandler', array("{$jsForm}.field_button_0", DataCenterJs::toScalar('click'), DataCenterJs::buildFunction(null, DataCenterJs::chain(array('dataCenter.renderer.getTarget' => DataCenterJs::toScalar('map'), 'showAddress' => array('document.form_save.field_region.value', DataCenterJs::toObject(array('latField' => "'{$jsForm}.field_latitude'", 'lngField' => "'{$jsForm}.field_longitude'")))))))); // Complete form parameters $formParameters = array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'facilities', 'type' => 'location'), 'row' => $location, 'fields' => array('tense' => array('type' => 'tense', 'disable' => !$path['id'] ? array('past') : array()), 'name' => array('type' => 'string'), 'region' => array('type' => 'string'), array('type' => 'button', 'label' => 'lookup'), 'latitude' => array('type' => 'string'), 'longitude' => array('type' => 'string')))); // Returns 2 columm layout with a form and a map widget return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', $formParameters))), DataCenterUI::renderWidget('map', !$path['id'] ? array() : array('location' => $location)))) . DataCenterXml::script($jsOut); }
public function configure($path) { // Detects mode if (!$path['id']) { if (is_array($path['parameter']) && count($path['parameter']) >= 2 && $path['parameter'][0] == 'space') { // Gets space from database $space = DataCenterDB::getSpace($path['parameter'][1]); // Creates new component $plan = DataCenterDBPlan::newFromValues(array('space' => $path['parameter'][1], 'tense' => 'present', 'name' => $space->get('name'))); // Sets 'do' specific parameters $formParameters = array('label' => 'create', 'hidden' => array('space'), 'success' => array('page' => 'plans')); $headingParameters = array('message' => 'adding-type', 'type' => 'plan'); } else { throw new MWException('Invalid parameters. space,# expected.'); } } else { // Gets component from database $plan = DataCenterDB::getPlan($path['id']); // Sets 'do' specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'plans', 'type' => 'plan', 'action' => 'view', 'id' => $path['id'])); $headingParameters = array('message' => 'configuring-type', 'type' => 'plan'); } // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'plans', 'type' => 'plan'), 'row' => $plan, 'fields' => array('tense' => array('type' => 'tense', 'disable' => !$path['id'] ? array('past') : array()), 'name' => array('type' => 'string'), 'note' => array('type' => 'text'))))))), DataCenterUI::renderWidget('plan', array('plan' => $plan)))); }
public function configure($path) { // Checks if... if (!$path['id'] && is_array($path['parameter']) && count($path['parameter']) >= 3 && $path['parameter'][0] == 'rack') { $object = DataCenterDB::getAsset('object', $path['parameter'][2]); $model = $object->getModel(); $rackLink = DataCenterDB::getAssetLink($path['parameter'][1]); $rack = $rackLink->getAsset(); $plan = DataCenterDB::getPlan($rackLink->get('plan')); $objectLink = DataCenterDBAssetLink::newFromValues(array('name' => $model->get('kind'), 'plan' => $plan->getId(), 'parent_link' => $rackLink->getId(), 'asset_type' => 'object', 'asset_id' => $object->getId(), 'z' => 1, 'orientation' => 0)); // Sets action specific parameters $formParameters = array('label' => 'attach', 'hidden' => array('plan', 'parent_link', 'asset_type', 'asset_id'), 'success' => array('page' => 'plans', 'type' => $path['parameter'][0], 'action' => 'view', 'id' => $path['parameter'][1])); $headingParameters = array('message' => 'attaching-type', 'type' => 'object'); } else { // Gets asset from database $objectLink = DataCenterDB::getAssetLink($path['id']); // Gets object that object link links to $object = $objectLink->getAsset(); // Gets plan from database $plan = DataCenterDB::getPlan($objectLink->get('plan')); // Gets rack link object is linked to $rackLink = DataCenterDB::getAssetLink($objectLink->get('parent_link')); // Extracts rack from rack link $rack = $rackLink->getAsset(); // Sets action specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'plans', 'type' => 'object', 'action' => 'view', 'id' => $path['id'])); $headingParameters = array('message' => 'configuring-type', 'type' => 'object'); } // Builds javascript that references the renderable asset $target = array('dataCenter.renderer.getTarget' => array(DataCenterJs::toScalar('plan')), 'getModule'); $rackId = $rack->getId(); $rackModel = $rack->getModel(); $objectModel = $object->getModel(); $objectId = $object->getId(); $maxZ = $rackModel->get('units') - $objectModel->get('units') + 1; // Builds form parameters $formFields = array('name' => array('type' => 'string'), 'position' => array('type' => 'number', 'field' => 'z', 'min' => 1, 'max' => $maxZ, 'effect' => DataCenterJs::chain(array_merge($target, array('setObjectPosition' => array(DataCenterJs::toScalar($rackId), DataCenterJs::toScalar($objectId), '{this}.value', DataCenterJs::toScalar(true)))), false)), 'orientation' => array('type' => 'number', 'min' => 0, 'max' => 1, 'effect' => DataCenterJs::chain(array_merge($target, array('setObjectOrientation' => array(DataCenterJs::toScalar($rackId), DataCenterJs::toScalar($objectId), '{this}.value', DataCenterJs::toScalar(true)))), false))); // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'plans', 'type' => 'object'), 'row' => $objectLink, 'fields' => $formFields))))), DataCenterUI::renderWidget('plan', array('plan' => $plan, 'current-rack' => $rack->getId(), 'look-at-rack' => $rack->getId(), 'current-object' => $object->getId(), 'include' => !$path['id'] ? $objectLink : null)))); }
public function main($path) { $plans = DataCenterDB::getPlans(DataCenterDB::buildSort('meta', 'plan', array('space', 'tense DESC'))); $numPlans = DataCenterDB::numPlans(); return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'plans')), DataCenterUI::renderWidget('table', array('rows' => $plans, 'num' => $numPlans, 'fields' => array('name', 'space' => array('field' => 'space_name'), 'tense' => array('format' => 'option')), 'link' => array('page' => 'plans', 'action' => 'view', 'type' => 'plan', 'id' => '#id'))))))); }
public function main($path) { return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'overview')), DataCenterUI::renderWidget('body', array('message' => 'important-welcome', 'style' => 'important')))))); }
public function manage($path) { // Checks if... if (!$path['id'] && is_scalar($path['parameter'])) { // Creates new asset with default parameters $asset = DataCenterDBAsset::newFromType($path['type'], array('model' => $path['parameter'], 'tense' => 'present')); // Sets action specific parameters $formParameters = array('label' => 'deploy', 'hidden' => array('model'), 'success' => array('page' => 'assets', 'type' => $path['type']), 'type' => 'deploy'); $headingParameters = array('message' => 'deploying-asset-type', 'subject' => DataCenterUI::message('type', $path['type'])); } else { // Gets asset from database $asset = DataCenterDB::getAsset($path['type'], $path['id']); // Sets 'do' specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'assets', 'type' => $path['type'], 'action' => 'view', 'id' => $path['id']), 'type' => 'manage'); $headingParameters = array('message' => 'managing-asset-type', 'subject' => DataCenterUI::message('type', $path['type'])); } // Gets model from database $model = $asset->getModel(); // Gets list of locations $locations = DataCenterDB::getLocations(); // Completes form parameters $formParameters = array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'assets', 'type' => $path['type']), 'row' => $asset, 'fields' => array('tense' => array('type' => 'tense', 'disable' => !$path['id'] ? array('past') : array()), 'location' => array('type' => 'list', 'rows' => $locations, 'labels' => array('name', 'region'), 'glue' => ' / '), 'serial' => array('type' => 'string'), 'asset' => array('type' => 'string')))); // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', $formParameters))), DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'model-type', 'type' => $path['type'])), DataCenterUI::renderWidget('details', array_merge(self::$options[$path['type']]['details'], array('row' => $model))))))); }
public function results($path) { return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', array('message' => 'search-results')), DataCenterUI::renderWidget('searchresults', array('query' => $path['parameter'])))))); }
public function modify($path) { // Checks if the type is supported if (!isset(self::$options[$path['type']]['gallery'])) { // Returns error message return wfMsg('datacenter-error-invalid-data'); } // Detects mode if (!$path['id']) { // Creates new component $model = DataCenterDBModel::newFromType($path['type']); // Sets 'do' specific parameters $formParameters = array('label' => 'create', 'success' => array('page' => 'models', 'type' => $path['type']), 'type' => 'create'); $headingParameters = array('message' => 'creating-model-type', 'subject' => DataCenterUI::message('type', $path['type'])); } else { // Gets component from database $model = DataCenterDB::getModel($path['type'], $path['id']); // Sets 'do' specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'models', 'type' => $path['type'], 'action' => 'view', 'id' => $path['id']), 'type' => 'modify'); $headingParameters = array('message' => 'modifying-model-type', 'subject' => DataCenterUI::message('type', $path['type'])); } // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', array_merge($formParameters, self::$options[$path['type']]['form'], array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'models', 'type' => $path['type']), 'row' => $model))))), '[MODEL VIEWER]')); }
public function configure($path) { // Checks if... if (!$path['id'] && is_array($path['parameter']) && count($path['parameter']) >= 3 && $path['parameter'][0] == 'plan') { // Gets plan from database $plan = DataCenterDB::getPlan($path['parameter'][1]); // Creates new asset with default parameters $rack = DataCenterDB::getAsset('rack', $path['parameter'][2]); // Creates new asset link $rackLink = DataCenterDBAssetLink::newFromValues(array('name' => DataCenterUI::message('type', 'rack'), 'plan' => $plan->getId(), 'asset_type' => 'rack', 'asset_id' => $rack->getId(), 'x' => 1, 'y' => 1, 'orientation' => 0)); // Sets action specific parameters $formParameters = array('label' => 'attach', 'hidden' => array('plan', 'asset_type', 'asset_id'), 'success' => array('page' => 'plans', 'type' => 'plan', 'action' => 'view', 'id' => $path['parameter'][1])); $headingParameters = array('message' => 'attaching-type', 'type' => 'rack'); } else { // Gets asset from database $rackLink = DataCenterDB::getAssetLink($path['id']); // Gets rack that rack link links to $rack = $rackLink->getAsset(); // Gets plan from database $plan = DataCenterDB::getPlan($rackLink->get('plan')); // Sets action specific parameters $formParameters = array('label' => 'save', 'hidden' => array('id'), 'success' => array('page' => 'plans', 'type' => 'rack', 'action' => 'view', 'id' => $path['id'])); $headingParameters = array('message' => 'configuring-type', 'type' => 'rack'); } // Gets parent asset from database $space = $plan->getSpace(); // Builds javascript that references the renderable asset $target = array('dataCenter.renderer.getTarget' => array(DataCenterJs::toScalar('plan')), 'getModule'); $objectId = $rack->getId(); // Builds form parameters $formParameters = array_merge($formParameters, array('do' => 'save', 'failure' => $path, 'action' => array('page' => 'plans', 'type' => 'rack'), 'row' => $rackLink, 'fields' => array('name' => array('type' => 'string'), 'position' => array('fields' => array('x' => array('field' => 'x', 'min' => 1, 'max' => $space->get('width')), 'y' => array('field' => 'y', 'min' => 1, 'max' => $space->get('depth'))), 'type' => 'position', 'effect' => DataCenterJs::chain(array_merge($target, array('setRackPosition' => array(DataCenterJs::toScalar($objectId), '{this.x}.value', '{this.y}.value', DataCenterJs::toScalar(true)))), false), 'mode' => 'iso'), 'orientation' => array('type' => 'number', 'min' => 0, 'max' => 3, 'effect' => DataCenterJs::chain(array_merge($target, array('setRackOrientation' => array(DataCenterJs::toScalar($objectId), '{this}.value', DataCenterJs::toScalar(true)))), false))))); // Returns 2 columm layout with a form and a scene return DataCenterUI::renderLayout('columns', array(DataCenterUI::renderLayout('rows', array(DataCenterUI::renderWidget('heading', $headingParameters), DataCenterUI::renderWidget('form', $formParameters))), DataCenterUI::renderWidget('plan', array('plan' => $plan, 'zoom-from-rack' => $rack->getIdOrZero(), 'current-rack' => $rack->getId(), 'include' => $rackLink)))); }