chore: Clarify usage of window fields in Settings app

Solves these eslint issues:

/puter/src/UI/Settings/UITabAccount.js
  34:13   error  'user' is not defined  no-undef
  47:99   error  'user' is not defined  no-undef
  55:12   error  'user' is not defined  no-undef
  59:105  error  'user' is not defined  no-undef

/puter/src/UI/Settings/UITabLanguage.js
  35:37  error  'listSupportedLanguages' is not defined  no-undef

/puter/src/UI/Settings/UITabUsage.js
   45:18  error  'api_origin' is not defined   no-undef
   50:46  error  'auth_token' is not defined   no-undef
   54:21  error  'logout' is not defined       no-undef
   96:18  error  'api_origin' is not defined   no-undef
  101:46  error  'auth_token' is not defined   no-undef
  105:21  error  'logout' is not defined       no-undef
  116:51  error  'byte_format' is not defined  no-undef
  123:41  error  'byte_format' is not defined  no-undef
  124:45  error  'byte_format' is not defined  no-undef

/puter/src/UI/Settings/UIWindowChangeEmail.js
   96:18  error  'api_origin' is not defined  no-undef
  100:44  error  'auth_token' is not defined  no-undef

/puter/src/UI/Settings/UIWindowFinalizeUserDeletion.js
   29:12  error  'user' is not defined        no-undef
   97:16  error  'user' is not defined        no-undef
  115:22  error  'api_origin' is not defined  no-undef
  120:50  error  'auth_token' is not defined  no-undef
  127:25  error  'logout' is not defined      no-undef
  139:25  error  'logout' is not defined      no-undef

/puter/src/UI/Settings/UIWindowSettings.js
  48:162  error  'icons' is not defined  no-undef
  86:13   error  Duplicate key 'height'  no-dupe-keys
This commit is contained in:
Sam Atkins
2024-05-01 14:31:26 +01:00
parent d17e0b80b3
commit c2ef0a9578
6 changed files with 23 additions and 24 deletions

View File

