aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/templates/index.html
blob: 07170051954a5020b689f745dbbe61b20777c716 (plain) (blame)
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <link href="/static/css/bootstrap.min.css" rel="stylesheet" defer>

  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Steam Game index</title>
</head>
<body>


<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
  <div class="container-fluid">
    <a class="navbar-brand" href="/">Steam Exporter</a>
    <button class="navbar-toggler"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#navbarsExampleDefault"
            aria-controls="navbarsExampleDefault"
            aria-expanded="false"
            aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarsExampleDefault">
      <ul class="navbar-nav me-auto mb-2 mb-md-0">
        <li class="nav-item">
          {{ if .Demo }}
          <span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip"
            data-bs-placement="bottom" title="Disabled for demo">
            <a class="nav-link disabled" aria-current="page" href="#">
              Download
            </a>
          </span>
          {{ else }}
          <a class="nav-link" aria-current="page"
            href="/steam-export-web.exe">
              Download
          </a>
          {{ end }}
        </li>
        <li class="nav-item">
          <a href="#"
            id="shareLink"
            data-clipboard-text="{{$.ShareLink}}"
            class="nav-link">
          Copy Share link
          </a>
        </li>
        {{ if .Local }}
        <li class="nav-item">
          <a class="nav-link" aria-current="page"
            data-bs-target="#installModal"
            data-bs-toggle="modal"
            href="#">
             Install Game
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" aria-current="page"
            data-bs-target="#libraryModal"
            data-bs-toggle="modal"
            href="#">
              Change Library Path
          </a>
        </li>
        {{ end }}
      </ul>

      <ul class="navbar-nav ">
      {{ if .Local }}
      <li class="nav-item">
        <a class="nav-link" href="#"
        data-bs-target="#versionModal"
        data-bs-toggle="modal"
        >
        Version
        </a>
      </li>
      {{if .Demo}}{{else}}
      <li class="nav-item">
        <a class="nav-link" href="/quit">Shutdown Server/Quit</a>
      </li>
      {{end}}
      {{ end }}
      </ul>
    </div>
  </div>
</nav>

<div class="container" style="padding-top: 6rem;">

<div class="position-fixed bottom-0 end-0 p-3" >
  <div id="notificationCopied" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
    <div class="toast-body" id="notificationCopiedText"></div>
  </div>
</div>

{{ if .Local }}
  <script src="/static/main.js"></script>
  <h2>Library: {{.Lib.Folder}}</h2>
  
  <div class="row">
    <div id="installBarContainer" class="progress" style="display: none;">
      <div id="installBar" class="progress-bar progress-bar-striped progress-bar-animated"
           role="progressbar"
           aria-valuenow="0"
           aria-valuemin="0"
           aria-valuemax="100"
           style="width: 0%;">
      </div>
    </div>
  </div>
  
  <div class="row" style="padding-top: 10px;">
    <pre><code id="message" style="display: none;"></code></pre>
  </div>
  
  <h3>About</h3>
  <p>
  The steam exporter is designed to let you export your steam games, either to
  another local hard drive or another computer on the network.
  </p>
  <p>
  It also allows you to import games from across the network as well if you
  provide an HTTP url from which to download the game file as exported
  from this application. {{ if .Demo }}Downloads are however disabled for the
  demo.{{end}}
  </p>
  <p>
  {{ if .Demo }}
  You would normally be able to download the application from here, but it's
  disabled for the demo. See
  <a href="https://git.riedstra.dev/mitch/steam-export/about/">here</a> for more info.
  {{ else }}
  <a href="/steam-export-web.exe">
    You can download this application from this UI as well here.
  </a>
  {{ end }}
  </p>
  
  <p>
  You can give people this link to view the library remotely and download
  games from your computer:
  <br /><br />
  <a href="{{.ShareLink}}">{{.ShareLink}}</a>
  </p>
{{ else }}
  
  <h2>Remote Steam library access</h2>
  
  <p>
  {{ if .Demo }}{{ else }}
  <a href="/steam-export-web.exe">
    If you need this program to install the games click here.
  </a>
  {{ end }}
  </p>
  
{{ end }}

<h3>Installed games:</h3>

<div class="container">
  <div class="row">
    <div class="col-3">
     <input class="form-control" type="text" id="gameTableSearch" onkeyup="gameTableFilter()" placeholder="Filter by name">
    </div>
    <div class="col-3">
     <button class="btn btn-secondary" onClick="clearGameTableSearch()">Clear</button>
    </div>
  </div>

  <table id="gameTable" class="table dark table-sm table-striped text-center">
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Size</th>
      <th scope="col" data-sort-method="none">Actions</th>
    </tr>
  </thead>
  <tbody>
    {{ range $key, $val := .Lib.Games}}
    <tr>

      <td>{{$key}}</td>
      <td>{{$val.GetSize}}</td>
      <td>
        {{if $.Demo}}
        <span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip"
            data-bs-placement="left" title="Disabled for demo">
          <a href="#" class="btn btn-secondary disabled">Download</a>
        </span>
        {{ else }}
        <a href="/download/{{$key}}" class="btn btn-secondary">Download</a>
        {{ end }}
        <button data-clipboard-text="{{$.ShareLink}}download/{{$key}}" class="btn btn-primary">Copy link</button>
        {{ if $.Local }}
        <button data-bs-target="#delete{{$val.Slug}}Modal" data-bs-toggle="modal" class="btn btn-danger">Delete</button>
        {{ end }}
      </td>
    </tr>
    {{ end }}
    </tbody>
  </table>
</div>

{{ if .Local }}


{{ range $key, $val := .Lib.Games }}
<div class="modal fade" id="delete{{$val.Slug}}Modal" tabindex="-1" aria-labelledby="delete{{$val.Slug}}ModalLabel" aria-hidden="true">

  <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="delete{{$val.Slug}}ModalLabel">
          Delete {{$key}}
        </h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">


        <form class="row row-cols-lg-auto g-3 align-items-center" action="/delete" method="POST">
          <div class="col-12">
            <div class="input-group">
              <div class="input-group-text">
                Are you sure you wish to delete '{{$key}}'?
              </div>
              <input type="hidden" name="name" value= "{{$key}}" />
            </div>
          </div>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
          Close
        </button>
        <input type="submit" class="btn btn-danger" value="Delete" />
      </div>
        </form>
    </div>
  </div>
</div>

{{ end }}


<div class="modal fade" id="installModal" tabindex="-1" aria-labelledby="installModalLabel" aria-hidden="true">

  <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="installModalLabel">
          Install Game
        </h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">


        <form class="row g-3 align-items-center" action="/install" method="GET">
          <div class="col-12">
            <label class="visually-hidden" for="inlineFormInputInstallModal">
              C:\Program Files (x86)\Steam\Steamapps
            </label>
            <div class="input-group">
              <div class="input-group-text">URI:</div>
              <input name="uri"
                     type="text"
                     class="form-control"
                     id="inlineFormInputInstallModal"
                     placeholder="https://10.0.0.123:8899/download/Some Game">
            </div>
          </div>

          <p>
          Enter a URI above, typically this will be another machine on your local network.
          </p>

          <p>
          The URI should return a stream with the Game's data, typically this
          is provided by running another copy of this program on the computer that has
          the game already installed.
          </p>

          <p>
          Simply click "copy link" over there and paste it in here to install.
          </p>

          <p>
          This will force a reload of the entire steam library when complete.
          </p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
          Close
        </button>
        <input type="submit" class="btn btn-primary" value="Submit" />
      </div>
      </form>
    </div>
  </div>
</div>

<!-- Modal -->
<div class="modal fade" id="libraryModal" tabindex="-1" aria-labelledby="libraryModalLabel" aria-hidden="true">

  <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="libraryModalLabel">
          Change Library Path
        </h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">


        <form class="row g-3 align-items-center" action="/setLib" method="GET">
          <div class="col-12">
            <label class="visually-hidden" for="inlineFormInputlibraryModal">
              C:\Program Files (x86)\Steam\Steamapps\common
            </label>
            <div class="input-group">
              <div class="input-group-text">Path:</div>
              <input name="path"
                     type="text"
                     class="form-control"
                     id="inlineFormInputlibraryModal"
                     placeholder="C:\Program Files (x86)\Steam\Steamapps\common">
            </div>
          </div>

          <p>
          Typically you will not need to change this, however if you have
          installed steam games on multiple hard drives you may need to.
          </p>

          <p>
          This will force a reload of the entire steam library.
          </p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
          Close
        </button>
        <input type="submit" class="btn btn-primary" value="Submit" />
      </div>
      </form>
    </div>
  </div>
</div>

{{ end }}

<div class="modal fade" id="versionModal" tabindex="-1"
                      aria-labelledby="versionModalLabel" aria-hidden="true">

  <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="versionModalLabel">
          Version Information
        </h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">

        <pre><code>{{.Version}}</pre></code>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
           Close
        </button>
      </div>
    </div>
  </div>
</div>


</div> <!-- /container -->

<!-- <script src="static/js/bootstrap.min.js"></script> -->
<script src="static/js/bootstrap.bundle.min.js"></script>
<script src="static/js/clipboard.min.js"></script>
<script src="static/js/tablesort/tablesort.min.js"></script>
<script src="static/js/tablesort/sorts/tablesort.filesize.min.js"></script>
<script>
function clipboardNotify(e) {
/*
console.log("Action:", e.action)
console.log("Text:", e.text)
console.log("Trigger:", e.trigger)
*/

var elem = document.getElementById("notificationCopied")
var toast = new bootstrap.Toast(elem)

var content = document.getElementById("notificationCopiedText")
content.innerHTML = "Copied: " + e.text

toast.show()
}
</script>
<script>
  clip = new ClipboardJS('.btn');
  clip1 = new ClipboardJS('#shareLink');

	clip.on('success', clipboardNotify);
	clip1.on('success', clipboardNotify);

  new Tablesort(document.getElementById("gameTable"), {
    })
</script>
<script>
</script>
<script>
  function clearGameTableSearch() {
      document.getElementById("gameTableSearch").value=""
      gameTableFilter()
  }
  function gameTableFilter() {
      var input, filter, table, tr, td, i, txtValue;
      input = document.getElementById("gameTableSearch");
      filter = input.value.toUpperCase();
      table = document.getElementById("gameTable");
      tr = table.getElementsByTagName("tr");

      for (i = 0; i < tr.length; i++) {
          td = tr[i].getElementsByTagName("td")[0];
          if (td) {
              txtValue = td.textContent || td.innerText;
              if (txtValue.toUpperCase().indexOf(filter) > -1) {
                  tr[i].style.display = "";
                } else {
                    tr[i].style.display = "none";
                  }
            }
        }
    }
</script>
<script>
  var tooltipTriggerList =
    [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
  var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl)
    })
</script>
</body>