-
-
Notifications
You must be signed in to change notification settings - Fork 708
Expand file tree
/
Copy pathshell.html
More file actions
1403 lines (1294 loc) · 53.6 KB
/
Copy pathshell.html
File metadata and controls
1403 lines (1294 loc) · 53.6 KB
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
Sandstorm - Personal Cloud Sandbox
Copyright (c) 2014 Sandstorm Development Group, Inc. and contributors
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Sandstorm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
</body>
<template name="layout">
{{>sandstormTopbar globalTopbar}}
{{#with demoExpired}}
{{>title "Demo Expired"}}
<div id="demo-expired" class="demo-expired-main-content {{#if hideNavbar}}hide-navbar{{else}}{{#if shrinkNavbar}}shrink-navbar{{/if}}{{/if}}">
<h1>Demo Expired</h1>
{{#if canUpgradeDemo}}
<p>Thanks for trying the Sandstorm Demo! Your demo account has expired. If
you'd like to continue using Sandstorm and make your data permanent, please sign in.</p>
<div class="login">
{{> loginButtonsDialog globalAccountsUi}}
</div>
{{else}}
<p>Thanks for trying the Sandstorm Demo! Your demo account has expired.</p>
<p><button class="logout">Sign out</button></p>
{{/if}}
</div>
{{else}}
{{#if identityUser}}
{{> identityLoginInterstitial}}
{{else}}
{{#if firstLogin}}
<div class="first-sign-in-main-content {{#if hideNavbar}}hide-navbar{{else}}{{#if shrinkNavbar}}shrink-navbar{{/if}}{{/if}}">
{{> sandstormAccountsFirstSignIn accountSettingsUi}}
</div>
{{else}}
{{#with firstTimeBillingPromptState}}
<div class="first-sign-in-main-content {{#if hideNavbar}}hide-navbar{{else}}{{#if shrinkNavbar}}shrink-navbar{{/if}}{{/if}}">
{{> billingPromptFirstTime}}
</div>
{{else}}
{{!-- standard topbar items --}}
{{#sandstormTopbarItem name="home-button" topbar=globalTopbar}}
<a href="/">Sandstorm</a>
{{/sandstormTopbarItem}}
{{#if showAccountButtons}}
{{>sandstormTopbarItem name="account" topbar=globalTopbar data=accountButtonsData
template="accountButtons" popupTemplate="accountButtonsPopup"}}
{{else}}
{{>sandstormTopbarItem name="login" topbar=globalTopbar data=globalAccountsUi
template="loginButtons" popupTemplate="loginButtonsPopup"}}
{{/if}}
{{#if currentUser}}
{{>sandstormTopbarItem name="notifications" topbar=globalTopbar
template="notifications" popupTemplate="notificationsPopup"
priority=-1}}
{{/if}}
{{!-- admin alerts --}}
{{#with adminAlert}}
{{#if adminAlertIsTooLarge}}
{{#sandstormTopbarItem name="admin-alert" topbar=globalTopbar priority=-2}}
{{!-- TODO(cleaup): Awkwardly, the event handlers on Template.layout actually work
on this topbar item solely because the whole topbar itself is embedded inside the
"layout" template. But, we shouldn't be relying on that! Move this to its own
template... --}}
<span id="admin-alert-icon" class="{{className}}">!</span>
{{else}}
<h4>Notice from Admin</h4>
<p>
{{#if alertUrl}}
<a href="{{alertUrl}}" class="alert {{className}}">{{text}}</a>
{{else}}
<span class="alert {{className}}">{{text}}</span>
{{/if}}
</p>
{{/sandstormTopbarItem}}
{{else}}
{{#sandstormTopbarItem name="admin-alert" topbar=globalTopbar}}
{{#if alertUrl}}
<a href="{{alertUrl}}" class="alert {{className}}">{{text}}</a>
{{else}}
<span class="alert {{className}}">{{text}}</span>
{{/if}}
{{/sandstormTopbarItem}}
{{/if}}
{{/with}}
{{#with billingPromptState}}
{{>billingPrompt}}
{{/with}}
{{/with}} {{!-- firstTimeBillingPromptState --}}
{{/if}} {{!-- firstLogin --}}
{{!-- If the main-content div were inside the {{#if firstLogin}} block, then grain views could be
blanked out when a demo user upgrades to a real account by linking an email identity.
--}}
<div class="main-content {{#if hideNavbar}}hide-navbar{{else}}{{#if shrinkNavbar}}shrink-navbar{{/if}}{{/if}}">
{{#unless firstLogin}}
{{> yield}}
{{/unless}}
</div>
{{/if}} {{!-- identityUser --}}
{{/with}} {{!-- demoExpired --}}
</template>
<template name="grainView">
{{!-- This template is rendered manually using Blaze.renderWithData() for each currently-open
grain and then injected into .main-content. We do things manually so that we can be
sure that adding or removing grains from the open grain list does not cause other grains'
iframes to be re-rendered, losing state. --}}
{{#with unpackedGrainState}}
<div class="grain-container {{#if active}}active-grain{{else}}inactive-grain{{/if}}">
{{#if error}}
<pre>{{error}}</pre>
{{else}}
{{#if appOrigin}}
{{!-- Selenium requires iframes to have an id in order to select them. id="grain-frame" is only
used for testing purposes. --}}
<iframe data-grainid="{{grainId}}" id="grain-frame" class="grain-frame" src="{{appOrigin}}/_sandstorm-init?sessionid={{sessionId}}&path={{originalPath}}"></iframe>
{{#if hasNotLoaded}}
{{> _grainSpinner}}
{{/if}}
{{else}}
{{#if interstitial}}
<div class="interstitial-button-box">
<p>With which of your identities would you like to open this grain?</p>
{{> identityPicker identityPickerData}}
<button class="incognito-button" data-token="{{token}}">Open in Incognito Mode</button>
</div>
{{else}}
{{> _grainSpinner}}
{{/if}}
{{/if}}
{{/if}}
</div>
{{/with}}
<input type="text" class="inline-powerbox">
</template>
<template name="invalidToken">
<pre> Invalid token: {{token}} </pre>
</template>
<template name="noLayout">
{{!-- An empty layout for resource windows e.g. grainLog that we want to put reactive stuff in,
but don't need the topbar and reload blocking and other fanciness that the layout gives --}}
{{> yield}}
</template>
<template name="notifications">
{{#if notificationCount}}
<span class="count">{{notificationCount}}</span>
{{/if}}
Notifications
</template>
<template name="notificationsPopup">
<h4>Notifications</h4>
<ul class="notification-list">
{{#each notifications}}
<li>
{{> notificationItem}}
</li>
{{else}}
<li>No Notifications...</li>
{{/each}}
</ul>
</template>
<template name="notificationItem">
<div class="notification-item">
<div class="notification-title">
{{notificationTitle}}:
</div>
{{#if isAppUpdates}}
<ul class="app-updates">
{{#each appUpdatesList}}
<li><b>{{name}}</b>: version {{marketingVersion}} is available</li>
{{/each}}
</ul>
{{else}}
{{#if adminLink}}
<a href="{{adminLink}}">{{text.defaultText}}</a>
{{else}}
{{text.defaultText}}
{{/if}}
{{/if}}
<div class="notification-footer">
<span title="{{timestamp}}" class="notification-timestamp">{{dateString timestamp}}</span>
{{#if isAppUpdates}}
<button title="Ignore the above updates" class="cancel-notification">Dismiss</button>
<button title="Update all of the above apps" class="accept-notification">Apply Updates</button>
{{else}}
{{#if showDismiss}}
<button title="{{titleHelperText}}" class="cancel-notification">Cancel</button>
{{/if}}
{{/if}}
</div>
</div>
</template>
<template name="title">
{{#sandstormTopbarItem name="title" priority=5 topbar=globalTopbar}}{{.}}{{/sandstormTopbarItem}}
</template>
<template name="loading">
{{>title "Loading..."}}
<div class="centered-box">Loading...</div>
</template>
<template name="loadingNoMessage">
{{!-- When switching between grains, we don't really want to show a "loading..." message until
the grain's subscriptions are ready, since we've already loaded the iframe and the user can be
interacting with it immediately. But we also want to use waitOn for the topbar items. So we
set a loading template that is effectively empty string, and everything is great. --}}
</template>
<template name="notFound">
{{>title "Not Found"}}
<div class="centered-box">404 Not Found :(</div>
</template>
<template name="root">
{{>title "Home"}}
<div id="intro" class="{{#if splashUrl}}has-splash{{/if}}">
{{#if needsAdminTokenLogin }}
<p>
This Sandstorm instance has no users. You should generate a token from the command line
with `sandstorm admin-token` in order to access the admin settings page.
</p>
{{else}}
{{> loginButtonsDialog globalAccountsUi}}
{{#if splashUrl}}
<iframe src="{{splashUrl}}"></iframe>
{{/if}}
{{/if}}
</div>
</template>
<template name="grainTitle">
<span class="editable" title="Rename" id="grainTitle" tabindex="0">{{title}}</span>
</template>
<template name="grainDeleteButton">
<button class="grain-button" title="Delete" id="deleteGrain">Delete</button>
</template>
<template name="grainDebugLogButton">
<button class="grain-button" title="Show Debug Log" id="openDebugLog">Log</button>
</template>
<template name="grainBackupButton">
<button class="grain-button {{#if isLoading}}loading{{/if}}" title="Download Backup" id="backupGrain" disabled="{{#if isLoading}}true{{/if}}">Backup</button>
</template>
<template name="grainRestartButton">
<button class="grain-button" title="Restart App" id="restartGrain">Restart</button>
</template>
<template name="grainApiTokenButton">
Get Webkey
</template>
<template name="grainApiTokenPopup">
<h4>Webkeys</h4>
{{#if generatedApiToken}}
{{#if generatedApiTokenPending}}
<p>Generating...</p>
<p><button id="resetApiToken">Cancel</button></p>
{{else}}
<p>Copy this webkey and give it to the external app:</p>
<a id="apiTokenText" class="copy-me" href="{{generatedApiToken}}">{{generatedApiToken}}</a>
{{#if currentUser}}
<p><button id="resetApiToken">Go back</button></p>
{{/if}}
{{/if}}
{{else}}
<p>A webkey allows you to connect an external app (e.g. a mobile app) to this app.</p>
<p><form class="newApiToken">
Label: <input type="text" id="api-token-petname" placeholder="e.g. 'Android app'">
{{#with viewInfo}}
{{#if roles}}
Role:
<select id="api-token-role">
<option title="has every app permission" selected=true>all access</option>
{{#each roles}}
<option title={{verbPhrase.defaultText}}
data-obsolete={{obsolete}}>
{{title.defaultText}}</option>
{{/each}}
</select>
{{/if}}
{{/with}}
<button>Create</button></form></p>
{{#if existingTokens}}
<p>Your existing webkeys:</p>
<ul>
{{#each existingTokens}}
{{#if displayToken}}
<li>
<span class="token-petname" data-token-id="{{_id}}">
{{petname}} ({{dateString created}})
</span>
<button class="revoke-token" title="revoke" data-token-id="{{_id}}">revoke</button>
</li>
{{/if}}
{{/each}}
</ul>
{{/if}}
{{/if}}
</template>
<template name="grainShareButton">
Share access
</template>
<template name="whoHasAccess">
<img src="/people.svg">
</template>
<template name="whoHasAccessPopup">
<h4 class="who-has-access">Who has access</h4>
<div class="tables-container">
<h5>People</h5>
{{#if transitiveShares.empty}}
{{#if existingShareTokens}}
<p>No logged-in users have visited your links yet.</p>
{{else}}
<p>You have granted access to nobody.</p>
{{/if}}
{{else}}
<table class="people">
{{#each transitiveShares}}
<tr>
<td> {{displayName recipient}} </td>
<td> added by
<ul>
{{#each shares}}
<li>{{displayName identityId}}</li>
{{/each}}
</ul>
</td>
</tr>
{{/each}}
</table>
{{/if}}
{{#if existingShareTokens}}
<h5>Sharing Links</h5>
<table class="shared-links">
{{!-- Renamed from sharing-links to shared-links due to a common adblock rule
in https://easylist.adblockplus.org/fanboy-social.txt --}}
{{#each existingShareTokens}}
{{#if displayToken}}
<tr>
<td>
<span class="token-petname" data-token-id="{{_id}}">
{{getPetname}} ({{dateString created}})
</span>
</td>
<td>
{{#if viewInfo.roles}}
<select class="share-token-role" data-token-id="{{_id}}">
{{#each indexedRoles}}
<option title={{title.defaultText}}
data-obsolete={{obsolete}}
selected={{hasCurrentRole ..}}>
{{roleText}}</option>
{{/each}}
{{#if hasCustomRole .}}
<option title="custom role" selected=true>
[has custom permissions]
</option>
{{/if}}
</select>
{{/if}}
</td>
<td>
<button class="revoke-token" title="revoke" data-token-id="{{_id}}">revoke</button>
</td>
</tr>
{{/if}}
{{/each}}
</table>
{{/if}}
</div>
</template>
<template name="selectRole">
{{#with viewInfo}}
{{#if roles}}
<select class="share-token-role" title="select a role">
{{#each roles}}
<option title={{title.defaultText}}
data-obsolete={{obsolete}}
{{!-- We need this special attributed because apparently Meteor does not play nice
with HTMLOptionElement.defaultSelected. --}}
data-default-selected={{default}}
selected={{default}}>
{{roleText}}</option>
{{/each}}
</select>
{{/if}}
{{/with}}
</template>
<template name="emailInviteTab">
<form class="email-invite">
<p>
<img class="inline-icon" src="/people-m.svg" role="presentation">
{{> contactInputBox contacts=contacts}}
{{> selectRole viewInfo=viewInfo}}
</p>
<div>
<textarea class="personal-message"
placeholder="Type a personal message (optional)..."></textarea>
</div>
{{#if completionState.clear}}
<div class="button-container" role="presentation">
<button>Send</button>
</div>
{{/if}}
</form>
{{#with completionState}}
{{#if success}}
<p>Successfully sent.</p>
<p><button class="reset-invite">+ Send more invites</button></p>
{{/if}}
{{#if pending}}
<p>Sending...</p>
{{/if}}
{{#if error}}
<p> {{error}} </p>
<p><button class="start-over-invite"><< Start over</button></p>
{{/if}}
{{/with}}
</template>
<template name="shareableLinkTab">
<form class="new-share-token">
<p>
<img class="inline-icon" src="/people-m.svg" role="presentation">
Anyone with this link{{#if viewInfo.roles}}:{{else}} can access the grain.{{/if}}
{{> selectRole viewInfo=viewInfo}}
</p>
<input type="text" class="label" placeholder="Label (optional)">
<p class="label-explanation">
Use a label to remind yourself to whom you sent this unique link.</p>
{{#if completionState.clear}}
<div class="button-container">
<button>Create</button>
</div>
{{/if}}
</form>
{{#with completionState}}
{{#if success}}
<p><img class="inline-icon" src="/copy-m.svg" role="presentation"> Copy this link:</p>
<a id="share-token-text" class="copy-me" href="{{success.url}}">{{success.url}}</a>
<p><button class="reset-share-token">+ Create another link</button></p>
{{/if}}
{{#if pending}}
<p>Generating...</p>
<p><button class="reset-share-token">Cancel</button></p>
{{/if}}
{{/with}}
</template>
<template name="shareWithOthers">
<h4 class="share-with-others">Share with others</h4>
{{#if grain.isOldSharingModel}}
<p>This grain uses the old sharing model. You can share it by copy/pasting the URL from the
location bar.</p>
{{#if grain.isOwner}}
<p>You can upgrade this grain to the new model, but anyone with whom you shared this grain
previously will lose access; you will have to share it with them again.</p>
<p>Upgrading cannot be undone.</p>
<p><button id="privatize-grain">upgrade</button></p>
{{/if}}
{{else}}
<div class="share-tabs" role="presentation">
<ul role="tablist">
<li id="send-invite-tab-header" tabindex="0" role="tab" aria-controls="send-invite-tab" aria-selected="true"> Send an invite </li>
<li id="shareable-link-tab-header" tabindex="-1" role="tab" aria-controls="shareable-link-tab" aria-selected="false"> Get shareable link </li>
</ul>
<div id="send-invite-tab" role="tabpanel" class="tabpanel" aria-labelledby="send-invite-tab-header" aria-hidden="false">
{{> emailInviteTab viewInfo=grain.viewInfo title=grain.title grainId=grain.grainId }}
</div>
<div id="shareable-link-tab" role="tabpanel" class="tabpanel" aria-labelledby="shareable-link-tab-header" aria-hidden="true">
{{> shareableLinkTab viewInfo=grain.viewInfo }}
</div>
</div>
<div class="footer">
<img class="inline-icon" src="/people-m.svg">
<button class="who-has-access">See who has access</button>
</div>
{{/if}}
</template>
<template name="grainSharePopup">
{{> shareWithOthers grain=currentGrain}}
</template>
<template name="grainPowerboxRequest">
P
</template>
<template name="grainPowerboxRequestPopup">
<h4>Powerbox Request</h4>
<div>
<form id="powerbox-request-form">
<label>Please input an api token: </label><input name="token" type="text" id="powerbox-request-input"><br>
<button class="submit">Import token</button>
</form>
{{#if error.get}}
<div class="error">{{error.get}}</div>
{{/if}}
</div>
</template>
<template name="grainPowerboxOffer">
P
</template>
<template name="grainPowerboxOfferPopup">
<h4>Powerbox Offer</h4>
<div>
<a class="copy-me" href="{{powerboxOfferUrl}}" id="powerbox-offer-url">{{powerboxOfferUrl}}</a>
<button class="dismiss">Dismiss</button>
</div>
</template>
<template name="grain">
{{>sandstormTopbarItem name="title" priority=5 topbar=globalTopbar template="grainTitle"}}
{{#sandstormTopbarItem name="grain-size" priority=5 topbar=globalTopbar}}
{{grainSize}}
{{/sandstormTopbarItem}}
{{>sandstormTopbarBlockReload}}
{{setGrainWindowTitle}}
{{#if currentUser}}
{{>sandstormTopbarItem name="share" topbar=globalTopbar
template="grainShareButton" popupTemplate="grainSharePopup"}}
{{>sandstormTopbarItem name="delete" topbar=globalTopbar template="grainDeleteButton"}}
{{/if}}
{{#if isOwner}}
{{>sandstormTopbarItem name="debug-log" topbar=globalTopbar template="grainDebugLogButton" data=globalTopbar}}
{{>sandstormTopbarItem name="backup" topbar=globalTopbar template="grainBackupButton" data=globalTopbar}}
{{>sandstormTopbarItem name="restart" topbar=globalTopbar template="grainRestartButton" data=globalTopbar}}
{{/if}}
{{#if displayWebkeyButton}}
{{>sandstormTopbarItem name="webkey" topbar=globalTopbar
template="grainApiTokenButton" popupTemplate="grainApiTokenPopup"}}
{{/if}}
{{#if showPowerboxRequest}}
{{>sandstormTopbarItem name="request" topbar=globalTopbar template="grainPowerboxRequest"
startOpen=true popupTemplate="grainPowerboxRequestPopup"}}
{{/if}}
{{#if showPowerboxOffer}}
{{>sandstormTopbarItem name="offer" topbar=globalTopbar template="grainPowerboxOffer"
startOpen=true popupTemplate="grainPowerboxOfferPopup"}}
{{/if}}
</template>
<template name="apps">
{{> sandstormAppListPage . }}
</template>
<template name="grains">
{{> sandstormGrainListPage . }}
</template>
<template name="appDetails">
{{> sandstormAppDetailsPage . }}
</template>
<template name="_grainSpinner">
{{!-- This is a terrible hack to center this thing. The styles shold go in css, but it's
arguably more confusing to put them there when all they're doing is this archaic pattern to
get a horizontally+vertically centered div --}}
<div id="grain-loading-spinner">
<div style="display:table-cell;vertical-align:middle;">
<div style="margin-left:auto;margin-right:auto;text-align:center;">
<img src="/spinner_96.gif" alt="loading">
</div>
</div>
</div>
</template>
<template name="grainLog">
<div class="grainlog-title">Debug log: {{title}}</div>
<div class="grainlog-contents" aria-live="polite">
<pre>...{{{html}}}</pre>
</div>
</template>
<template name="install">
{{> sandstormAppInstallPage . }}
</template>
<template name="account">
<div class="account">
{{#if .}}
{{>sandstormAccountSettings .}}
{{/if}}
</div>
</template>
<template name="accountUsage">
{{> billingUsage db=globalDb}}
{{> billingSettings db=globalDb}}
</template>
<template name="signup">
{{>title "Claim Invite"}}
<div class="centered-box">
{{#if alreadySignedUp}}
{{#if keyIsUsed}}
<p>You're all signed up! Now go <a href="https://apps.sandstorm.io/?host={{origin}}">install
some apps</a>.</p>
{{else}}
<p>It looks like you already have an account, so you don't need this signup key.</p>
{{/if}}
{{else}}
{{#if keyIsValid}}
{{#if keyIsUsed}}
<p>Sorry, this signup key has already been used.</p>
{{else}}
{{#if currentUser}}
<p>Please wait...</p>
{{else}}
<p>{{signupDialog}} First, you have to sign in. Click "Sign in" in the upper-right.</p>
<div id="sign-in-arrow"></div>
{{/if}}
{{/if}}
{{else}}
<p>Sorry, this is not a valid signup key.</p>
{{/if}}
{{/if}}
</div>
</template>
<template name="adminInvites">
{{setDocumentTitle}}
<div id="invite">
{{#if error}}
<p>{{error}}</p>
<p><button id="retry">Try Again</button></p>
{{else}}{{#if url}}
<p>New key: <input type="text" class="autoSelect" value="{{url}}" readonly></p>
<p>Send this key to someone to allow them to create an account on your server.</p>
<p><button id="retry">Create Another</button></p>
{{else}}{{#if sent}}
<p>Sent!</p>
<p><button id="retry">Send more</button></p>
{{else}}
<p>You can invite friends to create accounts on your server. People you invite will be
able to install apps and create grains of their own. You do NOT need to invite someone
if you just want to share your grains with them.</p>
<h3>Create a link:</h3>
<p>This will create a magic link which you can send to someone.</p>
<p>
{{#if quotaEnabled}}
Quota: <input id="key-quota" type="text" placeholder="(bytes; blank for none)"><br>
{{/if}}
<input id="key-note" type="text" placeholder="notes, e.g. name of the recipient">
<button id="create">Create</button></p>
<h3>Send an e-mail:</h3>
<p>This will create a link and send it in an e-mail. <code>$KEY</code> will be replaced
with the newly-generated link.</p>
<div style="text-align: right; margin-top: 1em;">
<p>From: <input type="text" id="invite-from" placeholder="me@example.com" value="{{email}}"></p>
<p>To:
<textarea id="invite-emails" placeholder="E-mail addresses, one per line."></textarea></p>
<p>Subject: <input type="text" id="invite-subject" value="Join my Sandstorm server!"></p>
<p>Body:
<textarea id="invite-message">Click on the following link to get access to my Sandstorm.io server.
$KEY</textarea></p>
{{#if quotaEnabled}}
<p>Quota: <input id="invite-quota" type="text" placeholder="(bytes; blank for none)"></p>
{{/if}}
<p><button id="send">Send</button></p>
</div>
{{#if quotaEnabled}}
<h3>Update quotas:</h3>
<p>You can batch modify existing users' quotas by specifying the e-mail address under which they were invited. This only works for user who were invited using the "Send an e-mail" form, above.</p>
<div style="text-align: right; margin-top: 1em;">
<p>Emails:
<textarea id="set-quota-emails" placeholder="E-mail addresses, one per line."></textarea></p>
<p>Quota: <input id="set-quota-quota" type="text" placeholder="(bytes; blank for none)"></p>
<p><button id="set-quota-submit">Update</button></p>
</div>
{{/if}}
{{/if}}
{{/if}}
{{/if}}
</div>
</template>
<template name="adminLog">
{{setDocumentTitle}}
<div id="adminLog">
<pre>...{{{html}}}</pre>
</div>
</template>
<template name="uploadStatus">
{{>title "Uploading..."}}
<div id="restoreGrain" class="centered-box">
{{#if error}}
<p>Upload failed: {{error.status}} {{error.statusText}}</p>
<pre>{{error.response}}</pre>
{{else}}
{{#if status}}
<p>{{status}}... {{#if progress}}{{progress}}%{{/if}}</p>
{{else}}
<p>Upload failed. Please try again.</p>
{{/if}}
{{/if}}
</div>
</template>
<template name="_adminConfigureLoginServiceDialog">
{{#if visible}}
<div id="configure-login-service-dialog" class="accounts-dialog accounts-centered-dialog">
{{> configurationSteps}}
<p>
Now, copy over some details.
</p>
<p>
<table>
<colgroup>
<col span="1" class="configuration_labels">
<col span="1" class="configuration_inputs">
</colgroup>
{{#each configurationFields}}
<tr>
<td>
<label for="configure-login-service-dialog-{{property}}">{{label}}</label>
</td>
<td>
<input id="configure-login-service-dialog-{{property}}" type="text" value="{{value}}">
</td>
</tr>
{{/each}}
</table>
</p>
<div class="new-section">
<div class="login-button configure-login-service-dismiss-button">
Cancel
</div>
<a class="accounts-close configure-login-service-dismiss-button">×</a>
<div class="login-button login-button-configure"
id="configure-login-service-dialog-save-configuration">
Save Configuration
</div>
</div>
</div>
{{/if}}
</template>
<template name="admin">
{{>title "Admin Settings"}}
{{> _adminConfigureLoginServiceDialog}}
<div id="admin-settings" class="centered-box">
{{#if isUserPermitted}}
<ul class="nav centered-box settings-tabs">
<li id="settings-tab" class="{{#if settingsActive}}active{{/if}}">
{{#linkTo route="adminSettings" data=getToken}}Settings{{/linkTo}}
</li>
<li id="users-tab" class="{{#if usersActive}}active{{/if}}">
{{#linkTo route="adminUsers" data=getToken}}Users{{/linkTo}}
</li>
<li id="stats-tab" class="{{#if statsActive}}active{{/if}}">
{{#linkTo route="adminStats" data=getToken}}Stats{{/linkTo}}
</li>
<li id="log-tab" class="{{#if logActive}}active{{/if}}">
{{#linkTo route="adminLog" data=getToken}}Log{{/linkTo}}
</li>
<li id="invites-tab" class="{{#if invitesActive}}active{{/if}}">
{{#linkTo route="adminInvites" data=getToken}}Send Invite{{/linkTo}}
</li>
<li id="caps-tab" class="{{#if capsActive}}active{{/if}}">
{{#linkTo route="adminCaps" data=getToken}}Capabilities{{/linkTo}}
</li>
<li id="advanced-tab" class="{{#if advancedActive}}active{{/if}}">
{{#linkTo route="adminAdvanced" data=getToken}}Advanced{{/linkTo}}
</li>
</ul>
{{> Template.dynamic template=adminTab}}
{{#if success}}
<div class="alert alert-success {{#if fadeAlert}}fade-out{{/if}}"><strong>Success!</strong> {{successMessage}}</div>
{{/if}}
{{#if failure}}
<div class="alert alert-danger {{#if fadeAlert}}fade-out{{/if}}"><strong>Failure!</strong>
<ul>
{{#each errors}}
<li>{{reason}}</li>
{{/each}}
</ul>
For internal server errors, see {{#linkTo route='adminLog' data=getToken}}the Sandstorm server log{{/linkTo}} for details.
</div>
{{/if}}
{{else}}
<p>
You are not logged in as admin and there isn't a valid token specified. You should
either log in as an admin user or generate a token from the command line by doing
`sandstorm admin-token` in order to access the admin settings page.
</p>
{{/if}}
</div>
</template>
<template name="adminSettings">
{{setDocumentTitle}}
<form id="admin-settings-form">
<p>
<label><input type="checkbox" class="oauth-checkbox" name="googleLogin"
value="value" checked={{googleEnabled}} data-servicename="google"> Enable Google Login
(<a class="configure-oauth" data-servicename="google" href="">configure</a>)
(<a class="reset-login-tokens" data-servicename="google" href="">log out all users</a>)</label><br>
<label><input type="checkbox" class="oauth-checkbox" name="githubLogin"
value="value" checked={{githubEnabled}} data-servicename="github"> Enable Github Login
(<a class="configure-oauth" data-servicename="github" href="">configure</a>)
(<a class="reset-login-tokens" data-servicename="github" href="">log out all users</a>)</label><br>
<label><input type="checkbox" name="emailTokenLogin" value="value" checked={{emailTokenEnabled}}> Enable Passwordless Email Login</label><br>
<span class="details">Choose which services users may use to identify themselves. Anyone can log in, but only users you {{#linkTo route="adminInvites" data=getToken}}invite{{/linkTo}} will be able to install apps or create files.</span></p>
<p>SMTP Url: <button id="admin-settings-send-toggle">Test</button><input id="smptUrl" type="text" name="smtpUrl" value="{{smtpUrl}}"><br>
<span class="details">Address of an SMTP relay server, like <code>smtp://user:pass@host:port</code>, which will be used by email apps and to send {{#linkTo route="adminInvites" data=getToken}}email invites{{/linkTo}}. The SMTP server should be configured to allow sending email from your Sandstorm domain and from email addresses that will be used to send invites. Read the <a href="https://docs.sandstorm.io/en/latest/administering/email/#outgoing-smtp">docs</a> for more details.</span>
</p>
{{#if isEmailTestActive}}
<p>
Send test email to: <input id="email-test-to" type="text">
<p><button id="admin-settings-send-test">Send</button></p>
</p>
{{/if}}
<p><button id="admin-settings-save">Save</button></p>
</form>
</template>
<template name="adminUsers">
{{setDocumentTitle}}
<table class="admin-table">
<thead>
<tr>
<td>Service</td>
<td>Handle</td>
<td>Name</td>
<td>User Class</td>
{{#if quotaEnabled}}
<td>Plan</td>
<td>Used</td>
{{/if}}
<td>Created</td>
<td>Last Active</td>
<td>Invited as</td>
</tr>
</thead>
<tbody>
{{#each users}}
<tr>
{{#with userIdentity}}
<td>{{profile.service}}</td>
<td>{{profile.handle}}</td>
<td>{{profile.name}}</td>
{{/with}}
<td>
<select class="user-class" name="select">
<option value="admin" selected={{#if userIsAdmin}}selected{{/if}}>Admin</option>
<option value="invited" selected={{#if userIsInvited}}selected{{/if}}>Invited User</option>
<option value="guest" selected={{#if userIsGuest}}selected{{/if}}>Guest</option>
</select>
</td>
{{#if quotaEnabled}}
<td>{{plan}}</td>
<td>{{userStorageUsage}}</td>
{{/if}}
<td title="{{createdAt}}">{{dateString createdAt}}</td>
<td title="{{lastActive}}">{{dateString lastActive}}</td>
<td>{{userSignupNote}}</td>
</tr>
{{/each}}
</tbody>
</table>
</template>
<template name="adminStats">
{{setDocumentTitle}}
<div id="stats">
{{#if reportStatsFirstVisit}}
<div class="report-stats-yesno-box">
<p>We'd like to know how many Sandstorm users there are, to make graphs and such. Is it OK to send the numbers on this page to Sandstorm, so that we can add them to the totals? Any stats you send are anonymous.</p>
<button class="yes">Send anonymous stats</button>
<button class="no">Don't send</button>
</div>
{{else}}
<label class="report-stats">
<input class="enableStatsCollection" type="checkbox" name="reportStats" checked={{reportStats}}>
Anonymously share the stats below with Sandstorm.io.
{{#if reportStatsSaving}}
{{#if reportStatsSaved}}
<span class="check-mark {{#if fadeCheckmark}}fade-out{{/if}}" title="saved">✓</span>
{{else}}
<img src="/spinner_96.gif" alt="loading">
{{/if}}
{{/if}}
</label>
{{/if}}
<p>Right now: {{current.activeUsers}} users, {{current.activeGrains}} grains</p>
<p>Today: {{today.activeUsers}} users, {{today.activeGrains}} grains</p>
<p>Previous days:</p>
<table>
<tr>
<td rowspan="2">date</td>
<td colspan="4">users</td>
<td colspan="4">grains</td>
</tr>
<tr>
<td>daily</td>
<td>weekly</td>
<td>monthly</td>
<td>forever</td>
<td>daily</td>
<td>weekly</td>
<td>monthly</td>
<td>forever</td>
</tr>
{{#each points}}
<tr>
<td>{{day}}</td>
<td>{{daily.activeUsers}}</td>
<td>{{weekly.activeUsers}}</td>
<td>{{monthly.activeUsers}}</td>
<td>{{forever.activeUsers}}</td>
<td>{{daily.activeGrains}}</td>
<td>{{weekly.activeGrains}}</td>
<td>{{monthly.activeGrains}}</td>
<td>{{forever.activeGrains}}</td>
</tr>
{{else}}
<tr>
<td colspan="7">There are no stats yet, or you are not admin.</td>
</tr>
{{/each}}
</table>
<h3 id="app-stats">Apps</h3>
<span>Select a date:</span>
<select class="package-date">
{{#each appDates}}
<option value="{{_id}}" selected="{{#if selected}}true{{/if}}">{{day}}</option>
{{/each}}
</select>
<table class="apps">
<tr>
<td rowspan="2">App Name</td>
<td colspan="4">owners</td>
<td colspan="4">sharedUsers</td>
<td colspan="4">grains</td>
</tr>
<tr>
<td>daily</td>
<td>weekly</td>
<td>monthly</td>
<td>forever</td>
<td>daily</td>
<td>weekly</td>
<td>monthly</td>
<td>forever</td>
<td>daily</td>
<td>weekly</td>
<td>monthly</td>