Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#718 Added state description for datasources, Added config messages l… #722

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions WebContent/WEB-INF/classes/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3154,5 +3154,14 @@ menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info
menu.point_hierarchy.info.tooltip=Info
header.changeTheme=
ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description



10 changes: 9 additions & 1 deletion WebContent/WEB-INF/classes/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3157,4 +3157,12 @@ menu.point_hierarchy.info.tooltip=Info


error.view_hierarchy.add.error1=Name is not validat
header.changeTheme=Change ScadaLTS application theme
header.changeTheme=Change ScadaLTS application theme
ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=\ With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3083,4 +3083,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2903,4 +2903,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3159,4 +3159,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_lu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3169,4 +3169,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2709,4 +2709,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
10 changes: 9 additions & 1 deletion WebContent/WEB-INF/classes/messages_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3070,4 +3070,12 @@ graphic.chartWidth=Długość (każdy wykres)
graphic.chartHeight=Wysokość (każdy wykres)

error.view_hierarchy.add.error1=Name is not validate
header.changeTheme=Zmień motyw aplikacji ScadaLTS
header.changeTheme=Zmień motyw aplikacji ScadaLTS
ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3149,4 +3149,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3120,4 +3120,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
9 changes: 8 additions & 1 deletion WebContent/WEB-INF/classes/messages_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2023,4 +2023,11 @@ menu.point_hierarchy.add.tooltip=Add folder
menu.point_hierarchy.delete.tooltip=Delete folder / Move point to root
menu.point_hierarchy.refresh.tooltip=Refresh
menu.point_hierarchy.info.tooltip=Info

ds.state.migrationOrErrorSerializeChangeEnableState=During data read/migration/error the on/off status of datasource has been changed
ds.state.stopChangeEnableStateDs=Due to the non-response of an external server and the properties stop enabled, datasource has been stopped
ds.state.userChangeEnableStateDs=The user has changed the on/off status of datasource
ds.state.apiChangeEnableStateDs=With the use of the API, the on/off status of DataSource has been changed
ds.state.importChangeEnableStateDs=During the import, the on/off status of DataSource was changed
ds.state.scryptChangeEnable=The script has changed the on/off status of datasource
ds.state.userCpChangeEnableStateDs=The user has copied datasource. The datasource is off by default
dsList.statusDescribe=Status description
13 changes: 11 additions & 2 deletions WebContent/WEB-INF/jsp/dataSourceList.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,22 @@
});
}

function updateStateDescription(idDs, description) {
var idStateDesc = "stateDes"+idDs;
jQuery("#"+idStateDesc).html(description);
}

function toggleDataSource(dataSourceId) {
var imgNode = $("dsImg"+ dataSourceId);
if (!hasImageFader(imgNode)) {
DataSourceListDwr.toggleDataSource(dataSourceId, function(result) {
updateStatusImg($("dsImg"+ result.id), result.enabled, true);
updateStateDescription(result.id, result.state);
});
startImageFader(imgNode);
}
}

