Skip to content

Commit

Permalink
Merge pull request #2982 from SCADA-LTS/feature/#1580_Improvement_des…
Browse files Browse the repository at this point in the history
…cribe_information_about_scada_on_top2

#1580 Improvement describe information about scada on top
  • Loading branch information
Limraj authored Aug 26, 2024
2 parents dd405c5 + c6f3a4c commit 98cc163
Show file tree
Hide file tree
Showing 22 changed files with 209 additions and 22 deletions.
41 changes: 34 additions & 7 deletions WebContent/WEB-INF/jsp/systemSettings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
$set("<c:out value="<%= SystemSettingsDAO.WEB_RESOURCE_GRAPHICS_PATH %>"/>", settings.<c:out value="<%= SystemSettingsDAO.WEB_RESOURCE_GRAPHICS_PATH %>"/>);
$set("<c:out value="<%= SystemSettingsDAO.WEB_RESOURCE_UPLOADS_PATH %>"/>", settings.<c:out value="<%= SystemSettingsDAO.WEB_RESOURCE_UPLOADS_PATH %>"/>);
setDisabled($("<c:out value="<%= SystemSettingsDAO.WORK_ITEMS_REPORTING_ITEMS_PER_SECOND_ENABLED %>"/>"), !settings.<c:out value="<%= SystemSettingsDAO.WORK_ITEMS_REPORTING_ENABLED %>"/>);
setDisabled($("<c:out value="<%= SystemSettingsDAO.WORK_ITEMS_REPORTING_ITEMS_PER_SECOND_LIMIT %>"/>"), !settings.<c:out value="<%= SystemSettingsDAO.WORK_ITEMS_REPORTING_ENABLED %>"/> || !settings.<c:out value="<%= SystemSettingsDAO.WORK_ITEMS_REPORTING_ITEMS_PER_SECOND_ENABLED %>"/>);
Expand All @@ -118,6 +119,8 @@
sel.options[sel.options.length] = new Option("${lang.value}", "${lang.key}");
</c:forEach>
$set(sel, settings.<c:out value="<%= SystemSettingsDAO.LANGUAGE %>"/>);
$set("<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION_PREFIX %>"/>", settings.<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION_PREFIX %>"/>);
$set("<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION %>"/>", settings.<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION %>"/>);
});
<%--
Expand Down Expand Up @@ -345,15 +348,23 @@
else
$set(type, "");
}
function saveInfoSettings() {
var topDescriptionPrefix = $get("<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION_PREFIX %>"/>");
var topDescription = $get("<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION %>"/>");
SystemSettingsDwr.saveInfoSettings("0",
//$get("<c:out value="<%= SystemSettingsDAO.NEW_VERSION_NOTIFICATION_LEVEL %>"/>"),
$get("<c:out value="<%= SystemSettingsDAO.INSTANCE_DESCRIPTION %>"/>"),
function() {
stopImageFader("saveInfoSettingsImg");
setUserMessage("infoMessage", "<fmt:message key="systemSettings.infoSaved"/>");
});
$get("<c:out value="<%= SystemSettingsDAO.INSTANCE_DESCRIPTION %>"/>"),
topDescriptionPrefix,
topDescription,
function() {
stopImageFader("saveInfoSettingsImg");
document.getElementById('top-description-prefix').innerText = topDescriptionPrefix;
document.getElementById('top-description').innerText = topDescription;
setUserMessage("infoMessage", "<fmt:message key='systemSettings.infoSaved'/>");
}
);
setUserMessage("infoMessage");
startImageFader("saveInfoSettingsImg");
}
Expand Down Expand Up @@ -552,6 +563,7 @@
}
$set("<c:out value="<%= SystemSettingsDAO.UI_PERFORMANCE %>"/>", uiPerformance);
}
</script>

<div class="borderDivPadded marB marR" style="float:left">
Expand All @@ -561,6 +573,9 @@
<span class="smallTitle"><fmt:message key="systemSettings.systemInformation"/></span>
<tag:help id="systemInformation"/>
</td>
<td align="right">
<tag:img id="saveInfoSettingsImg" png="save" onclick="saveInfoSettings();" title="common.save"/>
</td>
</tr>
</table>
<table>
Expand Down Expand Up @@ -613,6 +628,18 @@
<td class="formLabelRequired"><fmt:message key="systemSettings.eventCount"/></td>
<td class="formField" id="eventCount"></td>
</tr>
<tr>
<td class="formLabelRequired"><fmt:message key="systemsettings.top.description.prefix"/></td>
<td class="formField">
<input id="<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION_PREFIX %>"/>" type="text" class="formShort" style="width: 300px;"/>
</td>
</tr>
<tr>
<td class="formLabelRequired"><fmt:message key="systemsettings.top.description"/></td>
<td class="formField">
<input id="<c:out value="<%= SystemSettingsDAO.TOP_DESCRIPTION %>"/>" type="text" class="formShort" style="width: 300px;"/>
</td>
</tr>
<tr>
<td colspan="2" id="infoMessage" class="formError"></td>
</tr>
Expand Down
10 changes: 10 additions & 0 deletions WebContent/WEB-INF/tags/logo.tag
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
<div class="logo-section">
<div class="logo-section--title">
<img id="logo" src="assets/logo.png" alt="Logo">

