Skip to content

Commit 85224fe

Browse files
committed
Initial commit
0 parents  commit 85224fe

File tree

398 files changed

+82680
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

398 files changed

+82680
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

README.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Create SAS® App
2+
3+
## What is this?
4+
5+
This is a collection of open-source [Progressive Web Application (PWA)](https://en.wikipedia.org/wiki/Progressive_web_application) templates we maintain at [Boemska](https://boemskats.com/), which we fondly refer to as 'CSA apps'. These templates all implement a set of [core features](#core-features) that together offer SAS developers a standard and effortless way to begin developing Apps for their SAS platform. They're powered by [React](https://reactjs.org/) and [H54S](https://github.com/Boemska/h54s), and your choice of either [SAS Viya](https://www.sas.com/en_us/software/viya.html) or [SAS 9.4](https://www.sas.com/en_us/software/sas9.html).
6+
7+
'Standard and effortless' in this context means:
8+
9+
* **Zero Configuration, Native Security**
10+
11+
Developing apps with these templates will not any require any elevated privileges, Administrator access to SAS, or handling of any secrets, registration of clients, or deployment of refresh tokens. Instead, communication is handled through native mechanisms built into SAS and used by the other browser-based SAS client apps. Authentication, authorisation and session security between the browser runtime and backend services are all handled without the need for new server components, certificates, runtimes, or changes to the platform security configuration. In other words, if you can log on to SAS, you should have everything you need to get started.
12+
13+
* **Standard Create React App Development Experience**
14+
15+
These templates are provided with a set of added features, described in detail below. Aside from those features, they are standard, 'unejected' [Create React App](https://github.com/facebook/create-react-app) generated web apps. That means that if you're a developer learning how to build apps in React, the templates will make sense and align completely with any React learning material you're following. Likewise, if you already have experience developing with React, you should feel right at home.
16+
17+
18+
## Choice of CSA App Templates
19+
20+
The repository currently contains three pre-built template applications, based on three popular UI component libraries.
21+
22+
* **[IBM Carbon Design](./carbon-ui)** ([homepage](https://www.carbondesignsystem.com/))
23+
_"Carbon is IBM’s open-source design system for products and experiences. With the IBM Design Language as its foundation, the system consists of working code, design tools and resources, human interface guidelines, and a vibrant community of contributors."_
24+
* **[Onsen UI](./onsen-ui)** ([homepage](https://onsen.io/))
25+
_"Onsen UI is a large set of rich UI components specifically designed for mobile apps. It is packed with ready-to-implement features following native iOS and Android design standards."_
26+
* **[Bootstrap](./bootstrap)** ([homepage](https://getbootstrap.com/))
27+
_"Bootstrap is the world’s most popular framework for building responsive, mobile-first sites."_
28+
29+
The one you pick will depend on your objectives, preferences and skills. However, if you're just starting out or unsure of which one to use, this is our opinion:
30+
31+
- If you're not building a handset-first app, we recommend starting with the **[Carbon Design](./carbon-ui)** template. Its a rich UI framework, works well on both the Desktop and on Tablet devices, and is fairly easy to theme while remaining very good in terms of accessibility. We use it for most of the apps we build.
32+
33+
- If you _are_ building a handset-first app, consider using the **[Onsen UI](./onsen-ui)** template. The components it provides will offer an excellent 'native-like' feel to your users, and should enable you to build an awesome user experience.
34+
35+
- For maximum control over your design, have a look at **[Bootstrap](./bootstrap)**. Many of our larger clients have built their own design systems over time, the majority of them being based on Bootstrap. If you have an in-house digital team you're hoping to work with then this is probably the best choice.
36+
37+
38+
## Getting Started
39+
40+
To get started with one of the CSA apps in this repository you'll need to **either**:
41+
42+
1. Clone this repository and then copy the folder of the app you want to use to a location of your choice; or
43+
2. Download a copy of the app that you want to use from the Releases tab of this repository.
44+
45+
In the folder you just copied, you'll find a README with instructions on how to get started. For the _very_ quick guide, you'll need to do something like the following:
46+
47+
```js
48+
yarn install
49+
yarn run configure
50+
yarn start
51+
```
52+
53+
Here is an example of that process looks like with the carbon-ui app template.
54+
55+
## Core Features
56+
57+
The templates in this repository are configured with the following base features.
58+
59+
**Key**
60+
**⣿⣿⣿⣿⣿** - Implemented
61+
**⣿⣿⣿⣀⣀** - In progress
62+
**⣿⣀⣀⣀⣀** - Planned
63+
64+
| Feature | [carbon-ui](./carbon-ui) | [onsen-ui](./onsen-ui) | [bootstrap](bootstrap) |
65+
| -------| ------------------------ | ----------------------- | ---------------------- |
66+
| H54S (SAS Authentication + transport) | **⣿⣿⣿⣿⣿** | **⣿⣿⣿⣿⣿** | **⣿⣿⣿⣿⣿** |
67+
| Saving, loading, sharing of projects* | **⣿⣿⣿⣿⣿** | **⣿⣀⣀⣀⣀** | **⣿⣀⣀⣀⣀** |
68+
| Direct Deploy to Home Screen | **⣿⣿⣿⣿⣿** | **⣿⣀⣀⣀⣀** | **⣿⣀⣀⣀⣀** |
69+
| Automatic update of app runtime | **⣿⣿⣿⣿⣿** | **⣿⣿⣿⣿⣿** | **⣿⣿⣿⣿⣿** |
70+
| Offline mode | **⣿⣿⣿⣿⣿** | **⣿⣿⣿⣿⣿** | **⣿⣿⣿⣿⣿** |
71+
| Direct deployment of back end code* | **⣿⣿⣿⣀⣀** | **⣀⣀⣀⣀⣀** | **⣿⣀⣀⣀⣀** |
72+
73+
\* indicates SAS Viya-only REST API feature
74+
75+
76+
### Integrated SAS Authentication and Communication via H54S
77+
78+
These templates are designed to integrate with your SAS platform, and that integration is managed by [H54S](https://github.com/boemska/h54s), the HTML5 Data Adapter for SAS. The core H54S library manages your app's interaction with your SAS server: requests and data transport, authentication and session management, and debug log management.
79+
80+
<p align="center">
81+
<img src="docs/csa-final-login.svg" width="60%" />
82+
</p>
83+
84+
All app templates contained within this repository are pre-configured with an H54S adapter service (`_adapterService`) instance. In addition, the UI components that you would typically need to create to power the SASLogon handling functionality, as well as the transport status indicator, debug mode switch, application & debug log modals and Log Out button have already been created and integrated with H54S.
85+
86+
For more information about the core H54S library, it is recommended that you check out the [core adapter repository](https://github.com/Boemska/h54s). Some of this functionality is also documented in more detail in our (very) deprecated [Angular v1 Bootstrap Seed App](https://github.com/Boemska/h54s-angular-seed-app).
87+
88+
### Secure Saving, Loading and Sharing of In-app Projects (Viya only)
89+
90+
As you look through this repository and navigate through the templates, you'll notice that one of the core concepts is a _project_. A 'project' is like a saved snapshot of the state of your App. How much data you save is entirely up to you, and will depend on the size and complexity of your app. Saved data can range from a set of dropdown selections that would be recalled by loading a project, to multiple instances of parameter selections, each retaining the data from the time that model was last run.
91+
92+
<p align="center">
93+
<img src="docs/csa-final-projects.svg" width="60%" />
94+
</p>
95+
96+
This functionality will allow your users to Create, Save and Load projects. It will also allow them to Share projects with colleagues, either by copying and pasting a link, or for camera-enabled devices, showing a QR code to a colleague so they can just point their device's camera at it. If they are connected to the network, and are authorised within the Files service to read your project, it will load on an instance of the app on their device.
97+
98+
The project files generated by your app will be saved to the SAS Viya Files service, to a configurable 'Projects' folder location. When a shared project URL is loaded, this is what happens:
99+
100+
* the app loads on the device
101+
* if the user isn't logged in, they are asked to authenticate
102+
* once there is a valid auth session, the project file is requested
103+
* SAS evaluates permissions on that file, and if your colleague is allowed to read that project, it is loaded in to their instance of the app.
104+
105+
Note: This feature is Viya-only for now, as it depends on the Viya Files and Folders services. At Boemska we have an implementation of this functionality which stores projects and allows them to be shared via SAS v9 Metadata Document (TextStore) objects, where similar security / authorisation benefits apply. We may end up porting that functionality to these templates; if you're interested, please let us know by raising an issue.
106+
107+
108+
### App-store-Free Installation
109+
110+
These templates are Progressive Web Apps (PWAs), which means they are designed to be saved to your users' Home Screns. The first time a user opens an app on their iPad or mobile device, they will be prompted to install the application to their home screen (what this prompt looks like depends on their flavour of mobile OS). If they accept, they'll be able to open your CSA app from the home screen of their device, no different to an app they downloaded from their App Store!
111+
112+
<p align="center">
113+
<img src="docs/csa-final-deploytohome.svg" width="60%" />
114+
</p>
115+
116+
The parameters for configuring things like home-screen icons, app names and splash images depend on the target device OS, but are also easily configurable. Each template includes a pre-configured example of this.
117+
118+
119+
### Easy App Updates
120+
121+
Ensuring that your users update to the latest version of your app is a well-known challenge - especially if the update process is lengthy or requires them to jump through hoops.
122+
123+
With CSA apps, this isn't the case. Whenever you push a change your application, your users will be notified that there is a new version of the application available - regardless of the device they're on. If they choose to update the application, the context of the application is preserved to storage, and the app is updated in-place. Depending on how much of the app an update changes, they might not even notice that an update happened.
124+
125+
In the background, this process is handled by Google's excellent [workbox](https://developers.google.com/web/tools/workbox) library.
126+
127+
<p align="center">
128+
<img src="docs/csa-final-update.svg" width="60%" />
129+
</p>
130+
131+
I guess saying CSA apps are 'no different to an app downloaded from an App Store' isn't _entirely_ fair... to CSA apps.
132+
133+
134+
### Offline Mode
135+
136+
One of the really nice things about mobile devices and mobile applications is their... mobility. Frequently, your users can take them places without WiFi or a data connection.
137+
138+
All of the CSA templates within this repository are offline-capable, again courtesy of Google's excellent [workbox](https://developers.google.com/web/tools/workbox) library.
139+
140+
<p align="center">
141+
<img src="docs/csa-final-offlinemode.svg" width="60%" />
142+
</p>
143+
144+
How you decide what data you save to local storage and make available to your users in offline mode is mostly up to you. However, the ability to load your app when offline, the indicators that show your users that the app is offline, and the hooks that respond to the navigator.online() event are all there already. Documenting how you can make selected [projects](#secure-saving-loading-and-sharing-of-in-app-projects-viya-only) available in offline mode is something we plan to document and automate. Watch this space.
145+
146+
147+
### Automatic deployment of Back-end services (Viya only)
148+
149+
Unlike the other features outlined here, this one is still mostly experimental. It exists specifically for the initial deployment of apps developed using Boemska [AppFactory](https://boemskats.com/products/af/). However, the functionality can be extended to apps that aren't developed using AF.
150+
151+
AppFactory project files are hierarchical JSON files, where the code for SAS-based services is organised into folders representing the role grouping for those services. These AppFactory project files can optionally be bundled with the application front-end. You would package up your app as normal, as a .zip file containing the app build, for deploying to a web server. It would then be deployed to a web server, either by an administrator deploying to `/var/www/html` or a user deploying to their personal `~/public_html`.
152+
153+
<p align="center">
154+
<img src="docs/csa-final-autodeploy.svg" width="60%" />
155+
</p>
156+
157+
The first time that app is loaded into the browser, it won't have the back-end jobExecution services it needs. When this happens, this auto-deployment routine can iterate through all of the folders and services found in the included AF project json file. If the authenticated SAS user has the necessary permissions, the app can then deploy these code objects to the back-end by communicating directly with the `/jobDefinitions` and `/folders` services within SAS Viya.
158+
159+
160+

bootstrap/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.env

bootstrap/README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# h54s <3 Bootstrap
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Getting started
6+
In order to get the application up and running in no time at all, run the following 3 commands from within this folder:
7+
8+
### Deploy the backend
9+
1. Register our application's startup service. **On Viya** this is a File of type Job Definition, and can be registered through the SASJobExecution WebApp (`https://[yourViyaServer]/SASJobExecution/`). **On SAS v9** this is a Stored Process and can be registered through SAS Management Console or Enterprise Guide. In both cases you'll be registering the code object to a SAS folder that you have permission to write to. In both Viya and v9, I created mine in a sub-folder of my user's `My Folder` location: `csa-boostrap/common/startupService`:
10+
11+
2. Edit the code for the newly registered code object and populate it with the code from the `startupService.sas` file in the `sas` folder of this application.
12+
13+
3. Configure the output type for your newly registered code object.
14+
15+
**On Viya**, right click on the job name and select properties. From the properties menu select "Parameters". Add the following parameter and then click save:
16+
* Name: `_output_type`
17+
* Default value: `html`
18+
* Field type: `Character`
19+
* Required: `false`
20+
21+
**On SAS v9**, make sure you enable Streaming Output as the output type. If you are using Enterprise Guide to do this, also be sure to check "Global Macro Variables" and uncheck "Include Stored Procedure Macros" under the "Include code for" dropdown.
22+
23+
### Modify adapterService configuration
24+
Update the `config.js` file found in `./src/adapterService`. We need to update the `sasVersion` for the version of the SAS platform that we are running on and update the `metadataRoot` to the location of where we deployed our `startupService` in the step above.
25+
26+
27+
### `yarn install`
28+
Install all the dependencies listed within `package.json` in the local `node_modules` folder.
29+
30+
### `yarn run configure`
31+
In the `package.json` for this quick-start application we hav defined a scripts object called `configure`, this command will run the specified [configure] script. The `configure` script is a guided process for connecting your local quick-start application to your remote SAS instance.
32+
33+
### `yarn start`
34+
Runs the app in the development mode.<br />
35+
Open [https://localhost:3000](https://localhost:3000) to view it in the browser.
36+
37+
The app uses a proxy to communicate with the server so it has to open on a an https connection
38+
39+
The page will reload if you make edits.<br />
40+
You will also see any lint errors in the console.
41+
42+
43+
## Other commands
44+
45+
### `yarn test`
46+
47+
Launches the test runner in the interactive watch mode.<br />
48+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
49+
50+
### `yarn build`
51+
52+
Builds the app for production to the `build` folder.<br />
53+
It correctly bundles React in production mode and optimizes the build for the best performance.
54+
55+
The build is minified and the filenames include the hashes.<br />
56+
Your app is ready to be deployed!
57+
58+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
59+
60+
### `yarn watch`
61+
62+
Starts build with watch - used npm-watch with setthins in package.json
63+
```javascript
64+
"scripts": {
65+
...,
66+
"watch": "npm-watch"
67+
},
68+
"watch": {
69+
"build": "src/"
70+
}
71+
```
72+
73+
### `serve -s build`
74+
Serve prod build locally. To use this first run
75+
```javascript
76+
yarn global add serve
77+
```
78+
79+
### `yarn eject`
80+
81+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
82+
83+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
84+
85+
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
86+
87+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
88+
89+
### To run development scripts follow
90+
```text
91+
1. yarn watch
92+
2. in separated terminal run serve -s build
93+
3. in separated terminal cd build and run bapsync script
94+
```
95+
96+
## Learn More
97+
98+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
99+
100+
To learn React, check out the [React documentation](https://reactjs.org/).
101+
102+
### Code Splitting
103+
104+
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
105+
106+
### Analyzing the Bundle Size
107+
108+
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
109+
110+
### Making a Progressive Web App
111+
112+
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
113+
114+
### Advanced Configuration
115+
116+
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
117+
118+
### Deployment
119+
120+
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
121+
122+
### `yarn build` fails to minify
123+
124+
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

bootstrap/config-overrides.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const {rewireWorkboxInject, defaultInjectConfig} = require('react-app-rewire-workbox');
2+
const path = require('path');
3+
4+
module.exports = function override(config, env) {
5+
if (env === "production") {
6+
console.log("Production build - Adding Workbox for PWAs");
7+
// Extend the default injection config with required swSrc
8+
const workboxConfig = {
9+
...defaultInjectConfig,
10+
swSrc: path.join(__dirname, 'src', 'custom-sw.js'),
11+
importWorkboxFrom: "local"
12+
};
13+
config = rewireWorkboxInject(workboxConfig)(config, env);
14+
}
15+
16+
return config;
17+
};

0 commit comments

Comments
 (0)