mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
mv add form into advance
This commit is contained in:
@@ -26,7 +26,7 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TemplateOnce, Clone)]
|
#[derive(TemplateOnce, Clone)]
|
||||||
#[template(path = "panel/sitekey/add/index.html")]
|
#[template(path = "panel/sitekey/add/advance/index.html")]
|
||||||
pub struct IndexPage<'a> {
|
pub struct IndexPage<'a> {
|
||||||
pub levels: usize,
|
pub levels: usize,
|
||||||
pub form_title: &'a str,
|
pub form_title: &'a str,
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@import '../../../../reset';
|
@import '../../../../../reset';
|
||||||
@import '../../../../vars';
|
@import '../../../../../vars';
|
||||||
@import '../../../../components/button';
|
@import '../../../../../components/button';
|
||||||
@import '../../../../components/forms';
|
@import '../../../../../components/forms';
|
||||||
|
|
||||||
.sitekey-form {
|
.sitekey-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
15
templates/panel/sitekey/add/advance/index.html
Normal file
15
templates/panel/sitekey/add/advance/index.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<. include!("../../../../components/headers/index.html"); .>
|
||||||
|
<. include!("../../../navbar/index.html"); .>
|
||||||
|
<div class="tmp-layout">
|
||||||
|
<. include!("../../../header/index.html"); .>
|
||||||
|
|
||||||
|
<main class="panel-main">
|
||||||
|
<. include!("../../../help-banner/index.html"); .>
|
||||||
|
<!-- Main content container -->
|
||||||
|
<div class="inner-container">
|
||||||
|
<!-- Main menu/ important actions roaster -->
|
||||||
|
|
||||||
|
<. include!("./form.html"); .>
|
||||||
|
</div>
|
||||||
|
<!-- end of container -->
|
||||||
|
<. include!("../../../../components/footers.html"); .>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import getNumLevels from "./levels/getNumLevels";
|
import getNumLevels from "./levels/getNumLevels";
|
||||||
import {getAddForm, trim, addLevel} from "./setupTests";
|
import {getAddForm, trim, addLevel} from "./setupTests";
|
||||||
import setup from "../../../../components/error/setUpTests";
|
import setup from "../../../../../components/error/setUpTests";
|
||||||
|
|
||||||
document.body.innerHTML = getAddForm();
|
document.body.innerHTML = getAddForm();
|
||||||
document.body.appendChild(setup());
|
document.body.appendChild(setup());
|
||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
} from "./removeLevelButton";
|
} from "./removeLevelButton";
|
||||||
import CONST from "./const";
|
import CONST from "./const";
|
||||||
|
|
||||||
import log from "../../../../logger";
|
import log from "../../../../../logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets executed when 'Add' Button is clicked to add levels
|
* Gets executed when 'Add' Button is clicked to add levels
|
||||||
@@ -17,15 +17,15 @@
|
|||||||
|
|
||||||
import { LEVELS } from "../levels";
|
import { LEVELS } from "../levels";
|
||||||
|
|
||||||
import getFormUrl from "../../../../../utils/getFormUrl";
|
import getFormUrl from "../../../../../../utils/getFormUrl";
|
||||||
import genJsonPayload from "../../../../../utils/genJsonPayload";
|
import genJsonPayload from "../../../../../../utils/genJsonPayload";
|
||||||
|
|
||||||
import VIEWS from "../../../../../views/v1/routes";
|
import VIEWS from "../../../../../../views/v1/routes";
|
||||||
|
|
||||||
import validateDescription from "./validateDescription";
|
import validateDescription from "./validateDescription";
|
||||||
import validateDuration from "./validateDuration";
|
import validateDuration from "./validateDuration";
|
||||||
|
|
||||||
import createError from "../../../../../components/error";
|
import createError from "../../../../../../components/error";
|
||||||
|
|
||||||
export const SITE_KEY_FORM_CLASS = "sitekey-form";
|
export const SITE_KEY_FORM_CLASS = "sitekey-form";
|
||||||
export const FORM = <HTMLFormElement>(
|
export const FORM = <HTMLFormElement>(
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
import validateDescription from "./validateDescription";
|
import validateDescription from "./validateDescription";
|
||||||
import {getAddForm, fillDescription} from "../setupTests";
|
import {getAddForm, fillDescription} from "../setupTests";
|
||||||
import {mockAlert} from "../../../../../setUpTests";
|
import {mockAlert} from "../../../../../../setUpTests";
|
||||||
|
|
||||||
import setup from "../../../../../components/error/setUpTests";
|
import setup from "../../../../../../components/error/setUpTests";
|
||||||
|
|
||||||
mockAlert();
|
mockAlert();
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import isBlankString from "../../../../../utils/isBlankString";
|
import isBlankString from "../../../../../../utils/isBlankString";
|
||||||
|
|
||||||
const validateDescription = (e: Event): string => {
|
const validateDescription = (e: Event): string => {
|
||||||
const inputElement = <HTMLInputElement>document.getElementById("description");
|
const inputElement = <HTMLInputElement>document.getElementById("description");
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import isNumber from "../../../../../utils/isNumber";
|
import isNumber from "../../../../../../utils/isNumber";
|
||||||
|
|
||||||
const validateDuration = (): number => {
|
const validateDuration = (): number => {
|
||||||
const duartionElement = <HTMLInputElement>document.getElementById("duration");
|
const duartionElement = <HTMLInputElement>document.getElementById("duration");
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
import { Level } from "./index";
|
import { Level } from "./index";
|
||||||
import CONST from "../const";
|
import CONST from "../const";
|
||||||
|
|
||||||
import log from "../../../../../logger";
|
import log from "../../../../../../logger";
|
||||||
|
|
||||||
/** Fetches level from DOM using the ID passesd and validates */
|
/** Fetches level from DOM using the ID passesd and validates */
|
||||||
const getLevelFields = (id: number): Level => {
|
const getLevelFields = (id: number): Level => {
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import CONST from "../const";
|
import CONST from "../const";
|
||||||
|
|
||||||
import log from "../../../../../logger";
|
import log from "../../../../../../logger";
|
||||||
|
|
||||||
/** returns number of level input fields currently in DOM */
|
/** returns number of level input fields currently in DOM */
|
||||||
const getNumLevels = (): number => {
|
const getNumLevels = (): number => {
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import log from "../../../../../logger";
|
import log from "../../../../../../logger";
|
||||||
|
|
||||||
/** Datatype represenging an mCaptcha level */
|
/** Datatype represenging an mCaptcha level */
|
||||||
export type Level = {
|
export type Level = {
|
||||||
@@ -19,7 +19,7 @@ import CONST from "../const";
|
|||||||
import getLevelFields from "./getLevelFields";
|
import getLevelFields from "./getLevelFields";
|
||||||
import { LEVELS } from "./index";
|
import { LEVELS } from "./index";
|
||||||
|
|
||||||
import createError from "../../../../../components/error";
|
import createError from "../../../../../../components/error";
|
||||||
|
|
||||||
/** on-change event handler to update level */
|
/** on-change event handler to update level */
|
||||||
const updateLevel = (e: Event): void => {
|
const updateLevel = (e: Event): void => {
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import validateLevel from "./validateLevel";
|
import validateLevel from "./validateLevel";
|
||||||
import {getAddForm, level1, fillAddLevel} from "../setupTests";
|
import {getAddForm, level1, fillAddLevel} from "../setupTests";
|
||||||
import setup from "../../../../../components/error/setUpTests";
|
import setup from "../../../../../../components/error/setUpTests";
|
||||||
|
|
||||||
document.body.innerHTML = getAddForm();
|
document.body.innerHTML = getAddForm();
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import {LEVELS} from "./index";
|
import {LEVELS} from "./index";
|
||||||
import getLevelFields from "./getLevelFields";
|
import getLevelFields from "./getLevelFields";
|
||||||
import createError from "../../../../../components/error/";
|
import createError from "../../../../../../components/error/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches level from DOM using the ID passesd and validates
|
* Fetches level from DOM using the ID passesd and validates
|
||||||
@@ -18,7 +18,7 @@ import { LEVELS } from "../levels/index";
|
|||||||
import updateLevelNumbersOnDOM from "./updateDom";
|
import updateLevelNumbersOnDOM from "./updateDom";
|
||||||
import CONST from "../const";
|
import CONST from "../const";
|
||||||
|
|
||||||
import log from "../../../../../logger";
|
import log from "../../../../../../logger";
|
||||||
|
|
||||||
const REMOVE_LEVEL_BUTTON = "sitekey-form__level-remove-level-button";
|
const REMOVE_LEVEL_BUTTON = "sitekey-form__level-remove-level-button";
|
||||||
|
|
||||||
@@ -19,8 +19,8 @@ import getNumLevels from "../levels/getNumLevels";
|
|||||||
import { getAddForm, addLevel } from "../setupTests";
|
import { getAddForm, addLevel } from "../setupTests";
|
||||||
import CONST from "../const";
|
import CONST from "../const";
|
||||||
|
|
||||||
import log from "../../../../../logger";
|
import log from "../../../../../../logger";
|
||||||
import { MODE } from "../../../../../logger";
|
import { MODE } from "../../../../../../logger";
|
||||||
|
|
||||||
document.body.innerHTML = getAddForm();
|
document.body.innerHTML = getAddForm();
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
import getNumLevels from "../../levels/getNumLevels";
|
import getNumLevels from "../../levels/getNumLevels";
|
||||||
import CONST from "../../const";
|
import CONST from "../../const";
|
||||||
import log from "../../../../../../logger";
|
import log from "../../../../../../../logger";
|
||||||
|
|
||||||
import updateLabels from "./updateLabel";
|
import updateLabels from "./updateLabel";
|
||||||
import updateInputs from "./updateInputs";
|
import updateInputs from "./updateInputs";
|
||||||
@@ -19,8 +19,8 @@ import {getAddForm, trim} from "../../setupTests";
|
|||||||
import updateInputs from "./updateInputs";
|
import updateInputs from "./updateInputs";
|
||||||
import CONST from "../../const";
|
import CONST from "../../const";
|
||||||
|
|
||||||
import log from "../../../../../../logger";
|
import log from "../../../../../../../logger";
|
||||||
import {MODE} from "../../../../../../logger";
|
import {MODE} from "../../../../../../../logger";
|
||||||
|
|
||||||
import {setupAddlevels} from "./setupTests";
|
import {setupAddlevels} from "./setupTests";
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import CONST from "../../const";
|
import CONST from "../../const";
|
||||||
import log from "../../../../../../logger";
|
import log from "../../../../../../../logger";
|
||||||
|
|
||||||
/** update input IDs with new level */
|
/** update input IDs with new level */
|
||||||
const updateInput = (levelGroup: Element, newLevel: number): void => {
|
const updateInput = (levelGroup: Element, newLevel: number): void => {
|
||||||
@@ -19,8 +19,8 @@ import { trim } from "../../setupTests";
|
|||||||
import updateLabels from "./updateLabel";
|
import updateLabels from "./updateLabel";
|
||||||
import CONST from "../../const";
|
import CONST from "../../const";
|
||||||
|
|
||||||
import log from "../../../../../../logger";
|
import log from "../../../../../../../logger";
|
||||||
import { MODE } from "../../../../../../logger";
|
import { MODE } from "../../../../../../../logger";
|
||||||
|
|
||||||
/** get initial form to test remove button functionality */
|
/** get initial form to test remove button functionality */
|
||||||
export const labelLevel = (level: number): string => {
|
export const labelLevel = (level: number): string => {
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import CONST from "../../const";
|
import CONST from "../../const";
|
||||||
import log from "../../../../../../logger";
|
import log from "../../../../../../../logger";
|
||||||
|
|
||||||
/** update level lables to match new level */
|
/** update level lables to match new level */
|
||||||
const updateLabels = (levelGroup: Element, newLevel: number): void => {
|
const updateLabels = (levelGroup: Element, newLevel: number): void => {
|
||||||
@@ -19,8 +19,8 @@ import { trim} from "../../setupTests";
|
|||||||
import updateLevelGroup from "./updateLevelGroup";
|
import updateLevelGroup from "./updateLevelGroup";
|
||||||
import CONST from "../../const";
|
import CONST from "../../const";
|
||||||
|
|
||||||
import log from "../../../../../../logger";
|
import log from "../../../../../../../logger";
|
||||||
import {MODE} from "../../../../../../logger";
|
import {MODE} from "../../../../../../../logger";
|
||||||
|
|
||||||
|
|
||||||
/** get initial form to test remove button functionality */
|
/** get initial form to test remove button functionality */
|
||||||
@@ -19,8 +19,8 @@ import {trim} from "../../setupTests";
|
|||||||
import updateRemoveButton from "./updateRemoveButton";
|
import updateRemoveButton from "./updateRemoveButton";
|
||||||
import CONST from "../../const";
|
import CONST from "../../const";
|
||||||
|
|
||||||
import log from "../../../../../../logger";
|
import log from "../../../../../../../logger";
|
||||||
import {MODE} from "../../../../../../logger";
|
import {MODE} from "../../../../../../../logger";
|
||||||
|
|
||||||
/** get initial form to test remove button functionality */
|
/** get initial form to test remove button functionality */
|
||||||
export const labelLevel = (level: number): string => {
|
export const labelLevel = (level: number): string => {
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<. include!("../../../components/headers/index.html"); .>
|
|
||||||
<. include!("../../navbar/index.html"); .>
|
|
||||||
<div class="tmp-layout">
|
|
||||||
<. include!("../../header/index.html"); .>
|
|
||||||
|
|
||||||
<main class="panel-main">
|
|
||||||
<. include!("../../help-banner/index.html"); .>
|
|
||||||
<!-- Main content container -->
|
|
||||||
<div class="inner-container">
|
|
||||||
<!-- Main menu/ important actions roaster -->
|
|
||||||
|
|
||||||
<. include!("./form.html"); .>
|
|
||||||
</div>
|
|
||||||
<!-- end of container -->
|
|
||||||
<. include!("../../../components/footers.html"); .>
|
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import getNumLevels from "../add/ts/levels/getNumLevels";
|
import getNumLevels from "../add/advance/ts/levels/getNumLevels";
|
||||||
import {addLevel} from "../add/ts/setupTests";
|
import {addLevel} from "../add/advance/ts/setupTests";
|
||||||
import setup from "../../../components/error/setUpTests";
|
import setup from "../../../components/error/setUpTests";
|
||||||
import * as SETUP from "./setupTest";
|
import * as SETUP from "./setupTest";
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<. include!("./existing-level.html"); .>
|
<. include!("./existing-level.html"); .>
|
||||||
<. } .>
|
<. } .>
|
||||||
<. let level = levels.len() + 1; .>
|
<. let level = levels.len() + 1; .>
|
||||||
<. include!("../add/add-level.html"); .>
|
<. include!("../add/advance/add-level.html"); .>
|
||||||
<button data-sitekey="<.= key .>"
|
<button data-sitekey="<.= key .>"
|
||||||
id="sitekey-form__submit" class="sitekey-form__submit" type="submit">
|
id="sitekey-form__submit" class="sitekey-form__submit" type="submit">
|
||||||
Submit
|
Submit
|
||||||
|
|||||||
@@ -14,15 +14,15 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import * as Add from "../add/ts/form/";
|
import * as Add from "../add/advance/ts/form/";
|
||||||
import addLevelButtonAddEventListener from "../add/ts/addLevelButton";
|
import addLevelButtonAddEventListener from "../add/advance/ts/addLevelButton";
|
||||||
import { addRemoveLevelButtonEventListenerAll } from "../add/ts/removeLevelButton";
|
import { addRemoveLevelButtonEventListenerAll } from "../add/advance/ts/removeLevelButton";
|
||||||
import getNumLevels from "../add/ts/levels/getNumLevels";
|
import getNumLevels from "../add/advance/ts/levels/getNumLevels";
|
||||||
import validateLevel from "../add/ts/levels/validateLevel";
|
import validateLevel from "../add/advance/ts/levels/validateLevel";
|
||||||
import * as UpdateLevel from "../add/ts/levels/updateLevel";
|
import * as UpdateLevel from "../add/advance/ts/levels/updateLevel";
|
||||||
import validateDescription from "../add/ts/form/validateDescription";
|
import validateDescription from "../add/advance/ts/form/validateDescription";
|
||||||
import validateDuration from "../add/ts/form/validateDuration";
|
import validateDuration from "../add/advance/ts/form/validateDuration";
|
||||||
import { LEVELS } from "../add/ts/levels";
|
import { LEVELS } from "../add/advance/ts/levels";
|
||||||
|
|
||||||
import getFormUrl from "../../../utils/getFormUrl";
|
import getFormUrl from "../../../utils/getFormUrl";
|
||||||
import genJsonPayload from "../../../utils/genJsonPayload";
|
import genJsonPayload from "../../../utils/genJsonPayload";
|
||||||
|
|||||||
Reference in New Issue
Block a user