Pārlūkot izejas kodu

Deprecate and remove `UIWindowConfirmDownload`

Nariman Jelveh 1 gadu atpakaļ
vecāks
revīzija
9859a32e15
3 mainītis faili ar 0 papildinājumiem un 167 dzēšanām
  1. 0 1
      src/UI/UIDesktop.js
  2. 0 91
      src/UI/UIWindowConfirmDownload.js
  3. 0 75
      src/helpers.js

+ 0 - 1
src/UI/UIDesktop.js

@@ -817,7 +817,6 @@ async function UIDesktop(options){
     //-------------------------------------------
     //-------------------------------------------
     if(!is_embedded && !window.is_fullpage_mode){
     if(!is_embedded && !window.is_fullpage_mode){
         refresh_item_container(el_desktop, {fadeInItems: true})
         refresh_item_container(el_desktop, {fadeInItems: true})
-        window.launch_download_from_url();
     }
     }
 
 
     // -------------------------------------------
     // -------------------------------------------

+ 0 - 91
src/UI/UIWindowConfirmDownload.js

@@ -1,91 +0,0 @@
-/**
- * Copyright (C) 2024 Puter Technologies Inc.
- *
- * This file is part of Puter.
- *
- * Puter is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- * 
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-import UIWindow from './UIWindow.js'
-
-// todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
-async function UIWindowConfirmDownload(options){
-    return new Promise(async (resolve) => {
-        let h = '';
-        h += `<div>`;
-            // Confirm download
-            h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
-                // Message
-                h += `<p style="font-weight:bold;">Do you want to download this file?</p>`;
-                h += `<div style="overflow:hidden; float:left; width: 100px; height: 100px; display:flex; display: flex; justify-content: center; align-items: center;">`;
-                    h += `<img style="float:left; margin-right: 7px; width: 60px; height: 60px; filter: drop-shadow(0px 0px 1px rgba(102, 102, 102, 1));" src="${html_encode((await item_icon({is_dir: options.is_dir === '1' || options.is_dir === 'true', type: options.type, name: options.name})).image)}" />`;
-                h += `</div>`;
-                // Item information
-                h += `<div  style="overflow:hidden;">`;
-                    // Name
-                    h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">${i18n('name')}:</span> ${options.name ?? options.url}</p>`;
-                    // Type
-                    h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">${i18n('type')}:</span> ${options.is_dir === '1' || options.is_dir === 'true' ? 'Folder' : options.type  ?? 'Unknown File Type'}</p>`;
-                    // Source
-                    h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">${i18n('from')}:</span> ${options.source}</p>`;
-                h += `</div>`;
-            h += `</div>`;
-            // Download
-            h += `<button style="float:right; margin-top: 15px; margin-right: -2px; margin-left:10px;" class="button button-small button-primary btn-download-confirm">${i18n('download')}</button>`;
-            // Cancel
-            h += `<button style="float:right; margin-top: 15px;" class="button button-small btn-download-cancel">${i18n('cancel')}</button>`;
-        h +=`</div>`;
-
-        const el_window = await UIWindow({
-            title: `Upload`,
-            icon: window.icons[`app-icon-uploader.svg`],
-            uid: null,
-            is_dir: false,
-            body_content: h,
-            has_head: false,
-            selectable_body: false,
-            draggable_body: true,
-            allow_context_menu: false,
-            is_resizable: false,
-            is_droppable: false,
-            init_center: true,
-            allow_native_ctxmenu: false,
-            allow_user_select: false,
-            window_class: 'window-upload-progress',
-            width: 450,
-            dominant: true,
-            window_css:{
-                height: 'initial',
-            },
-            body_css: {
-                padding: '22px',
-                width: 'initial',
-                'background-color': 'rgba(231, 238, 245, .95)',
-                'backdrop-filter': 'blur(3px)',
-            }    
-        });
-
-        $(el_window).find('.btn-download-confirm').on('click submit', function(e){
-            $(el_window).close();
-            resolve(true);
-        })
-
-        $(el_window).find('.btn-download-cancel').on('click submit', function(e){
-            $(el_window).close();
-            resolve(false);
-        })
-    })
-}
-
-export default UIWindowConfirmDownload

+ 0 - 75
src/helpers.js

@@ -24,7 +24,6 @@ import UIItem from './UI/UIItem.js'
 import UIWindow from './UI/UIWindow.js'
 import UIWindow from './UI/UIWindow.js'
 import UIWindowLogin from './UI/UIWindowLogin.js';
 import UIWindowLogin from './UI/UIWindowLogin.js';
 import UIWindowSaveAccount from './UI/UIWindowSaveAccount.js';
 import UIWindowSaveAccount from './UI/UIWindowSaveAccount.js';
-import UIWindowConfirmDownload from './UI/UIWindowConfirmDownload.js';
 import UIWindowCopyProgress from './UI/UIWindowCopyProgress.js';
 import UIWindowCopyProgress from './UI/UIWindowCopyProgress.js';
 import UIWindowMoveProgress from './UI/UIWindowMoveProgress.js';
 import UIWindowMoveProgress from './UI/UIWindowMoveProgress.js';
 import UIWindowNewFolderProgress from './UI/UIWindowNewFolderProgress.js';
 import UIWindowNewFolderProgress from './UI/UIWindowNewFolderProgress.js';
@@ -1097,80 +1096,6 @@ window.show_save_account_notice_if_needed = function(message){
     })
     })
 }
 }
 
 
-window.launch_download_from_url = async function(){
-    // get url query params
-    const url_query_params = new URLSearchParams(window.location.search);
-
-    // is this download?
-    if(url_query_params.has('download')){
-        let url = url_query_params.get('download');
-        let name = url_query_params.get('name');
-        let is_dir = url_query_params.get('is_dir');
-        let url_obj;
-
-        // if url doesn't have a protocol, add http://
-        if(!url.startsWith('http://') && !url.startsWith('https://')){
-            url = 'http://' + url;
-        }
-
-        // parse url
-        try{
-            url_obj = new URL(url);
-        }catch(e){
-            UIAlert("Invalid download URL.");
-            return;
-        }
-
-        // get hostname from url
-        let hostname = url_obj.hostname;
-
-        // name
-        if(!name)
-            name = url.split('/').pop().split('#')[0].split('?')[0];
-
-        // determine file type from url
-        let file_type = mime.getType(name);
-
-        // confirm download
-        if(await UIWindowConfirmDownload({url: url, name: name, source: hostname, type: file_type, is_dir: is_dir})){
-            // download progress tracker
-            let dl_op_id = operation_id++;
-
-            // upload progress tracker defaults
-            window.progress_tracker[dl_op_id] = [];
-            window.progress_tracker[dl_op_id][0] = {};
-            window.progress_tracker[dl_op_id][0].total = 0;
-            window.progress_tracker[dl_op_id][0].ajax_uploaded = 0;
-            window.progress_tracker[dl_op_id][0].cloud_uploaded = 0;
-
-            const progress_window = await UIWindowDownloadProgress({operation_id: dl_op_id, item_name: name});
-
-            const res = await download({
-                url: url, 
-                name: name,
-                dest_path: desktop_path, 
-                auth_token: auth_token, 
-                api_origin: api_origin,
-                dedupe_name: true,
-                overwrite: false,
-                operation_id: dl_op_id,
-                item_upload_id: 0,
-                success: function(res){
-                    $(progress_window).close();
-                },
-                error: function(err){
-                    UIAlert(err && err.message ? err.message : "Download failed.");
-                    $(progress_window).close();
-                }
-            });
-
-            // clear window URL
-            window.history.pushState(null, document.title, '/');
-        }
-        
-    }
-}
-
 window.onpopstate = (event) => {
 window.onpopstate = (event) => {
     if(event.state !== null && event.state.window_id !== null){
     if(event.state !== null && event.state.window_id !== null){
         $(`.window[data-id="${event.state.window_id}"]`).focusWindow();
         $(`.window[data-id="${event.state.window_id}"]`).focusWindow();