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:
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.