-
Notifications
You must be signed in to change notification settings - Fork 0
/
step03.php
259 lines (236 loc) · 13.4 KB
/
step03.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<?php
include("content.php");
require_once 'lib/Functions.php';
use Util\Functions;
use Util\Config\Conn;
headerContent("");
breadcrumb(3);//cabecalho
$module_id = '';
$inputHidden = '';
foreach ($_REQUEST['module_id'] as $row) {
$module[] = Functions::getEntity('module', $row);
$inputHidden .= "<input type='hidden' name='module_id[]' value='" . $row . "' />";
$module_id .= "&module_id[]=" . $row;
}
?>
<script>
function onSkip() {
var skip = document.getElementById("skip");
var element = document.getElementById("next");
if (skip.checked == true) {
document.getElementById('type').required = false;
document.getElementById('host').required = false;
document.getElementById("name").required = false;
document.getElementById("user").required = false;
document.getElementById("password").required = false;
element.classList.remove("disabled");
} else {
document.getElementById('type').required = true;
document.getElementById('host').required = true;
document.getElementById("name").required = true;
document.getElementById("user").required = true;
document.getElementById("password").required = true;
element.classList.add("disabled");
}
}
function onSkipDocker() {
var skipDocker = document.getElementById("skipDocker");
if (skipDocker.checked == true) {
document.getElementById('docker_container').style.display = 'block';
document.getElementById('lb_docker_container').style.display = 'block';
} else {
document.getElementById('docker_container').style.display = 'none';
document.getElementById('lb_docker_container').style.display = 'none';
}
}
function onSkipSQLite(selectObject) {
var element = document.getElementById("next");
var type = selectObject.value;
if (type == 'sqlite') {
document.getElementById('host').required = false;
document.getElementById("user").required = false;
document.getElementById("password").required = false;
element.classList.remove("disabled");
} else {
document.getElementById('type').required = true;
document.getElementById('host').required = true;
document.getElementById("name").required = true;
document.getElementById("user").required = true;
document.getElementById("password").required = true;
element.classList.add("disabled");
}
}
</script>
<div class="container">
<div class="row">
<form id="formStep03" action="step04.php" method="POST">
<input type="hidden" name="product_id" value="<?php echo $_REQUEST['product_id']; ?>"/>
<?php echo $inputHidden; ?>
<!-- start content -->
<div class="card hoverable" style="height: 650px;">
<div class="card-content">
<span class="card-title"><b>Configurar Banco de Dados</b> <i
class="material-icons right">more_vert</i></span>
<div class="col s6">
<div class="row">
<div class="col s12">
<label>Tipo</label>
<select id="type" name="type" class="browser-default validate"
onchange="onSkipSQLite(this)">
<option value="0" selected="selected">::Escolha a sua opção::</option>
<option value="pgsql">PostgreSQL</option>
<option value="mysql">MySQL</option>
<option value="sqlite">SQLite</option>
</select>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="host" type="text" name="host" class="validate"
placeholder="200.000.000.000"
required>
<label for="host">Host</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="user" type="text" name="user" class="validate" required>
<label for="user">Usuário</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="password" name="password" type="password" class="validate" required>
<label for="password">Senha</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="name" type="text" name="name" class="validate" placeholder="db_name"
required>
<label for="name">Nome</label>
</div>
<p>
<input id="skip" type="checkbox" name="skip" class="filled-in" onclick="onSkip()">
<label for="skip">Pular</label>
</p>
</div>
</div><!--
<div class="col s6" style="margin-top: 50px;">
<span class="flow-text"> <b>Cloud VPS (Virtual Private Service)</b></span>
<div class="row">
<div class="col s12">
<i class="fa fa-amazon fa-5x" aria-hidden="true"></i>
<div style="margin-top: -60px;margin-left: 167px;">
<button type="button" class="btn #0091ea light-blue accent-4">Conectar
<i class="material-icons right">send</i></button>
</div>
</div>
</div>
<div class="row">
<div class="col s12" style="margin-top: 50px;">
<i class="fa fa-google fa-5x" aria-hidden="true"></i>
<div style="padding-left: 169px; margin-top: -55px;">
<button type="button" class="btn #0091ea light-blue accent-4">Conectar
<i class="material-icons right">send</i></button>
</div>
</div>
</div>
</div>
-->
</div>
<div class="col s6">
<div class="row">
<h5 style="margin-top: -60px;">Usa um Conteiner Docker?</h5>
<div class="input-field col s12">
<input id="docker_container" type="text" name="docker_container" class="validate"
placeholder="ID ou Nome" style="display: none;"
>
<label id="lb_docker_container" for="docker_container" style="display: none;">Docker
Container</label>
</div>
<div class="row">
<div class="switch" style="margin-left: 25px;">
<label>
Não
<input type="checkbox" id="skipDocker" name="skipDocker"
onclick="onSkipDocker()">
<span class="lever"></span>
Sim
</label>
</div>
</div>
<div class="row">
<a class="waves-effect waves-light btn #f9a825 yellow darken-3"
href="#" onclick="checkConn()" style="margin-top: 150px;margin-left: 170px; ">
<i class="material-icons right">check</i>Testar Conexão</a>
<script src="lib/jquery3.3.1.min.js"></script>
<style>
#toast-container {
top: auto !important;
right: auto !important;
bottom: 20%;
left: 60%;
}
</style>
<script>
function checkConn() {
$(document).ready(function () {
dataForm = document.getElementById('formStep03');
$.post("lib/checkConn.class.php", {
type: dataForm.type.value,
host: dataForm.host.value,
user: dataForm.user.value,
name: dataForm.name.value,
password: dataForm.password.value,
docker_container: dataForm.docker_container.value
})
.done(function (data) {
if (data == 1) {
Materialize.toast('<b style="color: #FFF;">Conectado com sucesso</b>', 2000, 'green');
var element = document.getElementById("next");
element.classList.remove("disabled");
} else {
Materialize.toast('<b style="color: #FFF;">Falha na conexão</b>', 2000, 'red');
var element = document.getElementById("next");
element.classList.add("disabled");
}
})
.fail(function (data) {
alert(data);
Materialize.toast('<b style="color: #FFF;">Falha na conexão</b>', 2000, 'red');
});
});
}
</script>
</div>
<div class="row">
<div class="col s12">
<h4 style="text-align: center">OBS para Postgres</h4>
<p style="text-align: center"> O banco de dados deve esta com o datestyle DMY<br>
Use o seguinte comando para mudar, se for o caso.<br><br>
ALTER DATABASE db_name SET datestyle TO ISO, DMY;
</p>
</div>
</div>
</div>
<p> </p>
</div>
<!-- /.card-content -->
<div class="col s12">
<div class="card-action" style="margin-top: -10px;">
<a class="waves-effect waves-light btn #0091ea light-blue accent-4"
href="step02.php?product_id=<?php echo $_REQUEST['product_id'] . $module_id; ?>">
<i class="material-icons right">arrow_back</i>Voltar</a>
<button id="next" type="submit" class="btn #4caf50 green disabled">Próximo<i
class="material-icons right">arrow_forward</i>
</button>
</div>
</div>
</div><!-- /.card-content -->
</form>
</div>
</div>
</div>
<?php
footerContent("");