Selaa lähdekoodia

Added unzip here feature

Toby Chui 3 vuotta sitten
vanhempi
commit
7dc981b841

BIN
documents/main logic folw.png


+ 1 - 1
mod/subservice/subservice.go

@@ -275,7 +275,7 @@ func (sr *SubServiceRouter) Launch(servicePath string, startupMode bool) error {
 		//log.Println(cmd.Dir,binaryExecPath)
 
 		//Spawn a new go routine to run this subservice
-		go func(cmdObject *exec.Cmd) {
+		go func(cmd *exec.Cmd) {
 			if err := cmd.Start(); err != nil {
 				panic(err)
 			}

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

@@ -657,6 +657,7 @@
              <button class="ts icon tiny button standard whiteTheme" title="New Folder" onclick="newFolder();"><i class="folder outline icon"></i></button>
              <button class="ts icon tiny button standard whiteTheme" title="Upload" onclick="upload();"><i class="upload icon"></i></button>
              <button class="ts icon tiny button standard whiteTheme" title="Create Zip" onclick="zipFile();"><i class="zip file icon"></i></button>
+             <button class="ts icon tiny button standard whiteTheme" title="Unzip Here" onclick="unzipHere();"><i class="inbox icon"></i></button>
 
              <button class="ts icon tiny button standard whiteTheme" title="Rename" onclick="rename();"><i class="i cursor icon"></i></button>
              <button class="ts icon tiny negative button" title="Delete" onclick="deleteFile();"><i class="trash outline icon"></i></button>
@@ -1089,6 +1090,9 @@
             <div class="item" onclick="zipFile();">
                 <i class="zip file icon"></i> <span locale="contextmenu/zip">Create Zip</span>
             </div>
+            <div class="item zipFileOnly" onclick="unzipHere();">
+                <i class="inbox icon"></i> <span locale="contextmenu/unzip">Unzip Here</span>
+            </div>
             <div class="item" onclick="rename();">
                 <i class="i cursor icon"></i> <span locale="contextmenu/rename">Rename</span>
             </div>
@@ -2162,6 +2166,7 @@
                     $("#contextmenu").find(".vroothide").show();
                     $("#contextmenu").find(".noSelectionOnly").hide();
                     $("#contextmenu").find(".vrootonly").hide();
+                    $("#contextmenu").find(".zipFileOnly").hide();
                     
                     //Hide backup manual
                     $("#contextmenu").find(".backuponly").hide();
@@ -2197,6 +2202,12 @@
                         $("#contextmenu").find(".mobileonly").hide();
                     }
 
+                    $(".fileObject.selected").each(function(){
+                        if ($(this).attr("filename").split(".").pop().toLowerCase() == "zip"){
+                            $(".zipFileOnly").show();
+                        }
+                    });
+
                 });
 
                 //Right click on empty space of the file selector
@@ -2208,6 +2219,7 @@
                         $("#contextmenu").find(".noSelectionOnly").show();
                         $("#contextmenu").find(".allowNoSelection").show();
                         $("#contextmenu").find(".vroothide").show();
+                        $("#contextmenu").find(".zipFileOnly").hide();
 
                         //Calculate the position of the context menu
                         calculateContextMenuOffsets(e);
@@ -2494,13 +2506,74 @@
                 }else{
                     title += applocale.getString("opr/zip/file"," file");
                 }
