Add Require password dialog
This commit is contained in:
parent
38e44440d0
commit
257bb49c52
|
@ -127,3 +127,4 @@ $inputControlEmColor: #f29424;
|
||||||
//buttons
|
//buttons
|
||||||
$linkFontColor: #489afe;
|
$linkFontColor: #489afe;
|
||||||
$linkHoverFontColor: #287ade;
|
$linkHoverFontColor: #287ade;
|
||||||
|
$errorColor: #c61600;
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
@include transition(all .2s ease-in);
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
margin-bottom: inherit;
|
margin-bottom: inherit;
|
||||||
|
@ -28,6 +30,11 @@
|
||||||
&::selection {
|
&::selection {
|
||||||
background-color: $defaultDarkSelectionColor;
|
background-color: $defaultDarkSelectionColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.error {
|
||||||
|
color: $errorColor;
|
||||||
|
border-color: $errorColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__em {
|
&__em {
|
||||||
|
@ -41,6 +48,10 @@
|
||||||
span {
|
span {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&_error {
|
||||||
|
color: $errorColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__container {
|
&__container {
|
||||||
|
|
|
@ -199,6 +199,7 @@
|
||||||
"passwordError2": "This conversation isn't currently protected by a password. Only the owner of the conference can set a password.",
|
"passwordError2": "This conversation isn't currently protected by a password. Only the owner of the conference can set a password.",
|
||||||
"connectError": "Oops! Something went wrong and we couldn't connect to the conference.",
|
"connectError": "Oops! Something went wrong and we couldn't connect to the conference.",
|
||||||
"connectErrorWithMsg": "Oops! Something went wrong and we couldn't connect to the conference: __msg__",
|
"connectErrorWithMsg": "Oops! Something went wrong and we couldn't connect to the conference: __msg__",
|
||||||
|
"incorrectPassword": "Password is incorrect",
|
||||||
"connecting": "Connecting",
|
"connecting": "Connecting",
|
||||||
"copy": "Copy",
|
"copy": "Copy",
|
||||||
"error": "Error",
|
"error": "Error",
|
||||||
|
|
|
@ -46,6 +46,11 @@ class Invite {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.conference.on(ConferenceEvents.CONFERENCE_JOINED, () => {
|
||||||
|
let roomLocker = this.getRoomLocker();
|
||||||
|
roomLocker.hideRequirePasswordDialog();
|
||||||
|
});
|
||||||
|
|
||||||
APP.UI.addListener( UIEvents.INVITE_CLICKED,
|
APP.UI.addListener( UIEvents.INVITE_CLICKED,
|
||||||
() => { this.openLinkDialog(); });
|
() => { this.openLinkDialog(); });
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/* global APP */
|
||||||
|
|
||||||
|
import UIUtil from '../util/UIUtil';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show dialog which asks for required conference password.
|
||||||
|
* @returns {Promise<string>} password or nothing if user canceled
|
||||||
|
*/
|
||||||
|
export default class RequirePasswordDialog {
|
||||||
|
constructor() {
|
||||||
|
this.titleKey = 'dialog.passwordRequired';
|
||||||
|
this.labelKey = 'dialog.passwordLabel';
|
||||||
|
this.errorKey = 'dialog.incorrectPassword';
|
||||||
|
this.errorId = 'passwordRequiredError';
|
||||||
|
this.inputId = 'passwordRequiredInput';
|
||||||
|
this.inputErrorClass = 'error';
|
||||||
|
this.isOpened = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_registerListeners() {
|
||||||
|
let el = document.getElementById(this.inputId);
|
||||||
|
el.addEventListener('keypress', this._hideError.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
_getBodyMessage() {
|
||||||
|
let passMsg = APP.translation.translateString("dialog.password");
|
||||||
|
let label = APP.translation.translateString(this.labelKey);
|
||||||
|
let error = APP.translation.translateString(this.errorKey);
|
||||||
|
return (
|
||||||
|
`<div class="input-control">
|
||||||
|
<label class="input-control__label"
|
||||||
|
data-i18n="${this.labelKey}">${label}</label>
|
||||||
|
<input class="input-control__input" name="lockKey" type="text"
|
||||||
|
data-i18n="[placeholder]dialog.password"
|
||||||
|
placeholder="${passMsg}" autofocus id="${this.inputId}">
|
||||||
|
<p class="input-control__hint input-control__hint_error hide"
|
||||||
|
id="${this.errorId}"
|
||||||
|
data-i18n="${this.errorKey}">${error}</p>
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
askForPassword() {
|
||||||
|
if (!this.isOpened) {
|
||||||
|
return this.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.resolve = resolve;
|
||||||
|
this.reject = reject;
|
||||||
|
this._showError();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
open() {
|
||||||
|
let { titleKey } = this;
|
||||||
|
let msgString = this._getBodyMessage();
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.resolve = resolve;
|
||||||
|
this.reject = reject;
|
||||||
|
let submitFunction = this._submitFunction.bind(this);
|
||||||
|
let closeFunction = this._closeFunction.bind(this);
|
||||||
|
|
||||||
|
APP.UI.messageHandler.openTwoButtonDialog({
|
||||||
|
titleKey,
|
||||||
|
msgString,
|
||||||
|
leftButtonKey: "dialog.Ok",
|
||||||
|
submitFunction,
|
||||||
|
closeFunction,
|
||||||
|
focus: ':input:first'
|
||||||
|
});
|
||||||
|
|
||||||
|
this._registerListeners();
|
||||||
|
this.isOpened = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_submitFunction(e, v, m, f) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (v && f.lockKey) {
|
||||||
|
this.resolve(UIUtil.escapeHtml(f.lockKey));
|
||||||
|
} else {
|
||||||
|
this.reject(APP.UI.messageHandler.CANCEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_closeFunction() {
|
||||||
|
this._hideError();
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
_showError() {
|
||||||
|
let className = this.inputErrorClass;
|
||||||
|
document.getElementById(this.errorId).classList.remove('hide');
|
||||||
|
document.getElementById(this.inputId).classList.add(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
_hideError() {
|
||||||
|
let className = this.inputErrorClass;
|
||||||
|
document.getElementById(this.errorId).classList.add('hide');
|
||||||
|
document.getElementById(this.inputId).classList.remove(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
APP.UI.messageHandler.closeDialog();
|
||||||
|
this.isOpened = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/* global APP, JitsiMeetJS */
|
/* global APP, JitsiMeetJS */
|
||||||
import askForPassword from './AskForPassword';
|
import RequirePasswordDialog from './RequirePasswordDialog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show notification that user cannot set password for the conference
|
* Show notification that user cannot set password for the conference
|
||||||
|
@ -31,7 +31,7 @@ const ConferenceErrors = JitsiMeetJS.errors.conference;
|
||||||
*/
|
*/
|
||||||
export default function createRoomLocker (room) {
|
export default function createRoomLocker (room) {
|
||||||
let password;
|
let password;
|
||||||
|
let requirePasswordDialog = new RequirePasswordDialog();
|
||||||
/**
|
/**
|
||||||
* If the room was locked from someone other than us, we indicate it with
|
* If the room was locked from someone other than us, we indicate it with
|
||||||
* this property in order to have correct roomLocker state of isLocked.
|
* this property in order to have correct roomLocker state of isLocked.
|
||||||
|
@ -104,7 +104,7 @@ export default function createRoomLocker (room) {
|
||||||
* Asks user for required conference password.
|
* Asks user for required conference password.
|
||||||
*/
|
*/
|
||||||
requirePassword () {
|
requirePassword () {
|
||||||
return askForPassword().then(
|
return requirePasswordDialog.askForPassword().then(
|
||||||
newPass => { password = newPass; }
|
newPass => { password = newPass; }
|
||||||
).catch(
|
).catch(
|
||||||
reason => {
|
reason => {
|
||||||
|
@ -116,6 +116,10 @@ export default function createRoomLocker (room) {
|
||||||
console.error(reason);
|
console.error(reason);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
hideRequirePasswordDialog() {
|
||||||
|
requirePasswordDialog.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue