Przeglądaj źródła

Added share embedded code auto generator, fixed reload empty storage pool crash bug

TC pushbot 5 4 lat temu
rodzic
commit
90d61867cf

+ 4 - 4
mod/disk/hybridBackup/hybridBackup.go

@@ -195,11 +195,11 @@ func (m *Manager) Close() error {
 	//Stop the schedule
 	if m != nil {
 		m.StopTicker <- true
-	}
 
-	//Close all database opened by backup task
-	for _, task := range m.Tasks {
-		task.Database.Close()
+		//Close all database opened by backup task
+		for _, task := range m.Tasks {
+			task.Database.Close()
+		}
 	}
 
 	return nil

+ 4 - 2
mod/share/share.go

@@ -370,12 +370,14 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 
 			}
 		} else {
-			if directDownload == true {
+			if directDownload {
 				//Serve the file directly
 				w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+strings.ReplaceAll(url.QueryEscape(filepath.Base(shareOption.FileRealPath)), "+", "%20"))
 				w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
 				http.ServeFile(w, r, shareOption.FileRealPath)
-			} else if directServe == true {
+			} else if directServe {
+				w.Header().Set("Access-Control-Allow-Origin", "*")
+				w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
 				w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
 				http.ServeFile(w, r, shareOption.FileRealPath)
 			} else {

+ 3 - 0
system/share/audio.html

@@ -1,7 +1,10 @@
 <p>Audio File Preview</p>
 <audio id="audioplayer" src="{{preview_url}}" style="width: 100%" controls></audio>
+<textarea id="embeddedCode" class="u-full-width" style="height: 100px;"></textarea>
 <script>
     player=document.getElementById("audioplayer");
     player.volume=0.2;
+
+    $("#embeddedCode").text(`<audio id="audioplayer" src="${location.protocol}//${window.location.hostname}:${window.location.port}{{preview_url}}" style="width: 400px" controls></audio>`);
 </script>
     

+ 5 - 1
system/share/downloadPage.html

@@ -28,6 +28,10 @@
             padding: 20px;
             color: white;
         }
+
+        .filename{
+          word-break: break-word;
+        }
     </style>
     </head>
     <body>
@@ -35,7 +39,7 @@
         <br>
         <div class="container">
             <h5>{{hostname}} File Sharing</h5>
-            <h3>{{filename}}</h3>
+            <h3 class="filename">{{filename}}</h3>
             <div class="row">
                 <div class="one-half column">
                     <table class="u-full-width">

+ 7 - 1
system/share/image.html

@@ -1 +1,7 @@
-<img src="{{preview_url}}" style="width: 100%"/>
+<img src="{{preview_url}}" style="width: 100%"/>
+<textarea id="embeddedCode" class="u-full-width" style="height: 100px;">
+    
+</textarea>
+<script>
+     $("#embeddedCode").text(`<img src="${location.protocol}//${window.location.hostname}:${window.location.port}{{preview_url}}" style="width: 30em"/>`);
+</script>

+ 6 - 0
system/share/video.html

@@ -1,5 +1,11 @@
 <p>Video File Preview</p>
 <video src="{{preview_url}}" style="width:100%" volume="0" controls></video>
+<textarea id="embeddedCode" class="u-full-width" style="height: 100px;">
+    
+</textarea>
 <script>
     document.getElementsByTagName('video')[0].volume = 0.2;
+
+    //Render an embedded code for this video preview
+    $("#embeddedCode").text(`<video src="${location.protocol}//${window.location.hostname}:${window.location.port}{{preview_url}}" style="width:560px; height: 340px; background-color: #000000;" controls></video>`);
 </script>

+ 6 - 7
web/SystemAO/file_system/file_explorer.html

@@ -1376,12 +1376,6 @@
 
             // ============================== FOLDER LISTING FUNCTIONS ====================
             function listDirectory(path, callback=undefined, recordUndo=true){
-                //If current mode is search mode, hide the serach bar
-                if (searchMode == true){
-                    //Hide searchbar and skip refresh list
-                    hideSearchBar(true);
-                }
-
                 var recordPreviousPage = true;
                 if (recordUndo == false){
                     recordPreviousPage = false;
@@ -2224,6 +2218,11 @@
             //=================================== FILE OPERATIONS ========================
 
             function refreshList(){
+                if (searchMode == true){
+                    //Do not allow refresh under serach Mode
+                    return;
+                }
+
                 shiftHold = false;
                 ctrlHold = false;
                 let currentScrollTop = JSON.parse(JSON.stringify($("#folderView").scrollTop()));
@@ -4716,7 +4715,7 @@
         }
 
         function handleSearchBarPress(e){
-            if (e.keyCode == 13){
+            if (e.keyCode == 13 || e.key == "Enter"){
                 e.preventDefault();
                 handleSearch();
             }