-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlive-docs.js
117 lines (110 loc) · 4.09 KB
/
live-docs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// $(document).foundation();
// Default branch is prod
let urlParms = new URLSearchParams(location.search);
let branch_name = urlParms.has('branch') ? urlParms.get('branch') : 'prod';
// list of APIS
var apis = [
{
name: 'Actors',
url: 'https://raw.githubusercontent.com/TACC/abaco/dev-v3/docs/specs/openapi_v3.yml'
},
{
name: 'Apps',
url: 'https://raw.githubusercontent.com/tapis-project/openapi-apps/' + branch_name + '/AppsAPI.yaml'
},
{
name: 'Authenticator',
url: 'https://raw.githubusercontent.com/tapis-project/authenticator/' + branch_name + '/service/resources/openapi_v3.yml'
},
{
name: 'Files',
url: 'https://raw.githubusercontent.com/tapis-project/openapi-files/' + branch_name + '/FilesAPI.yaml'
},
{
name: 'GlobusProxy',
url: 'https://raw.githubusercontent.com/tapis-project/globus-proxy/' + branch_name + '/service/resources/openapi_v3.yml'
},
{
name: 'Jobs',
url: 'https://raw.githubusercontent.com/tapis-project/tapis-client-java/' + branch_name + '/jobs-client/src/main/resources/JobsAPI.yaml'
},
{
name: 'Meta',
url: 'https://raw.githubusercontent.com/tapis-project/tapis-client-java/' + branch_name + '/meta-client/src/main/resources/metav3-openapi.yaml'
},
{
name: "Notifications",
url: 'https://raw.githubusercontent.com/tapis-project/openapi-notifications/' + branch_name + '/NotificationsAPI.yaml'
},
{
name: 'PgREST',
url: 'https://raw.githubusercontent.com/TACC/paas/' + branch_name + '/pgrest/resources/openapi_v3.yml'
},
{
name: 'Pods',
url: 'https://raw.githubusercontent.com/tapis-project/pods_service/main/docs/openapi_v3-pods.yml'
},
{
name: 'SK',
url: 'https://raw.githubusercontent.com/tapis-project/tapis-client-java/' + branch_name + '/security-client/src/main/resources/SKAuthorizationAPI.yaml'
},
{
name: 'Streams',
url: 'https://raw.githubusercontent.com/tapis-project/streams-api/' + branch_name + '/service/resources/openapi_v3.yml'
},
{
name: 'Systems',
url: 'https://raw.githubusercontent.com/tapis-project/openapi-systems/' + branch_name + '/SystemsAPI.yaml'
},
{
name: 'Tenants',
url: 'https://raw.githubusercontent.com/tapis-project/tenants-api/' + branch_name + '/service/resources/openapi_v3.yml'
},
{
name: 'Tokens',
url: 'https://raw.githubusercontent.com/tapis-project/tokens-api/' + branch_name + '/service/resources/openapi_v3.yml'
},
{
name: 'Workflows',
url: 'https://raw.githubusercontent.com/tapis-project/tapis-workflows/' + branch_name + '/src/api/specs/WorkflowsAPI.yaml'
}
];
function init() {
let service = urlParms.get("service");
if (service) {
apis.forEach((d) => {
if (d.name.toLowerCase() == service.toLowerCase()) {
Redoc.init(d.url);
}
});
} else {
// initially render first API
Redoc.init(apis[0].url);
}
}
$(document).ready(function($) {
function onClick() {
var url = this.getAttribute('data-link');
let serviceName = this.getAttribute('service');
Redoc.init(url);
var queryParams = new URLSearchParams(window.location.search);
queryParams.set("service", serviceName);
// history.replaceState(null, null, "?"+queryParams.toString());
// history.pushState(null, null, "?"+queryParams.toString());
window.location.search = queryParams.toString();
}
// dynamically building navigation items
var $list = document.getElementById('links_container');
apis.forEach(function (api) {
var $listitem = document.createElement('li');
$listitem.setAttribute('data-link', api.url);
$listitem.setAttribute('service', api.name);
$listitem.innerText = api.name;
$listitem.addEventListener('click', onClick);
$list.appendChild($listitem);
});
init();
$(window).on('popstate', function() {
init();
});
})