function toggleDataPoint(dataPointId) {
var imgNode = $("dpImg"+ dataPointId);
if (!hasImageFader(imgNode)) {
Expand Down Expand Up @@ -117,6 +123,7 @@
<td><fmt:message key="dsList.type"/></td>
<td><fmt:message key="dsList.connection"/></td>
<td><fmt:message key="dsList.status"/></td>
<td><fmt:message key="dsList.statusDescribe"/></td>
<td></td>
</tr>
<c:set var="hideText"><fmt:message key="dsList.hide"/></c:set>
Expand All @@ -138,6 +145,9 @@
</c:otherwise>
</c:choose>
</td>
<td id="stateDes${listParent.parent.id}">
${listParent.parent.state.describe}
</td>
<td>
<a href="data_source_edit.shtm?dsid=${listParent.parent.id}"><tag:img png="icon_ds_edit"
title="common.edit"/></a>
Expand Down Expand Up @@ -187,7 +197,6 @@
</table>
</td>
</tr>

</table>
</td>
</tr>
Expand Down
3 changes: 3 additions & 0 deletions src/br/org/scadabr/api/dao/MangoDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.serotonin.mango.vo.permission.Permissions;
import com.serotonin.util.StringUtils;
import com.serotonin.web.dwr.DwrResponseI18n;
import org.scada_lts.ds.state.ApiChangeEnableStateDs;

import java.util.*;

Expand Down Expand Up @@ -863,6 +864,7 @@ public int configureDataSource(DataSourceType dataSourceType,
ds.setId(config.getId());
ds.setName(config.getName());
ds.setEnabled(config.isEnabled());
ds.setState(new ApiChangeEnableStateDs());
ds.setHost(config.getHost());
ds.setPort(config.getPort());
ds.setUpdatePeriods((int) config.getPollingPeriod());
Expand Down Expand Up @@ -905,6 +907,7 @@ public int configureDataSource(DataSourceType dataSourceType,
ds.setId(config.getId());
ds.setName(config.getName());
ds.setEnabled(config.isEnabled());
ds.setState(new ApiChangeEnableStateDs());
ds.setCommPortId(config.getSerialPort());
ds.setBaudRate(config.getBaudrate());
ds.setUpdatePeriods((int) config.getPollingPeriod());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.serotonin.mango.rt.RuntimeManager;
import com.serotonin.mango.vo.dataSource.DataSourceVO;
import com.serotonin.mango.vo.permission.Permissions;
import org.scada_lts.ds.state.ScryptChangeEnableStateDs;

public class DSCommandsScriptContextObject extends ScriptContextObject {
public static final Type TYPE = Type.DATASOURCE_COMMANDS;
Expand All @@ -21,6 +22,7 @@ public void enableDataSource(String xid) {
Permissions.ensureDataSourcePermission(Common.getUser(), dataSource
.getId());
dataSource.setEnabled(true);
dataSource.setState(new ScryptChangeEnableStateDs());
runtimeManager.saveDataSource(dataSource);
}

Expand All @@ -33,6 +35,7 @@ public void disableDataSource(String xid) {
Permissions.ensureDataSourcePermission(Common.getUser(), dataSource
.getId());
dataSource.setEnabled(false);
dataSource.setState(new ScryptChangeEnableStateDs());
runtimeManager.saveDataSource(dataSource);
}

Expand Down
29 changes: 29 additions & 0 deletions src/com/serotonin/mango/vo/dataSource/DataSourceVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
import com.serotonin.util.StringUtils;
import com.serotonin.web.dwr.DwrResponseI18n;
import com.serotonin.web.i18n.LocalizableMessage;
import org.scada_lts.ds.state.MigrationOrErrorSerializeChangeEnableState;
import org.scada_lts.ds.state.IStateDs;

import java.io.IOException;
import java.io.ObjectInputStream;
Expand Down Expand Up @@ -381,6 +383,9 @@ public boolean isNew() {
private String name;
@JsonRemoteProperty
private boolean enabled;

private IStateDs state;

private Map<Integer, Integer> alarmLevels = new HashMap<Integer, Integer>();

public boolean isEnabled() {
Expand All @@ -391,6 +396,14 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public IStateDs getState() {
return state;
}

public void setState(IStateDs state) {
this.state = state;
}

public int getId() {
return id;
}
Expand Down Expand Up @@ -487,6 +500,8 @@ public final void addProperties(List<LocalizableMessage> list) {
AuditEventType.addPropertyMessage(list, "dsEdit.head.name", name);
AuditEventType.addPropertyMessage(list, "common.xid", xid);
AuditEventType.addPropertyMessage(list, "common.enabled", enabled);
AuditEventType.addPropertyMessage(list, "common.state", state);


addPropertiesImpl(list);
}
Expand All @@ -500,6 +515,8 @@ public final void addPropertyChanges(List<LocalizableMessage> list, T from) {
AuditEventType.maybeAddPropertyChangeMessage(list, "common.enabled",
from.isEnabled(), enabled);

AuditEventType.maybeAddPropertyChangeMessage(list, "common.describeStatus", from.getState(), state);

addPropertyChangesImpl(list, from);
}

Expand All @@ -520,6 +537,7 @@ private void writeObject(ObjectOutputStream out) throws IOException {
out.writeInt(version);
out.writeBoolean(enabled);
out.writeObject(alarmLevels);
out.writeObject(state);
}

@SuppressWarnings("unchecked")
Expand All @@ -532,9 +550,20 @@ private void readObject(ObjectInputStream in) throws IOException,
if (ver == 1) {
enabled = in.readBoolean();
alarmLevels = new HashMap<Integer, Integer>();
try {
state = (IStateDs) in.readObject();
} catch (Exception e) {
state = new MigrationOrErrorSerializeChangeEnableState();
}

} else if (ver == 2) {
enabled = in.readBoolean();
alarmLevels = (HashMap<Integer, Integer>) in.readObject();
try {
state = (IStateDs) in.readObject();
} catch (Exception e) {
state = new MigrationOrErrorSerializeChangeEnableState();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ private void readObject(ObjectInputStream in) throws IOException {
timeoutSeconds = in.readInt();
;
retries = in.readInt();
// We don't check version we work on latest when is not correctly set default value;
try {
stop = in.readBoolean();
} catch (Exception e) {
Expand Down
3 changes: 3 additions & 0 deletions src/com/serotonin/mango/web/dwr/DataSourceListDwr.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.serotonin.mango.vo.dataSource.DataSourceVO.Type;
import com.serotonin.mango.vo.permission.Permissions;
import com.serotonin.web.dwr.DwrResponseI18n;
import org.scada_lts.ds.state.UserChangeEnableStateDs;

/**
* @author Matthew Lohbihler
Expand Down Expand Up @@ -100,8 +101,10 @@ public Map<String, Object> toggleDataSource(int dataSourceId) {
Map<String, Object> result = new HashMap<String, Object>();

dataSource.setEnabled(!dataSource.isEnabled());
dataSource.setState(new UserChangeEnableStateDs());
runtimeManager.saveDataSource(dataSource);

result.put("state", dataSource.getState().getDescribe());
result.put("enabled", dataSource.isEnabled());
result.put("id", dataSourceId);
return result;
Expand Down