60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
export async function connect(secret, host='vista.northport.med.va.gov', port=19209) {
|
|
return await (await fetch('/v1/vista', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ params: { secret: secret, host: host, port: port }, id: Date.now() })
|
|
})).json();
|
|
}
|
|
|
|
export async function close(cid) {
|
|
return await (await fetch('/v1/vista/' + cid + '/close', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ id: Date.now() })
|
|
})).json();
|
|
}
|
|
|
|
export async function call(cid, method, ...params) {
|
|
return await (await fetch('/v1/vista/' + cid, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ method: method, params: params, id: Date.now() })
|
|
})).json();
|
|
}
|
|
|
|
export async function callctx(cid, context, method, ...params) {
|
|
return await (await fetch('/v1/vista/' + cid, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ method: method, params: params, context: context, id: Date.now() })
|
|
})).json();
|
|
}
|
|
|
|
export async function serverinfo(cid) {
|
|
return await (await fetch('/v1/vista/' + cid + '/serverinfo', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: '{}'
|
|
})).json();
|
|
}
|
|
|
|
export async function userinfo(cid) {
|
|
return await (await fetch('/v1/vista/' + cid + '/userinfo', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: '{}'
|
|
})).json();
|
|
}
|
|
|
|
export async function authenticate(cid, avcode=null) {
|
|
return await (await fetch('/v1/vista/' + cid + '/authenticate', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ params: avcode ? { avcode } : {} })
|
|
})).json();
|
|
}
|
|
|
|
export default window.vista = {
|
|
connect, close, call, callctx, serverinfo, userinfo, authenticate
|
|
};
|