-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding addWebLink to dashboard functionality.
- Loading branch information
Showing
9 changed files
with
138 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import {NavItemSelected, SideNavCollapse} from './home/index.js'; | ||
import {DeleteAccountModelInit, DisableMyAccountInit} from './setting/index.js'; | ||
import { NavItemSelected, SideNavCollapse, AddNewWebLinkInit } from './home/index.js'; | ||
import { DeleteAccountModelInit, DisableMyAccountInit } from './setting/index.js'; | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
NavItemSelected(); | ||
SideNavCollapse(); | ||
DeleteAccountModelInit(); | ||
DisableMyAccountInit(); | ||
console.log('App is loaded'); | ||
NavItemSelected(); | ||
SideNavCollapse(); | ||
DeleteAccountModelInit(); | ||
DisableMyAccountInit(); | ||
AddNewWebLinkInit(); | ||
console.info('App is loaded'); | ||
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export function RedirectToLogin() { | ||
window.location = '/logout'; | ||
window.location = '/logout'; | ||
} | ||
|
||
export function CloseModal(modalId, toClose) { | ||
const m = document.querySelector(modalId); | ||
m.addEventListener('click', () => { | ||
toClose.classList.toggle('hidden'); | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import {RedirectToLogin} from '../common/index.js'; | ||
import { RedirectToLogin } from '../common/index.js'; | ||
|
||
export function DeleteAccountModelInit() { | ||
const deleteBtn = document.querySelector('#delete-my-account'); | ||
if (!deleteBtn) { | ||
return; | ||
} | ||
const deleteModal = document.querySelector('#delete-account-modal'); | ||
deleteBtn.addEventListener('click', (e) => { | ||
deleteModal.classList.toggle('hidden'); | ||
}); | ||
const deleteBtn = document.querySelector('#delete-my-account'); | ||
if (!deleteBtn) { | ||
return; | ||
} | ||
const deleteModal = document.querySelector('#delete-account-modal'); | ||
deleteBtn.addEventListener('click', (e) => { | ||
deleteModal.classList.toggle('hidden'); | ||
}); | ||
} | ||
|
||
async function DisableAccount() { | ||
const url = '/setting/disablemyaccount'; | ||
try { | ||
const response = await fetch(url, {method: 'PUT'}); | ||
if (!response.ok) { | ||
throw new Error(`Response status: ${response.status}`); | ||
} | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error.message); | ||
const url = '/setting/disablemyaccount'; | ||
try { | ||
const response = await fetch(url, { method: 'PUT' }); | ||
if (!response.ok) { | ||
throw new Error(`Response status: ${response.status}`); | ||
} | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error.message); | ||
} | ||
} | ||
|
||
export function DisableMyAccountInit() { | ||
const disableBtn = document.querySelector('#disable-my-account'); | ||
if (!disableBtn) { | ||
return; | ||
const disableBtn = document.querySelector('#disable-my-account'); | ||
if (!disableBtn) { | ||
return; | ||
} | ||
disableBtn.addEventListener('click', async (e) => { | ||
console.info('Disable my account event'); | ||
const res = await DisableAccount(); | ||
if (res && res?.Status === 'OK') { | ||
console.info('Account is disabled until you logged in back.'); | ||
RedirectToLogin(); | ||
} | ||
disableBtn.addEventListener('click', async (e) => { | ||
console.log('Disable my account event'); | ||
const res = await DisableAccount(); | ||
if (res && res['Status'] === 'OK') { | ||
console.log('Account is disabled until you logged in back.'); | ||
RedirectToLogin(); | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{{define "widget/add_link"}} | ||
<div class="relative z-10 mx-right h-auto group"> | ||
<div class="flex items-center px-2 py-1 text-gray-700 group select-none hover:cursor-pointer hover:text-indigo-500"> | ||
<p id="add-weblink">Add Link</p> | ||
</div> | ||
</div> | ||
<!-- Modal Background --> | ||
<div id="add-weblink-modal" class="fixed inset-0 bg-gray-900 bg-opacity-50 flex justify-center pt-10 hidden"> | ||
<!-- Modal Content --> | ||
<div class="fixed bg-white w-full max-w-md mx-4 sm:mx-6 md:mx-8 lg:mx-12 p-6 sm:p-8 rounded-lg shadow-lg"> | ||
<!-- Close Button (Cross Icon) --> | ||
<button class="absolute top-4 right-4 text-gray-500 hover:text-black-700" id="close-modal"> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /> | ||
</svg> | ||
</button> | ||
|
||
<h2 class="text-sm sm:text-sm font-bold mb-4">Add Link</h2> | ||
|
||
<!-- Input Box --> | ||
<input type="text" id="add-weblink-input-box" placeholder="Enter link" class="w-full p-1 border rounded mb-3 focus:outline-none focus:ring-2 focus:ring-indigo-500"> | ||
|
||
<!-- Add Link Button --> | ||
<div class="flex justify-end"> | ||
<button class="bg-blue-500 text-white text-sm px-4 py-2 rounded hover:bg-blue-600" id="add-link-btn">Add Link</button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters