mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-02 18:20:06 +00:00
Compare commits
2 Commits
v1.7.1
...
suggestion
| Author | SHA1 | Date | |
|---|---|---|---|
| 9598c11f42 | |||
| 334a849caa |
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -21,13 +21,7 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
- name: Check code style
|
||||
run: npm run lint
|
||||
- name: Run unit tests
|
||||
run: npm test
|
||||
- name: Build Package
|
||||
run: npm run package:lib
|
||||
- run: npm ci
|
||||
- run: npm run package:lib
|
||||
env:
|
||||
CI: true
|
||||
|
||||
4
.github/workflows/npmpublish.yml
vendored
4
.github/workflows/npmpublish.yml
vendored
@@ -6,7 +6,7 @@ name: SASjs Build and Publish
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -16,8 +16,6 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
- name: Check code style
|
||||
run: npm run lint
|
||||
- name: Build Project
|
||||
run: npm run build
|
||||
- name: Semantic Release
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"trailingComma": "none",
|
||||
"tabWidth": 2,
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
||||
@@ -1,31 +1,82 @@
|
||||
# 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
|
||||
```
|
||||
# the following creates a tarball in the build folder of SASjs
|
||||
npm run-script package:lib
|
||||
|
||||
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:
|
||||
# now go to your app and run:
|
||||
npm install ../sasjs/build/<tarball filename>
|
||||
```
|
||||
|
||||
- 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,
|
||||
"editor.formatOnPaste": true,
|
||||
```
|
||||
Tests are run using cypress. Before running tests, you need to define the following backend services:
|
||||
|
||||
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.
|
||||
# SAS 9
|
||||
|
||||
## Testing
|
||||
```
|
||||
|
||||
This repository contains a suite of tests built using [@sasjs/test-framework](https://github.com/sasjs/test-framework).
|
||||
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)
|
||||
```
|
||||
|
||||
Detailed instructions for creating and running the tests can be found [here](https://github.com/sasjs/adapter/blob/master/sasjs-tests/README.md).
|
||||
# Viya
|
||||
|
||||
If you'd like to test your changes in an app that uses the adapter, you can do so as follows:
|
||||
```
|
||||
filename mc url "https://raw.githubusercontent.com/macropeople/macrocore/main/mc_all.sas";
|
||||
%inc mc;
|
||||
|
||||
1. Run `npm run package:lib` from the root folder in this repository.
|
||||
This creates a tarball in the `/build` folder.
|
||||
2. In your app's root folder, run `npm install <path/to/tarball>`.
|
||||
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`.
|
||||
|
||||
@@ -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.
|
||||
|
||||
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)
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -43,6 +43,6 @@ You now have a simple web app with a backend service!
|
||||
|
||||
# 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.
|
||||
|
||||
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
342
docs/index.html
342
docs/index.html
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
213
example.html
213
example.html
@@ -1,109 +1,114 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@1"></script>
|
||||
<script>
|
||||
var sasJs = new SASjs.default({
|
||||
appLoc: "/Public/app/readme"
|
||||
,serverType:"SAS9"
|
||||
,debug: false
|
||||
});
|
||||
function initSasJs() {
|
||||
$('#loading-spinner').show()
|
||||
// instantiate sasjs with options such as backend app location
|
||||
// login (it's also possible to set an autologin when making requests)
|
||||
sasJs.logIn(
|
||||
$('#username')[0].value
|
||||
,$('#password')[0].value
|
||||
).then((response) => {
|
||||
if (response.isLoggedIn === true) {
|
||||
$('#loading-spinner').hide()
|
||||
$('.login').hide()
|
||||
$('#getdata').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
|
||||
var type = $("#cars")[0].options[$("#cars")[0].selectedIndex].value;
|
||||
// request data from an endpoint under your appLoc
|
||||
sasJs.request("/common/getdata", {
|
||||
// send data as an array of objects - each object is one row
|
||||
fromjs: [{ type: type }]
|
||||
}).then((response) => {
|
||||
$('#myChart').show();
|
||||
var labels = []
|
||||
var data = []
|
||||
response.areas.map((d) => {
|
||||
labels.push(d.MAKE);
|
||||
data.push(d.AVPRICE);
|
||||
})
|
||||
$('#loading-spinner').hide()
|
||||
initGraph(labels, data, type);
|
||||
})
|
||||
}
|
||||
function initGraph(labels, data, type){
|
||||
var myCanvas = document.getElementById("myChart");
|
||||
var ctx = myCanvas.getContext("2d");
|
||||
var myChart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: "Average Invoice Price in USD for " + type + " Cars by Manufacturer",
|
||||
data: data,
|
||||
backgroundColor: "rgba(255,99,132,0.2)",
|
||||
borderColor: "rgba(255,99,132,1)",
|
||||
borderWidth: 1,
|
||||
hoverBackgroundColor: "rgba(255,99,132,0.4)",
|
||||
hoverBorderColor: "rgba(255,99,132,1)",
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
maintainAspectRatio: false,
|
||||
scales: {yAxes: [{ticks: {beginAtZero: true}}]}
|
||||
<head>
|
||||
<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>
|
||||
const sasJs = new SASjs.default({
|
||||
appLoc: '/Products/demo/readme',
|
||||
serverType:'SAS9',
|
||||
debug: 'false'
|
||||
})
|
||||
|
||||
const initSasJs = () => {
|
||||
$('#loading-spinner').show()
|
||||
|
||||
// instantiate sasJs with options such as backend app location
|
||||
// login (it's also possible to set an auto login when making requests)
|
||||
sasJs.logIn($('#username')[0].value, $('#password')[0].value)
|
||||
.then((response) => {
|
||||
if (response.isLoggedIn === true) {
|
||||
$('#loading-spinner').hide()
|
||||
$('.login').hide()
|
||||
$('#getDataBtn').show()
|
||||
$('#cars').show()
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
</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>
|
||||
<body>
|
||||
<div class="container-fluid" style="text-align: center; margin-top: 10px;">
|
||||
<div class="row">
|
||||
<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>
|
||||
<div class="login" id="login-form">
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" id="username" placeholder="Enter username" />
|
||||
|
||||
// make a request to a SAS service
|
||||
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
|
||||
// send data as an array of objects - each object is one row
|
||||
sasJs.request('/common/getdata', {fromjs: [{ type: type }]})
|
||||
.then((response) => {
|
||||
$('#myChart').show()
|
||||
$('#loading-spinner').hide()
|
||||
|
||||
const labels = response.areas.map(area => area.MAKE)
|
||||
const data = response.areas.map(area => area.AVPRICE)
|
||||
|
||||
initGraph(labels, data, type)
|
||||
})
|
||||
}
|
||||
|
||||
const initGraph = (labels, data, type) => {
|
||||
const myCanvas = document.getElementById('myChart')
|
||||
const ctx = myCanvas.getContext('2d')
|
||||
|
||||
const myChart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: `Average Invoice Price in USD for ${type} Cars by Manufacturer`,
|
||||
data: data,
|
||||
backgroundColor: 'rgba(255,99,132,0.2)',
|
||||
borderColor: 'rgba(255,99,132,1)',
|
||||
borderWidth: 1,
|
||||
hoverBackgroundColor: 'rgba(255,99,132,0.4)',
|
||||
hoverBorderColor: 'rgba(255,99,132,1)',
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
maintainAspectRatio: false,
|
||||
scales: {yAxes: [{ticks: {beginAtZero: true}}]}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class='container-fluid' style='text-align: center; margin-top: 10px'>
|
||||
<div class='row'>
|
||||
<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>
|
||||
<div class='login' id='login-form'>
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type='text' id='username' placeholder='Enter username' />
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type='password' id='password' placeholder='Enter password' />
|
||||
</div>
|
||||
<button id='login' onclick='initSasJs()' class='login btn btn-primary' style='margin-bottom: 5px'>Log In</button>
|
||||
</div>
|
||||
<select name='cars' id='cars' style='margin-bottom: 5px; display: none' class='form-control'>
|
||||
<option value='Hybrid'>Hybrid</option>
|
||||
<option value='SUV'>SUV</option>
|
||||
<option value='Sedan'>Sedan</option>
|
||||
<option value='Sports'>Sports</option>
|
||||
<option value='Truck'>Truck</option>
|
||||
<option value='Wagon'>Wagon</option>
|
||||
</select>
|
||||
<button id='getDataBtn' onclick='getData()' style='margin-bottom: 5px; display: none' class='btn btn-success'>Get Data</button>
|
||||
<br>
|
||||
<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 class="form-group">
|
||||
<input class="form-control" type="password" id="password" placeholder="Enter password" />
|
||||
</div>
|
||||
<button id="login" onclick="initSasJs()" class="login btn btn-primary" style="margin-bottom: 5px;">Log In</button>
|
||||
</div>
|
||||
<select name="cars" id="cars" style="margin-bottom: 5px; display: none;" class="form-control">
|
||||
<option value="Hybrid">Hybrid</option>
|
||||
<option value="SUV">SUV</option>
|
||||
<option value="Sedan">Sedan</option>
|
||||
<option value="Sports">Sports</option>
|
||||
<option value="Truck">Truck</option>
|
||||
<option value="Wagon">Wagon</option>
|
||||
</select>
|
||||
<button id="getdata" onclick="getData()" style="margin-bottom: 5px; display: none;" class="btn btn-success">Get Data</button><br><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 id="chart-container" style="height: 65vh; width: 100%; position: relative; margin: auto;">
|
||||
<canvas id="myChart" style="display: none;"></canvas>
|
||||
</div>
|
||||
</body>
|
||||
</head>
|
||||
<div id='chart-container' style='height: 65vh; width: 100%; position: relative; margin: auto'>
|
||||
<canvas id='myChart' style='display: none'></canvas>
|
||||
</div>
|
||||
</body>
|
||||
</head>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user