Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit db0c179

Browse files
author
Jamie Snape
committed
Migrate visualize module settings to database
1 parent 5a7af21 commit db0c179

File tree

19 files changed

+472
-424
lines changed

19 files changed

+472
-424
lines changed

modules/visualize/Notification.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/** Notification manager for the visualize module */
2222
class Visualize_Notification extends MIDAS_Notification
2323
{
24+
public $_models = array('Setting');
2425
public $_moduleComponents = array('Main');
2526
public $moduleName = 'visualize';
2627

@@ -77,9 +78,9 @@ public function canVisualize($params)
7778
/** generate dashboard information */
7879
public function getDashboard()
7980
{
80-
$modulesConfig = Zend_Registry::get('configsModules');
81-
$useparaview = $modulesConfig['visualize']->useparaview;
82-
if (!isset($useparaview) || !$useparaview) {
81+
$useParaView = $this->Setting->getValueByName(VISUALIZE_USE_PARAVIEW_WEB_KEY, $this->moduleName);
82+
83+
if (!isset($useParaView) || !$useParaView) {
8384
return false;
8485
}
8586

@@ -90,10 +91,10 @@ public function getDashboard()
9091
'503 Service Temporarily Unavailable'
9192
) !== false
9293
) {
93-
return array('ParaviewWeb Server' => array(false, 'Could not connect to paraview web server'));
94+
return array('ParaViewWeb Server' => array(false, 'Could not connect to ParaViewWeb server'));
9495
}
9596

96-
return array('ParaviewWeb Server' => array(true, ''));
97+
return array('ParaViewWeb Server' => array(true, ''));
9798
}
9899

99100
/** get server's url */
Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
[global]
2-
; version of the module
3-
version = 1.0.0
4-
; full name
5-
fullname = Visualization
6-
; description
7-
description = "Preview online various types of document (Beta version)"
8-
; category
9-
category = Visualization
10-
; dependencies
11-
dependencies = scheduler,api
1+
; MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
122

13-
useparaview = "true"
14-
userwebgl = "true"
15-
customtmp = ''
16-
pwapp = ''
17-
pvbatch = ''
18-
paraviewworkdir = ''
19-
usesymlinks = "true"
3+
[global]
4+
fullname = "Visualization"
5+
description = "Preview various types of document"
6+
category = "Visualization"
7+
dependencies = api,scheduler
8+
uuid = "43f85590-c8d7-403a-82cd-9e46300afd12"
9+
version = "1.1.0"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
5+
All rights reserved.
6+
More information http://www.kitware.com
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
define('VISUALIZE_TEMPORARY_DIRECTORY_KEY', 'temporary_directory');
22+
define('VISUALIZE_TEMPORARY_DIRECTORY_DEFAULT_VALUE', '');
23+
define('VISUALIZE_USE_PARAVIEW_WEB_KEY', 'use_paraview_web');
24+
define('VISUALIZE_USE_PARAVIEW_WEB_DEFAULT_VALUE', '');
25+
define('VISUALIZE_USE_WEB_GL_KEY', 'use_web_gl');
26+
define('VISUALIZE_USE_WEB_GL_DEFAULT_VALUE', '');
27+
define('VISUALIZE_USE_SYMLINKS_KEY', 'use_symlinks');
28+
define('VISUALIZE_USE_SYMLINKS_DEFAULT_VALUE', '');
29+
define('VISUALIZE_TOMCAT_ROOT_URL_KEY', 'tomcat_root_url');
30+
define('VISUALIZE_TOMCAT_ROOT_URL_DEFAULT_VALUE', '');
31+
define('VISUALIZE_PVBATCH_COMMAND_KEY', 'pvbatch_command');
32+
define('VISUALIZE_PVBATCH_COMMAND_DEFAULT_VALUE', '');
33+
define('VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_KEY', 'paraview_web_work_directory');
34+
define('VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_DEFAULT_VALUE', '');
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
5+
All rights reserved.
6+
More information http://www.kitware.com
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
/** Admin controller for the visualize module. */
22+
class Visualize_AdminController extends Visualize_AppController
23+
{
24+
/** @var array */
25+
public $_models = array('Setting');
26+
27+
/** Index action */
28+
public function indexAction()
29+
{
30+
$this->requireAdminPrivileges();
31+
32+
$this->view->pageTitle = 'Visualize Module Configuration';
33+
$form = new Visualize_Form_Admin();
34+
35+
if ($this->getRequest()->isPost()) {
36+
$data = $this->getRequest()->getPost();
37+
38+
if ($form->isValid($data)) {
39+
$values = $form->getValues();
40+
41+
foreach ($values as $key => $value) {
42+
if ($value !== null) {
43+
$this->Setting->setConfig($key, $value, $this->moduleName);
44+
}
45+
}
46+
}
47+
48+
$form->populate($data);
49+
} else {
50+
$elements = $form->getElements();
51+
52+
foreach ($elements as $element) {
53+
$name = $element->getName();
54+
55+
if ($name !== 'csrf' && $name !== 'submit') {
56+
$value = $this->Setting->getValueByName($name, $this->moduleName);
57+
58+
if (!is_null($value)) {
59+
$form->setDefault($name, $value);
60+
}
61+
}
62+
}
63+
}
64+
65+
$this->view->form = $form;
66+
session_start();
67+
}
68+
}

modules/visualize/controllers/ConfigController.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)