In the Build a React application article of this series, I described how you can create a web application based on React and how you can authenticate users against SAS Viya environment from that application. The previous articles in the series walk through integration of SAS Viya Jobs and CAS tables.
This article is the fourth one in the Develop web applications series:
In this article, we will go through the steps to build a page similar to the one we have seen in the previous articles but this time, the data will come directly from the SAS Compute Server. We will reuse the application structure which was created in this Build a React application article. The remainder of this article will focus on the Compute tab. As for the CAS content, we will display two dropdown boxes to select a library and table then a submit button to retrieve the data to populate a table. The result will be similar to this:
If you have been through the previous articles in the series, you should know by now that we are building a React application and that one of the major benefits of React is that we can reuse components. In the article covering SAS Viya Jobs and CAS, we have created different components that we will reuse in this article:
If you want to see the code for these elements, please check the Reusable components section of the Build a web application using SAS Viya Jobs article.
Up till now, the components that we have created so far do not meet the needs for the Compute page. We need to create a specific component: ComputeSelector. This component is a wrapper component that will reuse the LibrarySelector and the TableSelector components. The ComputeSelector is responsible for passing the needed information to the two selectors and to submit the request that will populate the TableViewer which will be added in the next section of this article where we update the Compute page.
Let's create a new file named: ComputeSelector.js. under the components/Selectors folder of our application. The file has multiple sections:
Now we have all the components needed to build the Compute page. It is time to update the Compute.js file under pages directory. Once again the file has multiple sections:
In this article, we've seen that by reusing components we have created in the previous articles, we can reduce the number of lines in new pages. If you test the application on your own, you will most probably notice that the time needed to populate the prompts and the result table is smaller compared to the SAS Viya Job but is longer than for the CAS server. The reason is that behind the scenes a Compute Server session is started. So the first request to get the list of libraries might be longer than subsequent requests. If you remember the code, the Compute Server session is reused if it exists. This mechanism allows you to reduce the time for the end-user which can give a better performance impression. As indicated, you should keep in mind that your application might access large tables (number of rows and columns). You can access SAS tables but also RDBMS tables. As a result, you should proactively manage unknown table size in your application to improve the user experience. There are plenty of components available on the web which can help you in that process without the need for you to reinvent the wheel. The code for this article can be downloaded here. This article is the fourth one in the Develop web applications series:
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.