@@ -37,12 +42,8 @@ include!("./navbar/index.html"); .>
-  "
- alt="copy sitekey" data-sitekey="<.= sitekey.key .>" />  "
- alt="sitekey copied" data-sitekey="<.= sitekey.key .>" />
+ <. let clipboard_data = ("sitekey", &sitekey.key); .>
+ <. include!("../components/clipboard/index.html"); .>
|
-  "
- alt="copy sitekey" data-sitekey="<.= sitekey.key .>" />  "
- alt="sitekey copied" data-sitekey="<.= sitekey.key .>" />
+ <. let clipboard_data = ("sitekey", &sitekey.key); .>
+ <. include!("../../../components/clipboard/index.html"); .>
|
-
- <. let key = format!("/sitekey/{}", &sitekey.key); .>
- <. include!("../view/__edit-sitekey-icon.html"); .>
-
+
+ <. let key = format!("/sitekey/{}", &sitekey.key); .>
+ <. include!("../view/__edit-sitekey-icon.html"); .>
+
|
<. } .>
diff --git a/templates/panel/sitekey/list/ts/index.ts b/templates/panel/sitekey/list/ts/index.ts
index 78ccc1bc..8eca0c9f 100644
--- a/templates/panel/sitekey/list/ts/index.ts
+++ b/templates/panel/sitekey/list/ts/index.ts
@@ -14,40 +14,19 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see
.
*/
-
-export const index = () => {
- registerCopySitekey();
-};
+import CopyIcon from '../../../../components/clipboard/';
const SITEKEY_COPY_ICON = `sitekey__copy-icon`;
const SITEKEY_COPY_DONE_ICON = `sitekey__copy-done-icon`;
-const registerCopySitekey = () => {
- const icons = document.querySelectorAll(`.${SITEKEY_COPY_ICON}`);
- icons.forEach(icon => {
- icon.addEventListener('click', e => copySitekey(e));
- });
-};
-
-/*
- * Copy sitekey to clipboard
- */
-const copySitekey = async (e: Event) => {
- const image =
e.target;
+export const index = () => {
+ const image = document.querySelector(`.${SITEKEY_COPY_ICON}`);
if (!image.classList.contains(SITEKEY_COPY_ICON)) {
throw new Error(
'This method should only be called when sitekey copy button/icon is clicked',
);
}
- const copyDoneIcon = (
- image.parentElement.querySelector(`.${SITEKEY_COPY_DONE_ICON}`)
- );
const sitekey = image.dataset.sitekey;
- await navigator.clipboard.writeText(sitekey);
- image.style.display = 'none';
- copyDoneIcon.style.display = 'block';
- setTimeout(() => {
- copyDoneIcon.style.display = 'none';
- image.style.display = 'block';
- }, 1200);
+
+ new CopyIcon(sitekey, SITEKEY_COPY_ICON, SITEKEY_COPY_DONE_ICON);
};
diff --git a/templates/views/v1/routes.ts b/templates/views/v1/routes.ts
index c513493d..4bf51ad0 100644
--- a/templates/views/v1/routes.ts
+++ b/templates/views/v1/routes.ts
@@ -20,6 +20,7 @@ const ROUTES = {
loginUser: '/login/',
signoutUser: '/api/v1/signout',
panelHome: '/',
+ settings: '/settings/',
docsHome: '/docs/',
notifications: '/notifications',
listSitekey: '/sitekeys/',