Upgrade GIS visualization page

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2014-12-05 17:26:54 +05:30
parent a750a799d7
commit 806178eca2
6 changed files with 57 additions and 85 deletions

View File

@ -200,7 +200,7 @@ AJAX.registerTeardown('tbl_gis_visualization.js', function () {
AJAX.registerOnload('tbl_gis_visualization.js', function () {
// If we are in GIS visualization, initialize it
if ($('table.gis_table').length > 0) {
if ($('#gis_div').length > 0) {
initGISVisualization();
}

View File

@ -121,14 +121,14 @@ function PMA_GIS_saveToFile($data, $visualizationSettings, $format, $fileName)
*
* @return string $html
*/
function PMA_getHtmlForColumn($column, $columnCandidates, $visualizationSettings)
function PMA_getHtmlForSelect($column, $columnCandidates, $visualizationSettings)
{
$html = '<tr><td><label for="labelColumn">';
$html = '<label for="' . $column . '">';
$html .= ($column=="labelColumn") ? __("Label column") : __("Spatial column");
$html .= '</label></td>';
$html .= '</label>';
$html .= '<td><select name="visualizationSettings[' . $column . ']" id="'
. $column . '">';
$html .= '<select name="visualizationSettings[' . $column . ']" id="'
. $column . '" class="autosubmit">';
if ($column == "labelColumn") {
$html .= '<option value="">' . __("-- None --") . '</option>';
@ -138,8 +138,7 @@ function PMA_getHtmlForColumn($column, $columnCandidates, $visualizationSettings
$columnCandidates, array($visualizationSettings[$column])
);
$html .= '</select></td>';
$html .= '</tr>';
$html .= '</select>';
return $html;
}
@ -168,6 +167,25 @@ function PMA_getHtmlForUseOpenStreetMaps($isSelected)
return $html;
}
/**
* Get the link for downloading GIS visualization in a particular format.
*
* @param string $url base url
* @param string $name format name
* @param string $label format label
*
* @return string HTML for download link
*/
function PMA_getHtmlForGisDownloadLink($url, $name, $label)
{
$html = '<li class="warp_link">';
$html .= '<a href="' . $url . '&fileFormat=' . $name . '"'
. ' class="disableAjax">' . $label . '</a>';
$html .= '</li>';
return $html;
}
/**
* Function to generate HTML for the GIS visualization page
*
@ -190,66 +208,47 @@ function PMA_getHtmlForGisVisualization(
$html .= '<fieldset>';
$html .= '<legend>' . __('Display GIS Visualization') . '</legend>';
$html .= '<div style="width: 400px; float: left;">';
$html .= '<div id="gis_div" style="position:relative;">';
$html .= '<form method="post" action="tbl_gis_visualization.php">';
$html .= PMA_URL_getHiddenInputs($url_params);
$html .= '<table class="gis_table">';
$html .= PMA_getHtmlForColumn(
$html .= PMA_getHtmlForSelect(
"labelColumn", $labelCandidates, $visualizationSettings
);
$html .= PMA_getHtmlForColumn(
$html .= PMA_getHtmlForSelect(
"spatialColumn", $spatialCandidates, $visualizationSettings
);
$html .= '<tr><td></td>';
$html .= '<td class="button"><input type="submit"';
$html .= ' name="displayVisualizationBtn" value="';
$html .= __('Redraw');
$html .= '" /></td></tr>';
$html .= '<input type="hidden" name="displayVisualization" value="redraw">';
$html .= '<input type="hidden" name="sql_query" value="';
$html .= htmlspecialchars($sql_query) . '" />';
$html .= '</form>';
if (! $GLOBALS['PMA_Config']->isHttps()) {
$isSelected = isset($visualizationSettings['choice']) ? true : false;
$html .= PMA_getHtmlForUseOpenStreetMaps($isSelected);
}
$html .= '</table>';
$html .= '<input type="hidden" name="displayVisualization" value="redraw">';
$html .= '<input type="hidden" name="sql_query" value="';
$html .= htmlspecialchars($sql_query) . '" />';
$html .= '</form>';
$html .= '</div>';
$html .= '<div id="pma_quick_warp" style="width: 50px; position: absolute;'
. ' right: 0; top: 0; cursor: pointer;">';
$html .= '<div class="drop_list">';
$html .= '<span class="drop_button" style="padding: 0; border: 0;">';
$html .= PMA_Util::getImage('b_saveimage', __('Save'));
$html .= '</span>';
$html .= '<div style="float:left;">';
$html .= '<form method="post" class="disableAjax"';
$html .= ' action="tbl_gis_visualization.php">';
$html .= PMA_URL_getHiddenInputs($url_params);
$html .= '<table class="gis_table">';
$html .= '<tr><td><label for="fileName">';
$html .= __("File name") . '</label></td>';
$html .= '<td><input type="text" name="fileName" id="fileName" /></td></tr>';
$html .= '<tr><td><label for="fileFormat">';
$html .= __("Format") . '</label></td>';
$html .= '<td><select name="fileFormat" id="fileFormat">';
$html .= '<option value="png">PNG</option>';
$html .= '<option value="pdf">PDF</option>';
$url_params['sql_query'] = $sql_query;
$url_params['saveToFile'] = 'download';
$url = 'tbl_gis_visualization.php' . PMA_URL_getCommon($url_params);
$html .= '<ul>';
$html .= PMA_getHtmlForGisDownloadLink($url, 'png', 'PNG');
$html .= PMA_getHtmlForGisDownloadLink($url, 'pdf', 'PDF');
if ($svg_support) {
$html .= '<option value="svg" selected="selected">SVG</option>';
$html .= PMA_getHtmlForGisDownloadLink($url, 'svg', 'SVG');
}
$html .= '</select></td></tr>';
$html .= '</ul>';
$html .= '</div></div>';
$html .= '<tr><td></td>';
$html .= '<td class="button"><input type="submit" name="saveToFileBtn" value="';
$html .= __('Download') . '" /></td></tr>';
$html .= '</table>';
$html .= '<input type="hidden" name="saveToFile" value="download">';
$html .= '<input type="hidden" name="sql_query" value="';
$html .= htmlspecialchars($sql_query) . '" />';
$html .= '</form>';
$html .= '</div>';
$html .= '<div style="clear:both;">&nbsp;</div>';

View File

@ -67,11 +67,7 @@ while ($row = $GLOBALS['dbi']->fetchAssoc($modified_result)) {
if (isset($_REQUEST['saveToFile'])) {
$response->disable();
$file_name = $_REQUEST['fileName'];
if ($file_name == '') {
$file_name = $visualizationSettings['spatialColumn'];
}
$file_name = $visualizationSettings['spatialColumn'];
$save_format = $_REQUEST['fileFormat'];
PMA_GIS_saveToFile($data, $visualizationSettings, $save_format, $file_name);
exit();

View File

@ -91,18 +91,18 @@ class PMA_TblGisVisualizaionTest extends PHPUnit_Framework_TestCase
}
/**
* Tests for PMA_getHtmlForColumn() method.
* Tests for PMA_getHtmlForSelect() method.
*
* @return void
* @test
*/
public function testPMAGetHtmlForColumn()
public function testPMAGetHtmlForSelect()
{
$column = 0;
$columnCandidates = array("option1", "option2");
$visualizationSettings = array("option2", "option3");
$html = PMA_getHtmlForColumn(
$html = PMA_getHtmlForSelect(
$column, $columnCandidates, $visualizationSettings
);
@ -164,7 +164,7 @@ class PMA_TblGisVisualizaionTest extends PHPUnit_Framework_TestCase
$html
);
$output = PMA_getHtmlForColumn(
$output = PMA_getHtmlForSelect(
"labelColumn", $labelCandidates, $visualizationSettings
);
$this->assertContains(
@ -172,7 +172,7 @@ class PMA_TblGisVisualizaionTest extends PHPUnit_Framework_TestCase
$html
);
$output = PMA_getHtmlForColumn(
$output = PMA_getHtmlForSelect(
"spatialColumn", $spatialCandidates, $visualizationSettings
);
$this->assertContains(
@ -180,28 +180,18 @@ class PMA_TblGisVisualizaionTest extends PHPUnit_Framework_TestCase
$html
);
$this->assertContains(
__('Redraw'),
$html
);
$this->assertContains(
__('Download'),
$html
);
$this->assertContains(
htmlspecialchars($sql_query),
$html
);
$this->assertContains(
'<option value="png">PNG</option>',
'>PNG</a>',
$html
);
$this->assertContains(
'<option value="pdf">PDF</option>',
'>PDF</a>',
$html
);

View File

@ -2049,7 +2049,7 @@ fieldset .disabled-field td {
#placeholder {
position: relative;
border: 1px solid #aaa;
float: right;
float: <?php echo $right; ?>;
overflow: hidden;
}

View File

@ -13,19 +13,6 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
}
?>
.gis_table td {
vertical-align: middle;
}
.gis_table select {
min-width: 151px;
margin: 6px;
}
.gis_table .button {
text-align: <?php echo $right; ?>;
}
/**
* GIS data editor styles
*/