Skip to content

Commit

Permalink
Merge pull request #8 from sdtabilit/SLTS-9-adding-to-configuration-p…
Browse files Browse the repository at this point in the history
…roperties-custom_image_logo_and_custom_css

Slts 9 adding to configuration properties custom image logo and custom css
  • Loading branch information
grzesiekb authored Jul 26, 2016
2 parents b72a2de + 6cb9693 commit 47d7c03
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ local.properties
seroUtils.jar
*deploy_rsa
*deploy_rsa.pub
*.exe
*.exe
*client*.png
*client*.css
9 changes: 9 additions & 0 deletions WebContent/WEB-INF/classes/env.properties
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,14 @@ abilit.MILLIS_SECONDS_PERIOD_UPDATE_EVENT_DETECTORS=1000
abilit.MILLIS_SECONDS_PERIOD_UPDATE_PENDING_EVENTS=1000
abilit.CRONE_UPDATE_CACHE_POINT_HIERARCHY=0 0/10 * * * ?

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
#grove.url=http://mango.serotoninsoftware.com/servlet
44 changes: 43 additions & 1 deletion WebContent/WEB-INF/jsp/pointHierarchySLTS.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<div class="row">
<table width="100%" cellspacing="0" cellpadding="0" border="0" id="mainHeader">
<tr>
<td><img class="logo" src="builder/assets/images/logos/SCADA-LTS.png" alt="Logo"/></td>
<td><img id="logo" class="logo" src="" alt="Logo"/></td>
<c:if test="${!simple}">
<td align="center" width="99%" id="eventsRow">
<a href="events.shtm">
Expand Down Expand Up @@ -284,6 +284,24 @@ var messages = {
var nodeActivate;
var nodeDragAndDrop;
var newNode;
function loadjscssfile(filename, filetype){
if (filetype=="js"){ //if filename is a external JavaScript file
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
} else if (filetype=="css"){ //if filename is an external CSS file
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
};
$(function () {
$('[data-toggle="tooltip"]').tooltip();
Expand All @@ -297,6 +315,30 @@ var messages = {
if (!myLocation) {
myLocation = location.protocol + "//" + location.host + "" + appScada + "/";
}
$.ajax({
type: "GET",
url:myLocation+'/viewutil/pathToLogo',
success: function(msg){
$("#logo").attr("src", msg);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$("#logo").attr("src", 'builder/assets/images/logos/SCADA-LTS.png');
}
});
$.ajax({
type: "GET",
url:myLocation+'/viewutil/pathToCommonsCSSForNewViews',
success: function(msg){
if (msg.length>0) {
loadjscssfile(msg,"css");
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
//not loaded additional css
}
});
var getParentId = function(node) {
if (node != undefined) {
var parentId=0;
Expand Down
1 change: 0 additions & 1 deletion WebContent/WEB-INF/jsp/scripting.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
if (!myLocation) {
myLocation = location.protocol + "//" + location.host + "/" + appScada + "/";
}
console.log(myLocation);
function executeScript(){
var xid = jQuery("#xid");
// saveScript() nie zdarzy zapisac !!!
Expand Down
55 changes: 54 additions & 1 deletion WebContent/WEB-INF/tags/page.tag
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,59 @@
<c:if test="${!simple}">
<script type="text/javascript" src="resources/header.js"></script>
<script type="text/javascript">
function loadjscssfile(filename, filetype){
if (filetype=="js"){ //if filename is a external JavaScript file
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
} else if (filetype=="css"){ //if filename is an external CSS file
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
};
jQuery((function () {
var pathArray = location.href.split( '/' );
var protocol = pathArray[0];
var host = pathArray[2];
var port = location.port;
var appScada = pathArray[3];
var url = protocol + '//' + host;
var myLocation;
if (!myLocation) {
myLocation = location.protocol + "//" + location.host + "/" + appScada + "/";
}
jQuery.ajax({
type: "GET",
url:myLocation+'/viewutil/pathToLogo',
success: function(msg){
console.log(msg);
jQuery("#logo").attr("src", msg);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jQuery("#logo").attr("src", 'builder/assets/images/logos/SCADA-LTS.png');
}
});
jQuery.ajax({
type: "GET",
url:myLocation+'/viewutil/pathToCommonsCSS',
success: function(msg){
console.log(msg);
loadjscssfile(msg,"css");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
loadjscssfile('/resources/common.css','css');
}
});
}));
dwr.util.setEscapeHtml(false);
<c:if test="${!empty sessionUser}">
dojo.addOnLoad(mango.header.onLoad);
Expand All @@ -103,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
121 changes: 121 additions & 0 deletions WebContent/resources/customClientScripts/customView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*****************************************************************
* Custom client side scripts for graphical views
****************************************************************/

/*****************************************************************
* 06.02.2015 Pawel
* Script for render color changing progress bar in predefined
* canvas.
* @arg0 canvas element used to draw on
* @arg1 minimal value
* @arg2 value below which bar is red
* @arg3 value below which bar is yellow
* @arg4 maximal value below which bar is green
* @arg5 actual value (in most cases should be set to this.value)
* @arg6 boolean; if true bar is vertical
* if false bar is horizontal
****************************************************************/
function renderBar() {
var canvas = document.getElementById(arguments[0]);
var height = canvas.offsetHeight;
var width = canvas.offsetWidth;
var min = arguments[1];
var step1 = arguments[2];
var step2 = arguments[3];
var max = arguments[4];
var value = arguments[5];
var isVertical = arguments[6];

var context = canvas.getContext("2d");

context.beginPath();
if(isVertical){
var val = (value-min)*height/(max-min);
context.rect(0, height-val, width, val);
} else {
var val = (value-min)*width/(max-min);
context.rect(0, 0, val, height);
}
if(value<step1){
context.fillStyle = "#FF0000";
} else if(value<step2){
context.fillStyle = "#FFFF00";
} else {
context.fillStyle = "#00FF00";
}
context.fill();
}

/*****************************************************************
* 20.02.2015 Pawel
* Script for hiding and unhiding specified images
* @arg0 set of components to hide/unhide
****************************************************************/
function showAndHide() {
var toHide = isMoreImagesVisible(arguments[0]);
var componentsList = arguments[0];
if(toHide){
for(var i=0; i<componentsList.length; i++){
componentsList[i].style.visibility = 'hidden';
}
} else {
for(var i=0; i<componentsList.length; i++){
componentsList[i].style.visibility = 'visible';
}
}
}

/*****************************************************************
* 20.02.2015 Pawel
* Script for checking if there are more visible elements than
* the hidden ones in given set
* @arg0 set of components
* @return boolean if there are more visible elements
****************************************************************/
function isMoreImagesVisible(){
var componentsList = arguments[0];
var visible = 0, hidden = 0;
for(var i=0; i<componentsList.length; i++){
if(componentsList[i].style.visibility == "hidden"){
++hidden;
}
else {
++visible;
}
}
return visible >= hidden;
}

/*****************************************************************
* 20.02.2015 Pawel
* Script for finding images which has specified text in src
* attribute in document
* @arg0 text that should be in src of component
* @return set of components with given text in src attribute
****************************************************************/
function findImagesBySrc() {
var images = Array.prototype.slice.apply(document.getElementsByTagName('img'));
var resultImages = [];
for(var i=0; i<images.length; i++){
if(images[i].src.indexOf(arguments[0]) !== -1){
resultImages.push(images[i]);
}
}
return resultImages;
}

/*****************************************************************
* 20.02.2015 Pawel
* Script for finding broken images in document
* @return set of broken images
****************************************************************/
function findBrokenImages() {
var images = Array.prototype.slice.apply(document.getElementsByTagName('img'));
var resultImages = [];
for(var i=0; i<images.length; i++){
if(!images[i].complete || (typeof images[i].naturalWidth != "undefined" && images[i].naturalWidth == 0)){
resultImages.push(images[i]);
}
}
return resultImages;
}
33 changes: 32 additions & 1 deletion src/org/scada_lts/config/ScadaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,42 @@ public class ScadaConfig {
*/
public static final String CRONE_UPDATE_CACHE_POINT_HIERARCHY = "abilit.CRONE_UPDATE_CACHE_POINT_HIERARCHY";

/**
* Uploads personalized logo in views.
*/
public static final String PATH_TO_CUSTOM_LOGO = "scadalts.custom_logo";

/**
* Default value path to image logo scada-lts
*/
public static final String VALUE_DEFAULT_PATH_TO_LOGO = "builder/assets/images/logos/SCADA-LTS.png";


/**
* Upload personalized CSS in views.
*/
public static final String PATH_TO_CUSTOM_CSS = "scadalts.custom_css";

/**
* Default value path to common.css
*/
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;
private Properties conf;


public static ScadaConfig getInstance() throws IOException {
if (instance == null) {
instance = new ScadaConfig();
Expand Down
Loading

0 comments on commit 47d7c03

Please sign in to comment.