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

Commit ce59f28

Browse files
author
Charles Ma
committed
ENH: refs #301 Added create folder in small browser
Added multi folder selection in the remoteprocessing.job.init
1 parent e58a729 commit ce59f28

File tree

4 files changed

+82
-34
lines changed

4 files changed

+82
-34
lines changed

modules/remoteprocessing/controllers/components/ExecutableComponent.php

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,31 @@ function initAndSchedule($itemDao, $xmlMeta, $javascriptResults)
9494
}
9595
else if($option->field->external == 1)
9696
{
97-
$item = $itemModel->load($result);
98-
if($item == false)
97+
if(strpos($result, 'folder') !== false)
9998
{
100-
throw new Zend_Exception('Unable to find item');
99+
$folder = $folderModel->load(str_replace('folder', '', $result));
100+
if($folder == false)
101+
{
102+
throw new Zend_Exception('Unable to find folder');
103+
}
104+
$items = $folder->getItems();
105+
$cmdOptions[$i] = array('type' => 'input', 'item' => array());
106+
foreach($items as $item)
107+
{
108+
$inputArray[] = $item;
109+
$cmdOptions[$i]['item'][] = $item;
110+
}
111+
}
112+
else
113+
{
114+
$item = $itemModel->load($result);
115+
if($item == false)
116+
{
117+
throw new Zend_Exception('Unable to find item');
118+
}
119+
$inputArray[] = $item;
120+
$cmdOptions[$i] = array('type' => 'input', 'item' => array($item));
101121
}
102-
$inputArray[] = $item;
103-
$cmdOptions[$i] = array('type' => 'input', 'item' => $item);
104122
}
105123
else
106124
{
@@ -152,14 +170,7 @@ function initAndSchedule($itemDao, $xmlMeta, $javascriptResults)
152170
foreach($commandMatrix as $key => $commandList)
153171
{
154172
$command = $executable->getName().' '. join('', $commandList);
155-
if($key == 1)
156-
{
157-
$command = str_replace('{{key}}', '', $command);
158-
}
159-
else
160-
{
161-
$command = str_replace('{{key}}', $key, $command);
162-
}
173+
$command = str_replace('{{key}}', $key, $command);
163174

164175
$script .= "process = subprocess.Popen('".$command."', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n";
165176
$script .= "process.wait()\n";
@@ -223,20 +234,45 @@ private function _createParametersMatrix($cmdOptions)
223234

224235
if($cmdOption['type'] == 'input')
225236
{
226-
$value .= '"'.$cmdOption['item']->getName().'" ';
237+
$values = $cmdOption['item'];
238+
$j = 0;
239+
for($i = 1; $i <= $totalLine; $i++)
240+
{
241+
$tmpvalue = $value.$values[$j]->getName().' ';
242+
if($i % $multipleElement == 0)
243+
{
244+
$j++;
245+
}
246+
if(!isset($values[$j]))
247+
{
248+
$j = 0;
249+
}
250+
$matrix[$i][$key] = $tmpvalue;
251+
}
252+
if(count($values) > 1)
253+
{
254+
$multipleElement = $multipleElement * count($values);
255+
}
227256
}
228257
elseif($cmdOption['type'] == 'output')
229258
{
230259
$ext = end(explode('.', $cmdOption['fileName']));
231260
$value .= '"'. str_replace('.'.$ext, '{{key}}.'.$ext, $cmdOption['fileName']).'" ';
261+
for($i = 1; $i <= $totalLine; $i++)
262+
{
263+
$matrix[$i][$key] = $value;
264+
}
232265
}
233-
234-
if($cmdOption['type'] == 'param')
266+
elseif($cmdOption['type'] == 'param')
235267
{
236268
$values = $cmdOption['values'];
237269
$j = 0;
238270
for($i = 1; $i <= $totalLine; $i++)
239271
{
272+
if(!isset($values[$j]))
273+
{
274+
$j = 0;
275+
}
240276
$tmpvalue = $value.$values[$j].' ';
241277
if($i % $multipleElement == 0)
242278
{
@@ -249,13 +285,6 @@ private function _createParametersMatrix($cmdOptions)
249285
$multipleElement = $multipleElement * count($values);
250286
}
251287
}
252-
else
253-
{
254-
for($i = 1; $i <= $totalLine; $i++)
255-
{
256-
$matrix[$i][$key] = $value;
257-
}
258-
}
259288
}
260289
return $matrix;
261290
}

modules/remoteprocessing/public/js/job/job.init.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ var currentBrowser = false;
33
$(document).ready(function(){
44

55
$('.selectInputFileLink').click(function(){
6-
loadDialog("select_"+$(this).attr('order'),"/browse/selectitem");
6+
loadDialog("selectitem_"+$(this).attr('order'),"/browse/selectitem");
77
showDialog('Browse');
88
currentBrowser = $(this).attr('order');
99
});
1010

1111
$('.selectOutputFolderLink').click(function(){
12-
loadDialog("select_"+$(this).attr('order'),"/browse/selectfolder");
12+
loadDialog("selectfolder_"+$(this).attr('order'),"/browse/selectfolder?policy=write");
13+
showDialog('Browse');
14+
currentBrowser = $(this).attr('order');
15+
});
16+
17+
$('.selectInputFolderLink').click(function(){
18+
loadDialog("selectfolder_"+$(this).attr('order'),"/browse/selectfolder?policy=read");
1319
showDialog('Browse');
1420
currentBrowser = $(this).attr('order');
1521
});
@@ -33,14 +39,22 @@ $(document).ready(function(){
3339
}
3440
else if($(this).find('.selectInputFileLink').length > 0)
3541
{
36-
if($(this).find('.selectedItem').attr('element') == '')
42+
if($(this).find('.selectedItem').attr('element') == '' && $(this).find('.selectedFolderContent').attr('element') == '')
3743
{
3844
createNotive('Please set '+$(this).attr('name'), 4000);
3945
cansubmit = false;
4046
}
4147
else
4248
{
43-
results[i] = $(this).find('.selectedItem').attr('element');
49+
var folderElement = $(this).find('.selectedFolderContent').attr('element');
50+
if(folderElement != '')
51+
{
52+
results[i] = 'folder'+folderElement;
53+
}
54+
else
55+
{
56+
results[i] = $(this).find('.selectedItem').attr('element');
57+
}
4458
}
4559
}
4660
else
@@ -87,16 +101,21 @@ $(document).ready(function(){
87101
function itemSelectionCallback(name, id)
88102
{
89103
var optionWrapper = $('#option_'+currentBrowser);
90-
optionWrapper.find('.selectedItem').html(name);
104+
optionWrapper.find('.selectedItem').html('Item '+name);
91105
optionWrapper.find('.selectedItem').attr('element',id);
106+
optionWrapper.find('.selectedFolder').attr('element', '');
92107
updateGeneratedCommand()
93108
}
94109

95110
function folderSelectionCallback(name, id)
96111
{
97112
var optionWrapper = $('#option_'+currentBrowser);
98-
optionWrapper.find('.selectedFolder').html(name);
99-
optionWrapper.find('.selectedFolder').attr('element',id);
113+
optionWrapper.find('.selectedFolderContent').html('Folder '+name);
114+
optionWrapper.find('.selectedFolder').html('Folder '+name);
115+
optionWrapper.find('.selectedItem').html('Folder '+name);
116+
optionWrapper.find('.selectedFolderContent').attr('element', id);
117+
optionWrapper.find('.selectedFolder').attr('element', id);
118+
optionWrapper.find('.selectedItem').attr('element', '');
100119
updateGeneratedCommand()
101120
}
102121

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
securityKey 4ea92d605a51e
2+
securityKey 4ea975edc43a9
33
url http://localhost/Midas/Midas3
44
os windows

modules/remoteprocessing/views/job/init.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This software is distributed WITHOUT ANY WARRANTY; without even
99
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
1010
PURPOSE. See the above copyright notices for more information.
1111
=========================================================================*/
12-
12+
$this->headScript()->appendFile($this->coreWebroot . '/public/js/jquery/jquery.form.js');
1313
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/job/job.init.js');
1414
?>
1515
<link type="text/css" rel="stylesheet" href="<?php echo $this->moduleWebroot?>/public/css/job/job.init.css" />
@@ -79,8 +79,8 @@ function elementOuputFile($i, $option)
7979

8080
function elementInputFile($i, $option)
8181
{
82-
echo "<a class='selectInputFileLink' order='$i'>Select Input File</a><br/>";
83-
echo "Selected: <span class='selectedItem' element=''></span>";
82+
echo "<a class='selectInputFileLink' order='$i'>Select Input File</a> or <a qtip='All the data contained in the selected folder will be processed' class='selectInputFolderLink' order='$i'>Select Input Folder</a><br/>";
83+
echo "Selected: <span style='display:none'; class='selectedFolderContent' element=''></span><span class='selectedItem' element=''></span>";
8484
}
8585

8686
function elementInputParam($i, $option)

0 commit comments

Comments
 (0)