<div id="top-description-container">
<span id="top-description-prefix" class="custom-text">
<c:out value="${scadaVersion.getTopDescriptionPrefix()}"/>
</span>
<span id="top-description" class="custom-text">
<c:out value="${scadaVersion.getTopDescription()}"/>
</span>
</div>

<c:if test="${(!empty scadaVersion) && scadaVersion.isShowVersionInfo()}">
<c:if test="${!empty scadaVersion.getCompanyName()}">
<div id="company-container">
Expand Down
27 changes: 26 additions & 1 deletion WebContent/assets/user_styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,29 @@
* #viewContainer > #viewContent .slts-btn {
* font-size: 1.5em;
* }
*/
*/

/* ----- Custom information stylesheet ----- */
#top-description-container {
display: flex;
align-items: flex-end;
justify-content: center;
}

#top-description-prefix {
color: black;
font-size: 2em;
margin-left: 0.5em;
margin-right: 0.5em;
display: inline-block;
vertical-align: bottom;
line-height: 1;
}

#top-description {
color: #39B54A;
font-size: 2em;
display: inline-block;
vertical-align: bottom;
line-height: 1;
}
4 changes: 3 additions & 1 deletion scadalts-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1074,5 +1074,7 @@
"systemsettings.misc.webResourceUploadsPath": "Uploaded images save path",
"systemsettings.misc.webResourceGraphicsPath": "Graphics images path",
"systemsettings.misc.webResourceUploadsPath.wrong":"Uploaded images save path must end with 'uploads' or 'uploads{0}' ",
"systemsettings.misc.webResourceGraphicsPath.wrong": "Graphics images path must end with 'graphics' or 'graphics{0}' "
"systemsettings.misc.webResourceGraphicsPath.wrong": "Graphics images path must end with 'graphics' or 'graphics{0}' ",
"systemsettings.top.description": "Top description",
"systemsettings.top.description.prefix": "Top description prefix"
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,21 @@
@change="watchDataChange()"
></v-switch>
</v-col>
</v-row>
<v-col cols="12">
<v-text-field
v-model="miscSettings.topDescriptionPrefix"
:label="$t('systemsettings.top.description.prefix')"
@change="watchDataChange()"
></v-text-field>
</v-col>
<v-col cols="12">
<v-text-field
v-model="miscSettings.topDescription"
:label="$t('systemsettings.top.description')"
@change="watchDataChange()"
></v-text-field>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-col>
Expand Down
8 changes: 7 additions & 1 deletion src/com/serotonin/mango/web/dwr/SystemSettingsDwr.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ public Map<String, Object> getSettings() {
systemSettingsService.getMiscSettings().getWebResourceUploadsPath());
settings.put(SystemSettingsDAO.EVENT_ASSIGN_ENABLED,
systemSettingsService.getMiscSettings().isEventAssignEnabled());
settings.put(SystemSettingsDAO.TOP_DESCRIPTION,
systemSettingsService.getMiscSettings().getTopDescription());
settings.put(SystemSettingsDAO.TOP_DESCRIPTION_PREFIX,
systemSettingsService.getMiscSettings().getTopDescriptionPrefix());
return settings;
}