@@ -31,7 +31,7 @@ export default {
let h = `<h1>${i18n('account')}</h1>`;
// change password button
if(!user.is_temp){
if(!window.user.is_temp){
h += `<div class="settings-card">`;
h += `<strong>${i18n('password')}</strong>`;
h += `<div style="flex-grow:1;">`;
@@ -44,7 +44,7 @@ export default {
h += `<div class="settings-card">`;
h += `<div>`;
h += `<strong style="display:block;">${i18n('username')}</strong>`;
h += `<span class="username" style="display:block; margin-top:5px;">${html_encode(user.username)}</span>`;
h += `<span class="username" style="display:block; margin-top:5px;">${html_encode(window.user.username)}</span>`;
h += `</div>`;
h += `<div style="flex-grow:1;">`;
h += `<button class="button change-username" style="float:right;">${i18n('change_username')}</button>`;
@@ -52,11 +52,11 @@ export default {
h += `</div>`;
// change email button
if(user.email){
if(window.user.email){
h += `<div class="settings-card">`;
h += `<div>`;
h += `<strong style="display:block;">${i18n('email')}</strong>`;
h += `<span class="user-email" style="display:block; margin-top:5px;">${html_encode(user.email)}</span>`;
h += `<span class="user-email" style="display:block; margin-top:5px;">${html_encode(window.user.email)}</span>`;
h += `</div>`;
h += `<div style="flex-grow:1;">`;
h += `<button class="button change-email" style="float:right;">${i18n('change_email')}</button>`;

View File

@@ -32,7 +32,7 @@ export default {
</div>`;
// list of languages
const available_languages = listSupportedLanguages();
const available_languages = window.listSupportedLanguages();
h += `<div class="language-list">`;
for (let lang of available_languages) {
h += `<div class="language-item ${window.locale === lang.code ? 'active': ''}" data-lang="${lang.code}" data-english-name="${html_encode(lang.english_name)}">${html_encode(lang.name)}</div>`;

View File

@@ -42,16 +42,16 @@ export default {
},
init: ($el_window) => {
$.ajax({
url: api_origin + "/drivers/usage",
url: window.api_origin + "/drivers/usage",
type: 'GET',
async: true,
contentType: "application/json",
headers: {
"Authorization": "Bearer " + auth_token
"Authorization": "Bearer " + window.auth_token
},
statusCode: {
401: function () {
logout();
window.logout();
},
},
success: function (res) {
@@ -93,16 +93,16 @@ export default {
// df
$.ajax({
url: api_origin + "/df",
url: window.api_origin + "/df",
type: 'GET',
async: true,
contentType: "application/json",
headers: {
"Authorization": "Bearer " + auth_token
"Authorization": "Bearer " + window.auth_token
},
statusCode: {
401: function () {
logout();
window.logout();
},
},
success: function (res) {
@@ -113,15 +113,15 @@ export default {
let host_usage_percentage = 0;
if ( res.host_used ) {
$('#storage-puter-used').html(byte_format(res.used));
$('#storage-puter-used').html(window.byte_format(res.used));
$('#storage-puter-used-w').show();
general_used = res.host_used;
host_usage_percentage = ((res.host_used - res.used) / res.capacity * 100).toFixed(0);
}
$('#storage-used').html(byte_format(general_used));
$('#storage-capacity').html(byte_format(res.capacity));
$('#storage-used').html(window.byte_format(general_used));
$('#storage-capacity').html(window.byte_format(res.capacity));
$('#storage-used-percent').html(
usage_percentage + '%' +
(host_usage_percentage > 0

View File

@@ -93,11 +93,11 @@ async function UIWindowChangeEmail(options){
$(el_window).find('.new-email').attr('disabled', true);
$.ajax({
url: api_origin + "/change_email/start",
url: window.api_origin + "/change_email/start",
type: 'POST',
async: true,
headers: {
"Authorization": "Bearer "+auth_token
"Authorization": "Bearer "+window.auth_token
},
contentType: "application/json",
data: JSON.stringify({

View File

@@ -26,7 +26,7 @@ async function UIWindowFinalizeUserDeletion(options){
let h = '';
// if user is temporary, ask them to type in 'confirm' to delete their account
if(user.is_temp){
if(window.user.is_temp){
h += `<div style="padding: 20px;">`;
h += `<div class="generic-close-window-button disable-user-select"> &times; </div>`;
h += `<img src="${window.icons['danger.svg']}" class="account-deletion-confirmation-icon">`;
@@ -94,7 +94,7 @@ async function UIWindowFinalizeUserDeletion(options){
$(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(window.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();
@@ -112,19 +112,19 @@ async function UIWindowFinalizeUserDeletion(options){
// delete user
$.ajax({
url: api_origin + "/delete-own-user",
url: window.api_origin + "/delete-own-user",
type: 'POST',
async: true,
contentType: "application/json",
headers: {
"Authorization": "Bearer " + auth_token
"Authorization": "Bearer " + window.auth_token
},
data: JSON.stringify({
password: $(el_window).find('.confirm-user-deletion-password').val(),
}),
statusCode: {
401: function () {
logout();
window.logout();
},
400: function(){
$(el_window).find('.error-message').html(i18n('incorrect_password'));
@@ -136,7 +136,7 @@ async function UIWindowFinalizeUserDeletion(options){
// mark user as deleted
window.user.deleted = true;
// log user out
logout();
window.logout();
}
else{
$(el_window).find('.error-message').html(html_encode(data.error));

View File

@@ -45,7 +45,7 @@ async function UIWindowSettings(options){
// side bar
h += `<div class="settings-sidebar disable-user-select">`;
tabs.forEach((tab, i) => {
h += `<div class="settings-sidebar-item disable-user-select ${i === 0 ? 'active' : ''}" data-settings="${tab.id}" style="background-image: url(${icons[tab.icon]});">${i18n(tab.title_i18n_key)}</div>`;
h += `<div class="settings-sidebar-item disable-user-select ${i === 0 ? 'active' : ''}" data-settings="${tab.id}" style="background-image: url(${window.icons[tab.icon]});">${i18n(tab.title_i18n_key)}</div>`;
});
h += `</div>`;
@@ -82,7 +82,6 @@ async function UIWindowSettings(options){
allow_user_select: true,
backdrop: false,
width: 800,
height: 500,
height: 'auto',
dominant: true,
show_in_taskbar: false,