153 lines
3.3 KiB
TypeScript
153 lines
3.3 KiB
TypeScript
|
|
/*
|
||
|
|
Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Frontend
|
||
|
|
Copyright (C) 2024 Christian Fraß
|
||
|
|
|
||
|
|
This program 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.
|
||
|
|
|
||
|
|
This program 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 this program. If not, see
|
||
|
|
<https://www.gnu.org/licenses/>.
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
namespace _zackeneule.widget.password_policy
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
*/
|
||
|
|
export class class_password_policy implements lib_plankton.zoo_widget.interface_widget
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
*/
|
||
|
|
private data : lib_plankton.password.type_policy;
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
*/
|
||
|
|
private title : (null | string);
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
*/
|
||
|
|
public constructor(
|
||
|
|
data : lib_plankton.password.type_policy,
|
||
|
|
{
|
||
|
|
"title": title = lib_plankton.translate.get("widget.password_policy.title"),
|
||
|
|
}
|
||
|
|
:
|
||
|
|
{
|
||
|
|
title ?: (null | string);
|
||
|
|
}
|
||
|
|
=
|
||
|
|
{
|
||
|
|
}
|
||
|
|
)
|
||
|
|
{
|
||
|
|
this.data = data;
|
||
|
|
this.title = title;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
*/
|
||
|
|
public load(
|
||
|
|
target_element : Element
|
||
|
|
) : Promise<void>
|
||
|
|
{
|
||
|
|
const entries : Array<string> = (
|
||
|
|
[]
|
||
|
|
// minimum_length
|
||
|
|
.concat(
|
||
|
|
(this.data.minimum_length === null)
|
||
|
|
?
|
||
|
|
[]
|
||
|
|
:
|
||
|
|
lib_plankton.translate.get(
|
||
|
|
"widget.password_policy.minimum_length",
|
||
|
|
{
|
||
|
|
"minimum_length": this.data.minimum_length.toFixed(0),
|
||
|
|
}
|
||
|
|
)
|
||
|
|
)
|
||
|
|
// maximum_length
|
||
|
|
.concat(
|
||
|
|
(this.data.minimum_length === null)
|
||
|
|
?
|
||
|
|
[]
|
||
|
|
:
|
||
|
|
lib_plankton.translate.get(
|
||
|
|
"widget.password_policy.maximum_length",
|
||
|
|
{
|
||
|
|
"maximum_length": this.data.maximum_length.toFixed(0),
|
||
|
|
}
|
||
|
|
)
|
||
|
|
)
|
||
|
|
// must_contain_letter
|
||
|
|
.concat(
|
||
|
|
(! this.data.must_contain_letter)
|
||
|
|
?
|
||
|
|
[]
|
||
|
|
:
|
||
|
|
lib_plankton.translate.get(
|
||
|
|
"widget.password_policy.must_contain_letter",
|
||
|
|
{
|
||
|
|
}
|
||
|
|
)
|
||
|
|
)
|
||
|
|
// must_contain_number
|
||
|
|
.concat(
|
||
|
|
(! this.data.must_contain_number)
|
||
|
|
?
|
||
|
|
[]
|
||
|
|
:
|
||
|
|
lib_plankton.translate.get(
|
||
|
|
"widget.password_policy.must_contain_number",
|
||
|
|
{
|
||
|
|
}
|
||
|
|
)
|
||
|
|
)
|
||
|
|
// must_contain_special_character
|
||
|
|
.concat(
|
||
|
|
(! this.data.must_contain_special_character)
|
||
|
|
?
|
||
|
|
[]
|
||
|
|
:
|
||
|
|
lib_plankton.translate.get(
|
||
|
|
"widget.password_policy.must_contain_special_character",
|
||
|
|
{
|
||
|
|
}
|
||
|
|
)
|
||
|
|
)
|
||
|
|
);
|
||
|
|
|
||
|
|
|
||
|
|
target_element.appendChild(_zackeneule.helpers.template_request("widget-password_policy"));
|
||
|
|
|
||
|
|
target_element.querySelector(".widget-password_policy").classList.toggle(
|
||
|
|
"widget-password_policy-without_title",
|
||
|
|
(this.title === null)
|
||
|
|
);
|
||
|
|
|
||
|
|
target_element.querySelector(".widget-password_policy-title").textContent = (this.title ?? "");
|
||
|
|
|
||
|
|
const element_ul : HTMLElement = target_element.querySelector(".widget-password_policy-entries");
|
||
|
|
entries.forEach(
|
||
|
|
entry => {
|
||
|
|
const element_li : HTMLElement = document.createElement("li");
|
||
|
|
element_li.textContent = entry;
|
||
|
|
element_ul.appendChild(element_li);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
|
||
|
|
return Promise.resolve<void>(undefined);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|