Ignition-react and ignition-lib

How can we get details on ignition-react and ignition-lib packages for react? We are trying to replicate the look and feel of our module status page and would like help with documentation for these packages

1 Like

I second this request. I’m finding no information on these.

Just to clarify:

IgnitionLib is a small library of useful helper functions - it does not have any react components.
IgnitionReact is a small set of react components used in parts of the gateway.

Clarification out of the way…

Unfortunately, there is not much in the way of documentation for these right now. While they’re not intended to be private libraries, they also weren’t really written with the intent be fully supported packages published as part of the SDK. In retrospect, we should have, but back then, jsdoc type libraries weren’t common, and we did not create any sort of public documentation to take their place.

Since both are older packages written in ‘vanilla’ javascript, they are also largely lacking types that might help describe component interfaces (props/state) though typescript, so adding useful documentation would be a bit of a time commitment and unlikely to happen given our intent to rewrite these.

That said, it looks like there may be some useful comment docs that we could try and pull out of each lib, but they are incomplete. I’ll make a ticket to see if we can get that done as a starting point, but I don’t know how helpful they would be given how incomplete they appear. These libs simply weren’t written with SDK users in mind.

For styling, you could reference the main.css (or the computed properties in the browser’s dev tools), which is the primary stylesheet for the gateway, but I realize that’s only helpful up to a point.

Are there any specific functions/components you have questions about? We can try answering some specifics much more easily than trying to add documentation for these libs as a whole.

I realize it won’t help now, but we do plan on correcting this and having first-class support for corollary packages being worked on for future major releases (Ignition 8.2). :frowning:

By any chance did any documentation about this ever get published? I am looking to recreate the same type of "intractable error" that exists on the Database Connection Status Page

image

However I am struggling to figure out how to customize the parameters provided to ItemTable that it would need to create that.

It looks like you just return your custom JSX directly into the data prop of the DataTable:


Where ConnectionStatusLabel uses UserFriendlyError to make that clickable link:

Progress has been made!

I can get the UserFriendlyError component, it works, etc.

However, what is the format the exception should be in? I have tried getting the stack trace and putting it into the JSON object I provide the table.

This is the script providing the data for my route.

public JSONObject getConnectionStatus(RequestContext requestContext, HttpServletResponse httpServletResponse) throws JSONException {
        JSONObject json = new JSONObject();
		List<DatabaseRecord> connectionList = Neo4JDriverGatewayHook.getDatabaseRecords();
		if (connectionList != null){
			json.put("count", connectionList.size());
			JSONArray jsonArray = new JSONArray();
			json.put("connections", jsonArray);
			for (DatabaseRecord record : connectionList){
				if (record != null) {
					JSONObject connectionJson = new JSONObject();
					jsonArray.put(connectionJson);
					connectionJson.put("name", record.getName());
					connectionJson.put("type", record.getType());
					connectionJson.put("status", record.getStatus());
					connectionJson.put("maxConnectionPoolSize", record.getMaxConnectionPoolSize());
					connectionJson.put("activeConnections", record.getActiveConnections());
					connectionJson.put("exception", record.exception.getStackTrace());
				}
			}
		}
        return json;
    }
1 Like

I actually managed to figure this one out by reverse engineering the connection status page a bit.

Looking at the web traffic, I saw that the route for the DB connections page is /data/status/databases

Looking at a response from that page I see the following structure:

[
	{
		"name": "NewConnection",
		"driver": "Microsoft SQLServer",
		"status": "Faulted",
		"connections": {
			"active": 0,
			"max": 8
		},
		"throughput": 0.0,
		"exception": {
			"message": "Cannot create PoolableConnectionFactory (The connection to the host localhost, named instance MSSQLSERVER failed. Error: \"java.net.SocketTimeoutException: Receive timed out\". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.)",
			"stacktrace": "java.sql.SQLException: Cannot create PoolableConnectionFactory (The connection to the host localhost, named instance MSSQLSERVER failed. Error: \"java.net.SocketTimeoutException: Receive timed out\". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.)\n\tat org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:656)\n\tat org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:534)\n\tat org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:734)\n\tat com.inductiveautomation.ignition.gateway.datasource.DatasourceImpl.getConnectionInternal(DatasourceImpl.java:300)\n\tat com.inductiveautomation.ignition.gateway.datasource.DatasourceImpl.runTest(DatasourceImpl.java:253)\n\tat com.inductiveautomation.ignition.gateway.datasource.DatasourceManagerImpl$FaultedDatasourceRetryer.lambda$newRetryRunnable$0(DatasourceManagerImpl.java:1096)\n\tat com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$TrackedTask.run(BasicExecutionEngine.java:587)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)\n\tat java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)\n\tat java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\tat java.base/java.lang.Thread.run(Unknown Source)\nCaused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host localhost, named instance MSSQLSERVER failed. Error: \"java.net.SocketTimeoutException: Receive timed out\". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.\n\tat com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:237)\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort(SQLServerConnection.java:6491)\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.primaryPermissionCheck(SQLServerConnection.java:2871)\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2612)\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2471)\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1470)\n\tat com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:915)\n\tat org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:52)\n\tat org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:357)\n\tat org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:103)\n\tat org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:652)\n\t... 12 more\n"
		}
	}
]

Using that structure, I updated my JSON Object to include message and stacktrace keys, and built them out the same way

Final Code to build Object

 public JSONObject getConnectionStatus(RequestContext requestContext, HttpServletResponse httpServletResponse) throws JSONException {
        JSONObject json = new JSONObject();
		List<DatabaseRecord> connectionList = Neo4JDriverGatewayHook.getDatabaseRecords();
		if (connectionList != null){
			json.put("count", connectionList.size());
			JSONArray jsonArray = new JSONArray();
			json.put("connections", jsonArray);
			for (DatabaseRecord record : connectionList){
				if (record != null) {
					JSONObject connectionJson = new JSONObject();
					jsonArray.put(connectionJson);
					connectionJson.put("name", record.getName());
					connectionJson.put("type", record.getType());
					connectionJson.put("status", record.getStatus());
					connectionJson.put("maxConnectionPoolSize", record.getMaxConnectionPoolSize());
					connectionJson.put("activeConnections", record.getActiveConnections());
					
					JSONObject exception = new JSONObject();
					exception.put("message", record.exception.getMessage());

					// Convert the stacktrace to a newline separated string
					StringWriter stringWriter = new StringWriter();
					PrintWriter printWriter = new PrintWriter(stringWriter);
					record.exception.printStackTrace(printWriter);
					String sStackTrace = stringWriter.toString();
					exception.put("stacktrace", sStackTrace);
					
					connectionJson.put("exception", exception);
				}
			}
		}
        return json;
    }
2 Likes