-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from HeyPuter/settings
Implement the Settings App
- Loading branch information
Showing
42 changed files
with
1,273 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* 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/>. | ||
*/ | ||
|
||
// About | ||
function UITabAbout(){ | ||
let h = ``; | ||
|
||
h += `<div class="settings-content active" data-settings="about">`; | ||
h += `<div class="about-container">` | ||
h += `<div class="about"> | ||
<a href="https://puter.com" target="_blank" class="logo"><img src="/images/logo.png"></a> | ||
<p class="description">${i18n('puter_description')}</p> | ||
<p class="links"> | ||
<a href="mailto:[email protected]" target="_blank">[email protected]</a> | ||
<span style="color: #CCC;">•</span> | ||
<a href="https://docs.puter.com" target="_blank">${i18n('developers')}</a> | ||
<span style="color: #CCC;">•</span> | ||
<a href="https://status.puter.com" target="_blank">${i18n('status')}</a> | ||
<span style="color: #CCC;">•</span> | ||
<a href="https://puter.com/terms" target="_blank">${i18n('terms')}</a> | ||
<span style="color: #CCC;">•</span> | ||
<a href="https://puter.com/privacy" target="_blank">${i18n('privacy')}</a> | ||
<span style="color: #CCC;">•</span> | ||
<a href="#" class="show-credits">${i18n('credits')}</a> | ||
</p> | ||
<div class="social-links"> | ||
<a href="https://twitter.com/HeyPuter/" target="_blank"> | ||
<svg viewBox="0 0 24 24" aria-hidden="true" style="opacity: 0.7;"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg> | ||
</a> | ||
<a href="https://github.com/HeyPuter/" target="_blank"> | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"> | ||
<g transform="translate(0, 0)"> | ||
<path fill-rule="evenodd" clip-rule="evenodd" fill="#5a606b" d="M24,0.6c-13.3,0-24,10.7-24,24c0,10.6,6.9,19.6,16.4,22.8 c1.2,0.2,1.6-0.5,1.6-1.2c0-0.6,0-2.1,0-4.1c-6.7,1.5-8.1-3.2-8.1-3.2c-1.1-2.8-2.7-3.5-2.7-3.5c-2.2-1.5,0.2-1.5,0.2-1.5 c2.4,0.2,3.7,2.5,3.7,2.5c2.1,3.7,5.6,2.6,7,2c0.2-1.6,0.8-2.6,1.5-3.2c-5.3-0.6-10.9-2.7-10.9-11.9c0-2.6,0.9-4.8,2.5-6.4 c-0.2-0.6-1.1-3,0.2-6.4c0,0,2-0.6,6.6,2.5c1.9-0.5,4-0.8,6-0.8c2,0,4.1,0.3,6,0.8c4.6-3.1,6.6-2.5,6.6-2.5c1.3,3.3,0.5,5.7,0.2,6.4 c1.5,1.7,2.5,3.8,2.5,6.4c0,9.2-5.6,11.2-11,11.8c0.9,0.7,1.6,2.2,1.6,4.4c0,3.2,0,5.8,0,6.6c0,0.6,0.4,1.4,1.7,1.2 C41.1,44.2,48,35.2,48,24.6C48,11.3,37.3,0.6,24,0.6z"> | ||
</path> | ||
</g> | ||
</svg> | ||
</a> | ||
<a href="https://discord.gg/PQcx7Teh8u" target="_blank"> | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M19.837,20.3a2.562,2.562,0,0,0,0,5.106,2.562,2.562,0,0,0,0-5.106Zm8.4,0a2.562,2.562,0,1,0,2.346,2.553A2.45,2.45,0,0,0,28.232,20.3Z" fill="#444444" data-color="color-2"></path> <path d="M39.41,1H8.59A4.854,4.854,0,0,0,4,6V37a4.482,4.482,0,0,0,4.59,4.572H34.672l-1.219-4.255L36.4,40.054,39.18,42.63,44,47V6A4.854,4.854,0,0,0,39.41,1ZM30.532,31.038s-.828-.989-1.518-1.863a7.258,7.258,0,0,0,4.163-2.737A13.162,13.162,0,0,1,30.532,27.8a15.138,15.138,0,0,1-3.335.989,16.112,16.112,0,0,1-5.957-.023,19.307,19.307,0,0,1-3.381-.989,13.112,13.112,0,0,1-2.622-1.357,7.153,7.153,0,0,0,4.025,2.714c-.69.874-1.541,1.909-1.541,1.909-5.083-.161-7.015-3.5-7.015-3.5a30.8,30.8,0,0,1,3.312-13.409,11.374,11.374,0,0,1,6.463-2.415l.23.276a15.517,15.517,0,0,0-6.049,3.013s.506-.276,1.357-.667a17.272,17.272,0,0,1,5.221-1.449,2.266,2.266,0,0,1,.391-.046,19.461,19.461,0,0,1,4.646-.046A18.749,18.749,0,0,1,33.2,15.007a15.307,15.307,0,0,0-5.727-2.921l.322-.368a11.374,11.374,0,0,1,6.463,2.415A30.8,30.8,0,0,1,37.57,27.542S35.615,30.877,30.532,31.038Z" fill="#444444"></path></g></svg> </a> | ||
<a href="https://www.linkedin.com/company/puter/" target="_blank"> | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"> | ||
<g transform="translate(0, 0)"> | ||
<path fill="#5a606b" d="M46,0H2C0.9,0,0,0.9,0,2v44c0,1.1,0.9,2,2,2h44c1.1,0,2-0.9,2-2V2C48,0.9,47.1,0,46,0z M14.2,40.9H7.1V18 h7.1V40.9z M10.7,14.9c-2.3,0-4.1-1.8-4.1-4.1c0-2.3,1.8-4.1,4.1-4.1c2.3,0,4.1,1.8,4.1,4.1C14.8,13,13,14.9,10.7,14.9z M40.9,40.9 h-7.1V29.8c0-2.7,0-6.1-3.7-6.1c-3.7,0-4.3,2.9-4.3,5.9v11.3h-7.1V18h6.8v3.1h0.1c0.9-1.8,3.3-3.7,6.7-3.7c7.2,0,8.5,4.7,8.5,10.9 V40.9z"> | ||
</path> | ||
</g> | ||
</svg> | ||
</a> | ||
</div> | ||
</div> | ||
<div class="version"></div> | ||
<dialog class="credits"> | ||
<div class="credit-content"> | ||
<p style="margin: 0; font-size: 18px; text-align: center;">${i18n('oss_code_and_content')}</p> | ||
<div style="max-height: 300px; overflow-y: scroll;"> | ||
<ul style="padding-left: 25px; padding-top:15px;"> | ||
<li>FileSaver.js <a target="_blank" href="https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md">${i18n('license')}</a></li> | ||
<li>html-entities <a target="_blank" href="https://github.com/mdevils/html-entities/blob/master/LICENSE">${i18n('license')}</a></li> | ||
<li>iro.js <a target="_blank" href="https://github.com/jaames/iro.js/blob/master/LICENSE.txt">${i18n('license')}</a></li> | ||
<li>jQuery <a target="_blank" href="https://jquery.org/license/">${i18n('license')}</a></li> | ||
<li>jQuery-dragster <a target="_blank" href="https://github.com/catmanjan/jquery-dragster/blob/master/LICENSE">${i18n('license')}</a></li> | ||
<li>jQuery-menu-aim <a target="_blank" href="https://github.com/kamens/jQuery-menu-aim?tab=readme-ov-file#faq">${i18n('license')}</a></li> | ||
<li>jQuery UI <a target="_blank" href="https://jquery.org/license/">${i18n('license')}</a></li> | ||
<li>lodash <a target="_blank" href="https://lodash.com/license">${i18n('license')}</a></li> | ||
<li>mime <a target="_blank" href="https://github.com/broofa/mime/blob/main/LICENSE">${i18n('license')}</a></li> | ||
<li>qrcodejs <a target="_blank" href="https://github.com/davidshimjs/qrcodejs/blob/master/LICENSE">${i18n('license')}</a></li> | ||
<li>Selection <a target="_blank" href="https://github.com/simonwep/selection/blob/master/LICENSE">${i18n('license')}</a></li> | ||
<li>socket.io <a target="_blank" href="https://github.com/socketio/socket.io/blob/main/LICENSE">${i18n('license')}</a></li> | ||
<li>Wallpaper by <a target="_blank" href="https://unsplash.com/@fakurian?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Milad Fakurian</a> on <a target="_blank" href="https://unsplash.com/photos/blue-orange-and-yellow-wallpaper-E8Ufcyxz514?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</dialog> | ||
`; | ||
h += `</div>`; | ||
h += `</div>`; | ||
|
||
return h; | ||
} | ||
export default UITabAbout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* 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' | ||
import UIWindowFinalizeUserDeletion from './UIWindowFinalizeUserDeletion.js' | ||
|
||
async function UIWindowConfirmUserDeletion(options){ | ||
return new Promise(async (resolve) => { | ||
options = options ?? {}; | ||
|
||
let h = ''; | ||
h += `<div style="padding: 20px;">`; | ||
h += `<div class="generic-close-window-button disable-user-select"> × </div>`; | ||
h += `<img src="${window.icons['danger.svg']}" class="account-deletion-confirmation-icon">`; | ||
h += `<p class="account-deletion-confirmation-prompt">${i18n('confirm_delete_user')}</p>`; | ||
h += `<button class="button button-block button-danger proceed-with-user-deletion">${i18n('proceed_with_account_deletion')}</button>`; | ||
h += `<button class="button button-block button-secondary cancel-user-deletion">${i18n('cancel')}</button>`; | ||
h += `</div>`; | ||
|
||
const el_window = await UIWindow({ | ||
title: i18n('confirm_delete_user_title'), | ||
icon: null, | ||
uid: null, | ||
is_dir: false, | ||
body_content: h, | ||
has_head: false, | ||
selectable_body: false, | ||
draggable_body: false, | ||
allow_context_menu: false, | ||
is_draggable: true, | ||
is_resizable: false, | ||
is_droppable: false, | ||
init_center: true, | ||
allow_native_ctxmenu: true, | ||
allow_user_select: true, | ||
backdrop: true, | ||
onAppend: function(el_window){ | ||
}, | ||
width: 500, | ||
dominant: true, | ||
window_css: { | ||
height: 'initial', | ||
padding: '0', | ||
border: 'none', | ||
boxShadow: '0 0 10px rgba(0,0,0,.2)', | ||
borderRadius: '5px', | ||
backgroundColor: 'white', | ||
color: 'black', | ||
}, | ||
}); | ||
|
||
$(el_window).find('.generic-close-window-button').on('click', function(){ | ||
$(el_window).close(); | ||
}); | ||
|
||
$(el_window).find('.cancel-user-deletion').on('click', function(){ | ||
$(el_window).close(); | ||
}); | ||
|
||
$(el_window).find('.proceed-with-user-deletion').on('click', function(){ | ||
UIWindowFinalizeUserDeletion(); | ||
$(el_window).close(); | ||
}); | ||
}) | ||
} | ||
|
||
export default UIWindowConfirmUserDeletion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/** | ||
* 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' | ||
|
||
async function UIWindowFinalizeUserDeletion(options){ | ||
return new Promise(async (resolve) => { | ||
options = options ?? {}; | ||
|
||
let h = ''; | ||
|
||
// if user is temporary, ask them to type in 'confirm' to delete their account | ||
if(user.is_temp){ | ||
h += `<div style="padding: 20px;">`; | ||
h += `<div class="generic-close-window-button disable-user-select"> × </div>`; | ||
h += `<img src="${window.icons['danger.svg']}" class="account-deletion-confirmation-icon">`; | ||
h += `<p class="account-deletion-confirmation-prompt">${i18n('type_confirm_to_delete_account')}</p>`; | ||
// error message | ||
h += `<div class="error-message"></div>`; | ||
// input field | ||
h += `<input type="text" class="confirm-temporary-user-deletion" placeholder="${i18n('type_confirm_to_delete_account')}">`; | ||
h += `<button class="button button-block button-danger proceed-with-user-deletion">${i18n('delete_account')}</button>`; | ||
h += `<button class="button button-block button-secondary cancel-user-deletion">${i18n('cancel')}</button>`; | ||
h += `</div>`; | ||
} | ||
// otherwise ask for password | ||
else{ | ||
h += `<div style="padding: 20px;">`; | ||
h += `<div class="generic-close-window-button disable-user-select"> × </div>`; | ||
h += `<img src="${window.icons['danger.svg']}" class="account-deletion-confirmation-icon">`; | ||
h += `<p class="account-deletion-confirmation-prompt">${i18n('enter_password_to_confirm_delete_user')}</p>`; | ||
// error message | ||
h += `<div class="error-message"></div>`; | ||
// input field | ||
h += `<input type="password" class="confirm-user-deletion-password" placeholder="${i18n('current_password')}">`; | ||
h += `<button class="button button-block button-danger proceed-with-user-deletion">${i18n('delete_account')}</button>`; | ||
h += `<button class="button button-block button-secondary cancel-user-deletion">${i18n('cancel')}</button>`; | ||
h += `</div>`; | ||
} | ||
|
||
const el_window = await UIWindow({ | ||
title: i18n('confirm_delete_user_title'), | ||
icon: null, | ||
uid: null, | ||
is_dir: false, | ||
body_content: h, | ||
has_head: false, | ||
selectable_body: false, | ||
draggable_body: false, | ||
allow_context_menu: false, | ||
is_draggable: true, | ||
is_resizable: false, | ||
is_droppable: false, | ||
init_center: true, | ||
allow_native_ctxmenu: true, | ||
allow_user_select: true, | ||
backdrop: true, | ||
onAppend: function(el_window){ | ||
}, | ||
width: 500, | ||
dominant: false, | ||
window_css: { | ||
height: 'initial', | ||
padding: '0', | ||
border: 'none', | ||
boxShadow: '0 0 10px rgba(0,0,0,.2)', | ||
} | ||
}); | ||
|
||
$(el_window).find('.generic-close-window-button').on('click', function(){ | ||
$(el_window).close(); | ||
}); | ||
|
||
$(el_window).find('.cancel-user-deletion').on('click', function(){ | ||
$(el_window).close(); | ||
}); | ||
|
||
$(el_window).find('.proceed-with-user-deletion').on('click', function(){ | ||
$(el_window).find('.error-message').hide(); | ||
// if user is temporary, check if they typed 'confirm' | ||
if(user.is_temp){ | ||
if($(el_window).find('.confirm-temporary-user-deletion').val() !== 'confirm'){ | ||
$(el_window).find('.error-message').html(i18n('type_confirm_to_delete_account'), false); | ||
$(el_window).find('.error-message').show(); | ||
return; | ||
} | ||
} | ||
// otherwise, check if password is correct | ||
else{ | ||
if($(el_window).find('.confirm-user-deletion-password').val() === ''){ | ||
$(el_window).find('.error-message').html(i18n('all_fields_required'), false); | ||
$(el_window).find('.error-message').show(); | ||
return; | ||
} | ||
} | ||
|
||
// delete user | ||
$.ajax({ | ||
url: api_origin + "/delete-own-user", | ||
type: 'POST', | ||
async: true, | ||
contentType: "application/json", | ||
headers: { | ||
"Authorization": "Bearer " + auth_token | ||
}, | ||
data: JSON.stringify({ | ||
password: $(el_window).find('.confirm-user-deletion-password').val(), | ||
}), | ||
statusCode: { | ||
401: function () { | ||
logout(); | ||
}, | ||
400: function(){ | ||
$(el_window).find('.error-message').html(i18n('incorrect_password')); | ||
$(el_window).find('.error-message').show(); | ||
} | ||
}, | ||
success: function(data){ | ||
if(data.success){ | ||
// mark user as deleted | ||
window.user.deleted = true; | ||
// log user out | ||
logout(); | ||
} | ||
else{ | ||
$(el_window).find('.error-message').html(data.error); | ||
$(el_window).find('.error-message').show(); | ||
|
||
} | ||
} | ||
}); | ||
}); | ||
}) | ||
} | ||
|
||
export default UIWindowFinalizeUserDeletion; |
Oops, something went wrong.