Expand Down Expand Up @@ -471,14 +475,16 @@ public DwrResponseI18n saveColourSettings(String chartBackgroundColour,


public void saveInfoSettings(String newVersionNotificationLevel,
String instanceDescription) {
String instanceDescription,String topDescriptionPrefix, String topDescription) {
Permissions.ensureAdmin();
SystemSettingsDAO systemSettingsDAO = new SystemSettingsDAO();
systemSettingsDAO.setValue(
SystemSettingsDAO.NEW_VERSION_NOTIFICATION_LEVEL,
newVersionNotificationLevel);
systemSettingsDAO.setValue(SystemSettingsDAO.INSTANCE_DESCRIPTION,
instanceDescription);
systemSettingsDAO.setValue(SystemSettingsDAO.TOP_DESCRIPTION_PREFIX, topDescriptionPrefix);
systemSettingsDAO.setValue(SystemSettingsDAO.TOP_DESCRIPTION, topDescription);
}


Expand Down
10 changes: 10 additions & 0 deletions src/org/scada_lts/config/ScadaVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import com.serotonin.mango.Common;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.scada_lts.dao.SystemSettingsDAO;


import java.io.FileInputStream;
import java.util.Properties;

import static org.scada_lts.dao.SystemSettingsDAO.TOP_DESCRIPTION;
import static org.scada_lts.dao.SystemSettingsDAO.TOP_DESCRIPTION_PREFIX;

/**
* Scada Version class
*
Expand Down Expand Up @@ -134,4 +138,10 @@ public String getCompanyName() {
public String getPoweredBy() {
return poweredBy;
}
public String getTopDescription() {
return SystemSettingsDAO.getValue(TOP_DESCRIPTION);
}
public String getTopDescriptionPrefix(){
return SystemSettingsDAO.getValue(TOP_DESCRIPTION_PREFIX);
}
}
4 changes: 4 additions & 0 deletions src/org/scada_lts/dao/SystemSettingsDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public class SystemSettingsDAO {
public static final String WEB_RESOURCE_GRAPHICS_PATH = "webResourceGraphicsPath";
public static final String WEB_RESOURCE_UPLOADS_PATH = "webResourceUploadsPath";
public static final String EVENT_ASSIGN_ENABLED = "eventAssignEnabled";
public static final String TOP_DESCRIPTION_PREFIX = "topDescriptionPrefix";
public static final String TOP_DESCRIPTION = "topDescription";

// @formatter:off
private static final String SELECT_SETTING_VALUE_WHERE = ""
Expand Down Expand Up @@ -414,6 +416,8 @@ public String getDatabaseSchemaVersion(String key, String defaultValue) {
DEFAULT_VALUES.put(WEB_RESOURCE_GRAPHICS_PATH, SystemSettingsUtils.getWebResourceGraphicsPath());
DEFAULT_VALUES.put(WEB_RESOURCE_UPLOADS_PATH, SystemSettingsUtils.getWebResourceUploadsPath());
DEFAULT_VALUES.put(EVENT_ASSIGN_ENABLED, SystemSettingsUtils.isEventAssignEnabled());
DEFAULT_VALUES.put(TOP_DESCRIPTION, "");
DEFAULT_VALUES.put(TOP_DESCRIPTION_PREFIX, "");
}

@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED, rollbackFor = SQLException.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.scada_lts.dao.migration.mysql;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.scada_lts.dao.DAO;
import org.springframework.jdbc.core.JdbcTemplate;

public class V2_8_0_2_AddTopDescriptionColumnsToSystemSettings extends BaseJavaMigration {

private static final Log LOG = LogFactory.getLog(V2_8_0_2_AddTopDescriptionColumnsToSystemSettings.class);

@Override
public void migrate(Context context) throws Exception {
final JdbcTemplate jdbcTmp = DAO.getInstance().getJdbcTemp();

try {
addTopDescriptionColumns(jdbcTmp);
} catch (Exception ex) {
LOG.error(ex.getMessage(), ex);
throw ex;
}
}

private void addTopDescriptionColumns(JdbcTemplate jdbcTmp) {
boolean existsTopDescriptionColumn = jdbcTmp.queryForObject(
"SELECT (SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`= DATABASE() AND `TABLE_NAME`='systemSettings' AND `COLUMN_NAME`='topDescription') IS NOT NULL;",
boolean.class
);

boolean existsTopDescriptionPrefixColumn = jdbcTmp.queryForObject(
"SELECT (SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`= DATABASE() AND `TABLE_NAME`='systemSettings' AND `COLUMN_NAME`='topDescriptionPrefix') IS NOT NULL;",
boolean.class
);

if (!existsTopDescriptionColumn) {
jdbcTmp.update("ALTER TABLE systemSettings ADD COLUMN topDescription VARCHAR(255) DEFAULT '';");
}

if (!existsTopDescriptionPrefixColumn) {
jdbcTmp.update("ALTER TABLE systemSettings ADD COLUMN topDescriptionPrefix VARCHAR(255) DEFAULT '';");
}
}
}
4 changes: 4 additions & 0 deletions src/org/scada_lts/mango/service/SystemSettingsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public JsonSettingsMisc getMiscSettings() {
json.setWebResourceGraphicsPath(SystemSettingsDAO.getValue(SystemSettingsDAO.WEB_RESOURCE_GRAPHICS_PATH));
json.setWebResourceUploadsPath(SystemSettingsDAO.getValue(SystemSettingsDAO.WEB_RESOURCE_UPLOADS_PATH));
json.setEventAssignEnabled(SystemSettingsDAO.getBooleanValue(SystemSettingsDAO.EVENT_ASSIGN_ENABLED));
json.setTopDescription(SystemSettingsDAO.getValue(SystemSettingsDAO.TOP_DESCRIPTION));
json.setTopDescriptionPrefix(SystemSettingsDAO.getValue(SystemSettingsDAO.TOP_DESCRIPTION_PREFIX));
return json;
}

Expand All @@ -162,6 +164,8 @@ public void saveMiscSettings(JsonSettingsMisc json) {
systemSettingsDAO.setValue(SystemSettingsDAO.WEB_RESOURCE_GRAPHICS_PATH, json.getWebResourceGraphicsPath());
systemSettingsDAO.setValue(SystemSettingsDAO.WEB_RESOURCE_UPLOADS_PATH, json.getWebResourceUploadsPath());
saveEventAssignEnabled(json.isEventAssignEnabled());
systemSettingsDAO.setValue(SystemSettingsDAO.TOP_DESCRIPTION, json.getTopDescription());
systemSettingsDAO.setValue(SystemSettingsDAO.TOP_DESCRIPTION_PREFIX, json.getTopDescriptionPrefix());
}

public SettingsDataRetention getDataRetentionSettings() {
Expand Down
18 changes: 18 additions & 0 deletions src/org/scada_lts/web/mvc/api/json/JsonSettingsMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class JsonSettingsMisc implements Serializable {
public String webResourceGraphicsPath;
public String webResourceUploadsPath;
public boolean eventAssignEnabled;
public String topDescription;
public String topDescriptionPrefix;

public JsonSettingsMisc() {}

Expand Down Expand Up @@ -123,4 +125,20 @@ public boolean isEventAssignEnabled() {
public void setEventAssignEnabled(boolean eventAssignEnabled) {
this.eventAssignEnabled = eventAssignEnabled;
}

public String getTopDescription(){
return topDescription;
}

public void setTopDescription(String topDescription){
this.topDescription = topDescription;
}

public String getTopDescriptionPrefix(){
return topDescriptionPrefix;
}

public void setTopDescriptionPrefix(String topDescriptionPrefix){
this.topDescriptionPrefix = topDescriptionPrefix;
}
}
4 changes: 3 additions & 1 deletion webapp-resources/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3355,4 +3355,6 @@ common.assignee=Assignee
event.system.assigned=Assigned Event
event.system.unassigned=Unassigned Event
event.assign.enabled=Event Assign enabled
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
systemsettings.top.description.prefix = Top description prefix
systemsettings.top.description = Top description
4 changes: 3 additions & 1 deletion webapp-resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3358,4 +3358,6 @@ common.assignee=Assignee
event.system.assigned=Assigned Event
event.system.unassigned=Unassigned Event
event.assign.enabled=Event Assign enabled
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
systemsettings.top.description.prefix = Top description prefix
systemsettings.top.description = Top description
4 changes: 3 additions & 1 deletion webapp-resources/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3398,4 +3398,6 @@ common.assignee=Assignee
event.system.assigned=Assigned Event
event.system.unassigned=Unassigned Event
event.assign.enabled=Event Assign enabled
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
systemsettings.top.description.prefix = Top description prefix
systemsettings.top.description = Top description
4 changes: 3 additions & 1 deletion webapp-resources/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3483,4 +3483,6 @@ common.assignee=Assignee
event.system.assigned=Assigned Event
event.system.unassigned=Unassigned Event
event.assign.enabled=Event Assign enabled
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
systemsettings.top.description.prefix = Top description prefix
systemsettings.top.description = Top description
4 changes: 3 additions & 1 deletion webapp-resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3352,4 +3352,6 @@ common.assignee=Assignee
event.system.assigned=Assigned Event
event.system.unassigned=Unassigned Event
event.assign.enabled=Event Assign enabled
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
systemsettings.top.description.prefix = Top description prefix
systemsettings.top.description = Top description
4 changes: 3 additions & 1 deletion webapp-resources/messages_lu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3371,4 +3371,6 @@ common.assignee=Assignee
event.system.assigned=Assigned Event
event.system.unassigned=Unassigned Event
event.assign.enabled=Event Assign enabled
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
viewEdit.graphic.hideAssigneeColumn=Hide Assignee column
systemsettings.top.description.prefix = Top description prefix
systemsettings.top.description = Top description
Loading

0 comments on commit 98cc163

Please sign in to comment.