In the previous 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. So far, the different pages of the application only contain the page title.
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 article but this time, the data will come directly from the SAS Cloud Analytic Service (CAS). We will reuse the application structure which was created in this article. We will focus on the CAS tab. As for the SAS Viya Jobs, 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:
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
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 the benefit of React is that we can reuse components. In the article covering the SAS Viya Jobs, 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 this article.
We can't only reuse components for the CAS page, we will have to create one specific component: CASSelector. This component is a wrapper component that will reuse the LibrarySelector and the TableSelector components. The CASSelector 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 CAS page.
Let's create a new file named: CASSelector.js. under the components/Selectors folder of our application. The file has multiple sections:
Now that all the components are created, it it time to update the CAS.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. Nevertheless, you should keep in mind that you can access really large tables and that you might have to handle this as a web developer as it might impact your application response time.
In this article, we've used basic CAS actions but you can use all the CAS actions that are available on your environment. For more information about CAS REST APIs: https://developer.sas.com/guides/restapis/cas-rest.html
The code for this article can be downloaded here.
This article is the fourth one in the Develop web applications series:
Find more articles from SAS Global Enablement and Learning here.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.