Still converting to bootstrap 5. JS Validation fixes
This commit is contained in:
@@ -55,9 +55,9 @@
|
|||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
${replaygain-preamp class="form-control"}
|
${replaygain-preamp class="form-control"}
|
||||||
<span class="input-group-text">dB</span>
|
<span class="input-group-text">dB</span>
|
||||||
</div>
|
<div class="invalid-feedback">
|
||||||
<div class="invalid-feedback">
|
${replaygain-preamp-info}
|
||||||
${replaygain-preamp-info}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
@@ -67,9 +67,9 @@
|
|||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
${replaygain-preamp-no-rg-info class="form-control"}
|
${replaygain-preamp-no-rg-info class="form-control"}
|
||||||
<span class="input-group-text">dB</span>
|
<span class="input-group-text">dB</span>
|
||||||
</div>
|
<div class="invalid-feedback">
|
||||||
<div class="invalid-feedback">
|
${replaygain-preamp-no-rg-info-info}
|
||||||
${replaygain-preamp-no-rg-info-info}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${<if-has-subsonic-api>}
|
${<if-has-subsonic-api>}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ add_executable(lms
|
|||||||
ui/admin/UserView.cpp
|
ui/admin/UserView.cpp
|
||||||
ui/admin/UsersView.cpp
|
ui/admin/UsersView.cpp
|
||||||
ui/common/DirectoryValidator.cpp
|
ui/common/DirectoryValidator.cpp
|
||||||
|
ui/common/DoubleValidator.cpp
|
||||||
ui/common/InfiniteScrollingContainer.cpp
|
ui/common/InfiniteScrollingContainer.cpp
|
||||||
ui/common/LoadingIndicator.cpp
|
ui/common/LoadingIndicator.cpp
|
||||||
ui/common/LoginNameValidator.cpp
|
ui/common/LoginNameValidator.cpp
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include <Wt/WCheckBox.h>
|
#include <Wt/WCheckBox.h>
|
||||||
#include <Wt/WComboBox.h>
|
#include <Wt/WComboBox.h>
|
||||||
#include <Wt/WDoubleValidator.h>
|
|
||||||
#include <Wt/WDoubleSpinBox.h>
|
#include <Wt/WDoubleSpinBox.h>
|
||||||
#include <Wt/WFormModel.h>
|
#include <Wt/WFormModel.h>
|
||||||
#include <Wt/WLineEdit.h>
|
#include <Wt/WLineEdit.h>
|
||||||
@@ -29,8 +28,9 @@
|
|||||||
#include <Wt/WString.h>
|
#include <Wt/WString.h>
|
||||||
#include <Wt/WTemplateFormView.h>
|
#include <Wt/WTemplateFormView.h>
|
||||||
|
|
||||||
#include "common/PasswordValidator.hpp"
|
#include "common/DoubleValidator.hpp"
|
||||||
#include "common/MandatoryValidator.hpp"
|
#include "common/MandatoryValidator.hpp"
|
||||||
|
#include "common/PasswordValidator.hpp"
|
||||||
#include "common/UUIDValidator.hpp"
|
#include "common/UUIDValidator.hpp"
|
||||||
#include "common/ValueStringModel.hpp"
|
#include "common/ValueStringModel.hpp"
|
||||||
|
|
||||||
@@ -108,12 +108,10 @@ class SettingsModel : public Wt::WFormModel
|
|||||||
setValidator(TranscodeBitrateField, createMandatoryValidator());
|
setValidator(TranscodeBitrateField, createMandatoryValidator());
|
||||||
setValidator(TranscodeFormatField, createMandatoryValidator());
|
setValidator(TranscodeFormatField, createMandatoryValidator());
|
||||||
setValidator(ReplayGainModeField, createMandatoryValidator());
|
setValidator(ReplayGainModeField, createMandatoryValidator());
|
||||||
auto createPreAmpValidator = []
|
auto createPreAmpValidator {[]
|
||||||
{
|
{
|
||||||
auto preampGainValidator {std::make_unique<Wt::WDoubleValidator>()};
|
return createDoubleValidator(MediaPlayer::Settings::ReplayGain::minPreAmpGain, MediaPlayer::Settings::ReplayGain::maxPreAmpGain);
|
||||||
preampGainValidator->setRange(MediaPlayer::Settings::ReplayGain::minPreAmpGain, MediaPlayer::Settings::ReplayGain::maxPreAmpGain);
|
}};
|
||||||
return preampGainValidator;
|
|
||||||
};
|
|
||||||
|
|
||||||
setValidator(ReplayGainPreAmpGainField, createPreAmpValidator());
|
setValidator(ReplayGainPreAmpGainField, createPreAmpValidator());
|
||||||
setValidator(ReplayGainPreAmpGainIfNoInfoField, createPreAmpValidator());
|
setValidator(ReplayGainPreAmpGainIfNoInfoField, createPreAmpValidator());
|
||||||
|
|||||||
@@ -69,12 +69,11 @@ class DatabaseSettingsModel : public Wt::WFormModel
|
|||||||
|
|
||||||
auto dirValidator {createDirectoryValidator()};
|
auto dirValidator {createDirectoryValidator()};
|
||||||
dirValidator->setMandatory(true);
|
dirValidator->setMandatory(true);
|
||||||
setValidator(MediaDirectoryField, dirValidator);
|
setValidator(MediaDirectoryField, move(dirValidator));
|
||||||
|
|
||||||
setValidator(UpdatePeriodField, createMandatoryValidator());
|
setValidator(UpdatePeriodField, createMandatoryValidator());
|
||||||
setValidator(UpdateStartTimeField, createMandatoryValidator());
|
setValidator(UpdateStartTimeField, createMandatoryValidator());
|
||||||
setValidator(RecommendationEngineTypeField, createMandatoryValidator());
|
setValidator(RecommendationEngineTypeField, createMandatoryValidator());
|
||||||
setValidator(TagsField, createTagsValidator());
|
|
||||||
|
|
||||||
// populate the model with initial data
|
// populate the model with initial data
|
||||||
loadData();
|
loadData();
|
||||||
@@ -144,11 +143,6 @@ class DatabaseSettingsModel : public Wt::WFormModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::shared_ptr<Wt::WValidator> createTagsValidator()
|
|
||||||
{
|
|
||||||
auto v = std::make_shared<Wt::WValidator>();
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
void initializeModels()
|
void initializeModels()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ namespace UserInterface
|
|||||||
{
|
{
|
||||||
class DirectoryValidator : public Wt::WValidator
|
class DirectoryValidator : public Wt::WValidator
|
||||||
{
|
{
|
||||||
public:
|
private:
|
||||||
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
||||||
|
std::string javaScriptValidate() const override { return {}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Wt::WValidator::Result
|
Wt::WValidator::Result
|
||||||
@@ -48,7 +49,7 @@ namespace UserInterface
|
|||||||
return Wt::WValidator::Result(Wt::ValidationState::Invalid, Wt::WString::tr("Lms.not-a-directory"));
|
return Wt::WValidator::Result(Wt::ValidationState::Invalid, Wt::WString::tr("Lms.not-a-directory"));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Wt::WValidator>
|
std::unique_ptr<Wt::WValidator>
|
||||||
createDirectoryValidator()
|
createDirectoryValidator()
|
||||||
{
|
{
|
||||||
return std::make_unique<DirectoryValidator>();
|
return std::make_unique<DirectoryValidator>();
|
||||||
|
|||||||
@@ -23,6 +23,6 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
std::shared_ptr<Wt::WValidator> createDirectoryValidator();
|
std::unique_ptr<Wt::WValidator> createDirectoryValidator();
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DoubleValidator.hpp"
|
||||||
|
|
||||||
|
#include <Wt/WDoubleValidator.h>
|
||||||
|
|
||||||
|
namespace UserInterface
|
||||||
|
{
|
||||||
|
class DoubleValidator : public Wt::WDoubleValidator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Wt::WDoubleValidator::WDoubleValidator;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string javaScriptValidate() const override { return {}; }
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<Wt::WValidator>
|
||||||
|
createDoubleValidator(double min, double max)
|
||||||
|
{
|
||||||
|
auto validator {std::make_unique<DoubleValidator>(min, max)};
|
||||||
|
return validator;
|
||||||
|
}
|
||||||
|
} // namespace UserInterface
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Wt/WValidator.h>
|
||||||
|
|
||||||
|
namespace UserInterface
|
||||||
|
{
|
||||||
|
std::unique_ptr<Wt::WValidator> createDoubleValidator(double min, double max);
|
||||||
|
} // namespace UserInterface
|
||||||
|
|
||||||
@@ -24,10 +24,16 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
std::shared_ptr<Wt::WValidator>
|
class LengthValidator : public Wt::WLengthValidator
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string javaScriptValidate() const override { return {}; }
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<Wt::WValidator>
|
||||||
createLoginNameValidator()
|
createLoginNameValidator()
|
||||||
{
|
{
|
||||||
auto v = std::make_unique<Wt::WLengthValidator>();
|
auto v = std::make_unique<LengthValidator>();
|
||||||
v->setMandatory(true);
|
v->setMandatory(true);
|
||||||
v->setMinimumLength(::Database::User::MinNameLength);
|
v->setMinimumLength(::Database::User::MinNameLength);
|
||||||
v->setMaximumLength(::Database::User::MaxNameLength);
|
v->setMaximumLength(::Database::User::MaxNameLength);
|
||||||
|
|||||||
@@ -23,6 +23,6 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
std::shared_ptr<Wt::WValidator> createLoginNameValidator();
|
std::unique_ptr<Wt::WValidator> createLoginNameValidator();
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,16 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
std::shared_ptr<Wt::WValidator>
|
class MandatoryValidator : public Wt::WValidator
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string javaScriptValidate() const override { return {}; }
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<Wt::WValidator>
|
||||||
createMandatoryValidator()
|
createMandatoryValidator()
|
||||||
{
|
{
|
||||||
auto v {std::make_shared<Wt::WValidator>()};
|
auto v {std::make_unique<MandatoryValidator>()};
|
||||||
v->setMandatory(true);
|
v->setMandatory(true);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,6 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
std::shared_ptr<Wt::WValidator> createMandatoryValidator();
|
std::unique_ptr<Wt::WValidator> createMandatoryValidator();
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace UserInterface
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
||||||
|
std::string javaScriptValidate() const override { return {}; }
|
||||||
|
|
||||||
PasswordValidationContextGetFunc _passwordValidationContextGetFunc;
|
PasswordValidationContextGetFunc _passwordValidationContextGetFunc;
|
||||||
};
|
};
|
||||||
@@ -61,16 +62,17 @@ namespace UserInterface
|
|||||||
throw LmsException {"internal error"};
|
throw LmsException {"internal error"};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Wt::WValidator>
|
std::unique_ptr<Wt::WValidator>
|
||||||
createPasswordStrengthValidator(PasswordValidationContextGetFunc passwordValidationContextGetFunc)
|
createPasswordStrengthValidator(PasswordValidationContextGetFunc passwordValidationContextGetFunc)
|
||||||
{
|
{
|
||||||
return std::make_shared<PasswordStrengthValidator>(std::move(passwordValidationContextGetFunc));
|
return std::make_unique<PasswordStrengthValidator>(std::move(passwordValidationContextGetFunc));
|
||||||
}
|
}
|
||||||
|
|
||||||
class PasswordCheckValidator : public Wt::WValidator
|
class PasswordCheckValidator : public Wt::WValidator
|
||||||
{
|
{
|
||||||
public:
|
private:
|
||||||
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
||||||
|
std::string javaScriptValidate() const override { return {}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Wt::WValidator::Result
|
Wt::WValidator::Result
|
||||||
@@ -96,10 +98,10 @@ namespace UserInterface
|
|||||||
throw LmsException {"InternalError"};
|
throw LmsException {"InternalError"};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Wt::WValidator>
|
std::unique_ptr<Wt::WValidator>
|
||||||
createPasswordCheckValidator()
|
createPasswordCheckValidator()
|
||||||
{
|
{
|
||||||
return std::make_shared<PasswordCheckValidator>();
|
return std::make_unique<PasswordCheckValidator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|||||||
@@ -22,15 +22,14 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <Wt/WValidator.h>
|
#include <Wt/WValidator.h>
|
||||||
|
|
||||||
#include "services/database/Types.hpp"
|
|
||||||
#include "services/auth/Types.hpp"
|
#include "services/auth/Types.hpp"
|
||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
using PasswordValidationContextGetFunc = std::function<::Auth::PasswordValidationContext()>;
|
using PasswordValidationContextGetFunc = std::function<::Auth::PasswordValidationContext()>;
|
||||||
std::shared_ptr<Wt::WValidator> createPasswordStrengthValidator(PasswordValidationContextGetFunc passwordValidationContextGetFunc);
|
std::unique_ptr<Wt::WValidator> createPasswordStrengthValidator(PasswordValidationContextGetFunc passwordValidationContextGetFunc);
|
||||||
|
|
||||||
// Check current user password
|
// Check current user password
|
||||||
std::shared_ptr<Wt::WValidator> createPasswordCheckValidator();
|
std::unique_ptr<Wt::WValidator> createPasswordCheckValidator();
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,18 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
std::shared_ptr<Wt::WValidator>
|
class RegExpValidator : public Wt::WRegExpValidator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Wt::WRegExpValidator::WRegExpValidator;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string javaScriptValidate() const override { return {}; }
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<Wt::WValidator>
|
||||||
createUUIDValidator()
|
createUUIDValidator()
|
||||||
{
|
{
|
||||||
return std::make_unique<Wt::WRegExpValidator>("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}");
|
return std::make_unique<RegExpValidator>("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}");
|
||||||
}
|
}
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|||||||
@@ -23,6 +23,6 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
std::shared_ptr<Wt::WValidator> createUUIDValidator();
|
std::unique_ptr<Wt::WValidator> createUUIDValidator();
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user