Skip to content

Commit 992c96b

Browse files
committed
UI - generator connector
1 parent 5f288d1 commit 992c96b

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

ui/generator-connector.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
$backend = gethostbyname(backend);
3+
4+
$url = "http://$backend:8080";
5+
$model = $_REQUEST['input_name'];
6+
$payload = array(
7+
'input.name' => $model,
8+
'input.files' => $_REQUEST['input_files'],
9+
'metaphor' => $_REQUEST['metaphor'],
10+
'city.building_type' => $_REQUEST['city_building_type'],
11+
'city.building_base' => $_REQUEST['city_show_building_base'],
12+
'city.original_building_metric' => $_REQUEST['city_original_building_metric'],
13+
'city.width_min' => $_REQUEST['city_width_min'],
14+
'city.height_min' => $_REQUEST['city_height_min'],
15+
'city.building.horizontal_margin' => $_REQUEST['city_building_horizontal_margin'],
16+
'city.building.horizontal_gap' => $_REQUEST['city_building_horizontal_gap'],
17+
'city.building.vertical_margin' => $_REQUEST['city_building_vertical_margin'],
18+
'city.package.color_start' => $_REQUEST['city_package_color_start'],
19+
'city.package.color_end' => $_REQUEST['city_package_color_end'],
20+
'city.class.color_start' => $_REQUEST['city_class_color_start'],
21+
'city.class.color_end' => $_REQUEST['city_class_color_end'],
22+
'city.class.color' => $_REQUEST['city_class_color']
23+
);
24+
25+
// foreach($parameters as $key => $value) {
26+
// echo "$key = $value";
27+
// echo '</br>';
28+
// }
29+
30+
// use key 'http' even if you send the request to https://...
31+
$options = array(
32+
'http' => array(
33+
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
34+
'method' => 'POST',
35+
'content' => http_build_query($payload)
36+
)
37+
);
38+
$context = stream_context_create($options);
39+
$result = file_get_contents($url, false, $context);
40+
41+
// false, because we receive redirect
42+
if ($result === FALSE) {
43+
header("Location: http://localhost:8082/ui/index.php?aframe=true&model=$model&setup=web_a-frame/default&srcDir=data-gen");
44+
die();
45+
}
46+
47+
var_dump($result);
48+
49+
?>

ui/index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585

8686
var canvasId = "<?php echo $canvasId; ?>";
8787
var visMode = "<?php echo $visMode; ?>";
88-
const BACKEND = "<?php $backend = gethostbyname(backend ); echo $backend; ?>";
8988
</script>
9089
<html>
9190
<title>Getaviz</title>

ui/scripts/GenerationForm/GenerationFormController.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,9 @@ var generationFormController = (function() {
10811081
const btn_submit = settingsForm.jqxForm('getComponentByName', 'submitButton');
10821082
btn_submit.on('click', function () {
10831083
settingsForm.jqxValidator('validate');
1084-
settingsForm.jqxForm('submit', "http://" + BACKEND +":8080", "_self", 'POST');
1084+
let currentPage = window.location.href;
1085+
let currentPath = currentPage.replace(/[^\/]*$/, '');
1086+
settingsForm.jqxForm('submit', currentPath + "generator-connector.php", "_self", 'POST');
10851087
});
10861088

10871089
// Cancel Form Data

0 commit comments

Comments
 (0)