This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revise tracker module configuration form and add install script
- Loading branch information
Jamie Snape
committed
Dec 8, 2014
1 parent
3ebfbca
commit 5a7af21
Showing
10 changed files
with
188 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
; MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0. | ||
|
||
[global] | ||
; version of the module | ||
version = 1.0.5 | ||
; full name of the module (displayed on admin page) | ||
fullname = Tracker Dashboard | ||
; description (displayed on admin page) | ||
description = "Tracks scalar results over time" | ||
; category | ||
category = Visualization | ||
; dependencies (comma separated list of other module dependencies) | ||
fullname = "Tracker Dashboard" | ||
description = "Track scalar results over time" | ||
category = "Visualization" | ||
dependencies = api,scheduler | ||
uuid = "3048a9fa-89ab-4e61-a55e-a49379fa6dc" | ||
version = "1.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information http://www.kitware.com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** Admin controller for the tracker module. */ | ||
class Tracker_AdminController extends Tracker_AppController | ||
{ | ||
/** @var array */ | ||
public $_models = array('Setting'); | ||
|
||
/** Index action */ | ||
public function indexAction() | ||
{ | ||
$this->requireAdminPrivileges(); | ||
|
||
$this->view->pageTitle = 'Tracker Module Configuration'; | ||
$form = new Tracker_Form_Admin(); | ||
|
||
if ($this->getRequest()->isPost()) { | ||
$data = $this->getRequest()->getPost(); | ||
|
||
if ($form->isValid($data)) { | ||
$values = $form->getValues(); | ||
|
||
foreach ($values as $key => $value) { | ||
if ($value !== null) { | ||
$this->Setting->setConfig($key, $value, $this->moduleName); | ||
} | ||
} | ||
} | ||
|
||
$form->populate($data); | ||
} else { | ||
$elements = $form->getElements(); | ||
|
||
foreach ($elements as $element) { | ||
$name = $element->getName(); | ||
|
||
if ($name !== 'csrf' && $name !== 'submit') { | ||
$value = $this->Setting->getValueByName($name, $this->moduleName); | ||
|
||
if (!is_null($value)) { | ||
$form->setDefault($name, $value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$this->view->form = $form; | ||
session_start(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information http://www.kitware.com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
require_once BASE_PATH.'/modules/tracker/constant/module.php'; | ||
|
||
/** Install the tracker module. */ | ||
class Tracker_InstallScript extends MIDASModuleInstallScript | ||
{ | ||
/** @var string */ | ||
public $moduleName = 'tracker'; | ||
|
||
/** Post database install. */ | ||
public function postInstall() | ||
{ | ||
/** @var SettingModel $settingModel */ | ||
$settingModel = MidasLoader::loadModel('Setting'); | ||
$settingModel->setConfig(MIDAS_TRACKER_TEMP_SCALAR_TTL_KEY, MIDAS_TRACKER_TEMP_SCALAR_TTL_DEFAULT_VALUE, $this->moduleName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information http://www.kitware.com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** Admin form for the tracker module. */ | ||
class Tracker_Form_Admin extends Zend_Form | ||
{ | ||
/** Initialize this form. */ | ||
public function init() | ||
{ | ||
$this->setName('tracker_admin'); | ||
$this->setMethod('POST'); | ||
|
||
$csrf = new Midas_Form_Element_Hash('csrf'); | ||
$csrf->setSalt('APSey8FJpXfDssQU5CqA9qe5'); | ||
$csrf->setDecorators(array('ViewHelper')); | ||
|
||
$tempScalarTtl = new Zend_Form_Element_Text(MIDAS_TRACKER_TEMP_SCALAR_TTL_KEY); | ||
$tempScalarTtl->setLabel('Unofficial Scalar TTL'); | ||
$tempScalarTtl->setRequired(true); | ||
$tempScalarTtl->addValidator('NotEmpty', true); | ||
$tempScalarTtl->addValidator('Digits', true); | ||
$tempScalarTtl->addValidator('GreaterThan', true, array('min' => 0)); | ||
|
||
$this->addDisplayGroup(array($tempScalarTtl), 'global'); | ||
|
||
$submit = new Zend_Form_Element_Submit('submit'); | ||
$submit->setLabel('Save'); | ||
|
||
$this->addElements(array($csrf, $tempScalarTtl, $submit)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters