123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Share Manager</title>
- <meta name="viewport" content="width=device-width, initial-scale=1" >
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" />
- <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
- <style>
- body{
- background-color: rgb(243, 243, 243);
- }
- </style>
- </head>
- <body>
- <br>
- <div class="ui container">
- <div class="ui segment">
- <h3 class="ui header">
- <img src="img/opr/share.svg">
- <div class="content">
- Shares Manager
- <div class="sub header">All the shared files on the SD card</div>
- </div>
- </h3>
- <table class="ui celled striped table">
- <thead>
- <tr><th colspan="4">
- List of shares on this WebStick
- </th>
- </tr>
- </thead>
- <tbody id="sharesListTable">
- <tr>
- <td colspan="4">
- <i class="ui loading spinner icon"></i> Loading
- </td>
- </tr>
- </tbody>
- </table>
- <button onclick="initShareList();" class="ui basic button"><i class="ui green refresh icon"></i>Refresh List</button>
- <div class="ui divider"></div>
- <b>Share Entry Cleaning</b>
- <p>Some share links might point to files that no longer exists on the SD card. <br>
- Click the "Clean Shares" button below to remove broken share links and regenerate the shared link table.</p>
- <button onclick="runShareCleaning();" class="ui basic button"><i class="ui green recycle icon"></i>Clean Shares</button>
- </div>
- </div>
- <script>
- function initShareList(){
- $("#sharesListTable").html(`<tr>
- <td colspan="4">
- <i class="ui loading spinner icon"></i> Loading
- </td>
- </tr>`);
- $.get("/api/share/list", function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- $("#sharesListTable").html("");
- data.forEach(share => {
- $("#sharesListTable").append(`<tr>
- <td class="collapsing">
- <i class="grey file outline icon"></i> ${share.filename}
- </td>
- <td><i class="yellow folder icon"></i> ${share.filepath}</td>
- <td>${share.shareid}</td>
- <td class="right aligned collapsing">
- <a class="ui basic icon button" href="/share?id=${share.shareid}&download" target="_blank" download="" title="Download"><i class="ui blue download icon"></i></a>
- <a class="ui basic icon button" href="/share?id=${share.shareid}" target="_blank" title="Open Share"><i class="ui linkify green icon"></i></a>
- <button class="ui basic icon button" onclick="removeShareFromList('${share.filename}', '${share.filepath}', '${share.shareid}');" title="Remove Share"><i class="ui red trash icon"></i></button>
- </td>
- </tr>`);
- });
- if (data.length == 0){
- $("#sharesListTable").append(`<tr>
- <td colspan="4">
- <i class="green check circle icon"></i> No shared files on this WebStick
- </td>
- </tr>`);
- }
- }
- });
- }
- initShareList();
- //Remove a share from the share list
- function removeShareFromList(filename, filepath, uuid){
- if (confirm("Confirm share for " + filename + " ?")){
- $.post("/api/share/del?filename=" + filepath, function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- initShareList();
- }
- })
- }
-
- }
- function runShareCleaning(){
- $.get("/api/share/clean", function(data){
- if (data.error != undefined){
- alert(data.error);
- }else{
- initShareList();
- alert("Share cleaning completed");
- }
- })
- }
- </script>
- </body>
- </html>
|