/**
* 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
Loading...
`); }, 1000); puter.hosting.list().then(function (sites){ setTimeout(function(){ // clear loading clearTimeout(loading); // user has sites if(sites.length > 0){ let h =''; for(let i=0; i< sites.length; i++){ h += ``;
h+= ``;
h+= `${sites[i].root_dir.path}`;
h += `
`;
h += ``;
h += `Disassociate Folder`;
h += `
You haven't published any websites!
`); } }, Date.now() - init_ts < 1000 ? 0 : 2000); }) } $(document).on('click', '.mywebsites-dir-path', function(e){ e = e.target; UIWindow({ path: $(e).attr('data-path'), title: $(e).attr('data-name'), icon: window.icons['folder.svg'], uid: $(e).attr('data-uuid'), is_dir: true, app: 'explorer', }); }) $(document).on('click', '.mywebsites-site-setting', function(e){ const pos = e.target.getBoundingClientRect(); UIContextMenu({ parent_element: e.target, position: {top: pos.top+25, left: pos.left-193}, items: [ //-------------------------------------------------- // Release Address //-------------------------------------------------- { html: `Release Address`, onClick: async function(){ const alert_resp = await UIAlert({ message: `Are you sure you want to release this address?`, buttons:[ { label: 'Yes, Release It', type: 'primary', }, { label: 'Cancel' }, ] }) if(alert_resp !== 'Yes, Release It'){ return; } $.ajax({ url: api_origin + "/delete-site", type: 'POST', data: JSON.stringify({ site_uuid: $(e.target).attr('data-site-uuid'), }), async: false, contentType: "application/json", headers: { "Authorization": "Bearer "+auth_token }, statusCode: { 401: function () { logout(); }, }, success: function (){ $(`.mywebsites-card[data-uuid="${$(e.target).attr('data-site-uuid')}"]`).fadeOut(); } }) } } ] }); }) $(document).on('click', '.mywebsites-dis-dir', function(e){ puter.hosting.delete( // dir $(e.target).attr('data-dir-uuid'), // hostname $(e.target).attr('data-site-uuid'), // success function (){ $(`.mywebsites-no-dir-notice[data-site-uuid="${$(e.target).attr('data-site-uuid')}"]`).show(); $(`.mywebsites-dir-path[data-uuid="${$(e.target).attr('data-dir-uuid')}"]`).remove(); // remove the website badge from all instances of the dir $(`.item[data-uid="${$(e.target).attr('data-dir-uuid')}"]`).find('.item-has-website-badge').fadeOut(300); $(e.target).hide(); } ) }) export default UIWindowMyWebsites