-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrial-page.php
477 lines (428 loc) · 20.8 KB
/
trial-page.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<?php
/*
* Template Name: Trial Page
* Description: Page template that shows a trial license configurator form
*/
get_header(); ?>
<!-- Start Page Content -->
<div class="justify-content-center" id="trial">
<div class="container">
<div class="row justify-content-center">
<div class="col">
<p>The Initializer makes it easy to setup a new Speedment project with Maven. Fill in your project details and see the configuration change in real time. If you choose any Enterprise features you will be asked to fill in a License Key. Just send us a request and you will <a href="#" data-toggle="modal" data-target="#trialModal">get a 30 days free trial license</a>!</p>
</div>
</div>
<div class="row justify-content-center gray-area-oss">
<div class="col-md-6 col-sm-12 config-column">
<?php /////////////////////////////////////////////////////////////// ?>
<?php // Configuration Form // ?>
<?php /////////////////////////////////////////////////////////////// ?>
<form method="post" id="speedmentForm">
<!-- Select Database Type -->
<div class="form-group row">
<legend class="col-form-legend col-sm-3">Database Type</legend>
<div class="col-sm-9">
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType1" value="mysql" checked>
<span class="custom-control-indicator"></span>
<span class="custom-control-description">MySQL</span>
</label>
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType2" value="postgresql">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">PostgreSQL</span>
</label>
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType3" value="mariadb">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">MariaDB</span>
</label>
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType4" value="oracle">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Oracle<i class="fa fa-asterisk" aria-hidden="true"></i></span>
</label>
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType5" value="db2">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">DB2<i class="fa fa-asterisk" aria-hidden="true"></i></span>
</label>
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType6" value="as400">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">AS400<i class="fa fa-asterisk" aria-hidden="true"></i></span>
</label>
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType7" value="mssql">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">SQL Server<i class="fa fa-asterisk" aria-hidden="true"></i></span>
</label>
<label class="custom-control custom-radio">
<input class="custom-control-input" type="radio" name="radioDatabaseType" id="radioDatabaseType1" value="sqlite">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">SQLite</span>
</label>
</div>
</div>
<!-- Select Driver Version -->
<div class="form-group row">
<label for="inputDriverVersion" class="col-sm-3 col-form-label">JDBC Driver Version</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="inputDriverVersion" placeholder="Database Driver Version" value="8.0.13">
</div>
</div>
<!-- Select Java Version -->
<div class="form-group row">
<legend class="col-form-legend col-sm-3">Java Version</legend>
<div class="col-sm-9">
<label class="custom-control custom-radio">
<input type="radio" class="custom-control-input" name="javaVersion" id="inputJava8" value="1.8" checked>
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Java 8</span>
</label>
<label class="custom-control custom-radio">
<input type="radio" class="custom-control-input" name="javaVersion" id="inputJava9" value="9">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Java 9</span>
</label>
<label class="custom-control custom-radio">
<input type="radio" class="custom-control-input" name="javaVersion" id="inputJava10" value="10">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Java 10</span>
</label>
</div>
</div>
<!-- Plugins -->
<div class="form-group row">
<legend class="col-form-legend col-sm-3">Plugins</legend>
<div class="col-sm-9">
<label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="checkPluginEnums">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Enums</span>
</label>
<label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="checkPluginSpring">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Spring</span>
</label>
<label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="checkPluginJson">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">JSON</span>
</label>
</div>
</div>
<!-- In-memory Acceleration -->
<div class="form-group row">
<label class="col-sm-3 col-form-label">In-memory Acceleration</label>
<div class="col-sm-9" id="inMemoryContainer">
<label class="custom-control custom-radio">
<input type="radio" class="custom-control-input" name="inMemory" id="inputInMemoryTrue" value="true" checked>
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Enable<i class="fa fa-asterisk" aria-hidden="true"></i></span>
</label>
<label class="custom-control custom-radio">
<input type="radio" class="custom-control-input" name="inMemory" id="inputInMemoryFalse" value="false">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Disable</span>
</label>
</div>
</div>
<!-- Project Info -->
<div class="form-group row">
<label for="inputGroupId" class="col-sm-3 col-form-label">GroupId</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="inputGroupId" placeholder="GroupId" value="com.example">
</div>
</div>
<div class="form-group row">
<label for="inputArtifactId" class="col-sm-3 col-form-label">ArtifactId</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="inputArtifactId" placeholder="ArtifactId" value="demo">
</div>
</div>
<div class="form-group row">
<label for="inputVersion" class="col-sm-3 col-form-label">Version</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="inputVersion" placeholder="Version" value="1.0.0-SNAPSHOT">
</div>
</div>
<!-- Submit -->
<div class="form-group row" id="submitGroup">
<div class="col align-middle">
<div class="asteriskDescription">
<!-- <i class="fa fa-asterisk" aria-hidden="true"></i>
<small class="text-muted">Enterprise Features require a valid License Key.</small> -->
</div>
</div>
<div class="col-md col-md-auto submit-group">
<button type="submit" class="btn btn-primary">Generate Project</button>
</div>
</div>
</form>
</div>
<div class="col-md-6 col-sm-12 preview-column">
<!-- License Key -->
<div class="form-group row" id="licenseKey" style="display:none;">
<div style="overflow:hidden;position:relative;width:100%;height:100px;top:-10px;margin-bottom:-100px;margin-right:-100px;right:-2px;z-index:1;pointer-events:none;">
<div class="cr cr-top cr-right cr-blue">Enterprise</div>
</div>
<label for="inputLicenseKey" class="col-sm-12 col-form-label">You have selected an Enterprise Feature<i class="fa fa-asterisk" aria-hidden="true"></i></label>
<div class="col-sm-12 row rightSide">
<small class="request-trial-link">
<a href="#" rel="Send me a trial" data-toggle="modal" data-target="#trialModal">Request a Free Trial License Key</a>
</small>
<textarea class="form-control col-12" id="inputLicenseKey" placeholder="Enter the License Key that has been sent to you"><?php
if (isset($_GET['licenseKey'])) {
echo $_GET['licenseKey'];
}
?></textarea>
</div>
</div>
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#fileMaven" role="tab">pom.xml</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#fileMain" role="tab">Main.java</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="fileMaven" role="tabpanel">
<pre><code class="language-xml" class="preview" id="previewMaven"></code></pre>
</div>
<div class="tab-pane" id="fileMain" role="tabpanel">
<pre><code class="language-java" class="preview" id="previewMain"></code></pre>
</div>
</div>
</div>
<?php ///////////////////////////////////////////////////////////////// ?>
<?php // Form logic // ?>
<?php ///////////////////////////////////////////////////////////////// ?>
<script>
jQuery.fn.extend({
disable: function(state) {
return this.each(function() {
this.disabled = state;
});
}
});
jQuery(document).ready(function($) {
var groupId = $('#inputGroupId');
var artifactId = $('#inputArtifactId');
var version = $('#inputVersion');
var driverVersion = $('#inputDriverVersion');
var email = $('#inputEmail');
var licenseKey = $('#inputLicenseKey');
var javaVersion = $('input[type=radio][name=javaVersion]');
var inMemory = $('input[type=radio][name=inMemory]');
var dbType = $('input[type=radio][name=radioDatabaseType]');
var useEnums = $('#checkPluginEnums');
var useSpring = $('#checkPluginSpring');
var useJson = $('#checkPluginJson');
var enterprise = false;
var enterpriseDb = false;
function prepareUrl(service) {
var selectedDbType = $('input[type=radio][name=radioDatabaseType]:checked').val();
var url = 'https://service.speedment.com/' + service;
url += '/' + (selectedDbType === 'as400' ? 'db2' : selectedDbType);
if ('true' == $('input[type=radio][name=inMemory]:checked').val()) {
url += ',virtual-columns,datastore';
}
if (useEnums.is(':checked')) {
url += ',enums';
}
if (useSpring.is(':checked')) {
url += ',spring';
}
if (useJson.is(':checked')) {
url += ',json';
}
var args = {
'groupId' : groupId.val(),
'artifactId' : artifactId.val(),
'version' : version.val(),
'packaging' : 'jar'
};
if ($('input[type=radio][name=javaVersion]:checked').val()) {
args.javaVersion = $('input[type=radio][name=javaVersion]:checked').val();
}
if (selectedDbType === 'mysql') {
args['mysqlVersion'] = driverVersion.val();
} else if (this.value === 'sqlite') {
driverVersion.val('3.23.1');
} else if (selectedDbType === 'postgresql') {
args['postgresqlVersion'] = driverVersion.val();
} else if (selectedDbType === 'mariadb') {
args['mariadbVersion'] = driverVersion.val();
} else if (selectedDbType === 'oracle') {
args['oracleVersion'] = driverVersion.val();
} else if (selectedDbType === 'db2') {
args['db2Version'] = driverVersion.val();
} else if (selectedDbType === 'as400') {
args['as400Version'] = driverVersion.val();
} else if (selectedDbType === 'mssql') {
args['sqlserverVersion'] = driverVersion.val();
}
url += '?groupId=' + encodeURIComponent(groupId.val());
url += '&artifactId=' + encodeURIComponent(artifactId.val());
url += '&version=' + encodeURIComponent(version.val());
var key = licenseKey.val().trim();
if (key) {
url += '&licenseKey=' + encodeURIComponent(key);
}
return url;
}
function updateCode() {
var url;
var page;
var lang;
if ($('.preview-column .tab-content .tab-pane.active').attr('id') === 'fileMain') {
page = 'Main';
url = prepareUrl('generate/main');
lang = Prism.languages.java;
} else {
page = 'Maven';
url = prepareUrl('generate/maven');
lang = Prism.languages.xml;
}
var container = $('#preview' + page);
container.fadeOut(100);
$.ajax({
url: url,
type: "GET",
crossDomain: true,
dataType: 'text',
success: function (data) {
console.log(data);
$('#preview' + page).text(data).fadeIn(100);
Prism.highlightAll();
},
error: function (xhr, status) {
console.error(xhr);
console.error('Error! Server responded with ' + status + '.');
}
});
}
function updateEnterprise() {
var selectedDbType = $('input[type=radio][name=radioDatabaseType]:checked').val();
enterpriseDb = selectedDbType === 'oracle'
|| selectedDbType === 'db2'
|| selectedDbType === 'as400'
|| selectedDbType === 'mssql';
enterprise = 'true' == $('input[type=radio][name=inMemory]:checked').val()
|| enterpriseDb;
if (enterprise) {
$('#licenseKey').show();
} else {
$('#licenseKey').hide();
}
$('#submitGroup button[type="submit"]').disable(
enterprise && !licenseKey.val().trim()
);
}
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
updateCode();
});
groupId.change(updateCode);
artifactId.change(updateCode);
version.change(updateCode);
driverVersion.change(updateCode);
javaVersion.change(function() {
updateCode();
});
inMemory.change(function() {
updateEnterprise();
updateCode();
});
licenseKey.change(function() {
updateEnterprise();
updateCode();
});
dbType.change(function() {
if (this.value === 'mysql') {
driverVersion.val('8.0.18');
} else if (this.value === 'sqlite') {
driverVersion.val('3.28.0');
} else if (this.value === 'postgresql') {
driverVersion.val('42.2.8');
} else if (this.value === 'mariadb') {
driverVersion.val('2.4.4');
} else if (this.value == 'oracle') {
driverVersion.val('19.3.0.0');
} else if (this.value === 'db2') {
driverVersion.val('11.5.0.0');
} else if (this.value === 'as400') {
driverVersion.val('9.8');
} else if (this.value === 'mssql') {
driverVersion.val('7.4.1.jre8');
} else {
console.error('Unknown database type "' + this.value + '".');
return;
}
updateEnterprise();
updateCode();
});
useEnums.click(updateCode);
useSpring.click(updateCode);
useJson.click(updateCode);
updateEnterprise();
updateCode();
licenseKey.keyup(function () {
$('#submitGroup button[type="submit"]').disable(
!licenseKey.val().trim()
);
});
$('#speedmentForm').submit(function(ev) {
ev.preventDefault();
$.ajax({
url: prepareUrl('generate/maven'),
type: "GET",
crossDomain: true,
dataType: 'text',
success: function (data) {
console.log(data);
$('#finalCode').text(data);
Prism.highlightAll();
$('#generationComplete').modal('show');
},
error: function (xhr, status) {
console.error(xhr);
console.error('Error! Server responded with ' + status + '.');
}
});
});
});
</script>
<?php include('trial-modal.php'); ?>
<div id="generationComplete" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="popupTitle" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Success!</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Your project has been generated! To build it, create a file
somewhere on your computer called <span class="code">pom.xml</span>
and insert the following text:</p>
<pre style="max-height:320px;"><code class="language-xml" id="finalCode"></code></pre>
<p>To launch the Speedment Tool, run the following command in your terminal:</p>
<pre><code class="language-shell">mvn speedment:tool</code></pre>
<p>To compile the Maven project, run:</p>
<pre><code class="language-shell">mvn clean install</code></pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End Page Content -->
<?php get_footer(); ?>