cleaning and corrections

This commit is contained in:
zuzanna-maria 2024-06-18 13:02:46 +01:00
parent 716442f348
commit 6993487d2a
4 changed files with 221 additions and 259 deletions

View file

@ -48,7 +48,7 @@ define([
) {
//XXX
Messages.admin_appSelection = 'App configuration saved'
Messages.admin_appSelection = 'App configuration'
Messages.admin_appsTitle = "Choose your applications"
Messages.admin_appsHint = "Choose which apps are available to users on your instance."
Messages.admin_cat_apps = "Apps"
@ -79,7 +79,6 @@ define([
content: [
'logo',
'color',
'colorpalette'
]
},
'broadcast' : { // Msg.admin_cat_broadcast
@ -1008,31 +1007,31 @@ define([
colors = h('div#cp-kanban-edit-colors'),
]);
// var $colors = $(colors);
// var palette = [''];
// for (var i=1; i<=8; i++) { palette.push('color'+i); }
// var selectedColor = '';
// palette.forEach(function (color) {
// var $color = $(h('div.cp-kanban-palette.cp-kanban-palette-card.fa'), );
// $color.addClass('cp-kanban-palette-'+(color || 'nocolor'));
// $color.click(function () {
// if (color === selectedColor) { return; }
// selectedColor = $color.css('background-color');
// $colors.find('.cp-kanban-palette').removeClass('fa-check');
// var $col = $colors.find('.cp-kanban-palette-'+(color || 'nocolor'));
// $col.addClass('fa-check');
// sframeCommand('CHANGE_COLOR', {selectedColor}, (err, response) => {
// if (err) {
// UI.warn(Messages.error);
// console.error(err, response);
// // done(false);
// return;
// }
// done(true);
// UI.log(Messages.saved);
// });
// }).appendTo($colors);
// });
var $colors = $(colors);
var palette = [''];
for (var i=1; i<=8; i++) { palette.push('color'+i); }
var selectedColor = '';
palette.forEach(function (color) {
var $color = $(h('div.cp-kanban-palette.cp-kanban-palette-card.fa'), );
$color.addClass('cp-kanban-palette-'+(color || 'nocolor'));
$color.click(function () {
if (color === selectedColor) { return; }
selectedColor = $color.css('background-color');
$colors.find('.cp-kanban-palette').removeClass('fa-check');
var $col = $colors.find('.cp-kanban-palette-'+(color || 'nocolor'));
$col.addClass('fa-check');
sframeCommand('CHANGE_COLOR', {selectedColor}, (err, response) => {
if (err) {
UI.warn(Messages.error);
console.error(err, response);
// done(false);
return;
}
done(true);
UI.log(Messages.saved);
});
}).appendTo($colors);
});
let form = blocks.form([
labelCurrent,
@ -1042,45 +1041,6 @@ define([
cb([form, labelPreview, content]);
});
// sidebar.addItem('colorpalette', cb => {
// var colors;
// var content = h('div.cp-onboardscreen-colorpick', [
// h('label', {for:'cp-kanban-edit-color'}, Messages.kanban_color),
// colors = h('div#cp-kanban-edit-colors'),
// ]);
// var $colors = $(colors);
// var palette = [''];
// for (var i=1; i<=8; i++) { palette.push('color'+i); }
// var selectedColor = '';
// palette.forEach(function (color) {
// var $color = $(h('div.cp-kanban-palette.cp-kanban-palette-card.fa'), );
// $color.addClass('cp-kanban-palette-'+(color || 'nocolor'));
// $color.click(function () {
// if (color === selectedColor) { return; }
// selectedColor = $color.css('background-color');
// $colors.find('.cp-kanban-palette').removeClass('fa-check');
// var $col = $colors.find('.cp-kanban-palette-'+(color || 'nocolor'));
// $col.addClass('fa-check');
// sendAdminRpc('CHANGE_COLOR', {selectedColor}, function (e, response) {
// if (e || response.error) {
// UI.warn(Messages.error);
// console.error(e, response);
// // done(false);
// return;
// }
// // flushCache();
// // done(true);
// // redraw();
// // spinner.done();
// UI.log(Messages.saved);
// });
// }).appendTo($colors);
// });
// cb([content]);
// });
// Msg.admin_registrationHint, .admin_registrationTitle
// Msg.admin_registrationSsoTitle
sidebar.addItem('registration', function(cb){

View file

@ -1006,6 +1006,7 @@
"snapshots_cantMake": "The snapshot could not be created. You are disconnected.",
"admin_registrationHint": "Do not allow any new users to register",
"admin_registrationTitle": "Close registration",
"install_registrationTitle": "Close registration",
"admin_defaultlimitHint": "Maximum storage limit for CryptDrives (users and teams) when no custom rule is applied",
"admin_defaultlimitTitle": "Storage limit (MB)",
"admin_setlimitButton": "Set limit",
@ -1681,6 +1682,7 @@
"kanban_showTags": "See all tags",
"kanban_hideTags": "See less tags",
"admin_forcemfaTitle": "Mandatory Two-Factor Authentication",
"install_forcemfaTitle": "Mandatory Two-Factor Authentication",
"admin_forcemfaHint": "All users on this instance will be asked to set up two-factor authentication to log in to their account.",
"loading_mfa_required": "Two-factor authentication is required on this instance. Please update your account using an authenticator app and the form below.",
"admin_cat_users": "User directory",

View file

@ -81,141 +81,141 @@ define([
var registerClick = function () {
showTitleScreen()
// showTitleScreen()
// var uname = $uname.val().trim();
// // trim whitespace surrounding the username since it is otherwise included in key derivation
// // most people won't realize that its presence is significant
// $uname.val(uname);
var uname = $uname.val().trim();
// trim whitespace surrounding the username since it is otherwise included in key derivation
// most people won't realize that its presence is significant
$uname.val(uname);
// var passwd = $passwd.val();
// var confirmPassword = $confirm.val();
var passwd = $passwd.val();
var confirmPassword = $confirm.val();
// if (!token) { token = $token.val().trim(); }
if (!token) { token = $token.val().trim(); }
// var shouldImport = false;
// var doesAccept;
// try {
// // if this throws there's either a horrible bug (which someone will report)
// // or the instance admins did not configure a terms page.
// doesAccept = true;
// } catch (err) {
// console.error(err);
// }
var shouldImport = false;
var doesAccept;
try {
// if this throws there's either a horrible bug (which someone will report)
// or the instance admins did not configure a terms page.
doesAccept = true;
} catch (err) {
console.error(err);
}
// if (Cred.isEmail(uname) && !I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME) {
// var emailWarning = [
// Messages.register_emailWarning0,
// br(), br(),
// Messages.register_emailWarning1,
// br(), br(),
// Messages.register_emailWarning2,
// br(), br(),
// Messages.register_emailWarning3,
// ];
if (Cred.isEmail(uname) && !I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME) {
var emailWarning = [
Messages.register_emailWarning0,
br(), br(),
Messages.register_emailWarning1,
br(), br(),
Messages.register_emailWarning2,
br(), br(),
Messages.register_emailWarning3,
];
// Feedback.send("EMAIL_USERNAME_WARNING", true);
Feedback.send("EMAIL_USERNAME_WARNING", true);
// return void UI.confirm(emailWarning, function (yes) {
// if (!yes) { return; }
// I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME = true;
// registerClick();
// });
// }
return void UI.confirm(emailWarning, function (yes) {
if (!yes) { return; }
I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME = true;
registerClick();
});
}
// /* basic validation */
// if (!Cred.isLongEnoughPassword(passwd)) {
// var warning = Messages._getKey('register_passwordTooShort', [
// Cred.MINIMUM_PASSWORD_LENGTH
// ]);
// return void UI.alert(warning);
// }
/* basic validation */
if (!Cred.isLongEnoughPassword(passwd)) {
var warning = Messages._getKey('register_passwordTooShort', [
Cred.MINIMUM_PASSWORD_LENGTH
]);
return void UI.alert(warning);
}
// if (passwd !== confirmPassword) { // do their passwords match?
// return void UI.alert(Messages.register_passwordsDontMatch);
// }
if (passwd !== confirmPassword) { // do their passwords match?
return void UI.alert(Messages.register_passwordsDontMatch);
}
// if (Pages.customURLs.terms && !doesAccept) { // do they accept the terms of service? (if they exist)
// return void UI.alert(Messages.register_mustAcceptTerms);
// }
if (Pages.customURLs.terms && !doesAccept) { // do they accept the terms of service? (if they exist)
return void UI.alert(Messages.register_mustAcceptTerms);
}
// let startOnboarding = function (network, proxy) {
// Rpc.create(network, proxy.edPrivate, proxy.edPublic, function (e, rpc) {
// if (e) {
// // TODO: handle error
// return;
// }
let startOnboarding = function (network, proxy) {
Rpc.create(network, proxy.edPrivate, proxy.edPublic, function (e, rpc) {
if (e) {
// TODO: handle error
return;
}
// let sendAdminDecree = function (command, data, callback) {
// var params = ['ADMIN_DECREE', [command, data]];
// rpc.send('ADMIN', params, callback)
// };
let sendAdminDecree = function (command, data, callback) {
var params = ['ADMIN_DECREE', [command, data]];
rpc.send('ADMIN', params, callback)
};
// let sendAdminRpc = function (command, data, callback) {
// var params = [command, data];
// rpc.send('ADMIN', params, callback)
// };
let sendAdminRpc = function (command, data, callback) {
var params = [command, data];
rpc.send('ADMIN', params, callback)
};
// showTitleScreen(sendAdminDecree, sendAdminRpc)
showTitleScreen(sendAdminDecree, sendAdminRpc)
// });
});
// };
};
// setTimeout(function () {
// var span = h('span', [
// h('h2', [
// h('i.fa.fa-warning'),
// ' ',
// Messages.register_warning,
// ]),
// Messages.register_warning_note
// ]);
setTimeout(function () {
var span = h('span', [
h('h2', [
h('i.fa.fa-warning'),
' ',
Messages.register_warning,
]),
Messages.register_warning_note
]);
// UI.confirm(span,
// function (yes) {
// if (!yes) { return; }
UI.confirm(span,
function (yes) {
if (!yes) { return; }
// Login.loginOrRegisterUI({
// uname,
// passwd,
// isRegister: true,
// onOTP: UI.getOTPScreen,
// shouldImport,
// cb: function (data) {
// var proxy = data.proxy;
// if (!proxy || !proxy.edPublic) { UI.alert(Messages.error); return true; }
Login.loginOrRegisterUI({
uname,
passwd,
isRegister: true,
onOTP: UI.getOTPScreen,
shouldImport,
cb: function (data) {
var proxy = data.proxy;
if (!proxy || !proxy.edPublic) { UI.alert(Messages.error); return true; }
// Rpc.createAnonymous(data.network, function (e, call) {
// if (e) { UI.alert(Messages.error); return console.error(e); }
// var anon_rpc = call;
Rpc.createAnonymous(data.network, function (e, call) {
if (e) { UI.alert(Messages.error); return console.error(e); }
var anon_rpc = call;
// anon_rpc.send('ADD_FIRST_ADMIN', {
// token: token,
// edPublic: proxy.edPublic
// }, function (e) {
// if (e) { UI.alert(Messages.error); return console.error(e); }
// startOnboarding(data.network, proxy);
// });
// });
anon_rpc.send('ADD_FIRST_ADMIN', {
token: token,
edPublic: proxy.edPublic
}, function (e) {
if (e) { UI.alert(Messages.error); return console.error(e); }
startOnboarding(data.network, proxy);
});
});
// return true;
// }
// });
// }, {
// ok: Messages.register_writtenPassword,
// cancel: Messages.register_cancel,
// /* If we're certain that we aren't using these "*Class" APIs
// anywhere else then we can deprecate them and make this a
// custom modal in common-interface (or here). */
// cancelClass: 'btn.btn-cancel.btn-register',
// okClass: 'btn.btn-danger.btn-register',
// reverseOrder: true,
// done: function ($dialog) {
// $dialog.find('> div').addClass('half');
// },
// });
// }, 150);
return true;
}
});
}, {
ok: Messages.register_writtenPassword,
cancel: Messages.register_cancel,
/* If we're certain that we aren't using these "*Class" APIs
anywhere else then we can deprecate them and make this a
custom modal in common-interface (or here). */
cancelClass: 'btn.btn-cancel.btn-register',
okClass: 'btn.btn-danger.btn-register',
reverseOrder: true,
done: function ($dialog) {
$dialog.find('> div').addClass('half');
},
});
}, 150);
};
$register.click(registerClick);

View file

@ -21,17 +21,16 @@ define([
) {
//XXX
Messages.admin_onboardingNameTitle = 'Welcome to your CryptPad instance';
Messages.admin_onboardingNameHint = 'Please choose a title and description';
Messages.admin_onboardingAppsTitle = "Choose your applications";
Messages.admin_onboardingAppsHint = "Choose which apps are available to users on your instance";
Messages.admin_onboardingRegistrationTitle = "Options";
Messages.admin_onboardingRegistrationHint = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id tristique justo";
Messages.admin_onboardingRegistration = "Visitors to the instance are not able to create accounts. Invitations can be created by administrators";
Messages.admin_onboardingMFA = "All accounts on the instance have to use 2-factor authentication";
Messages.install_onboardingNameTitle = 'Welcome to your CryptPad instance';
Messages.install_onboardingNameHint = 'Please choose a title and description';
Messages.install_onboardingAppsTitle = "Choose your applications";
Messages.install_onboardingAppsHint = "Choose which apps are available to users on your instance";
Messages.install_onboardingRegistrationTitle = "Options";
Messages.install_onboardingRegistrationHint = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id tristique justo";
Messages.install_onboardingRegistration = "Visitors to the instance are not able to create accounts. Invitations can be created by administrators";
Messages.install_onboardingMfa = "All accounts on the instance have to use 2-factor authentication";
var OnboardScreen = {};
// const blocks = Sidebar.blocks('install');
var displayForm = function(sendAdminDecree, page) {
@ -145,9 +144,9 @@ define([
$remove.attr('disabled', 'disabled');
sendAdminRpc('REMOVE_LOGO', {}, function (e, response) {
$remove.removeAttr('disabled');
if (err) {
if (e) {
UI.warn(Messages.error);
console.error(err, response);
console.error(e, response);
spinner.hide();
return;
}
@ -204,32 +203,32 @@ define([
var button = blocks.activeButton('primary', '', Messages.settings_save, function (done) {
// sendAdminDecree('SET_INSTANCE_NAME', [$(titleInput).val().trim()], function (e, response) {
// if (e || response.error) {
// UI.warn(Messages.error);
// $input.val('');
// console.error(e, response);
// done(false);
// return;
// }
// // flushCache();
// done(true);
// UI.log(Messages.saved);
sendAdminDecree('SET_INSTANCE_NAME', [$(titleInput).val().trim()], function (e, response) {
if (e || response.error) {
UI.warn(Messages.error);
$input.val('');
console.error(e, response);
done(false);
return;
}
// flushCache();
done(true);
UI.log(Messages.saved);
// })
// sendAdminDecree('SET_INSTANCE_DESCRIPTION', [$(desc).val().trim()], function (e, response) {
// if (e || response.error) {
// UI.warn(Messages.error);
// $input.val('');
// console.error(e, response);
// done(false);
// return;
// }
// // flushCache();
// done(true);
// UI.log(Messages.saved);
})
sendAdminDecree('SET_INSTANCE_DESCRIPTION', [$(desc).val().trim()], function (e, response) {
if (e || response.error) {
UI.warn(Messages.error);
$input.val('');
console.error(e, response);
done(false);
return;
}
// flushCache();
done(true);
UI.log(Messages.saved);
// })
})
displayForm(sendAdminDecree, 0);
});
@ -240,7 +239,7 @@ define([
var colorInput = h('div.cp-onboardscreen-color', colorBlock());
var screenTitle = h('div.cp-onboardscreen-screentitle');
$(screenTitle).append(h('div.cp-onboardscreen-maintitle', h('span.cp-onboardscreen-title', Messages.admin_onboardingNameTitle), h('br'), h('span', Messages.admin_onboardingNameHint)));
$(screenTitle).append(h('div.cp-onboardscreen-maintitle', h('span.cp-onboardscreen-title', Messages.install_onboardingNameTitle), h('br'), h('span', Messages.install_onboardingNameHint)));
var nav = blocks.nav([button]);
$(button).addClass('cp-onboardscreen-save');
@ -291,19 +290,19 @@ define([
});
var save = blocks.activeButton('primary', '', Messages.settings_save, function (done) {
// sendAdminDecree('DISABLE_APPS', availableApps, function (e, response) {
// if (e || response.error) {
// UI.warn(Messages.error);
// $input.val('');
// console.error(e, response);
// done(false);
// return;
// }
// // flushCache();
// done(true);
// UI.log(Messages.saved);
sendAdminDecree('DISABLE_APPS', availableApps, function (e, response) {
if (e || response.error) {
UI.warn(Messages.error);
$input.val('');
console.error(e, response);
done(false);
return;
}
// flushCache();
done(true);
UI.log(Messages.saved);
// })
})
UI.log(Messages.saved);
displayForm(sendAdminDecree, 1)
@ -314,7 +313,7 @@ define([
});
var screenTitle = h('div.cp-onboardscreen-screentitle');
$(screenTitle).append(h('div.cp-onboardscreen-maintitle', h('span.cp-onboardscreen-title', Messages.admin_onboardingAppsTitle), h('br'), h('span', Messages.admin_onboardingAppsHint)))
$(screenTitle).append(h('div.cp-onboardscreen-maintitle', h('span.cp-onboardscreen-title', Messages.install_onboardingAppsTitle), h('br'), h('span', Messages.install_onboardingAppsHint)))
$(save).addClass('cp-onboardscreen-save');
$(prev).addClass('cp-onboardscreen-prev');
var nav = blocks.nav([prev, save])
@ -329,7 +328,7 @@ define([
return form;
}
OnboardScreen.mfaRegistrationScreen = function(sendAdminDecree) {
OnboardScreen.mfaRegistrationScreen = function(sendAdminDecree, app) {
const blocks = Sidebar.blocks('install');
var restrict = blocks.activeCheckbox({
@ -337,20 +336,21 @@ define([
getState: function () {
return false;
},
label: 'registration',
query: function (val, setState) {
// sendAdminDecree('RESTRICT_REGISTRATION', [val], function (e, response) {
// if (e || response.error) {
// UI.warn(Messages.error);
// $input.val('');
// console.error(e, response);
// done(false);
// return;
// }
// // flushCache();
// // done(true);
// UI.log(Messages.saved);
sendAdminDecree('RESTRICT_REGISTRATION', [val], function (e, response) {
if (e || response.error) {
UI.warn(Messages.error);
$input.val('');
console.error(e, response);
done(false);
return;
}
// flushCache();
// done(true);
UI.log(Messages.saved);
// });
});
},
});
@ -359,31 +359,31 @@ define([
getState: function () {
return false;
},
label: 'forcemfa',
query: function (val, setState) {
// sendAdminDecree('ENFORCE_MFA', [val], function (e, response) {
// if (e || response.error) {
// UI.warn(Messages.error);
// $input.val('');
// console.error(e, response);
// done(false);
// return;
// }
// // flushCache();
// done(true);
// UI.log(Messages.saved);
sendAdminDecree('ENFORCE_MFA', [val], function (e, response) {
if (e || response.error) {
UI.warn(Messages.error);
$input.val('');
console.error(e, response);
done(false);
return;
}
// flushCache();
// done(true);
UI.log(Messages.saved);
// })
})
},
});
const grid = blocks.block([], 'cp-admin-customize-options-grid');
const options = [restrict, forceMFA];
options.forEach(option => {
console.log('opt', option, option.toString())
let optionBlock = h('div.cp-optionblock.inactive-app', { id: `${option.toString()}-block`}, "option");
$(grid).append(optionBlock);
});
let mfaOption = h('div.cp-appblock.inactive-app', forceMFA, h('br'), Messages.install_onboardingMfa);
$(grid).append(mfaOption);
let registrationOption = h('div.cp-appblock.inactive-app', restrict, h('br'), Messages.install_onboardingRegistration);
$(grid).append(registrationOption);
var save = blocks.activeButton('primary', '', Messages.settings_save, function () {
document.location.href = '/drive/';
@ -395,7 +395,7 @@ define([
});
var screenTitle = h('div.cp-onboardscreen-screentitle');
$(screenTitle).append(h('div.cp-onboardscreen-maintitle', h('span.cp-onboardscreen-title', Messages.admin_onboardingRegistrationTitle), h('br'), h('span', Messages.admin_onboardingRegistrationHint)));
$(screenTitle).append(h('div.cp-onboardscreen-maintitle', h('span.cp-onboardscreen-title', Messages.install_onboardingRegistrationTitle), h('br'), h('span', Messages.install_onboardingRegistrationHint)));
$(save).addClass('cp-onboardscreen-save');
$(prev).addClass('cp-onboardscreen-prev');
var nav = blocks.nav([prev, save])