@sassoftware/viya-serverjs 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +6 -5
- package/.env.server +28 -17
- package/Dockerfile +1 -1
- package/lib/handlers/codeAuth.js +9 -11
- package/lib/handlers/logon.js +2 -1
- package/lib/handlers/setCookies.js +11 -15
- package/lib/iService.js +38 -22
- package/lib/plugins/setContext.js +1 -0
- package/lib/plugins/setDefaultRoutes.js +48 -32
- package/lib/plugins/setupUserRoutes.js +3 -11
- package/package.json +4 -5
- package/public/auth.html +24 -0
- package/public/help.html +1 -1
- package/server.js +6 -5
- package/src/handlers/codeAuth.js +10 -10
- package/src/handlers/logon.js +2 -1
- package/src/handlers/setCookies.js +6 -5
- package/src/iService.js +143 -121
- package/src/plugins/setContext.js +2 -1
- package/src/plugins/setDefaultRoutes.js +11 -7
- package/testca.js +10 -0
- package/public/indexProxy.html +0 -351
- package/public/simplesubmit.html +0 -233
package/public/indexProxy.html
DELETED
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<!--
|
|
3
|
-
~ /* ------------------------------------------------------------------------------------
|
|
4
|
-
~ * Copyright (c) SAS Institute Inc.
|
|
5
|
-
~ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
~ * you may not use this file except in compliance with the License.
|
|
7
|
-
~ * You may obtain a copy of the License at
|
|
8
|
-
~ *
|
|
9
|
-
~ * http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
~ *
|
|
11
|
-
~ * Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
~ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
~ * See the License for the specific language governing permissions and
|
|
15
|
-
~ * limitations under the License.
|
|
16
|
-
~ ----------------------------------------------------------------------------------------*/
|
|
17
|
-
~
|
|
18
|
-
-->
|
|
19
|
-
|
|
20
|
-
<html lang="en">
|
|
21
|
-
<head>
|
|
22
|
-
<meta charset="UTF-8" />
|
|
23
|
-
|
|
24
|
-
<script
|
|
25
|
-
crossorigin
|
|
26
|
-
src="https://unpkg.com/react@16/umd/react.production.min.js"
|
|
27
|
-
></script>
|
|
28
|
-
<script
|
|
29
|
-
crossorigin
|
|
30
|
-
src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"
|
|
31
|
-
></script>
|
|
32
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
|
|
33
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js"></script>
|
|
34
|
-
<script src="https://unpkg.com/@sassoftware/restaf@alpha"></script>
|
|
35
|
-
<script src="https://unpkg.com/@sassoftware/restaflib@alpha"></script>
|
|
36
|
-
<script src="/appenv"></script>
|
|
37
|
-
|
|
38
|
-
<style>
|
|
39
|
-
.container {
|
|
40
|
-
display: flex;
|
|
41
|
-
flex-direction: column;
|
|
42
|
-
flex-wrap: nowrap;
|
|
43
|
-
min-height: 800px;
|
|
44
|
-
}
|
|
45
|
-
.elabel {
|
|
46
|
-
display: inline-block;
|
|
47
|
-
|
|
48
|
-
clear: left;
|
|
49
|
-
width: 250px;
|
|
50
|
-
text-align: right;
|
|
51
|
-
}
|
|
52
|
-
.einput {
|
|
53
|
-
display: inline-block;
|
|
54
|
-
}
|
|
55
|
-
.div1 {
|
|
56
|
-
border: 1px solid black;
|
|
57
|
-
background: lightskyblue;
|
|
58
|
-
}
|
|
59
|
-
.div2 {
|
|
60
|
-
border: 1px solid black;
|
|
61
|
-
background: lightskyblue;
|
|
62
|
-
height: 200px;
|
|
63
|
-
}
|
|
64
|
-
</style>
|
|
65
|
-
|
|
66
|
-
<script>
|
|
67
|
-
debugger;
|
|
68
|
-
let store = restaf.initStore({
|
|
69
|
-
casProxy: true,
|
|
70
|
-
options: {
|
|
71
|
-
proxyServer: APPENV.PROXYSERVER,
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
debugger; console.log(store.config);
|
|
75
|
-
|
|
76
|
-
let session = null;
|
|
77
|
-
let servers = null;
|
|
78
|
-
let services = null;
|
|
79
|
-
let files = null;
|
|
80
|
-
let reports = null;
|
|
81
|
-
let compute = null;
|
|
82
|
-
|
|
83
|
-
function setup() {
|
|
84
|
-
debugger;
|
|
85
|
-
document.getElementById('output').innerHTML = '...initializing';
|
|
86
|
-
|
|
87
|
-
initSession()
|
|
88
|
-
.then(r => {
|
|
89
|
-
document.getElementById('output').innerHTML = 'ready';
|
|
90
|
-
keepAlive();
|
|
91
|
-
})
|
|
92
|
-
.catch(e => {
|
|
93
|
-
|
|
94
|
-
console.log(e);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function keepAlive() {
|
|
98
|
-
if (LOGONPAYLOAD.keepAlive != null) {
|
|
99
|
-
let interval = 120;
|
|
100
|
-
let timeout = 14400;
|
|
101
|
-
if (LOGONPAYLOAD.timers != null) {
|
|
102
|
-
let opts = LOGONPAYLOAD.timers.split(',');
|
|
103
|
-
interval = parseInt(opts[ 0 ]);
|
|
104
|
-
timeout = parseInt(opts[ 1 ]);
|
|
105
|
-
}
|
|
106
|
-
console.log(`Keepalive is active`);
|
|
107
|
-
store.keepViyaAlive(LOGONPAYLOAD.keepAlive, interval, timeout, () => {
|
|
108
|
-
console.log('timed out at', Date());
|
|
109
|
-
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`;
|
|
110
|
-
window.open(`${appOptions.logonPayload.host}/SASLogon/timedout`, 'Timed Out', params);
|
|
111
|
-
return true;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
function logoff() {
|
|
117
|
-
let url = `${window.location.protocol}//${window.location.host}/${LOGONPAYLOAD.appName}/logout?callbackUrl=onlogoff.html`;
|
|
118
|
-
window.location.replace(url);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
async function initSession() {
|
|
123
|
-
|
|
124
|
-
console.log(APPENV);
|
|
125
|
-
|
|
126
|
-
console.log(LOGONPAYLOAD);
|
|
127
|
-
debugger;
|
|
128
|
-
LOGONPAYLOAD.host = 'https://localhost:8080';
|
|
129
|
-
let msg = await store.logon(LOGONPAYLOAD);
|
|
130
|
-
console.log(msg);
|
|
131
|
-
|
|
132
|
-
/*
|
|
133
|
-
services = await store.addServices(
|
|
134
|
-
'files', 'compute', 'casManagement'
|
|
135
|
-
);
|
|
136
|
-
console.log(services.casManagement.links().toJS())
|
|
137
|
-
*/
|
|
138
|
-
debugger;
|
|
139
|
-
return 'done';
|
|
140
|
-
}
|
|
141
|
-
function runit(type) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
document.getElementById('output').innerHTML = '...running';
|
|
145
|
-
let testcase;
|
|
146
|
-
switch (type) {
|
|
147
|
-
case 'files': {
|
|
148
|
-
testcase = SASfileService;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case 'compute': {
|
|
152
|
-
testcase = dsCompute;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
case 'cas': {
|
|
156
|
-
testcase = runCas;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
case 'timedout': {
|
|
160
|
-
testcase = timedout;
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
case 'redir': {
|
|
164
|
-
testcase= noaction;
|
|
165
|
-
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case 'spre': {
|
|
169
|
-
testcase= spre;
|
|
170
|
-
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
case 'proxy': {
|
|
174
|
-
testcase= testproxy;
|
|
175
|
-
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
default: {
|
|
180
|
-
testcase = SASfileService;
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
testcase(store)
|
|
186
|
-
.then(r => {
|
|
187
|
-
document.getElementById(
|
|
188
|
-
'output'
|
|
189
|
-
).innerHTML = JSON.stringify(r, null, 4);
|
|
190
|
-
})
|
|
191
|
-
.catch(err => {
|
|
192
|
-
|
|
193
|
-
document.getElementById(
|
|
194
|
-
'output'
|
|
195
|
-
).innerHTML = JSON.stringify(err, null, 4);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
async function noaction() {
|
|
200
|
-
r = {msg: 'redirects completed'};
|
|
201
|
-
return r;
|
|
202
|
-
}
|
|
203
|
-
async function spre(store) {
|
|
204
|
-
let p = {
|
|
205
|
-
method: 'GET',
|
|
206
|
-
url : 'http://localhost:3000/api/test',
|
|
207
|
-
withCredentials: true
|
|
208
|
-
}
|
|
209
|
-
let r = await store.request(p);
|
|
210
|
-
return r.data;
|
|
211
|
-
}
|
|
212
|
-
async function timedout(store) {
|
|
213
|
-
console.log('timed out at', Date() );
|
|
214
|
-
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`;
|
|
215
|
-
window.open(`${LOGONPAYLOAD.host}/SASLogon/timedout`,'Timed Out', params);
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
async function runCas(store) {
|
|
219
|
-
|
|
220
|
-
let {casManagement} = await store.addServices('casManagement');
|
|
221
|
-
let servers = await store.apiCall(
|
|
222
|
-
casManagement.links('servers')
|
|
223
|
-
);
|
|
224
|
-
let serverName = servers.itemsList(0);
|
|
225
|
-
let session = await store.apiCall(
|
|
226
|
-
servers.itemsCmd(serverName, 'createSession')
|
|
227
|
-
);
|
|
228
|
-
let payload = {
|
|
229
|
-
action: 'builtins.echo',
|
|
230
|
-
data: { code: { x: 1 } }
|
|
231
|
-
};
|
|
232
|
-
console.log(JSON.stringify(session.links("execute"), null, 4));
|
|
233
|
-
let r = await store.runAction(session, payload);
|
|
234
|
-
console.log('echo completed');
|
|
235
|
-
await store.apiCall(session.links('delete'));
|
|
236
|
-
return r.items();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
async function SASfileService(store) {
|
|
240
|
-
debugger;
|
|
241
|
-
try {
|
|
242
|
-
debugger;
|
|
243
|
-
let {files} = await store.addServices('files');
|
|
244
|
-
debugger;
|
|
245
|
-
console.log(JSON.stringify(files.links(), null, 4));
|
|
246
|
-
console.log('items - should be an array of files(empty array is ok)')
|
|
247
|
-
console.log(files.items().toJS());
|
|
248
|
-
let payload = {
|
|
249
|
-
data: { x: 1, y: 'This was saved earlier in the step' },
|
|
250
|
-
headers: { 'content-type': 'application/json' }
|
|
251
|
-
};
|
|
252
|
-
let createCmd = files.links('create');
|
|
253
|
-
let newFile = await store.apiCall(createCmd, payload);
|
|
254
|
-
|
|
255
|
-
let content = await store.apiCall(newFile.links('content'));
|
|
256
|
-
} catch(err) {
|
|
257
|
-
console.log(err);
|
|
258
|
-
debugger;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return content.items();
|
|
262
|
-
}
|
|
263
|
-
async function dsCompute(store) {
|
|
264
|
-
let log = null;
|
|
265
|
-
debugger;
|
|
266
|
-
let {compute} = await store.addServices('compute');
|
|
267
|
-
let servers = await store.apiCall(compute.links('servers'));
|
|
268
|
-
|
|
269
|
-
let contexts = await store.apiCall(compute.links('contexts'));
|
|
270
|
-
|
|
271
|
-
// lookup the name of the first context and then use it to get the associated createSession restafLink
|
|
272
|
-
let createSession = contexts.itemsCmd(
|
|
273
|
-
contexts.itemsList(0),
|
|
274
|
-
'createSession'
|
|
275
|
-
);
|
|
276
|
-
let session = await store.apiCall(createSession);
|
|
277
|
-
|
|
278
|
-
// Now run a simple data step in that session
|
|
279
|
-
let payload = {
|
|
280
|
-
data: {
|
|
281
|
-
code: [`data _null_; do i = 1 to 100; x=1; end; run; `]
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
// Now execute the data step and wait for completion
|
|
286
|
-
let job = await store.apiCall(
|
|
287
|
-
session.links('execute'),
|
|
288
|
-
payload
|
|
289
|
-
);
|
|
290
|
-
let status = await store.jobState(job, null, 5, 2);
|
|
291
|
-
|
|
292
|
-
if (status.data === 'running') {
|
|
293
|
-
throw `ERROR: Job did not complete in allotted time`;
|
|
294
|
-
} else {
|
|
295
|
-
switch (status.data) {
|
|
296
|
-
case 'warning':
|
|
297
|
-
console.log(`Warning: check your log for warnings`);
|
|
298
|
-
break;
|
|
299
|
-
case 'error':
|
|
300
|
-
throw `Please correct errors and rerun program`;
|
|
301
|
-
default:
|
|
302
|
-
log = await store.apiCall(status.job.links('log'));
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return log === null ? status : log.items();
|
|
307
|
-
}
|
|
308
|
-
</script>
|
|
309
|
-
</head>
|
|
310
|
-
<body onload="setup()">
|
|
311
|
-
<h1 id="head">Hi</h1>
|
|
312
|
-
<div>
|
|
313
|
-
<button onclick="runit('redir')">
|
|
314
|
-
Press to do some redirs
|
|
315
|
-
</button>
|
|
316
|
-
<button onclick="runit('files')">
|
|
317
|
-
Press to make a call to file service
|
|
318
|
-
</button>
|
|
319
|
-
<br />
|
|
320
|
-
<br />
|
|
321
|
-
<button onclick="runit('compute')">
|
|
322
|
-
Press to make a call compute service
|
|
323
|
-
</button>
|
|
324
|
-
<br />
|
|
325
|
-
<br />
|
|
326
|
-
<button onclick="runit('cas')">
|
|
327
|
-
Press to make a call to cas echo
|
|
328
|
-
</button>
|
|
329
|
-
<br />
|
|
330
|
-
<br />
|
|
331
|
-
<button onclick="runit('spre')">
|
|
332
|
-
REST call
|
|
333
|
-
</button>
|
|
334
|
-
<br />
|
|
335
|
-
<br />
|
|
336
|
-
<input id='filename'> </input>
|
|
337
|
-
<button onclick="runit('timedout')">
|
|
338
|
-
Press to test timedout
|
|
339
|
-
</button>
|
|
340
|
-
<br />
|
|
341
|
-
<br />
|
|
342
|
-
<button onclick="logoff()">
|
|
343
|
-
logoff
|
|
344
|
-
</button>
|
|
345
|
-
<br />
|
|
346
|
-
</div>
|
|
347
|
-
<div>
|
|
348
|
-
<pre id="output"></pre>
|
|
349
|
-
</div>
|
|
350
|
-
</body>
|
|
351
|
-
</html>
|
package/public/simplesubmit.html
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<!--
|
|
3
|
-
~ /* ------------------------------------------------------------------------------------
|
|
4
|
-
~ * Copyright (c) SAS Institute Inc.
|
|
5
|
-
~ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
~ * you may not use this file except in compliance with the License.
|
|
7
|
-
~ * You may obtain a copy of the License at
|
|
8
|
-
~ *
|
|
9
|
-
~ * http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
~ *
|
|
11
|
-
~ * Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
~ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
~ * See the License for the specific language governing permissions and
|
|
15
|
-
~ * limitations under the License.
|
|
16
|
-
~ ----------------------------------------------------------------------------------------*/
|
|
17
|
-
~
|
|
18
|
-
-->
|
|
19
|
-
|
|
20
|
-
<html lang="en">
|
|
21
|
-
|
|
22
|
-
<head>
|
|
23
|
-
<meta charset="UTF-8" />
|
|
24
|
-
<title>index.html</title>
|
|
25
|
-
|
|
26
|
-
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
|
|
27
|
-
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
|
|
28
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
|
|
29
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js"></script>
|
|
30
|
-
<script src="https://unpkg.com/@sassoftware/restaf@5.2.4"></script>
|
|
31
|
-
<script src="https://unpkg.com/@sassoftware/restaflib@5.2.4"></script>
|
|
32
|
-
|
|
33
|
-
<script src="/appenv"></script>
|
|
34
|
-
|
|
35
|
-
<style>
|
|
36
|
-
.body {
|
|
37
|
-
overflow: hidden;
|
|
38
|
-
}
|
|
39
|
-
.container {
|
|
40
|
-
display: flex;
|
|
41
|
-
flex-direction: row;
|
|
42
|
-
flex-wrap: nowrap;
|
|
43
|
-
min-height: 800px;
|
|
44
|
-
max-height: 80vh;
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.elabel {
|
|
49
|
-
display: inline-block;
|
|
50
|
-
|
|
51
|
-
clear: left;
|
|
52
|
-
width: 250px;
|
|
53
|
-
text-align: right;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.einput {
|
|
57
|
-
display: inline-block;
|
|
58
|
-
}
|
|
59
|
-
.child {
|
|
60
|
-
flex: 1;
|
|
61
|
-
border: 1px solid black;
|
|
62
|
-
margin: 5px;
|
|
63
|
-
padding: 5px;
|
|
64
|
-
overflow: auto;
|
|
65
|
-
}
|
|
66
|
-
.div1 {
|
|
67
|
-
border: 1px solid black;
|
|
68
|
-
background: lightskyblue;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.div2 {
|
|
72
|
-
border: 1px solid black;
|
|
73
|
-
background: lightskyblue;
|
|
74
|
-
height: 200px;
|
|
75
|
-
}
|
|
76
|
-
</style>
|
|
77
|
-
|
|
78
|
-
<script>
|
|
79
|
-
debugger;
|
|
80
|
-
console.log(JSON.stringify(APPENV, null, 4));
|
|
81
|
-
let store = restaf.initStore({
|
|
82
|
-
casProxy: true,
|
|
83
|
-
options: {
|
|
84
|
-
proxyServer: APPENV.PROXYSERVER,
|
|
85
|
-
httpOptions: null
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
debugger; console.log(store.config);
|
|
89
|
-
|
|
90
|
-
let session = null;
|
|
91
|
-
let servers = null;
|
|
92
|
-
let services = null;
|
|
93
|
-
let files = null;
|
|
94
|
-
let reports = null;
|
|
95
|
-
let compute = null;
|
|
96
|
-
|
|
97
|
-
function setup() {
|
|
98
|
-
debugger;
|
|
99
|
-
document.getElementById('ods').innerHTML = 'waiting...';
|
|
100
|
-
document.getElementById('log').innerHTML = 'waiting...';
|
|
101
|
-
|
|
102
|
-
initSession()
|
|
103
|
-
.then(r => {
|
|
104
|
-
document.getElementById('ods').innerHTML = 'ready';
|
|
105
|
-
document.getElementById('log').innerHTML = 'ready';
|
|
106
|
-
})
|
|
107
|
-
.catch(e => {
|
|
108
|
-
console.log(e);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function logoff() {
|
|
112
|
-
let url = `${window.location.protocol}//${window.location.host}/${LOGONPAYLOAD.appName}/logout?callbackUrl=onlogoff.html`;
|
|
113
|
-
window.location.replace(url);
|
|
114
|
-
}
|
|
115
|
-
async function initSession() {
|
|
116
|
-
debugger;
|
|
117
|
-
console.log(APPENV);
|
|
118
|
-
console.log(LOGONPAYLOAD);
|
|
119
|
-
debugger;
|
|
120
|
-
if (LOGONPAYLOAD.host == null) {
|
|
121
|
-
return 'done';
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
let msg = await store.logon(LOGONPAYLOAD);
|
|
125
|
-
debugger;
|
|
126
|
-
} catch (err) {
|
|
127
|
-
console.log('Error logging in', JSON.stringify(err, null, 4));
|
|
128
|
-
throw err;
|
|
129
|
-
}
|
|
130
|
-
let name = 'user';
|
|
131
|
-
document.getElementById('ods').innerHTML = `Creating SAS session...`;
|
|
132
|
-
session = await restaflib.computeSetup(store, null, null);
|
|
133
|
-
document.getElementById('ods').innerHTML = `Ready`;
|
|
134
|
-
|
|
135
|
-
//document.getElementById('output').innerHTML = '...running';
|
|
136
|
-
return 'done';
|
|
137
|
-
}
|
|
138
|
-
function runit(type) {
|
|
139
|
-
|
|
140
|
-
dsCompute(store)
|
|
141
|
-
.then(r => {
|
|
142
|
-
document.getElementById('ods').innerHTML = r.ods;
|
|
143
|
-
document.getElementById('log').innerHTML = r.log;
|
|
144
|
-
})
|
|
145
|
-
.catch(err => {
|
|
146
|
-
document.getElementById('ods').innerHTML = '<pre>' + err + '</pre>';
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function dsCompute(store) {
|
|
151
|
-
//let { computeResults, computeFetchData, computeRun } = restaflib
|
|
152
|
-
|
|
153
|
-
debugger;
|
|
154
|
-
let lib = document.getElementById('lib').value;
|
|
155
|
-
let name = document.getElementById('name').value;
|
|
156
|
-
let macros = { lib, name };
|
|
157
|
-
let src = `ods html; proc print data=&lib..&name.; run; ods html close;`
|
|
158
|
-
try {
|
|
159
|
-
let computeSummary = await restaflib.computeRun(
|
|
160
|
-
store,
|
|
161
|
-
session,
|
|
162
|
-
src,
|
|
163
|
-
macros
|
|
164
|
-
);
|
|
165
|
-
debugger;
|
|
166
|
-
let jobStatus = computeSummary.SASJobStatus;
|
|
167
|
-
let result = {};
|
|
168
|
-
if (jobStatus === 'failed' || jobStatus === 'error' || jobStatus === 'running') {
|
|
169
|
-
let msg = `Job ended with status of ${jobStatus}. Please check the log for errors.`;
|
|
170
|
-
result.log = await restflib.computeResults(store, computeSummary, 'log');
|
|
171
|
-
return result;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
let log = await restaflib.computeResults(store, computeSummary, 'log');
|
|
175
|
-
let logText = '';
|
|
176
|
-
// eslint-disable-next-line array-callback-return
|
|
177
|
-
log.map((data) => {
|
|
178
|
-
let line = data.line.replace(/(\r\n|\n|\r)/gm, "");
|
|
179
|
-
if (line.length === 0) {
|
|
180
|
-
logText = logText + '\n';
|
|
181
|
-
} else { }
|
|
182
|
-
logText = logText + line + '\n';
|
|
183
|
-
});
|
|
184
|
-
result.log = logText;
|
|
185
|
-
|
|
186
|
-
result.ods = await restaflib.computeResults(store, computeSummary, 'ods');
|
|
187
|
-
let odsUrl = computeSummary.ods.get('link').get('uri');
|
|
188
|
-
let connection = store.connection();
|
|
189
|
-
let host = (connection.options.proxyServer == null) ? LOGONPAYLOAD.host : connection.options.proxyServer;
|
|
190
|
-
result.odsurl = `${host}${odsUrl}`;
|
|
191
|
-
|
|
192
|
-
return result;
|
|
193
|
-
} catch (err) {
|
|
194
|
-
debugger;
|
|
195
|
-
console.log(JSON.stringify(err, null, 4));
|
|
196
|
-
return JSON.stringify(err, null, 4);
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
</script>
|
|
201
|
-
</head>
|
|
202
|
-
|
|
203
|
-
<body onload="setup()">
|
|
204
|
-
<h1 id="head">Submit SAS code</h1>
|
|
205
|
-
<div>
|
|
206
|
-
<label class="elabel" for="lib">Library: </label>
|
|
207
|
-
<input id='lib'> </input>
|
|
208
|
-
<br />
|
|
209
|
-
<br />
|
|
210
|
-
<label class="elabel" for="name">Name: </label>
|
|
211
|
-
<input id='name'> </input>
|
|
212
|
-
<br />
|
|
213
|
-
</br />
|
|
214
|
-
</div>
|
|
215
|
-
<button onclick="runit('compute')">
|
|
216
|
-
Submit
|
|
217
|
-
</button>
|
|
218
|
-
<br />
|
|
219
|
-
<br />
|
|
220
|
-
|
|
221
|
-
</div>
|
|
222
|
-
<div class="container">
|
|
223
|
-
<div class="child">
|
|
224
|
-
<pre id="ods"></pre>
|
|
225
|
-
</div>
|
|
226
|
-
<div class="child">
|
|
227
|
-
<pre id="log"></pre>
|
|
228
|
-
</div>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
</body>
|
|
232
|
-
|
|
233
|
-
</html>
|