Skip to content

Commit 25b6069

Browse files
author
naraesk
authored
Merge pull request #85 from VlaD-T/dev_local
UI - generator connector
2 parents c632743 + 8a8c17d commit 25b6069

3 files changed

Lines changed: 96 additions & 2 deletions

File tree

ui/generator-connector.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
$backend = gethostbyname(backend);
3+
4+
$url = "http://$backend:8080";
5+
$model = $_REQUEST['input_name']; // is also used for redirect url
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.scheme' => $_REQUEST['city_scheme'],
12+
'city.class_elements_mode' => $_REQUEST['city_class_elements_mode'],
13+
'city.class_elements_sort_mode_coarse' => $_REQUEST['city_class_elements_sort_mode_coarse'],
14+
'city.class_elements_sort_mode_fine' => $_REQUEST['city_class_elements_sort_mode_fine'],
15+
'city.class_elements_sort_mode_fine_direction_reversed' => $_REQUEST['city_class_elements_sort_mode_fine_direction_reversed'],
16+
'city.show_building_base' => $_REQUEST['city_show_building_base'],
17+
'city.show_attributes_as_cylinders' => $_REQUEST['city_show_attributes_as_cylinders'],
18+
'city.brick.layout' => $_REQUEST['city_brick_layout'],
19+
'city.brick.size' => $_REQUEST['city_brick_size'],
20+
'city.brick.horizontal_margin' => $_REQUEST['city_brick_horizontal_margin'],
21+
'city.brick.horizontal_gap' => $_REQUEST['city_brick_horizontal_gap'],
22+
'city.brick.vertical_margin' => $_REQUEST['city_brick_vertical_margin'],
23+
'city.brick.vertical_gap' => $_REQUEST['city_brick_vertical_gap'],
24+
'city.panel.separator_mode' => $_REQUEST['city_panel_separator_mode'],
25+
'city.panel.height_treshold_nos' => $_REQUEST['city_panel_height_treshold_nos'],
26+
'city.panel.height_unit' => $_REQUEST['city_panel_height_unit'],
27+
'city.panel.horizontal_margin' => $_REQUEST['city_panel_horizontal_margin'],
28+
'city.panel.vertical_margin' => $_REQUEST['city_panel_vertical_margin'],
29+
'city.panel.vertical_gap' => $_REQUEST['city_panel_vertical_gap'],
30+
'city.panel.separator_height' => $_REQUEST['city_panel_separator_height'],
31+
'city.original_building_metric' => $_REQUEST['city_original_building_metric'],
32+
'city.width_min' => $_REQUEST['city_width_min'],
33+
'city.height_min' => $_REQUEST['city_height_min'],
34+
'city.building.horizontal_margin' => $_REQUEST['city_building_horizontal_margin'],
35+
'city.building.horizontal_gap' => $_REQUEST['city_building_horizontal_gap'],
36+
'city.building.vertical_margin' => $_REQUEST['city_building_vertical_margin'],
37+
'city.package.color_start' => $_REQUEST['city_package_color_start'],
38+
'city.package.color_end' => $_REQUEST['city_package_color_end'],
39+
'city.class.color_start' => $_REQUEST['city_class_color_start'],
40+
'city.class.color_end' => $_REQUEST['city_class_color_end'],
41+
'city.class.color' => $_REQUEST['city_class_color'],
42+
'city.color.blue' => $_REQUEST['city_color_blue'],
43+
'city.color.aqua' => $_REQUEST['city_color_aqua'],
44+
'city.color.light_green' => $_REQUEST['city_color_light_green'],
45+
'city.color.dark_green' => $_REQUEST['city_color_dark_green'],
46+
'city.color.yellow' => $_REQUEST['city_color_yellow'],
47+
'city.color.orange' => $_REQUEST['city_color_orange'],
48+
'city.color.red' => $_REQUEST['city_color_red'],
49+
'city.color.pink' => $_REQUEST['city_color_pink'],
50+
'city.color.violet' => $_REQUEST['city_color_violet'],
51+
'city.color.light_grey' => $_REQUEST['city_color_light_grey'],
52+
'city.color.dark_grey' => $_REQUEST['city_color_dark_grey'],
53+
'city.color.white' => $_REQUEST['city_color_white'],
54+
'city.color.black' => $_REQUEST['city_color_black'],
55+
'rd.data_factor' => $_REQUEST['rd_data_factor'],
56+
'rd.height' => $_REQUEST['rd_height'],
57+
'rd.ring_width' => $_REQUEST['rd_ring_width'],
58+
'rd.ring_width_ad' => $_REQUEST['rd_ring_width_ad'],
59+
'rd.min_area' => $_REQUEST['rd_min_area'],
60+
'rd.namespace_transparency' => $_REQUEST['rd_namespace_transparency'],
61+
'rd.class_transparency' => $_REQUEST['rd_class_transparency'],
62+
'rd.method_transparency' => $_REQUEST['rd_method_transparency'],
63+
'rd.data_transparency' => $_REQUEST['rd_data_transparency'],
64+
'rd.color.class' => $_REQUEST['rd_color_class'],
65+
'rd.color.data' => $_REQUEST['rd_color_data'],
66+
'rd.color.method' => $_REQUEST['rd_color_method'],
67+
'rd.color.namespace' => $_REQUEST['rd_color_namespace'],
68+
'rd.method_disks' => $_REQUEST['rd_method_disks'],
69+
'rd.data_disks' => $_REQUEST['rd_data_disks'],
70+
'rd.method_type_mode' => $_REQUEST['rd_method_type_mode']
71+
);
72+
73+
// use key 'http' even if you send the request to https://..
74+
$options = array(
75+
'http' => array(
76+
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
77+
'method' => 'POST',
78+
'content' => http_build_query($payload)
79+
)
80+
);
81+
$context = stream_context_create($options);
82+
$result = file_get_contents($url, false, $context);
83+
84+
// false, because we receive redirect
85+
if ($result === FALSE) {
86+
header("Location: http://localhost:8082/ui/index.php?aframe=true&model=$model&setup=web_a-frame/default&srcDir=data-gen");
87+
die();
88+
}
89+
90+
// will be seen if something went wrong
91+
var_dump($result);
92+
93+
?>

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)