Skip to content

Commit

Permalink
SLTS-9 correcting configuration and adding to config env.properties "…
Browse files Browse the repository at this point in the history
…scadalts.custom_css_for_new_views" set custom css for new views (*SLTS.jsp)
  • Loading branch information
grzesiekb committed Jul 26, 2016
1 parent be16692 commit 6cb9693
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 15 deletions.
3 changes: 3 additions & 0 deletions WebContent/WEB-INF/classes/env.properties
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ scadalts.custom_logo=builder/assets/images/logos/SCADA-LTS.png
#scadalts.custom_logo=builder/assets/images/logos/client_*.png
scadalts.custom_css=resources/common.css
#scadalts.custom_css=resources/client_*.css
scadalts.custom_css_for_new_views=
#scadalts.custom_css_for_new_views=resources/client_*_for_new_views.css



#security.hashAlgorithm=NONE
Expand Down
13 changes: 7 additions & 6 deletions WebContent/WEB-INF/jsp/pointHierarchySLTS.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -320,21 +320,22 @@ var messages = {
type: "GET",
url:myLocation+'/viewutil/pathToLogo',
success: function(msg){
jQuery("#logo").attr("src", msg);
$("#logo").attr("src", msg);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jQuery("#logo").attr("src", 'builder/assets/images/logos/SCADA-LTS.png');
$("#logo").attr("src", 'builder/assets/images/logos/SCADA-LTS.png');
}
});
$.ajax({
type: "GET",
url:myLocation+'/viewutil/pathToCommonsCSS',
url:myLocation+'/viewutil/pathToCommonsCSSForNewViews',
success: function(msg){
loadjscssfile(msg,"css");
if (msg.length>0) {
loadjscssfile(msg,"css");
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
loadjscssfile('/resources/common.css','css');
//not loaded additional css
}
});
Expand Down
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/tags/page.tag
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<body>
<table width="100%" cellspacing="0" cellpadding="0" border="0" id="mainHeader">
<tr>
<td><img src="builder/assets/images/logos/SCADA-LTS.png" alt="Logo"/></td>
<td><img id="logo" src="builder/assets/images/logos/SCADA-LTS.png" alt="Logo"/></td>
<c:if test="${!simple}">
<td align="center" width="99%" id="eventsRow">
<a href="events.shtm">
Expand Down
10 changes: 10 additions & 0 deletions src/org/scada_lts/config/ScadaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ public class ScadaConfig {
*/
public static final String VALUE_DEFAULT_PATH_TO_CSS="/resources/common.css";

/**
* Upload personalized CSS in new views of scada-lts (*LTS.jsp).
*/
public static final String PATH_TO_CUSTOM_CSS_FOR_NEW_VIEWS = "scadalts.custom_css_for_new_views";

/**
* Default value path to common.css for new views of scada-lts (*LTS.jsp).
*/
public static final String VALUE_DEFAULT_PATH_TO_CSS_FOR_NEW_VIEWS="";


private static final Log LOG = LogFactory.getLog(ScadaConfig.class);
private static ScadaConfig instance = null;
Expand Down
42 changes: 34 additions & 8 deletions src/org/scada_lts/web/mvc/controller/ViewUtilController.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,51 @@ public class ViewUtilController {
}

@RequestMapping(value = "/viewutil/pathToLogo", method = RequestMethod.GET)
public @ResponseBody String getPathToCustomLogo(HttpServletRequest request, HttpServletResponse response) throws IOException {
public @ResponseBody String getPathToCustomLogo(HttpServletRequest request, HttpServletResponse response) {
LOG.debug("/viewutil/customlogo");
String customLogo=ScadaConfig.getInstance().getProperty(ScadaConfig.PATH_TO_CUSTOM_LOGO);
if (customLogo != null) {
return customLogo;
String pathToLogo;
try {
pathToLogo=ScadaConfig.getInstance().getProperty(ScadaConfig.PATH_TO_CUSTOM_LOGO);
} catch (IOException e) {
return ScadaConfig.VALUE_DEFAULT_PATH_TO_LOGO;
}
if (pathToLogo != null) {
return pathToLogo;
} else {
return ScadaConfig.VALUE_DEFAULT_PATH_TO_LOGO;
}
}

@RequestMapping(value = "/viewutil/pathToCommonsCSS", method = RequestMethod.GET)
public @ResponseBody String getPathToCustomCSS(HttpServletRequest request, HttpServletResponse response) throws IOException {
public @ResponseBody String getPathToCustomCSS(HttpServletRequest request, HttpServletResponse response) {
LOG.debug("/viewutil/customlogo");
String customLogo=ScadaConfig.getInstance().getProperty(ScadaConfig.PATH_TO_CUSTOM_CSS);
if (customLogo != null) {
return customLogo;
String pathToCommonsCSS;
try {
pathToCommonsCSS=ScadaConfig.getInstance().getProperty(ScadaConfig.PATH_TO_CUSTOM_CSS);
} catch (IOException e) {
return ScadaConfig.VALUE_DEFAULT_PATH_TO_CSS;
}
if (pathToCommonsCSS != null) {
return pathToCommonsCSS;
} else {
return ScadaConfig.VALUE_DEFAULT_PATH_TO_CSS;
}
}

@RequestMapping(value = "/viewutil/pathToCommonsCSSForNewViews", method = RequestMethod.GET)
public @ResponseBody String getPathToCustomCSSForNew(HttpServletRequest request, HttpServletResponse response) {
String pathToCommonsCSSForNewViews;
LOG.debug("/viewutil/pathToCommonsCSSForNewViews");
try {
pathToCommonsCSSForNewViews=ScadaConfig.getInstance().getProperty(ScadaConfig.PATH_TO_CUSTOM_CSS_FOR_NEW_VIEWS);
} catch (IOException e) {
return ScadaConfig.VALUE_DEFAULT_PATH_TO_CSS_FOR_NEW_VIEWS;
}
if (pathToCommonsCSSForNewViews != null) {
return pathToCommonsCSSForNewViews;
} else {
return ScadaConfig.VALUE_DEFAULT_PATH_TO_CSS_FOR_NEW_VIEWS;
}
}

}

0 comments on commit 6cb9693

Please sign in to comment.