From 6cb96931a7dffeb118a64eca9cdf06acca202d83 Mon Sep 17 00:00:00 2001 From: "grzegorz.bylica@gmail.com" Date: Tue, 26 Jul 2016 19:30:57 +0200 Subject: [PATCH] SLTS-9 correcting configuration and adding to config env.properties "scadalts.custom_css_for_new_views" set custom css for new views (*SLTS.jsp) --- WebContent/WEB-INF/classes/env.properties | 3 ++ WebContent/WEB-INF/jsp/pointHierarchySLTS.jsp | 13 +++--- WebContent/WEB-INF/tags/page.tag | 2 +- src/org/scada_lts/config/ScadaConfig.java | 10 +++++ .../mvc/controller/ViewUtilController.java | 42 +++++++++++++++---- 5 files changed, 55 insertions(+), 15 deletions(-) diff --git a/WebContent/WEB-INF/classes/env.properties b/WebContent/WEB-INF/classes/env.properties index b289ea2a44..9b79b90a0b 100644 --- a/WebContent/WEB-INF/classes/env.properties +++ b/WebContent/WEB-INF/classes/env.properties @@ -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 diff --git a/WebContent/WEB-INF/jsp/pointHierarchySLTS.jsp b/WebContent/WEB-INF/jsp/pointHierarchySLTS.jsp index 809abf0019..84153b4058 100644 --- a/WebContent/WEB-INF/jsp/pointHierarchySLTS.jsp +++ b/WebContent/WEB-INF/jsp/pointHierarchySLTS.jsp @@ -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 } }); diff --git a/WebContent/WEB-INF/tags/page.tag b/WebContent/WEB-INF/tags/page.tag index 1147968f5d..29c75ca50a 100644 --- a/WebContent/WEB-INF/tags/page.tag +++ b/WebContent/WEB-INF/tags/page.tag @@ -156,7 +156,7 @@ - +
Logo diff --git a/src/org/scada_lts/config/ScadaConfig.java b/src/org/scada_lts/config/ScadaConfig.java index a4c28a2f53..dc31e6e3b1 100644 --- a/src/org/scada_lts/config/ScadaConfig.java +++ b/src/org/scada_lts/config/ScadaConfig.java @@ -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; diff --git a/src/org/scada_lts/web/mvc/controller/ViewUtilController.java b/src/org/scada_lts/web/mvc/controller/ViewUtilController.java index c566447444..a0ccb1aa3c 100644 --- a/src/org/scada_lts/web/mvc/controller/ViewUtilController.java +++ b/src/org/scada_lts/web/mvc/controller/ViewUtilController.java @@ -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; + } + } }