forked from Sage-Bionetworks/Synapse-React-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
340 lines (310 loc) · 11.9 KB
/
index.html
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"
/>
<!-- production version of react-- errors obfuscated -->
<!-- <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script> -->
<!-- <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> -->
<script
crossorigin
src="https://unpkg.com/[email protected]/prop-types.min.js"
></script>
<!-- development version of react -->
<script
crossorigin
src="https://unpkg.com/react@16/umd/react.development.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
></script>
<!-- react-router-dom -->
<script src="https://unpkg.com/react-router/umd/react-router.min.js"></script>
<script src="https://unpkg.com/react-router-dom/umd/react-router-dom.min.js"></script>
<!-- katex -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y"
crossorigin="anonymous"
/>
<script
defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz"
crossorigin="anonymous"
></script>
<!-- react-measure -->
<script src="https://unpkg.com/[email protected]/dist/index.umd.js"></script>
<!-- react-tooltip -->
<script
crossorigin
src="https://unpkg.com/[email protected]/standalone/react-tooltip.min.js"
></script>
<!-- plotly -->
<script
crossorigin
src="https://cdn.plot.ly/plotly-basic-1.47.3.min.js"
></script>
<script
crossorigin
src="https://unpkg.com/[email protected]/dist/create-plotly-component.js"
></script>
<!-- rss-parser -->
<script src="https://unpkg.com/browse/[email protected]/dist/rss-parser.min.js"></script>
<!-- react-native-parser -->
<script src="https://unpkg.com/browse/[email protected]/umd/react-mailchimp-subscribe.min.js"></script>
<!-- markdown imports -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/markdown-it.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-synapse.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-center-text.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-synapse-heading.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-synapse-table.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-strikethrough-alt.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-emphasis-alt.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-math.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-sup.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-sub.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-inline-comments.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/markdown-it-br.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/markdown-it-container.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sanitize-html.min.js"></script>
<script
crossorigin
src="https://unpkg.com/universal-cookie@3/umd/universalCookie.min.js"
></script>
<!-- end imports -->
<!-- react-css-transition-group -->
<script src="https://unpkg.com/[email protected]/dist/react-transition-group.min.js"></script>
<!-- react json schema form -->
<script src="https://unpkg.com/react-jsonschema-form/dist/react-jsonschema-form.js"></script>
<!-- local imports-- change in prod -->
<link
rel="stylesheet"
href="../../umd/synapse-react-client.production.styles.css"
/>
<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Synapse React Client</title>
</head>
<style>
/* Configure css */
.SRC-primary-background-color-hover:hover {
background: #d53f77 !important;
color: white;
}
.SRC-primary-background-color-hover:hover > * {
background: #d53f77;
color: white;
}
</style>
<body>
<button id="signoutButton" class="btn btn-primary" onclick="signout()">Sign Out</button>
<div id="panel1"></div>
<!-- spacer div below -->
<div id="panel2"></div>
<div id="panel3"></div>
<div id="panel4"></div>
<div id="panel5"></div>
<div id="panel6"></div>
<div id="panel7"></div>
<div id="panel8"></div>
<div id="panel9"></div>
<div id="panel10"></div>
<div id="panel11"></div>
<div id="panel12"></div>
<div id="panel13"></div>
<div style="height: 300px;"></div>
<!--
This HTML file is a an example configuration of SRC used in a plain HTML page,
if you open it directly in the browser, you will see some components render.
-->
</body>
<!-- bootstrap components -->
<script
src="https://unpkg.com/react-bootstrap@next/dist/react-bootstrap.min.js"
crossorigin
></script>
<script src="../../umd/synapse-react-client.production.min.js"></script>
<script type="text/javascript">
// set portal endpoints
// window.SRC.OVERRIDE_ENDPOINT_CONFIG = {
// REPO: 'https://repo-staging.prod.sagebase.org/',
// PORTAL: 'https://staging.synapse.org/',
// }
//attempt to read access token from cookies
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
function signout() {
document.cookie = "org.sagebionetworks.security.user.login.token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"
location.reload()
}
const token = getCookie("org.sagebionetworks.security.user.login.token")
const e = React.createElement // utility for creating elements
const renderInTryCatch = (reactNode, container, name) => {
try {
ReactDOM.render(reactNode, container)
} catch (e) {
console.error('Error rendering: ', name)
// error message isn't informative
}
}
const markdownContainer = document.querySelector('#panel2')
const markdownProps = {
token,
wikiId: '582150',
ownerId: 'syn14306197',
}
const userCardSmallContainer = document.querySelector('#panel3')
const userCardPropsSmall = {
ownerId: '3374422',
size: SRC.SynapseConstants.SMALL_USER_CARD,
}
const UserCardMediumAndLargeContainer = document.querySelector('#panel4')
const userCardPropsMedium = {
ownerId: '3374422',
size: SRC.SynapseConstants.MEDIUM_USER_CARD,
}
renderInTryCatch(
e(SRC.SynapseComponents.Markdown, markdownProps, null),
markdownContainer,
'MarkdownSynapse',
)
renderInTryCatch(
e(SRC.SynapseComponents.UserCard, userCardPropsSmall, null),
userCardSmallContainer,
'UserCardSmall',
)
renderInTryCatch(
e(SRC.SynapseComponents.UserCard, userCardPropsMedium, null),
UserCardMediumAndLargeContainer,
'UserCardMediumAndLargeContainer',
)
const formContainer = document.querySelector('#panel5')
const entityFormProps = {
parentContainerId: 'syn20355732',
token,
formSchemaEntityId: 'syn20184776',
formUiSchemaEntityId: 'syn20184771',
initFormData: false,
}
renderInTryCatch(
e(SRC.SynapseComponents.EntityForm, entityFormProps, null),
formContainer,
'EntityForm',
)
const statsPlotProps = {
token,
request: {
concreteType:
'org.sagebionetworks.repo.model.statistics.ProjectFilesStatisticsRequest',
objectId: 'syn5585645',
fileDownloads: true,
fileUploads: true,
},
endpoint: 'https://repo-staging.prod.sagebase.org/',
}
const statsPlotContainer = document.querySelector('#panel6')
renderInTryCatch(
e(SRC.SynapseComponents.StatisticsPlot, statsPlotProps, null),
statsPlotContainer,
'EntityForm',
)
// verified window.SRC.OVERRIDE_ENDPOINT_CONFIG is used in Login component (including Forgot Password and Register links)
if (!token) {
const loginContainer = document.querySelector('#panel7')
const loginProps = {
sessionCallback: () => {
console.log('session was just changed!')
location.reload()
},
}
renderInTryCatch(
e(SRC.SynapseComponents.Login, loginProps, null),
loginContainer,
'Login',
)
const signoutButtonEl = document.getElementById("signoutButton")
signoutButtonEl.style.display = "none"
}
const hasAccessContainer = document.querySelector('#panel8')
const hasAccessProps = {
token,
synapseId: 'syn12664802',
}
renderInTryCatch(
e(SRC.SynapseComponents.HasAccess, hasAccessProps, null),
hasAccessContainer,
'HasAccess',
)
const accessTokenPageContainer = document.querySelector('#panel9')
const accessTokenPageProps = {
title: 'Personal Access Token Management',
body: 'Manage your tokens right here!!!!!',
token
}
renderInTryCatch(
e(SRC.SynapseComponents.AccessTokenPage, accessTokenPageProps, null),
accessTokenPageContainer,
'Personal Access Token Page',
)
const evaluationQueueEditorListContainer = document.querySelector('#panel10')
const evaluationRoundEditorListProps = {
accessToken: token,
evaluationId: '9614644',
utc: true
}
renderInTryCatch(
e(SRC.SynapseComponents.EvaluationRoundEditorList, evaluationRoundEditorListProps, null),
evaluationQueueEditorListContainer,
'EvaluationRoundEditorList',
)
const evaluationQueueCardContainer = document.querySelector('#panel11')
const evaluationQueueCardProps = {
accessToken: token,
evaluationId: '9614644',
utc: true
}
renderInTryCatch(
e(SRC.SynapseComponents.EvaluationCard, evaluationQueueCardProps, null),
evaluationQueueCardContainer,
'EvaluationCard',
)
const evaluationQueueEditorContainer = document.querySelector('#panel12')
const evaluationQueueEditorProps = {
accessToken: token,
evaluationId: '9614644',
utc: true
}
renderInTryCatch(
e(SRC.SynapseComponents.EvaluationEditor, evaluationQueueEditorProps, null),
evaluationQueueEditorContainer,
'EvaluationEditor',
)
const accountLevelBadgeContainer = document.querySelector('#panel13')
const accountLevelBadgeProps = {
userId: '273980'
}
renderInTryCatch(
e(SRC.SynapseComponents.AccountLevelBadge, accountLevelBadgeProps, null),
accountLevelBadgeContainer,
'AccountLevelBadge',
)
</script>
</html>