Skip to content

Commit 905eb79

Browse files
tobiasakeemichaf
authored andcommitted
Iframe tag replaced with div tag. Context Path and HTTPS settings. (#9)
* Changed so sub pages is inject to div tag. Underscore is valid to be specified in SubscriptionName. * Fixed visually sorting list arraws css class. * Fixed alot of small fixes and pages that did not load properly with new way of loading sub pages. * Some minor visual improvements in subscription datatables and login page. * Solved alot of css/js conflicts which caused some issues with menus and buttons. * Solved knockout observables cleanup when Subscription page is reloaded. * Changed so Knockout object applybindings to a div tag dom object so it easier can be cleaned and used in webui. * Solved issue with menu arrow button that didn't minimize vertical menu bar. Fixed Save subscription button that had stopped working. * Added back some css templates that was commented out and that is needed. * Added new properties file which has now settings for address context path and secure HTTPS.
1 parent df13252 commit 905eb79

19 files changed

+184
-234
lines changed

src/main/java/com/ericsson/ei/frontend/EIRequestsController.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class EIRequestsController {
7272

7373
private String backendServerHost;
7474
private int backendServerPort;
75+
private String backendContextPath;
76+
private boolean useSecureHttp;
7577

7678
private static final String APPLICATION_JSON = "application/json";
7779

@@ -91,9 +93,33 @@ public int getBackendServerPort() {
9193
public void setBackendServerPort(int backendServerPort) {
9294
this.backendServerPort = backendServerPort;
9395
}
96+
97+
public String getBackendContextPath() {
98+
return backendContextPath;
99+
}
100+
101+
public void setBackendContextPath(String backendContextPath) {
102+
this.backendContextPath = backendContextPath;
103+
}
104+
105+
public boolean getUseSecureHttp() {
106+
return useSecureHttp;
107+
}
108+
109+
public void setUseSecureHttp(boolean useSecureHttp) {
110+
this.useSecureHttp = useSecureHttp;
111+
}
94112

95113
public String getEIBackendSubscriptionAddress() {
96-
return "http://" + this.getBackendServerHost() + ":" + this.getBackendServerPort();
114+
String httpMethod = "http";
115+
if (useSecureHttp) {
116+
httpMethod = "https";
117+
}
118+
119+
if (backendContextPath != null && !backendContextPath.isEmpty()) {
120+
return httpMethod + "://" + this.getBackendServerHost() + ":" + this.getBackendServerPort() + "/" + backendContextPath;
121+
}
122+
return httpMethod + "://" + this.getBackendServerHost() + ":" + this.getBackendServerPort();
97123
}
98124

99125

src/main/java/com/ericsson/ei/frontend/WebController.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class WebController {
3131
private int frontendServicePort;
3232
private String backendServerHost;
3333
private int backendServerPort;
34+
private String frontendContextPath;
35+
private boolean useSecureHttp;
3436

3537
private String eiffelDocumentationUrls;
3638

@@ -49,11 +51,21 @@ public String greeting(Model model) {
4951

5052
@RequestMapping("/subscriptionpage.html")
5153
public String subscription(Model model) {
52-
53-
String frontendServiceUrl = String.format("http://%s:%d", frontendServiceHost, frontendServicePort);
54-
54+
55+
String httpMethod = "http";
56+
if (useSecureHttp) {
57+
httpMethod = "https";
58+
}
59+
60+
String frontendServiceUrl;
61+
if (frontendContextPath != null && !frontendContextPath.isEmpty()) {
62+
frontendServiceUrl = String.format("%s://%s:%d/%s", httpMethod , frontendServiceHost, frontendServicePort, frontendContextPath);
63+
}
64+
else {
65+
frontendServiceUrl = String.format("%s://%s:%d", httpMethod, frontendServiceHost, frontendServicePort);
66+
}
5567
model.addAttribute("frontendServiceUrl", frontendServiceUrl); // inject in DOM for AJAX etc
56-
68+
5769
return "subscription";
5870
}
5971

@@ -110,6 +122,22 @@ public void setFrontendServicePort(int frontendServicePort) {
110122
this.frontendServicePort = frontendServicePort;
111123
}
112124

125+
public String getFrontendContextPath() {
126+
return frontendContextPath;
127+
}
128+
129+
public void setFrontendContextPath(String contextPath) {
130+
this.frontendContextPath = contextPath;
131+
}
132+
133+
public boolean getUseSecureHttp() {
134+
return useSecureHttp;
135+
}
136+
137+
public void setUseSecureHttp(boolean useSecureHttp) {
138+
this.useSecureHttp = useSecureHttp;
139+
}
140+
113141
public String getBackendServerHost() {
114142
return backendServerHost;
115143
}

src/main/resources/application.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ spring.application.name=ei-frontend
55
#${project.artifactId}
66

77
server.port=8080
8+
#server.ssl.key-store: <keystore.p12>
9+
#server.ssl.key-store-password: <mypassword>
10+
#server.ssl.keyStoreType: <PKCS12>
11+
#server.ssl.keyAlias: <tomcat>
12+
813

914
######## EI Backend
1015
ei.frontendServiceHost=localhost
1116
ei.frontendServicePort=8080
17+
ei.frontendContextPath=
1218
ei.backendServerHost=localhost
1319
ei.backendServerPort=8090
20+
ei.backendContextPath=
21+
ei.useSecureHttp=false
1422

1523
###### Subscription Template file ########
1624
ei.subscriptionFilePath=subscriptions/subscriptionsTemplate.json

src/main/resources/static/js/eiInfo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jQuery(document).ready(function() {
99

1010
var tableTdKeyWidth = '250';
1111

12-
var body = document.getElementsByTagName('body')[0];
13-
12+
var body = document.getElementById('eiPageFrame');
13+
1414
function createTable() {
1515
var tbl = document.createElement('table');
1616
tbl.style.width = '40%';

src/main/resources/static/js/main.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,19 @@ jQuery(document).ready(function() {
66
var frontendServiceUrl = $('#frontendServiceUrl').text();
77

88
document.getElementById("testRulesBtn").onclick = function() {
9-
10-
var iframe = document.getElementById("mainFrame");
11-
iframe.src = frontendServiceUrl + "/testRules.html";
9+
10+
$("#mainFrame").load("testRules.html");
1211
}
1312

1413
document.getElementById("eiInfoBtn").onclick = function() {
15-
16-
var iframe = document.getElementById("mainFrame");
17-
iframe.src = frontendServiceUrl + "/eiInfo.html";
14+
15+
$("#mainFrame").load("eiInfo.html");
1816
}
1917

2018

2119
function loadLoginPage() {
22-
var iframe = document.getElementById("mainFrame");
23-
iframe.src = frontendServiceUrl + "/login.html";
20+
21+
$("#mainFrame").load("login.html");
2422
}
2523

2624
document.getElementById("loginBtn").onclick = function() {
@@ -34,25 +32,23 @@ jQuery(document).ready(function() {
3432
}
3533

3634
document.getElementById("registerBtn").onclick = function() {
37-
38-
var iframe = document.getElementById("mainFrame");
39-
iframe.src = frontendServiceUrl + "/register.html";
35+
36+
$("#mainFrame").load("register.html");
4037
}
4138

4239
document.getElementById("forgotPasswordBtn").onclick = function() {
43-
44-
var iframe = document.getElementById("mainFrame");
45-
iframe.src = frontendServiceUrl + "/forgot-password.html";
40+
41+
$("#mainFrame").load("forgot-password.html");
4642
}
4743

4844
function loadMainPage() {
49-
var iframe = document.getElementById("mainFrame");
50-
iframe.src = frontendServiceUrl + "/subscriptionpage.html";
45+
46+
$("#mainFrame").load("subscriptionpage.html");
5147
}
5248

5349
document.getElementById("subscriptionBtn").onclick = function() {
5450

55-
loadMainPage();
51+
loadMainPage();
5652
}
5753

5854
function loadDocumentLinks(){

src/main/resources/static/js/subscription.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var table;
44
var frontendServiceUrl;
55
var subscriptionTemplateFile;
66

7+
78
jQuery(document).ready(function() {
89

910

@@ -59,7 +60,9 @@ jQuery(document).ready(function() {
5960
// Check EI Backend Server Status ########################################
6061
function checkEiBackendServer() {
6162
var EIConnBtn = document.getElementById("btnEIConnection");
62-
63+
if (EIConnBtn == null ) {
64+
return;
65+
}
6366
$.ajax({
6467
url: frontendServiceUrl + "/subscriptions/testDummySubscription",
6568
contentType : 'application/json; charset=utf-8',
@@ -114,8 +117,8 @@ jQuery(document).ready(function() {
114117

115118
// Validating subscriptionName inputs
116119
this.subscriptionName.subscribe(function (subscriptionName) {
117-
if (!(/[a-z]|[A-Z]|[0-9]/.test(String(subscriptionName).slice(-1)))) {
118-
$.jGrowl("Only numbers and letters is valid to type in subscriptionName field.", {
120+
if (!(/[a-z]|[A-Z]|[0-9]|[\_]/.test(String(subscriptionName).slice(-1)))) {
121+
$.jGrowl("Only numbers,letters and underscore is valid to type in subscriptionName field.", {
119122
sticky : false,
120123
theme : 'Error'
121124
});
@@ -203,11 +206,12 @@ jQuery(document).ready(function() {
203206

204207
};// var SubscriptionViewModel = function(){
205208

206-
209+
// Cleanup old ViewModel and Knockout Obeservables from previous page load.
210+
var observableObject = $('#ViewModelDOMObject')[0];
211+
ko.cleanNode(observableObject);
207212
// Apply bindings
208-
var vm = new SubscriptionViewModel();
209-
ko.applyBindings(vm);
210-
213+
var vm = new SubscriptionViewModel();
214+
ko.applyBindings(vm, document.getElementById("ViewModelDOMObject"));
211215

212216

213217
// /Stop ## Knockout #####################################################
@@ -291,7 +295,7 @@ jQuery(document).ready(function() {
291295
},
292296

293297
],
294-
298+
295299
});
296300
// /Stop ## Datatables ##################################################
297301

@@ -665,7 +669,7 @@ jQuery(document).ready(function() {
665669

666670

667671
// /Start ## Save Subscription ##########################################
668-
$('div.modal-content').on( 'click', 'button.save_record', function (event) {
672+
$('div.modal-footer').on( 'click', 'button.save_record', function (event) {
669673

670674
event.stopPropagation();
671675
event.preventDefault();

src/main/resources/static/vendor/bootstrap/css/bootstrap.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/vendor/bootstrap/css/bootstrap.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/vendor/bootstrap/js/bootstrap.bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/vendor/bootstrap/js/bootstrap.bundle.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/vendor/bootstrap/js/bootstrap.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/templates/eiInfo.html

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,18 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
88
<title>Eiffel Intelligence Subscription Handling</title>
99

10-
<!-- Style Sheets -->
11-
12-
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
13-
14-
<!-- JavaScript imports -->
15-
16-
<script type="text/javascript" src="assets/jquery/jquery-3.2.1.min.js"></script>
17-
<script type="text/javascript"
18-
src="assets/bootstrap/js/bootstrap.min.js"></script>
19-
<script type="text/javascript"
20-
src="assets/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
21-
<script type="text/javascript" src="assets/knockout/knockout-3.4.2.js"></script>
22-
<script type="text/javascript" src="assets/knockout/knockout.mapping.js"></script>
23-
<script type="text/javascript"
24-
src="assets/jquery-confirm/js/jquery-confirm.js"></script>
25-
<script type="text/javascript" src="assets/jgrowl/jquery.jgrowl.min.js"></script>
26-
<script type="text/javascript" src="assets/jquery-ui/jquery-ui.min.js"></script>
27-
<script type="text/javascript" src="assets/datatables/js/jquery.dataTables.min.js"></script>
28-
<script type="text/javascript" src="assets/datatables/js/dataTables.bootstrap.min.js"></script>
29-
3010

3111
</head>
3212

3313
<body class="nav-link">
34-
<div class="hidden" id="frontendServiceUrl"
14+
<div class="hidden" id="frontendServiceUrl" style="display: none"
3515
th:text="${frontendServiceUrl}"></div>
36-
<div class="hidden" id="backendServerUrl"
16+
<div class="hidden" id="backendServerUrl" style="display: none"
3717
th:text="${backendServerUrl}"></div>
38-
18+
19+
<div id="eiPageFrame"></div>
20+
3921
<script type="text/javascript" src="js/eiInfo.js"></script>
22+
4023
</body>
4124
</html>

src/main/resources/templates/forgot-password.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
1414
<!-- Custom styles for this template-->
1515
<link href="css/sb-admin.css" rel="stylesheet" />
16+
17+
18+
1619
</head>
1720

1821
<body class="bg-dark">
@@ -37,11 +40,6 @@ <h4>Forgot your password?</h4>
3740
</div>
3841
</div>
3942
</div>
40-
<!-- Bootstrap core JavaScript-->
41-
<script src="vendor/jquery/jquery.min.js"></script>
42-
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
43-
<!-- Core plugin JavaScript-->
44-
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
4543
</body>
4644

4745
</html>

0 commit comments

Comments
 (0)