-                parent.newFloatWindow({
-                    url: "SystemAO/file_system/file_operation.html#" + configHash,
-                    width: 400,
-                    height: 220,
-                    appicon: "SystemAO/file_system/img/selector.png",
-                    title: title
+
+                if (!ao_module_virtualDesktop){
+                    window.open("file_operation.html#" + configHash);
+                }else{
+                    parent.newFloatWindow({
+                        url: "SystemAO/file_system/file_operation.html#" + configHash,
+                        width: 400,
+                        height: 220,
+                        appicon: "SystemAO/file_system/img/selector.png",
+                        title: title
+                    });
+                }
+
+                
+           }
+
+           function unzipHere(){
+                $(".popup").fadeOut('fast');
+
+                //Get a list of zip files selected
+                var unzippingFiles = [];
+                $(".fileObject.selected").each(function(){
+                    var filepath = $(this).attr("filepath");
+                    if ((filepath.split(".").pop()).toLowerCase() == "zip"){
+                        unzippingFiles.push(filepath);
+                    }
                 });
+
+                if(unzippingFiles.length == 0){
+                    msgbox("remove", applocale.getString("opr/zip/nozipfile", "No zip file selected"));
+                    return;
+                }
+
+                //Start unzip progress
+                console.log(unzippingFiles);
+
+                //Unzip and open them to tmp:/
+                var oprConfig = {
+                    opr: "unzip",
+                    src: unzippingFiles,
+                    dest: currentPath,
+                    overwriteMode: "overwrite",
+                    callbackWindowID: ao_module_windowID,
+                    callbackFunction: `callRefresh("${currentPath}")`
+                }
+
+                //Render the dialog title name
+                var configHash = encodeURIComponent(JSON.stringify(oprConfig));
+                var title = applocale.getString("opr/zip/unzipping","Unzipping ") + unzippingFiles.length;
+                if (unzippingFiles.length > 1){
+                    title += applocale.getString("opr/zip/files", " files");
+                }else{
+                    title += applocale.getString("opr/zip/file"," file");
+                }
+
+            
+                if (!ao_module_virtualDesktop){
+                    window.open("file_operation.html#" + configHash);
+                }else{
+                    parent.newFloatWindow({
+                        url: "SystemAO/file_system/file_operation.html#" + configHash,
+                        width: 400,
+                        height: 220,
+                        appicon: "SystemAO/file_system/img/selector.png",
+                        title: title,
+                    });
+                }
+
            }
 
             let renameFileObjects = [];

+ 12 - 0
web/SystemAO/locale/file_explorer.json

@@ -93,6 +93,8 @@
                 "opr/openwith/cancel": "取消",
 
                 "opr/zip/zipping": "正在壓縮 ",
+                "opr/zip/unzipping": "正在解壓縮 ",
+                "opr/zip/nozipfile": "沒有已選擇的壓縮檔",
                 "opr/zip/file": " 個檔案",
                 "opr/zip/files": " 個檔案",
 
@@ -110,6 +112,7 @@
                 "contextmenu/newFolder": "新增資料夾",
                 "contextmenu/upload": "上載",
                 "contextmenu/zip": "建立壓縮檔",
+                "contextmenu/unzip": "解壓縮至此",
                 "contextmenu/rename": "重新命名",
                 "contextmenu/delete": "刪除",
                 "contextmenu/backup": "備份及還原",
@@ -181,6 +184,7 @@
                 "New Folder": "新增資料夾",
                 "Upload": "上載",
                 "Create Zip": "建立壓縮檔",
+                "Unzip Here": "解壓縮至此",
                 "Rename": "重新命名",
                 "Delete": "刪除",
                 "Refresh": "重新整理",
@@ -294,6 +298,8 @@
                 "opr/openwith/cancel": "取消",
 
                 "opr/zip/zipping": "正在壓縮 ",
+                "opr/zip/unzipping": "正在解壓縮 ",
+                "opr/zip/nozipfile": "沒有已選擇的壓縮檔",
                 "opr/zip/file": " 個檔案",
                 "opr/zip/files": " 個檔案",
 
@@ -311,6 +317,7 @@
                 "contextmenu/newFolder": "新增資料夾",
                 "contextmenu/upload": "上載",
                 "contextmenu/zip": "建立壓縮檔",
+                "contextmenu/unzip": "解壓縮至此",
                 "contextmenu/rename": "重新命名",
                 "contextmenu/delete": "刪除",
                 "contextmenu/backup": "備份及還原",
@@ -379,6 +386,7 @@
                 "New Folder": "新增資料夾",
                 "Upload": "上載",
                 "Create Zip": "建立壓縮檔",
+                "Unzip Here": "解壓縮至此",
                 "Rename": "重新命名",
                 "Delete": "刪除",
                 "Refresh": "重新整理",
@@ -492,6 +500,8 @@
                 "opr/openwith/cancel": "取消",
 
                 "opr/zip/zipping": "正在压缩 ",
+                "opr/zip/unzipping": "正在解压缩 ",
+                "opr/zip/nozipfile": "没有已选择的压缩文件",
                 "opr/zip/file": " 个文件",
                 "opr/zip/files": " 个文件",
 
@@ -509,6 +519,7 @@
                 "contextmenu/newFolder": "新建文件夹",
                 "contextmenu/upload": "上传",
                 "contextmenu/zip": "建立压缩档",
+                "contextmenu/unzip": "解压缩至此",
                 "contextmenu/rename": "重新命名",
                 "contextmenu/delete": "删除",
                 "contextmenu/backup": "备份及还原",
@@ -577,6 +588,7 @@
                 "New Folder": "新增文件夹",
                 "Upload": "上传",
                 "Create Zip": "建立压缩档",
+                "Unzip Here": "解压缩至此",
                 "Rename": "重新命名",
                 "Delete": "删除",
                 "Refresh": "重新整理",