1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-14 23:50:06 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
9598c11f42 Added suggestions 2020-07-16 15:02:40 -04:00
334a849caa Added suggestions 2020-07-16 15:02:17 -04:00
175 changed files with 3898 additions and 38262 deletions

View File

@@ -21,13 +21,7 @@ jobs:
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Install Dependencies - run: npm ci
run: npm ci - run: npm run package:lib
- name: Check code style
run: npm run lint
- name: Run unit tests
run: npm test
- name: Build Package
run: npm run package:lib
env: env:
CI: true CI: true

View File

@@ -6,7 +6,7 @@ name: SASjs Build and Publish
on: on:
push: push:
branches: branches:
- master - main
jobs: jobs:
build: build:
@@ -16,8 +16,6 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install Dependencies - name: Install Dependencies
run: npm ci run: npm ci
- name: Check code style
run: npm run lint
- name: Build Project - name: Build Project
run: npm run build run: npm run build
- name: Semantic Release - name: Semantic Release

View File

@@ -1,6 +0,0 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}

View File

@@ -1,31 +1,82 @@
# Contributing # Contributing
Contributions to SASjs are very welcome! When making a PR, test cases should be included. Contributions to SASjs are very welcome! When making a PR, test cases should be included. To help in unit testing, be sure to run the following when making changes:
## Code Style
This repository uses `Prettier` to ensure a uniform code style.
If you are using VS Code for development, you can automatically fix your code to match the style as follows:
- Install the `Prettier` extension for VS Code.
- Open your `settings.json` file by choosing 'Preferences: Open Settings (JSON)' from the command palette.
- Add the following items to the JSON.
``` ```
"editor.formatOnSave": true, # the following creates a tarball in the build folder of SASjs
"editor.formatOnPaste": true, npm run-script package:lib
# now go to your app and run:
npm install ../sasjs/build/<tarball filename>
``` ```
If you are using another editor, or are unable to install the extension, you can run `npm run lint:fix` to fix the formatting after you've made your changes. Tests are run using cypress. Before running tests, you need to define the following backend services:
## Testing # SAS 9
This repository contains a suite of tests built using [@sasjs/test-framework](https://github.com/sasjs/test-framework). ```
Detailed instructions for creating and running the tests can be found [here](https://github.com/sasjs/adapter/blob/master/sasjs-tests/README.md). filename mc url "https://raw.githubusercontent.com/macropeople/macrocore/main/mc_all.sas?_=1";
%inc mc;
filename ft15f001 temp;
parmcards4;
%webout(OPEN)
%macro x();
%do i=1 %to &_webin_file_count; %webout(OBJ,&&_webin_name&i) %end;
%mend; %x()
%webout(CLOSE)
;;;;
%mm_createwebservice(path=/Public/app/common,name=sendObj)
parmcards4;
%webout(OPEN)
%macro x();
%do i=1 %to &_webin_file_count; %webout(ARR,&&_webin_name&i) %end;
%mend; %x()
%webout(CLOSE)
;;;;
%mm_createwebservice(path=/Public/app/common,name=sendArr)
```
If you'd like to test your changes in an app that uses the adapter, you can do so as follows: # Viya
1. Run `npm run package:lib` from the root folder in this repository. ```
This creates a tarball in the `/build` folder. filename mc url "https://raw.githubusercontent.com/macropeople/macrocore/main/mc_all.sas";
2. In your app's root folder, run `npm install <path/to/tarball>`. %inc mc;
This will install the changed version of the adapter in your app.
filename ft15f001 temp;
parmcards4;
%webout(OPEN)
%global sasjs_tables;
%let sasjs_tables=&sasjs_tables;
%put &=sasjs_tables;
%let sasjs_tables=&sasjs_tables;
%macro x();
%global sasjs_tables;
%do i=1 %to %sysfunc(countw(&sasjs_tables));
%let table=%scan(&sasjs_tables,&i);
%webout(OBJ,&table)
%end;
%mend;
%x()
%webout(CLOSE)
;;;;
%mv_createwebservice(path=/Public/app/common,name=sendObj)
filename ft15f001 temp;
parmcards4;
%webout(OPEN)
%global sasjs_tables;
%let sasjs_tables=&sasjs_tables;
%put &=sasjs_tables;
%macro x();
%do i=1 %to %sysfunc(countw(&sasjs_tables));
%let table=%scan(&sasjs_tables,&i);
%webout(ARR,&table)
%end;
%mend;
%x()
%webout(CLOSE)
;;;;
%mv_createwebservice(path=/Public/app/common,name=sendArr)
```
The above services will return anything you send. To run the tests simply launch `npm run cypress`.

View File

@@ -10,13 +10,13 @@ SASjs is a open-source framework for building Web Apps on SAS® platforms. You c
3 - Reference directly from the CDN - in which case click [here](https://www.jsdelivr.com/package/npm/@sasjs/adapter?tab=collection) and select "SRI" to get the script tag with the integrity hash. 3 - Reference directly from the CDN - in which case click [here](https://www.jsdelivr.com/package/npm/@sasjs/adapter?tab=collection) and select "SRI" to get the script tag with the integrity hash.
If you are short on time and just need to build an app quickly, then check out [this video](https://vimeo.com/393161794) and the [react-seed-app](https://github.com/sasjs/react-seed-app) which provides some boilerplate. If you are short on time and just need to build an app quickly, then check out [this video](https://vimeo.com/393161794) and the [react-seed-app](https://github.com/macropeople/react-seed-app) which provides some boilerplate.
For more information on building web apps with SAS, check out [sasjs.io](https://sasjs.io) For more information on building web apps with SAS, check out [sasjs.io](https://sasjs.io)
## None of this makes sense. How do I build an app with it? ## None of this makes sense. How do I build an app with it?
Ok ok. Deploy this [example.html](https://raw.githubusercontent.com/sasjs/adapter/master/example.html) file to your web server, and update `servertype` to `SAS9` or `SASVIYA` depending on your backend. Ok ok. Deploy this [example.html](https://github.com/sasjs/adapter/blob/main/example.html) file to your web server, and update `servertype` to `SAS9` or `SASVIYA` depending on your backend.
The backend part can be deployed as follows: The backend part can be deployed as follows:
@@ -43,6 +43,6 @@ You now have a simple web app with a backend service!
# More resources # More resources
For more information and examples specific to this adapter you can check out the [user guide](https://sasjs.io/sasjs-adapter/) or the [technical](http://adapter.sasjs.io/) documentation. For more information specific to this adapter you can check out this [user guide](https://sasjs.io/sasjs/sasjs-adapter/) or the [technical](http://adapter.sasjs.io/) documentation.
For more information on building web apps in general, check out these [resources](https://sasjs.io/training/resources/) or contact the [author](https://www.linkedin.com/in/allanbowe/) directly. For more information on building web apps in general, check out these [resources](https://sasjs.io/training/resources/) or contact the [author](https://www.linkedin.com/in/allanbowe/) directly.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,109 +1,114 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@1"></script> <meta charset='utf-8' http-equiv='X-UA-Compatible' content='IE=edge' />
<link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css' integrity='sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh' crossorigin='anonymous'>
<script src='https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@1'></script>
<script> <script>
var sasJs = new SASjs.default({ const sasJs = new SASjs.default({
appLoc: "/Public/app/readme" appLoc: '/Products/demo/readme',
,serverType:"SAS9" serverType:'SAS9',
,debug: false debug: 'false'
}); })
function initSasJs() {
const initSasJs = () => {
$('#loading-spinner').show() $('#loading-spinner').show()
// instantiate sasjs with options such as backend app location
// instantiate sasJs with options such as backend app location
// login (it's also possible to set an auto login when making requests) // login (it's also possible to set an auto login when making requests)
sasJs.logIn( sasJs.logIn($('#username')[0].value, $('#password')[0].value)
$('#username')[0].value .then((response) => {
,$('#password')[0].value
).then((response) => {
if (response.isLoggedIn === true) { if (response.isLoggedIn === true) {
$('#loading-spinner').hide() $('#loading-spinner').hide()
$('.login').hide() $('.login').hide()
$('#getdata').show() $('#getDataBtn').show()
$('#cars').show() $('#cars').show()
} }
}) })
} }
function getData(){
$('#loading-spinner').show()
$('#myChart').remove();
$('#chart-container').append('<canvas id="myChart" style="display: none;"></canvas>')
// make a request to a SAS service // make a request to a SAS service
var type = $("#cars")[0].options[$("#cars")[0].selectedIndex].value; const getData = () => {
$('#loading-spinner').show()
$('#myChart').remove()
$('#chart-container').append("<canvas id='myChart' style='display: none'></canvas>")
const type = $('#cars')[0].options[$('#cars')[0].selectedIndex].value
// request data from an endpoint under your appLoc // request data from an endpoint under your appLoc
sasJs.request("/common/getdata", {
// send data as an array of objects - each object is one row // send data as an array of objects - each object is one row
fromjs: [{ type: type }] sasJs.request('/common/getdata', {fromjs: [{ type: type }]})
}).then((response) => { .then((response) => {
$('#myChart').show(); $('#myChart').show()
var labels = []
var data = []
response.areas.map((d) => {
labels.push(d.MAKE);
data.push(d.AVPRICE);
})
$('#loading-spinner').hide() $('#loading-spinner').hide()
initGraph(labels, data, type);
const labels = response.areas.map(area => area.MAKE)
const data = response.areas.map(area => area.AVPRICE)
initGraph(labels, data, type)
}) })
} }
function initGraph(labels, data, type){
var myCanvas = document.getElementById("myChart"); const initGraph = (labels, data, type) => {
var ctx = myCanvas.getContext("2d"); const myCanvas = document.getElementById('myChart')
var myChart = new Chart(ctx, { const ctx = myCanvas.getContext('2d')
const myChart = new Chart(ctx, {
type: 'bar', type: 'bar',
data: { data: {
labels: labels, labels: labels,
datasets: [{ datasets: [{
label: "Average Invoice Price in USD for " + type + " Cars by Manufacturer", label: `Average Invoice Price in USD for ${type} Cars by Manufacturer`,
data: data, data: data,
backgroundColor: "rgba(255,99,132,0.2)", backgroundColor: 'rgba(255,99,132,0.2)',
borderColor: "rgba(255,99,132,1)", borderColor: 'rgba(255,99,132,1)',
borderWidth: 1, borderWidth: 1,
hoverBackgroundColor: "rgba(255,99,132,0.4)", hoverBackgroundColor: 'rgba(255,99,132,0.4)',
hoverBorderColor: "rgba(255,99,132,1)", hoverBorderColor: 'rgba(255,99,132,1)',
}] }]
}, },
options: { options: {
maintainAspectRatio: false, maintainAspectRatio: false,
scales: {yAxes: [{ticks: {beginAtZero: true}}]} scales: {yAxes: [{ticks: {beginAtZero: true}}]}
} }
}); })
} }
</script> </script>
<meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head> </head>
<body> <body>
<div class="container-fluid" style="text-align: center; margin-top: 10px;"> <div class='container-fluid' style='text-align: center; margin-top: 10px'>
<div class="row"> <div class='row'>
<div class="col-lg-5 col-md-7 col-sm-10 mx-auto mx-auto"> <div class='col-lg-5 col-md-7 col-sm-10 mx-auto mx-auto'>
<h1>Demo Seed App for <span class="code">SASjs</span></h1> <h1>Demo Seed App for <span class='code'>SASjs</span></h1>
<div class="login" id="login-form"> <div class='login' id='login-form'>
<div class="form-group"> <div class='form-group'>
<input class="form-control" type="text" id="username" placeholder="Enter username" /> <input class='form-control' type='text' id='username' placeholder='Enter username' />
</div> </div>
<div class="form-group"> <div class='form-group'>
<input class="form-control" type="password" id="password" placeholder="Enter password" /> <input class='form-control' type='password' id='password' placeholder='Enter password' />
</div> </div>
<button id="login" onclick="initSasJs()" class="login btn btn-primary" style="margin-bottom: 5px;">Log In</button> <button id='login' onclick='initSasJs()' class='login btn btn-primary' style='margin-bottom: 5px'>Log In</button>
</div> </div>
<select name="cars" id="cars" style="margin-bottom: 5px; display: none;" class="form-control"> <select name='cars' id='cars' style='margin-bottom: 5px; display: none' class='form-control'>
<option value="Hybrid">Hybrid</option> <option value='Hybrid'>Hybrid</option>
<option value="SUV">SUV</option> <option value='SUV'>SUV</option>
<option value="Sedan">Sedan</option> <option value='Sedan'>Sedan</option>
<option value="Sports">Sports</option> <option value='Sports'>Sports</option>
<option value="Truck">Truck</option> <option value='Truck'>Truck</option>
<option value="Wagon">Wagon</option> <option value='Wagon'>Wagon</option>
</select> </select>
<button id="getdata" onclick="getData()" style="margin-bottom: 5px; display: none;" class="btn btn-success">Get Data</button><br><br> <button id='getDataBtn' onclick='getData()' style='margin-bottom: 5px; display: none' class='btn btn-success'>Get Data</button>
<div id="loading-spinner" class="spinner-border text-primary" role="status" style="display: none;"> <br>
<span class="sr-only">Loading...</span> <br>
</div><br> <div id='loading-spinner' class='spinner-border text-primary' role='status' style='display: none'>
<span class='sr-only'>Loading...</span>
</div>
<br>
</div> </div>
</div> </div>
</div> </div>
<div id="chart-container" style="height: 65vh; width: 100%; position: relative; margin: auto;"> <div id='chart-container' style='height: 65vh; width: 100%; position: relative; margin: auto'>
<canvas id="myChart" style="display: none;"></canvas> <canvas id='myChart' style='display: none'></canvas>
</div> </div>
</body> </body>
</head> </head>

Some files were not shown because too many files have changed in this diff Show More