From b2bfb82833b6deebc3a44918b8e0fe70c003e379 Mon Sep 17 00:00:00 2001 From: ivinayakg Date: Sat, 14 Jan 2023 19:46:40 +0530 Subject: [PATCH 01/36] refactor private options handler --- script.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index 1281fd51..fc5652ac 100644 --- a/script.js +++ b/script.js @@ -1,13 +1,16 @@ const userManagementLink = document.getElementById(USER_MANAGEMENT_LINK); -export async function showUserManagementButton() { + +export async function showSuperUserOptions(...privateBtns) { try { const isSuperUser = await checkUserIsSuperUser(); if (isSuperUser) { - userManagementLink.classList.remove('element-display-remove'); + privateBtns.forEach((btn) => + btn.classList.remove('element-display-remove'), + ); } } catch (err) { console.log(err); } } -showUserManagementButton(); +showSuperUserOptions(userManagementLink); From d4691d079a0f5742db82d4dd97d561da8e950d22 Mon Sep 17 00:00:00 2001 From: ivinayakg Date: Sat, 14 Jan 2023 19:59:11 +0530 Subject: [PATCH 02/36] basic setup --- constants.js | 3 ++- extension-requests/index.html | 11 +++++++++++ extension-requests/script.js | 0 extension-requests/style.css | 0 index.html | 7 +++++++ script.js | 9 ++++++++- style.css | 31 ++++++++++++++++++++++++++----- 7 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 extension-requests/index.html create mode 100644 extension-requests/script.js create mode 100644 extension-requests/style.css diff --git a/constants.js b/constants.js index d4b50532..61341eac 100644 --- a/constants.js +++ b/constants.js @@ -1,2 +1,3 @@ -const API_BASE_URL = 'https://api.realdevsquad.com'; +const API_BASE_URL = 'http://localhost:3000'; const USER_MANAGEMENT_LINK = 'user-management-link'; +const EXTENSION_REQUESTS_LINK = 'extension-requests-link'; diff --git a/extension-requests/index.html b/extension-requests/index.html new file mode 100644 index 00000000..3e796a6e --- /dev/null +++ b/extension-requests/index.html @@ -0,0 +1,11 @@ + + + + + + + Extension Requests + + + + diff --git a/extension-requests/script.js b/extension-requests/script.js new file mode 100644 index 00000000..e69de29b diff --git a/extension-requests/style.css b/extension-requests/style.css new file mode 100644 index 00000000..e69de29b diff --git a/index.html b/index.html index 3d82a865..c779a060 100644 --- a/index.html +++ b/index.html @@ -37,6 +37,13 @@ > User Management + + Extension Requests + Online Members diff --git a/script.js b/script.js index fc5652ac..b0a86648 100644 --- a/script.js +++ b/script.js @@ -1,4 +1,5 @@ const userManagementLink = document.getElementById(USER_MANAGEMENT_LINK); +const extensionRequestsLink = document.getElementById(EXTENSION_REQUESTS_LINK); export async function showSuperUserOptions(...privateBtns) { try { @@ -13,4 +14,10 @@ export async function showSuperUserOptions(...privateBtns) { } } -showSuperUserOptions(userManagementLink); +/* + * To show the super user options only to the super user, give all those + * buttons or node the class "element-display-remove" so by default they are hidden. + * Then get the node from the DOM into a variable and pass that variable in the + * function below. + */ +showSuperUserOptions(userManagementLink, extensionRequestsLink); diff --git a/style.css b/style.css index a24d3915..c650199d 100644 --- a/style.css +++ b/style.css @@ -35,8 +35,9 @@ body { height: 80vh; display: flex; justify-content: center; - align-items: center; + align-content: center; gap: 20px; + flex-wrap: wrap; } button { @@ -58,7 +59,7 @@ button { .create-task-btn:hover { color: white; background-color: #1d1283; - border: none; + border-color: transparent; } /* profile section */ @@ -82,7 +83,7 @@ button { .profile-task-btn:hover { color: white; background-color: #1d1283; - border: none; + border-color: transparent; } #user-management-link { color: black; @@ -100,7 +101,27 @@ button { #user-management-link:hover { color: var(--white-color); background-color: var(--blue-color); - border: none; + border-color: transparent; +} + +/* Extension Requests */ +#extension-requests-link { + color: black; + font-weight: 500; + font-size: larger; + background-color: var(--white-color); + border: 2px solid var(--black-color); + border-radius: 5px; + padding: 10px 50px; + cursor: pointer; + transition: all 0.5s ease; + width: max-content; + text-decoration: none; +} +#extension-requests-link:hover { + color: var(--white-color); + background-color: var(--blue-color); + border-color: transparent; } /* Online-members */ @@ -117,7 +138,7 @@ button { .online-members-link:hover { color: white; background-color: #1d1283; - border: none; + border-color: transparent; } .info-repo { From 2047c82c3c5beb5af6c6b0a86a1d5837c8c7d73d Mon Sep 17 00:00:00 2001 From: ivinayakg Date: Mon, 16 Jan 2023 23:41:12 +0530 Subject: [PATCH 03/36] draft feature --- extension-requests/index.html | 46 ++++++- extension-requests/local-utils.js | 92 ++++++++++++++ extension-requests/script.js | 150 +++++++++++++++++++++++ extension-requests/style.css | 192 ++++++++++++++++++++++++++++++ utils.js | 27 +++++ 5 files changed, 506 insertions(+), 1 deletion(-) create mode 100644 extension-requests/local-utils.js diff --git a/extension-requests/index.html b/extension-requests/index.html index 3e796a6e..f64bcd32 100644 --- a/extension-requests/index.html +++ b/extension-requests/index.html @@ -7,5 +7,49 @@ Extension Requests - + +
+
+ +
+

Update Extension Request Status

+ + + + + + + + + + +
+
+
+

Extension Requests

+
+
+
+
+

+ + + + + diff --git a/extension-requests/local-utils.js b/extension-requests/local-utils.js new file mode 100644 index 00000000..b0264636 --- /dev/null +++ b/extension-requests/local-utils.js @@ -0,0 +1,92 @@ +async function getExtensionRequests(query = {}) { + const url = new URL(`${API_BASE_URL}/extensionRequests`); + + const { assignee, status, taskId } = query; + if (assignee) url.searchParams.set('assignee', assignee); + if (status) url.searchParams.set('status', status); + if (taskId) url.searchParams.set('taskId', taskId); + + const res = await fetch(url, { + credentials: 'include', + method: 'GET', + headers: { + 'Content-type': 'application/json', + }, + }); + return await res.json(); +} + +async function createExtensionRequestStatus({ extensionRequest }) { + const url = `${API_BASE_URL}/extensionRequests`; + const res = await fetch(url, { + credentials: 'include', + method: 'POST', + body: JSON.stringify(extensionRequest), + headers: { + 'Content-type': 'application/json', + }, + }); + return await res.json(); +} + +async function updateExtensionRequestStatus({ id, status }) { + const url = `${API_BASE_URL}/extensionRequests/${id}/status`; + const res = await fetch(url, { + credentials: 'include', + method: 'PATCH', + body: JSON.stringify({ status }), + headers: { + 'Content-type': 'application/json', + }, + }); + return await res.json(); +} + +async function getTaskDetails(taskId) { + if (!taskId) return; + const url = `${API_BASE_URL}/tasks/${taskId}/details`; + const res = await fetch(url, { + credentials: 'include', + method: 'GET', + headers: { + 'Content-type': 'application/json', + }, + }); + return await res.json(); +} + +function getTimeFromTimestamp(timestamp) { + return new Date(timestamp * 1000).toLocaleString(); +} + +function createTable(headings, data, className = '') { + const main = createElement({ + type: 'table', + attributes: { + class: className, + }, + }); + const content = createElement({ type: 'tbody' }); + headings.forEach(({ title, key, time, bold }) => { + let row = createElement({ type: 'tr' }); + let heading = createElement({ type: 'th', innerText: title }); + + let contentText = ''; + if (time) contentText = getTimeFromTimestamp(data[key]); + else contentText = key ? data[key] : data[title.toLowerCase()]; + + let text = createElement({ + type: 'td', + innerText: contentText, + attributes: { + class: bold ? 'bold' : '', + }, + }); + row.appendChild(heading); + row.appendChild(text); + content.appendChild(row); + }); + + main.appendChild(content); + return main; +} diff --git a/extension-requests/script.js b/extension-requests/script.js index e69de29b..aa0eb759 100644 --- a/extension-requests/script.js +++ b/extension-requests/script.js @@ -0,0 +1,150 @@ +const container = document.querySelector('.container'); +const extensionRequestsContainer = document.querySelector( + '.extension-requests', +); + +const errorHeading = document.querySelector('h2#error'); +const modalParent = document.querySelector('.extension-requests-modal-parent'); +const closeModal = document.querySelectorAll('#close-modal'); + +//modal containers +const modalShowInfo = document.querySelector('.extension-requests-info'); +const modalStatusForm = document.querySelector( + '.extension-requests-status-form', +); + +const state = { + currentExtensionRequest: null, +}; + +const render = async () => { + try { + addLoader(container); + const extensionRequests = await getExtensionRequests(); + const allExtensionRequests = extensionRequests.allExtensionRequests; + allExtensionRequests.forEach((data) => { + extensionRequestsContainer.appendChild(createExtensionRequestCard(data)); + }); + } catch (error) { + errorHeading.textContent = 'Something went wrong'; + errorHeading.classList.add('error-visible'); + reload(); + } finally { + removeLoader(); + } +}; + +const showTaskDetails = async (taskId) => { + if (!taskId) return; + try { + modalShowInfo.innerHTML = '

Task Details

'; + addLoader(modalShowInfo); + const taskDetails = await getTaskDetails(taskId); + const taskData = taskDetails.taskData; + modalShowInfo.append(createTaskInfoModal(taskData)); + } catch (error) { + errorHeading.textContent = 'Something went wrong'; + errorHeading.classList.add('error-visible'); + reload(); + } finally { + removeLoader(); + } +}; + +function updateStatusForm() { + document.querySelector('.extensionId').value = + state.currentExtensionRequest.id; + document.querySelector('.extensionTitle').value = + state.currentExtensionRequest.title; + document.querySelector('.extensionAssignee').value = + state.currentExtensionRequest.assignee; +} + +function createTaskInfoModal(data) { + if (!data) return; + + const dataHeadings = [ + { title: 'Title' }, + { title: 'Ends On', key: 'endsOn', time: true }, + { title: 'Purpose' }, + { title: 'Assignee' }, + { title: 'Created By', key: 'createdBy' }, + { title: 'Is Noteworthy', key: 'isNoteworthy' }, + ]; + + const updateStatus = createElement({ + type: 'button', + attributes: { class: 'status-form' }, + innerText: 'Update Status', + }); + const closeModal = createElement({ + type: 'button', + attributes: { id: 'close-modal' }, + innerText: 'Cancel', + }); + updateStatus.addEventListener('click', () => { + showModal('status-form'); + updateStatusForm(); + }); + closeModal.addEventListener('click', () => hideModal()); + + const main = createTable(dataHeadings, data); + + main.appendChild(updateStatus); + main.appendChild(closeModal); + return main; +} + +function createExtensionRequestCard(data) { + if (!data) return; + + const dataHeadings = [ + { title: 'Title' }, + { title: 'Reason' }, + { title: 'Old Ends On', key: 'oldEndsOn', time: true }, + { title: 'New Ends On', key: 'newEndsOn', time: true }, + { title: 'Status', bold: true }, + { title: 'Assignee' }, + { title: 'Created At', key: 'timestamp', time: true }, + { title: 'Task', key: 'taskId' }, + ]; + + const moreInfoBtn = createElement({ + type: 'button', + attributes: { class: 'more' }, + innerText: 'More', + }); + moreInfoBtn.addEventListener('click', () => { + showModal('info'); + showTaskDetails(data.taskId); + state.currentExtensionRequest = data; + }); + + const main = createTable(dataHeadings, data, 'extension-request'); + + main.appendChild(moreInfoBtn); + return main; +} + +render(); + +modalParent.addEventListener('click', hideModal); +closeModal.forEach((node) => node.addEventListener('click', () => hideModal())); + +function showModal(show = 'form') { + modalParent.classList.add('visible'); + modalParent.setAttribute('show', show); +} +function hideModal(e) { + if (!e) { + modalParent.classList.remove('visible'); + return; + } + e.stopPropagation(); + if (e.target === modalParent) { + modalParent.classList.remove('visible'); + } +} +function reload() { + setTimeout(() => window.history.go(0), 2000); +} diff --git a/extension-requests/style.css b/extension-requests/style.css index e69de29b..14b9a60b 100644 --- a/extension-requests/style.css +++ b/extension-requests/style.css @@ -0,0 +1,192 @@ +:root { + --dark-blue: #1b1378; + --light-aqua: #d4f9f2; + --scandal: #e5fcf5; + --white: #ffffff; + --black-transparent: #000000a8; + --black: #181717; + --light-gray: #d9d9d9; + --razzmatazz: #df0057; + --gray: #808080; + --button-proceed: #008000; +} + +*, +::after, +::before { + box-sizing: border-box; +} + +button { + cursor: pointer; +} + +.bold { + font-weight: bolder; +} + +body { + font-family: 'Roboto', sans-serif; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + min-height: 100vh; + user-select: none; + max-width: 100vw; +} + +.container { + width: 100%; + text-align: center; + padding: 10px; +} + +.header { + background-color: var(--dark-blue); + text-align: center; + color: var(--white); +} + +.extension-requests-modal-parent { + display: none; +} +.extension-requests-modal-parent.visible { + z-index: 1; + position: fixed; + top: 0; + left: 0; + display: flex; + justify-content: center; + align-items: center; + min-width: 100vw; + min-height: 100vh; + background-color: #00000048; +} + +.extension-requests-modal-parent > * { + display: none; + flex-direction: column; + justify-content: center; + align-items: flex-start; + width: 40%; + height: 100%; + margin: 10px 0px; + background-color: var(--white); + padding: 20px; + border-radius: 5px; + min-width: 250px; +} + +#close-modal { + align-self: center; +} + +/* task info */ +.extension-requests-modal-parent[show='info'] .extension-requests-info { + display: flex; +} + +.extension-requests-info table { + text-align: left; + margin: 10px; + color: var(--black); + border-radius: 5px; +} + +.extension-requests-info button { + background-color: var(--button-proceed); + border: none; + color: var(--white); + padding: 8px 16px; + font-size: medium; + font-weight: bold; + border-radius: 5px; + margin: 10px; +} + +/* task info ends here */ + +/* status form */ +.extension-requests-modal-parent[show='status-form'] + .extension-requests-status-form { + display: flex; +} + +.extension-requests-status-form input, +.extension-requests-status-form select { + margin: 5px 0px 15px 0px; + padding: 5px; + width: 100%; + border: none; + border-bottom: 1px solid var(--gray); +} +.extension-requests-status-form input:focus { + outline: none; + border-bottom: 1px solid var(--gray); +} +.extension-requests-status-form button { + background-color: var(--button-proceed); + border: none; + color: var(--white); + padding: 8px 16px; + font-size: medium; + font-weight: bold; + border-radius: 5px; + margin: 10px; +} + +/* status form ends here */ + +.extension-requests { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(475px, 1fr)); + flex-wrap: wrap; +} + +.extension-request { + text-align: left; + border: 2px solid var(--black-transparent); + padding: 20px; + margin: 10px; + color: var(--black); + border-radius: 5px; +} + +.extension-request tr th { + width: 50%; +} + +.extension-request .more { + background-color: var(--button-proceed); + border: none; + color: var(--white); + width: 40%; + padding: 8px 16px; + font-size: medium; + font-weight: bold; + border-radius: 5px; + margin-top: 10px; +} + +/* Loader Container */ +.loader-text { + text-align: center; + font-size: 2rem; +} +.loader { + margin: auto auto; +} + +.loader p { + font-weight: 800; + font-size: 3em; +} + +/* Error Heading */ +.error { + display: none; +} +.error-visible { + display: block; +} diff --git a/utils.js b/utils.js index fe287218..fcd10ebe 100644 --- a/utils.js +++ b/utils.js @@ -14,3 +14,30 @@ async function checkUserIsSuperUser() { const self_user = await getSelfUser(); return self_user?.roles['super_user']; } + +function createElement({ type, attributes = {}, innerText }) { + const element = document.createElement(type); + Object.keys(attributes).forEach((item) => { + element.setAttribute(item, attributes[item]); + }); + element.textContent = innerText; + return element; +} + +function addLoader(container) { + const loader = createElement({ + type: 'div', + attributes: { class: 'loader' }, + }); + const loadertext = createElement({ + type: 'p', + attributes: { class: 'loader-text' }, + innerText: 'Loading...', + }); + loader.appendChild(loadertext); + container.appendChild(loader); +} + +function removeLoader() { + document.querySelector('.loader').remove(); +} From 896ccda07d072f0c94bb20c5a22593960eb9ad89 Mon Sep 17 00:00:00 2001 From: ivinayakg Date: Wed, 1 Feb 2023 01:52:23 +0530 Subject: [PATCH 04/36] added feature --- extension-requests/index.html | 56 ++++++++++++++- extension-requests/local-utils.js | 21 ++++-- extension-requests/script.js | 109 ++++++++++++++++++++++++------ extension-requests/style.css | 36 +++++++++- 4 files changed, 194 insertions(+), 28 deletions(-) diff --git a/extension-requests/index.html b/extension-requests/index.html index f64bcd32..e2ceca7e 100644 --- a/extension-requests/index.html +++ b/extension-requests/index.html @@ -10,7 +10,61 @@
- +
+

Update Extension Request

+ + + + + + + + + + + + + + + + +

Update Extension Request Status

diff --git a/extension-requests/local-utils.js b/extension-requests/local-utils.js index b0264636..9a75e3ec 100644 --- a/extension-requests/local-utils.js +++ b/extension-requests/local-utils.js @@ -16,12 +16,12 @@ async function getExtensionRequests(query = {}) { return await res.json(); } -async function createExtensionRequestStatus({ extensionRequest }) { - const url = `${API_BASE_URL}/extensionRequests`; +async function updateExtensionRequest({ id, body }) { + const url = `${API_BASE_URL}/extensionRequests/${id}`; const res = await fetch(url, { credentials: 'include', - method: 'POST', - body: JSON.stringify(extensionRequest), + method: 'PATCH', + body: JSON.stringify(body), headers: { 'Content-type': 'application/json', }, @@ -29,12 +29,12 @@ async function createExtensionRequestStatus({ extensionRequest }) { return await res.json(); } -async function updateExtensionRequestStatus({ id, status }) { +async function updateExtensionRequestStatus({ id, body }) { const url = `${API_BASE_URL}/extensionRequests/${id}/status`; const res = await fetch(url, { credentials: 'include', method: 'PATCH', - body: JSON.stringify({ status }), + body: JSON.stringify(body), headers: { 'Content-type': 'application/json', }, @@ -90,3 +90,12 @@ function createTable(headings, data, className = '') { main.appendChild(content); return main; } + +function formDataToObject(formData) { + if (!formData) return; + const result = {}; + for (let x of formData.keys()) { + result[x] = formData.get(x); + } + return result; +} diff --git a/extension-requests/script.js b/extension-requests/script.js index aa0eb759..726568d3 100644 --- a/extension-requests/script.js +++ b/extension-requests/script.js @@ -12,6 +12,7 @@ const modalShowInfo = document.querySelector('.extension-requests-info'); const modalStatusForm = document.querySelector( '.extension-requests-status-form', ); +const modalUpdateForm = document.querySelector('.extension-requests-form'); const state = { currentExtensionRequest: null, @@ -33,15 +34,14 @@ const render = async () => { removeLoader(); } }; - -const showTaskDetails = async (taskId) => { +const showTaskDetails = async (taskId, approved) => { if (!taskId) return; try { modalShowInfo.innerHTML = '

Task Details

'; addLoader(modalShowInfo); const taskDetails = await getTaskDetails(taskId); const taskData = taskDetails.taskData; - modalShowInfo.append(createTaskInfoModal(taskData)); + modalShowInfo.append(createTaskInfoModal(taskData, approved)); } catch (error) { errorHeading.textContent = 'Something went wrong'; errorHeading.classList.add('error-visible'); @@ -50,17 +50,7 @@ const showTaskDetails = async (taskId) => { removeLoader(); } }; - -function updateStatusForm() { - document.querySelector('.extensionId').value = - state.currentExtensionRequest.id; - document.querySelector('.extensionTitle').value = - state.currentExtensionRequest.title; - document.querySelector('.extensionAssignee').value = - state.currentExtensionRequest.assignee; -} - -function createTaskInfoModal(data) { +function createTaskInfoModal(data, approved) { if (!data) return; const dataHeadings = [ @@ -84,17 +74,16 @@ function createTaskInfoModal(data) { }); updateStatus.addEventListener('click', () => { showModal('status-form'); - updateStatusForm(); + fillStatusForm(); }); closeModal.addEventListener('click', () => hideModal()); const main = createTable(dataHeadings, data); - main.appendChild(updateStatus); + if (!approved) main.appendChild(updateStatus); main.appendChild(closeModal); return main; } - function createExtensionRequestCard(data) { if (!data) return; @@ -109,25 +98,77 @@ function createExtensionRequestCard(data) { { title: 'Task', key: 'taskId' }, ]; + const updateRequestBtn = createElement({ + type: 'button', + attributes: { class: 'update_request' }, + innerText: 'Update Request', + }); const moreInfoBtn = createElement({ type: 'button', attributes: { class: 'more' }, innerText: 'More', }); + updateRequestBtn.addEventListener('click', () => { + showModal('update-form'); + state.currentExtensionRequest = data; + fillUpdateForm(); + }); moreInfoBtn.addEventListener('click', () => { showModal('info'); - showTaskDetails(data.taskId); + showTaskDetails(data.taskId, data.status === 'APPROVED'); state.currentExtensionRequest = data; }); const main = createTable(dataHeadings, data, 'extension-request'); main.appendChild(moreInfoBtn); + main.appendChild(updateRequestBtn); return main; } - render(); +//API functions +async function onStatusFormSubmit(e) { + e.preventDefault(); + try { + addLoader(container); + let formData = formDataToObject(new FormData(e.target)); + await updateExtensionRequestStatus({ + id: state.currentExtensionRequest.id, + body: formData, + }); + reload(); + } catch (error) { + errorHeading.textContent = 'Something went wrong'; + errorHeading.classList.add('error-visible'); + reload(); + } finally { + removeLoader(); + } +} +async function onUpdateFormSubmit(e) { + e.preventDefault(); + try { + addLoader(container); + let formData = formDataToObject(new FormData(e.target)); + formData['newEndsOn'] = new Date(formData['newEndsOn']).getTime() / 1000; + await updateExtensionRequest({ + id: state.currentExtensionRequest.id, + body: formData, + }); + reload(); + } catch (error) { + errorHeading.textContent = 'Something went wrong'; + errorHeading.classList.add('error-visible'); + reload(); + } finally { + removeLoader(); + } +} + +modalUpdateForm.addEventListener('submit', onUpdateFormSubmit); +modalStatusForm.addEventListener('submit', onStatusFormSubmit); + modalParent.addEventListener('click', hideModal); closeModal.forEach((node) => node.addEventListener('click', () => hideModal())); @@ -148,3 +189,33 @@ function hideModal(e) { function reload() { setTimeout(() => window.history.go(0), 2000); } +function fillStatusForm() { + modalStatusForm.querySelector('.extensionId').value = + state.currentExtensionRequest.id; + modalStatusForm.querySelector('.extensionTitle').value = + state.currentExtensionRequest.title; + modalStatusForm.querySelector('.extensionAssignee').value = + state.currentExtensionRequest.assignee; +} +function fillUpdateForm() { + modalUpdateForm.querySelector('.extensionNewEndsOn').value = new Date( + state.currentExtensionRequest.newEndsOn * 1000, + ) + .toISOString() + .replace('Z', ''); + modalUpdateForm.querySelector('.extensionOldEndsOn').value = new Date( + state.currentExtensionRequest.oldEndsOn * 1000, + ) + .toISOString() + .replace('Z', ''); + modalUpdateForm.querySelector('.extensionStatus').value = + state.currentExtensionRequest.status; + modalUpdateForm.querySelector('.extensionId').value = + state.currentExtensionRequest.id; + modalUpdateForm.querySelector('.extensionTitle').value = + state.currentExtensionRequest.title; + modalUpdateForm.querySelector('.extensionAssignee').value = + state.currentExtensionRequest.assignee; + modalUpdateForm.querySelector('.extensionReason').value = + state.currentExtensionRequest.reason; +} diff --git a/extension-requests/style.css b/extension-requests/style.css index 14b9a60b..039c30ec 100644 --- a/extension-requests/style.css +++ b/extension-requests/style.css @@ -107,6 +107,36 @@ body { /* task info ends here */ +/* update form */ +.extension-requests-modal-parent[show='update-form'] .extension-requests-form { + display: flex; +} + +.extension-requests-form input, +.extension-requests-form select { + margin: 5px 0px 15px 0px; + padding: 5px; + width: 100%; + border: none; + border-bottom: 1px solid var(--gray); +} +.extension-requests-form input:focus { + outline: none; + border-bottom: 1px solid var(--gray); +} +.extension-requests-form button { + background-color: var(--button-proceed); + border: none; + color: var(--white); + padding: 8px 16px; + font-size: medium; + font-weight: bold; + border-radius: 5px; + margin: 10px; +} + +/* update form ends here */ + /* status form */ .extension-requests-modal-parent[show='status-form'] .extension-requests-status-form { @@ -157,16 +187,18 @@ body { width: 50%; } -.extension-request .more { +.extension-request .more, +.extension-request .update_request { background-color: var(--button-proceed); border: none; color: var(--white); width: 40%; + min-width: max-content; padding: 8px 16px; font-size: medium; font-weight: bold; border-radius: 5px; - margin-top: 10px; + margin: 10px 10px 0px 0px; } /* Loader Container */ From 3bb1d85e744529e7fac300f96e62f8329c8c6f89 Mon Sep 17 00:00:00 2001 From: ivinayakg Date: Wed, 1 Feb 2023 01:57:17 +0530 Subject: [PATCH 05/36] . --- constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants.js b/constants.js index 61341eac..94fd1b91 100644 --- a/constants.js +++ b/constants.js @@ -1,3 +1,3 @@ -const API_BASE_URL = 'http://localhost:3000'; +const API_BASE_URL = 'https://api.realdevsquad.com'; const USER_MANAGEMENT_LINK = 'user-management-link'; const EXTENSION_REQUESTS_LINK = 'extension-requests-link'; From ca2ca3c0b7c05de6e27c9c3ae4cfbbe2702e5d17 Mon Sep 17 00:00:00 2001 From: ivinayakg Date: Tue, 21 Feb 2023 22:36:59 +0530 Subject: [PATCH 06/36] made suggested changes --- extension-requests/local-utils.js | 36 +++++++++++++++---------------- extension-requests/script.js | 2 +- extension-requests/style.css | 15 +++++++------ utils.js | 1 + 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/extension-requests/local-utils.js b/extension-requests/local-utils.js index 9a75e3ec..513555ad 100644 --- a/extension-requests/local-utils.js +++ b/extension-requests/local-utils.js @@ -1,10 +1,10 @@ async function getExtensionRequests(query = {}) { - const url = new URL(`${API_BASE_URL}/extensionRequests`); + const url = new URL(`${API_BASE_URL}/extension-requests`); - const { assignee, status, taskId } = query; - if (assignee) url.searchParams.set('assignee', assignee); - if (status) url.searchParams.set('status', status); - if (taskId) url.searchParams.set('taskId', taskId); + queryParams = ['assignee', 'status', 'taskId']; + queryParams.forEach( + (key) => query[key] && url.searchParams.set(key, query[key]), + ); const res = await fetch(url, { credentials: 'include', @@ -17,7 +17,7 @@ async function getExtensionRequests(query = {}) { } async function updateExtensionRequest({ id, body }) { - const url = `${API_BASE_URL}/extensionRequests/${id}`; + const url = `${API_BASE_URL}/extension-requests/${id}`; const res = await fetch(url, { credentials: 'include', method: 'PATCH', @@ -30,7 +30,7 @@ async function updateExtensionRequest({ id, body }) { } async function updateExtensionRequestStatus({ id, body }) { - const url = `${API_BASE_URL}/extensionRequests/${id}/status`; + const url = `${API_BASE_URL}/extension-requests/${id}/status`; const res = await fetch(url, { credentials: 'include', method: 'PATCH', @@ -60,42 +60,42 @@ function getTimeFromTimestamp(timestamp) { } function createTable(headings, data, className = '') { - const main = createElement({ + const table = createElement({ type: 'table', attributes: { class: className, }, }); - const content = createElement({ type: 'tbody' }); + const tableBody = createElement({ type: 'tbody' }); headings.forEach(({ title, key, time, bold }) => { let row = createElement({ type: 'tr' }); - let heading = createElement({ type: 'th', innerText: title }); + let rowHeading = createElement({ type: 'th', innerText: title }); let contentText = ''; if (time) contentText = getTimeFromTimestamp(data[key]); else contentText = key ? data[key] : data[title.toLowerCase()]; - let text = createElement({ + let tableData = createElement({ type: 'td', innerText: contentText, attributes: { class: bold ? 'bold' : '', }, }); - row.appendChild(heading); - row.appendChild(text); - content.appendChild(row); + row.appendChild(rowHeading); + row.appendChild(tableData); + tableBody.appendChild(row); }); - main.appendChild(content); - return main; + table.appendChild(tableBody); + return table; } function formDataToObject(formData) { if (!formData) return; const result = {}; - for (let x of formData.keys()) { - result[x] = formData.get(x); + for (const [key, value] of formData.entries()) { + result[key] = value; } return result; } diff --git a/extension-requests/script.js b/extension-requests/script.js index 726568d3..154faa1f 100644 --- a/extension-requests/script.js +++ b/extension-requests/script.js @@ -127,7 +127,7 @@ function createExtensionRequestCard(data) { } render(); -//API functions +//PATCH requests functions async function onStatusFormSubmit(e) { e.preventDefault(); try { diff --git a/extension-requests/style.css b/extension-requests/style.css index 039c30ec..9105d0f4 100644 --- a/extension-requests/style.css +++ b/extension-requests/style.css @@ -9,6 +9,7 @@ --razzmatazz: #df0057; --gray: #808080; --button-proceed: #008000; + --modal-color: #00000048; } *, @@ -61,7 +62,7 @@ body { align-items: center; min-width: 100vw; min-height: 100vh; - background-color: #00000048; + background-color: var(--modal-color); } .extension-requests-modal-parent > * { @@ -73,7 +74,7 @@ body { height: 100%; margin: 10px 0px; background-color: var(--white); - padding: 20px; + padding: 1.25rem; border-radius: 5px; min-width: 250px; } @@ -98,7 +99,7 @@ body { background-color: var(--button-proceed); border: none; color: var(--white); - padding: 8px 16px; + padding: 0.5rem 1rem; font-size: medium; font-weight: bold; border-radius: 5px; @@ -128,7 +129,7 @@ body { background-color: var(--button-proceed); border: none; color: var(--white); - padding: 8px 16px; + padding: 0.5rem 1rem; font-size: medium; font-weight: bold; border-radius: 5px; @@ -159,7 +160,7 @@ body { background-color: var(--button-proceed); border: none; color: var(--white); - padding: 8px 16px; + padding: 0.5rem 1rem; font-size: medium; font-weight: bold; border-radius: 5px; @@ -177,7 +178,7 @@ body { .extension-request { text-align: left; border: 2px solid var(--black-transparent); - padding: 20px; + padding: 1.25rem; margin: 10px; color: var(--black); border-radius: 5px; @@ -194,7 +195,7 @@ body { color: var(--white); width: 40%; min-width: max-content; - padding: 8px 16px; + padding: 0.5rem 1rem; font-size: medium; font-weight: bold; border-radius: 5px; diff --git a/utils.js b/utils.js index fcd10ebe..26b53963 100644 --- a/utils.js +++ b/utils.js @@ -25,6 +25,7 @@ function createElement({ type, attributes = {}, innerText }) { } function addLoader(container) { + if (!container) return; const loader = createElement({ type: 'div', attributes: { class: 'loader' }, From b116156507de8077b63a1fe5d001fc91ddffada6 Mon Sep 17 00:00:00 2001 From: Khushi Shukla <81404366+khushi818@users.noreply.github.com> Date: Sun, 12 Mar 2023 07:25:41 +0530 Subject: [PATCH 07/36] #326 Add cursor pointer in clickable elements (#329) * feat: add cursor pointer in clickable elements * fix : global css file * import css to links in html * fix:goal import --- featureFlag/index.html | 1 + featureFlag/style.css | 1 + global.css | 4 ++++ goal/index.html | 1 + index.html | 1 + online-members/online-members.css | 1 + online-members/online-members.html | 2 ++ profile/index.html | 1 + profile/style.css | 1 + style.css | 1 + task/index.html | 1 + task/style.css | 1 + taskEvents/style.css | 5 +++++ users/details/index.html | 1 + users/details/style.css | 1 + users/index.html | 1 + users/style.css | 4 ++++ wallet/index.html | 1 + 18 files changed, 29 insertions(+) create mode 100644 global.css diff --git a/featureFlag/index.html b/featureFlag/index.html index 4bfa8955..563ddf59 100644 --- a/featureFlag/index.html +++ b/featureFlag/index.html @@ -4,6 +4,7 @@ + Feature Flag | Dashboard Real Dev Squad diff --git a/featureFlag/style.css b/featureFlag/style.css index 02ffb95b..333c0ef2 100644 --- a/featureFlag/style.css +++ b/featureFlag/style.css @@ -103,6 +103,7 @@ body { height: 20px; width: 20px; } + .checkbox__tick-box--reversed { margin-left: 20px; margin-right: 0; diff --git a/global.css b/global.css new file mode 100644 index 00000000..a7f1a7c2 --- /dev/null +++ b/global.css @@ -0,0 +1,4 @@ +button, +input[type='submit'] { + cursor: pointer; +} diff --git a/goal/index.html b/goal/index.html index 5bc83741..c960ba54 100644 --- a/goal/index.html +++ b/goal/index.html @@ -3,6 +3,7 @@ + Tasks diff --git a/index.html b/index.html index 40efae90..f0a947b5 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,7 @@ + Dashboard | Real Dev Squad diff --git a/online-members/online-members.css b/online-members/online-members.css index 2f425709..b8412196 100644 --- a/online-members/online-members.css +++ b/online-members/online-members.css @@ -77,6 +77,7 @@ background-color: rgb(58, 247, 58); border-radius: 50%; } + .members-online-hidden { display: none; } diff --git a/online-members/online-members.html b/online-members/online-members.html index cce8a62a..d217dcd6 100644 --- a/online-members/online-members.html +++ b/online-members/online-members.html @@ -6,6 +6,7 @@ Online Members | Real Dev Squad + @@ -13,6 +14,7 @@ +
diff --git a/profile/index.html b/profile/index.html index b2d3f4b3..23ec5764 100644 --- a/profile/index.html +++ b/profile/index.html @@ -6,6 +6,7 @@ Profile Diffs | Real Dev Squad + diff --git a/profile/style.css b/profile/style.css index a6f61b30..5c5a47f2 100644 --- a/profile/style.css +++ b/profile/style.css @@ -47,6 +47,7 @@ body { from { transform: rotate(0deg); } + to { transform: rotate(360deg); } diff --git a/style.css b/style.css index 302c3af5..44b847a0 100644 --- a/style.css +++ b/style.css @@ -3,6 +3,7 @@ ::before { box-sizing: border-box; } + :root { --black-color: black; --white-color: white; diff --git a/task/index.html b/task/index.html index b4e9d819..5b9785e8 100644 --- a/task/index.html +++ b/task/index.html @@ -4,6 +4,7 @@ + Create Tasks | Real Dev Squad diff --git a/task/style.css b/task/style.css index df1b327d..512de446 100644 --- a/task/style.css +++ b/task/style.css @@ -173,6 +173,7 @@ footer { 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } diff --git a/taskEvents/style.css b/taskEvents/style.css index 1e23d5c9..f0ca72d1 100644 --- a/taskEvents/style.css +++ b/taskEvents/style.css @@ -34,15 +34,18 @@ body { border-radius: 10px; user-select: none; } + .main-title { font-family: 'roboto mono'; text-align: center; text-transform: capitalize; } + .summary { display: flex; align-items: center; } + .name { margin: 0; font-weight: 800; @@ -187,6 +190,7 @@ details[open] .dropDown { transform: translateY(30%); margin-left: 0.4rem; } + #close-btn, #close-generic-modal { border: none; @@ -447,6 +451,7 @@ details[open] .dropDown { 0% { background-color: #ffffff; } + 50%, 100% { background-color: rgba(0, 0, 0, 0.25); diff --git a/users/details/index.html b/users/details/index.html index b21ac413..94c5ed73 100644 --- a/users/details/index.html +++ b/users/details/index.html @@ -6,6 +6,7 @@ User Management | Real Dev Squad + diff --git a/users/details/style.css b/users/details/style.css index 99e5c8ad..882c28df 100644 --- a/users/details/style.css +++ b/users/details/style.css @@ -438,6 +438,7 @@ footer p a { display: flex; justify-content: center; } + .not-found-img { max-width: 350px; width: 55%; diff --git a/users/index.html b/users/index.html index 5df7e681..76b70fc0 100644 --- a/users/index.html +++ b/users/index.html @@ -6,6 +6,7 @@ User Management | Real Dev Squad + diff --git a/users/style.css b/users/style.css index 3a791a57..7ef907b2 100644 --- a/users/style.css +++ b/users/style.css @@ -65,6 +65,10 @@ background-color: var(--button-active-color); } +#user-list > ul li { + cursor: pointer; +} + ul { list-style-type: none; padding-inline-start: 0px; diff --git a/wallet/index.html b/wallet/index.html index 778e5a21..aaae8db6 100644 --- a/wallet/index.html +++ b/wallet/index.html @@ -4,6 +4,7 @@ + Wallets | Real Dev Squad From 304dfb91d85eb2c0f496a8347e2313ea6d0b7dc3 Mon Sep 17 00:00:00 2001 From: ivinayakg Date: Sun, 12 Mar 2023 12:22:20 +0530 Subject: [PATCH 08/36] requested changes done --- extension-requests/constants.js | 19 ++++++++++ extension-requests/index.html | 1 + extension-requests/script.js | 63 ++++++++++++--------------------- utils.js | 4 +-- 4 files changed, 45 insertions(+), 42 deletions(-) create mode 100644 extension-requests/constants.js diff --git a/extension-requests/constants.js b/extension-requests/constants.js new file mode 100644 index 00000000..95f314f1 --- /dev/null +++ b/extension-requests/constants.js @@ -0,0 +1,19 @@ +const taskInfoModelHeadings = [ + { title: 'Title' }, + { title: 'Ends On', key: 'endsOn', time: true }, + { title: 'Purpose' }, + { title: 'Assignee' }, + { title: 'Created By', key: 'createdBy' }, + { title: 'Is Noteworthy', key: 'isNoteworthy' }, +]; + +const extensionRequestCardHeadings = [ + { title: 'Title' }, + { title: 'Reason' }, + { title: 'Old Ends On', key: 'oldEndsOn', time: true }, + { title: 'New Ends On', key: 'newEndsOn', time: true }, + { title: 'Status', bold: true }, + { title: 'Assignee' }, + { title: 'Created At', key: 'timestamp', time: true }, + { title: 'Task', key: 'taskId' }, +]; diff --git a/extension-requests/index.html b/extension-requests/index.html index e2ceca7e..9675032c 100644 --- a/extension-requests/index.html +++ b/extension-requests/index.html @@ -102,6 +102,7 @@

Extension Requests

+ diff --git a/extension-requests/script.js b/extension-requests/script.js index 154faa1f..b4ca3c4b 100644 --- a/extension-requests/script.js +++ b/extension-requests/script.js @@ -24,14 +24,16 @@ const render = async () => { const extensionRequests = await getExtensionRequests(); const allExtensionRequests = extensionRequests.allExtensionRequests; allExtensionRequests.forEach((data) => { - extensionRequestsContainer.appendChild(createExtensionRequestCard(data)); + extensionRequestsContainer.appendChild( + createExtensionRequestCard(data, extensionRequestCardHeadings), + ); }); } catch (error) { errorHeading.textContent = 'Something went wrong'; errorHeading.classList.add('error-visible'); reload(); } finally { - removeLoader(); + removeLoader('loader'); } }; const showTaskDetails = async (taskId, approved) => { @@ -41,27 +43,20 @@ const showTaskDetails = async (taskId, approved) => { addLoader(modalShowInfo); const taskDetails = await getTaskDetails(taskId); const taskData = taskDetails.taskData; - modalShowInfo.append(createTaskInfoModal(taskData, approved)); + modalShowInfo.append( + createTaskInfoModal(taskData, approved, taskInfoModelHeadings), + ); } catch (error) { errorHeading.textContent = 'Something went wrong'; errorHeading.classList.add('error-visible'); reload(); } finally { - removeLoader(); + removeLoader('loader'); } }; -function createTaskInfoModal(data, approved) { +function createTaskInfoModal(data, approved, dataHeadings) { if (!data) return; - const dataHeadings = [ - { title: 'Title' }, - { title: 'Ends On', key: 'endsOn', time: true }, - { title: 'Purpose' }, - { title: 'Assignee' }, - { title: 'Created By', key: 'createdBy' }, - { title: 'Is Noteworthy', key: 'isNoteworthy' }, - ]; - const updateStatus = createElement({ type: 'button', attributes: { class: 'status-form' }, @@ -84,20 +79,9 @@ function createTaskInfoModal(data, approved) { main.appendChild(closeModal); return main; } -function createExtensionRequestCard(data) { +function createExtensionRequestCard(data, dataHeadings) { if (!data) return; - const dataHeadings = [ - { title: 'Title' }, - { title: 'Reason' }, - { title: 'Old Ends On', key: 'oldEndsOn', time: true }, - { title: 'New Ends On', key: 'newEndsOn', time: true }, - { title: 'Status', bold: true }, - { title: 'Assignee' }, - { title: 'Created At', key: 'timestamp', time: true }, - { title: 'Task', key: 'taskId' }, - ]; - const updateRequestBtn = createElement({ type: 'button', attributes: { class: 'update_request' }, @@ -143,7 +127,7 @@ async function onStatusFormSubmit(e) { errorHeading.classList.add('error-visible'); reload(); } finally { - removeLoader(); + removeLoader('loader'); } } async function onUpdateFormSubmit(e) { @@ -162,7 +146,7 @@ async function onUpdateFormSubmit(e) { errorHeading.classList.add('error-visible'); reload(); } finally { - removeLoader(); + removeLoader('loader'); } } @@ -198,24 +182,23 @@ function fillStatusForm() { state.currentExtensionRequest.assignee; } function fillUpdateForm() { + const { newEndsOn, oldEndsOn, status, id, title, assignee, reason } = + state.currentExtensionRequest; + modalUpdateForm.querySelector('.extensionNewEndsOn').value = new Date( - state.currentExtensionRequest.newEndsOn * 1000, + newEndsOn * 1000, ) .toISOString() .replace('Z', ''); modalUpdateForm.querySelector('.extensionOldEndsOn').value = new Date( - state.currentExtensionRequest.oldEndsOn * 1000, + oldEndsOn * 1000, ) .toISOString() .replace('Z', ''); - modalUpdateForm.querySelector('.extensionStatus').value = - state.currentExtensionRequest.status; - modalUpdateForm.querySelector('.extensionId').value = - state.currentExtensionRequest.id; - modalUpdateForm.querySelector('.extensionTitle').value = - state.currentExtensionRequest.title; - modalUpdateForm.querySelector('.extensionAssignee').value = - state.currentExtensionRequest.assignee; - modalUpdateForm.querySelector('.extensionReason').value = - state.currentExtensionRequest.reason; + + modalUpdateForm.querySelector('.extensionStatus').value = status; + modalUpdateForm.querySelector('.extensionId').value = id; + modalUpdateForm.querySelector('.extensionTitle').value = title; + modalUpdateForm.querySelector('.extensionAssignee').value = assignee; + modalUpdateForm.querySelector('.extensionReason').value = reason; } diff --git a/utils.js b/utils.js index cb8cea2e..b7bf4176 100644 --- a/utils.js +++ b/utils.js @@ -43,6 +43,6 @@ function addLoader(container) { container.appendChild(loader); } -function removeLoader() { - document.querySelector('.loader').remove(); +function removeLoader(classname) { + document.querySelector(`.${classname}`).remove(); } From 51d7a2e3e7f10a9654a7c5c79c7664cc0a665293 Mon Sep 17 00:00:00 2001 From: musukeshu Date: Mon, 20 Mar 2023 05:28:23 +0530 Subject: [PATCH 09/36] [Issue 333] Refactored / replaces redundant API URLs using global constants.js file --- admin-panel/index.html | 1 + admin-panel/index.js | 7 +++---- featureFlag/helper.js | 1 - featureFlag/index.html | 2 +- profile/constants.js | 1 - profile/index.html | 1 + profile/utils.js | 1 - taskEvents/index.html | 1 + taskEvents/utils.js | 22 ++++++++++------------ users/constants.js | 1 - users/details/constants.js | 1 - users/details/index.html | 1 + users/index.html | 1 + wallet/index.html | 2 ++ wallet/script.js | 1 - 15 files changed, 21 insertions(+), 23 deletions(-) diff --git a/admin-panel/index.html b/admin-panel/index.html index 41577f91..528249ff 100644 --- a/admin-panel/index.html +++ b/admin-panel/index.html @@ -6,6 +6,7 @@ Admin Panel | Real Dev Squad + diff --git a/admin-panel/index.js b/admin-panel/index.js index 11342117..b0f28001 100644 --- a/admin-panel/index.js +++ b/admin-panel/index.js @@ -3,10 +3,9 @@ const mainContainer = document.getElementById('main-container'); const main = document.getElementById('main'); const loading = document.getElementById('loading'); const selectElement = document.getElementById('select-tags'); -const BASE_URL = 'https://api.realdevsquad.com'; (async function setAuth() { try { - const res = await fetch(`${BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users/self`, { method: 'GET', credentials: 'include', headers: { @@ -70,7 +69,7 @@ async function createLevel() { setLoadingState(); button.textContent = 'Creating Level...'; - const response = await fetch(`${BASE_URL}/levels`, { + const response = await fetch(`${API_BASE_URL}/levels`, { method: 'POST', credentials: 'include', body: JSON.stringify(body), @@ -103,7 +102,7 @@ async function createSkill() { setLoadingState(); button.textContent = 'creating skill...'; - const response = await fetch(`${BASE_URL}/tags`, { + const response = await fetch(`${API_BASE_URL}/tags`, { method: 'POST', credentials: 'include', body: JSON.stringify(body), diff --git a/featureFlag/helper.js b/featureFlag/helper.js index 8fe34459..d7f5a471 100644 --- a/featureFlag/helper.js +++ b/featureFlag/helper.js @@ -1,6 +1,5 @@ 'use strict'; -const API_BASE_URL = 'https://api.realdevsquad.com'; const roles = ['super_user', 'member', 'no_role']; const mockData = [ { diff --git a/featureFlag/index.html b/featureFlag/index.html index 563ddf59..a9ec59b9 100644 --- a/featureFlag/index.html +++ b/featureFlag/index.html @@ -8,7 +8,7 @@ Feature Flag | Dashboard Real Dev Squad - + diff --git a/profile/constants.js b/profile/constants.js index 493dd76e..20c128e8 100644 --- a/profile/constants.js +++ b/profile/constants.js @@ -1,4 +1,3 @@ -export const API_BASE_URL = 'https://api.realdevsquad.com'; export const YEARS_OF_EXPERIENCE = 'yoe'; export const SUPER_USER = 'super_user'; export const APPROVE_BUTTON_TEXT = 'Approve'; diff --git a/profile/index.html b/profile/index.html index 23ec5764..83070572 100644 --- a/profile/index.html +++ b/profile/index.html @@ -8,6 +8,7 @@ Profile Diffs | Real Dev Squad + diff --git a/profile/utils.js b/profile/utils.js index cc301fc1..8da6237e 100644 --- a/profile/utils.js +++ b/profile/utils.js @@ -1,5 +1,4 @@ import { - API_BASE_URL, YEARS_OF_EXPERIENCE, APPROVE_BUTTON_TEXT, REJECT_BUTTON_TEXT, diff --git a/taskEvents/index.html b/taskEvents/index.html index 42b6f000..00fff439 100644 --- a/taskEvents/index.html +++ b/taskEvents/index.html @@ -15,6 +15,7 @@ rel="stylesheet" /> + diff --git a/taskEvents/utils.js b/taskEvents/utils.js index fd3daab2..b10e0e4b 100644 --- a/taskEvents/utils.js +++ b/taskEvents/utils.js @@ -1,5 +1,3 @@ -const BASE_URL = 'https://api.realdevsquad.com'; - function createElement({ type, attributes = {}, innerText }) { const element = document.createElement(type); Object.keys(attributes).forEach((item) => { @@ -43,8 +41,8 @@ function addErrorMessage(container) { async function getTaskLogs(username) { const url = username - ? `${BASE_URL}/logs/task?meta.username=${username}` - : `${BASE_URL}/logs/task`; + ? `${API_BASE_URL}/logs/task?meta.username=${username}` + : `${API_BASE_URL}/logs/task`; const res = await fetch(url, { method: 'GET', credentials: 'include', @@ -58,7 +56,7 @@ async function getTaskLogs(username) { } async function getTaskData(id) { - const res = await fetch(`${BASE_URL}/tasks/${id}/details`, { + const res = await fetch(`${API_BASE_URL}/tasks/${id}/details`, { method: 'GET', credentials: 'include', headers: { @@ -70,7 +68,7 @@ async function getTaskData(id) { } async function getUserData(username) { - const res = await fetch(`${BASE_URL}/users/${username}`, { + const res = await fetch(`${API_BASE_URL}/users/${username}`, { method: 'GET', credentials: 'include', headers: { @@ -82,7 +80,7 @@ async function getUserData(username) { } async function getSelfDetails() { - const res = await fetch(`${BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users/self`, { method: 'GET', credentials: 'include', headers: { @@ -109,7 +107,7 @@ async function getData(data) { async function getUserSkills(userId) { try { - const response = await fetch(`${BASE_URL}/users/${userId}/skills`, { + const response = await fetch(`${API_BASE_URL}/users/${userId}/skills`, { method: 'GET', credentials: 'include', headers: { @@ -131,14 +129,14 @@ async function getUserSkills(userId) { async function getTagLevelOptions() { try { - const levelsResponse = await fetch(`${BASE_URL}/levels`, { + const levelsResponse = await fetch(`${API_BASE_URL}/levels`, { method: 'GET', credentials: 'include', headers: { 'Content-type': 'application/json', }, }); - const tagsResponse = await fetch(`${BASE_URL}/tags`, { + const tagsResponse = await fetch(`${API_BASE_URL}/tags`, { method: 'GET', credentials: 'include', headers: { @@ -177,7 +175,7 @@ async function addSkillToUser(tagToAdd, levelToAdd, userId) { ], }; try { - const response = await fetch(`${BASE_URL}/items`, { + const response = await fetch(`${API_BASE_URL}/items`, { method: 'POST', credentials: 'include', body: JSON.stringify(body), @@ -203,7 +201,7 @@ async function removeSkillFromUser(tagId, userId) { tagId, }; try { - const response = await fetch(`${BASE_URL}/items`, { + const response = await fetch(`${API_BASE_URL}/items`, { method: 'DELETE', credentials: 'include', headers: { diff --git a/users/constants.js b/users/constants.js index 46ea093c..d5337da4 100644 --- a/users/constants.js +++ b/users/constants.js @@ -1,4 +1,3 @@ -const API_BASE_URL = 'https://api.realdevsquad.com'; const RDS_API_USERS = `${API_BASE_URL}/users/`; const USER_LIST_ELEMENT = 'user-list'; const LOADER_ELEMENT = 'loader'; diff --git a/users/details/constants.js b/users/details/constants.js index e98f6b47..7de75182 100644 --- a/users/details/constants.js +++ b/users/details/constants.js @@ -1,4 +1,3 @@ -const API_BASE_URL = 'https://api.realdevsquad.com'; const defaultAvatar = '../images/profile.svg'; const socialMedia = ['twitter_id', 'github_id', 'linkedin_id']; const iconMapper = { diff --git a/users/details/index.html b/users/details/index.html index 94c5ed73..8453b34a 100644 --- a/users/details/index.html +++ b/users/details/index.html @@ -8,6 +8,7 @@ User Management | Real Dev Squad + diff --git a/users/index.html b/users/index.html index 76b70fc0..3ec33dc2 100644 --- a/users/index.html +++ b/users/index.html @@ -8,6 +8,7 @@ User Management | Real Dev Squad + diff --git a/wallet/index.html b/wallet/index.html index aaae8db6..016f13b0 100644 --- a/wallet/index.html +++ b/wallet/index.html @@ -41,6 +41,8 @@

+ + diff --git a/wallet/script.js b/wallet/script.js index 989f7d6e..c6dada58 100644 --- a/wallet/script.js +++ b/wallet/script.js @@ -1,4 +1,3 @@ -const API_BASE_URL = 'https://api.realdevsquad.com'; const walletsRef = document.querySelector('.wallets'); From 0bca13197af1293c6bf7c039034c52543a114019 Mon Sep 17 00:00:00 2001 From: Khushi Shukla <81404366+khushi818@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:44:35 +0530 Subject: [PATCH 10/36] Add footer and footer test for all page (#330) * feat: Addition of footer element and footer test * fix:brower closing error * fix:brower closing error * feat: footerTest for all urls * fix:removed unnecessary styling and changed urls * fix: unnecessary styles * optimise test * fix/removed console --------- Co-authored-by: Prakash Choudhary <34452139+prakashchoudhary07@users.noreply.github.com> --- featureFlag/index.html | 11 +++++ featureFlag/style.css | 10 +++++ footerTest.js | 66 ++++++++++++++++++++++++++++++ online-members/online-members.css | 11 +++++ online-members/online-members.html | 12 ++++++ style.css | 1 + taskEvents/index.html | 13 ++++++ users/index.html | 12 ++++++ users/style.css | 10 +++++ 9 files changed, 146 insertions(+) create mode 100644 footerTest.js diff --git a/featureFlag/index.html b/featureFlag/index.html index 563ddf59..ec2eff0c 100644 --- a/featureFlag/index.html +++ b/featureFlag/index.html @@ -108,5 +108,16 @@
+ diff --git a/featureFlag/style.css b/featureFlag/style.css index 333c0ef2..12a22e65 100644 --- a/featureFlag/style.css +++ b/featureFlag/style.css @@ -123,6 +123,16 @@ body { background-color: var(--add-btn-color); } +.info-repo { + font-weight: 100; + padding: 8px; + text-align: center; +} + +footer { + margin-top: auto; +} + .submit-button__disabled { color: white; background-color: var(--add-btn-color); diff --git a/footerTest.js b/footerTest.js new file mode 100644 index 00000000..c6c03fe7 --- /dev/null +++ b/footerTest.js @@ -0,0 +1,66 @@ +const puppeteer = require('puppeteer'); + +let config = { + launchOptions: { + headless: true, + ignoreHTTPSErrors: true, + }, +}; + +let urls = [ + 'https://dashboard.realdevsquad.com/index.html', + 'https://dashboard.realdevsquad.com/profile/index.html', + 'https://dashboard.realdevsquad.com/goal/index.html', + 'https://dashboard.realdevsquad.com/task/index.html', + 'https://dashboard.realdevsquad.com/users/index.html', + 'https://dashboard.realdevsquad.com/users/details/index.html', + 'https://dashboard.realdevsquad.com/taskevents/index.html', + 'https://dashboard.realdevsquad.com/featureflag/index.html', + 'https://dashboard.realdevsquad.com/wallet/index.html', + 'https://dashboard.realdevsquad.com/online-members/online-members.html', +]; + +const test_footer = async (url, index) => { + await puppeteer.launch(config.launchOptions).then(async (browser) => { + const context = await browser.createIncognitoBrowserContext(); + const page = await context.newPage(); + await page.goto(url, { waitUntil: ['load', 'networkidle2'] }); + await page.content(); + page.setDefaultNavigationTimeout(0); + const footer = await page.$('footer'); + if (footer) { + // is the text same in footer? + const footer_text = await page.evaluate(() => { + const element = document.querySelector('.info-repo'); + return ( + element && + element.innerText === + 'The contents of this website are deployed from this open sourced repo' + ); + }); + console.log(`✅ footer text:${footer_text} index:${index}:${url}`); + + if (footer_text) { + // links inside footer are working or not + await page.click('.info-repo a', { delay: 2000 }); + console.log(`✅ link works for ${url}`); + } + } else { + console.log(`❌no footer at ${url}`); + } + + context.close(); + }); +}; + +async function runTest() { + for (let url of urls) { + await test_footer(url, urls.indexOf(url)); + + if (urls.indexOf(url) === urls.length - 1) { + process.exit(0); + } + } +} + +runTest(); diff --git a/online-members/online-members.css b/online-members/online-members.css index b8412196..c1fa094d 100644 --- a/online-members/online-members.css +++ b/online-members/online-members.css @@ -112,3 +112,14 @@ display: flex; align-items: center; } + +footer { + display: block; + width: 100%; + padding: 8px; +} + +footer .info-repo { + font-weight: 100; + text-align: center; +} diff --git a/online-members/online-members.html b/online-members/online-members.html index d217dcd6..4924001e 100644 --- a/online-members/online-members.html +++ b/online-members/online-members.html @@ -22,5 +22,17 @@
+ diff --git a/style.css b/style.css index 44b847a0..1651573e 100644 --- a/style.css +++ b/style.css @@ -42,6 +42,7 @@ body { button { width: 250px; + cursor: pointer; } /* profile section */ diff --git a/taskEvents/index.html b/taskEvents/index.html index 42b6f000..66a30fea 100644 --- a/taskEvents/index.html +++ b/taskEvents/index.html @@ -17,6 +17,7 @@ +
+ diff --git a/users/index.html b/users/index.html index 76b70fc0..f6e19166 100644 --- a/users/index.html +++ b/users/index.html @@ -80,5 +80,17 @@

Filters

+ diff --git a/users/style.css b/users/style.css index 7ef907b2..cfab1c3b 100644 --- a/users/style.css +++ b/users/style.css @@ -278,6 +278,16 @@ li p { display: none; } +.info-repo { + font-weight: 100; + padding: auto; + text-align: center; +} + +footer { + margin-top: auto; +} + @keyframes spin { 0% { transform: rotate(0deg); From cc8fd03d96dd3f2d7cabb0d47897665e77ae2b80 Mon Sep 17 00:00:00 2001 From: musukeshu Date: Tue, 28 Mar 2023 08:00:19 +0530 Subject: [PATCH 11/36] Run prettier check package-lock.json --- wallet/index.html | 1 - wallet/script.js | 1 - 2 files changed, 2 deletions(-) diff --git a/wallet/index.html b/wallet/index.html index 016f13b0..53214af3 100644 --- a/wallet/index.html +++ b/wallet/index.html @@ -43,6 +43,5 @@ - diff --git a/wallet/script.js b/wallet/script.js index c6dada58..5e9d02ef 100644 --- a/wallet/script.js +++ b/wallet/script.js @@ -1,4 +1,3 @@ - const walletsRef = document.querySelector('.wallets'); const ipUsernames = document.querySelector('#all-users'); From fdc01831fe98f03f578a2d4ba95db494bfec131c Mon Sep 17 00:00:00 2001 From: musukeshu Date: Fri, 31 Mar 2023 01:52:29 +0530 Subject: [PATCH 12/36] Fixed constants in the online-members contants file --- online-members/constants.js | 4 ++-- online-members/online-members.html | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/online-members/constants.js b/online-members/constants.js index 80eb4dd3..3c9f5c9c 100644 --- a/online-members/constants.js +++ b/online-members/constants.js @@ -29,8 +29,8 @@ const TASKS_CLASS_LIST = ['task']; const TASKS_CONTAINER_CLASS_LIST = ['tasks-container']; // RDS Api Constants -const RDS_API_MEMBERS = 'https://api.realdevsquad.com/members'; -const RDS_API_TASKS_USERS = 'https://api.realdevsquad.com/tasks'; +const RDS_API_MEMBERS = API_BASE_URL + '/members'; +const RDS_API_TASKS_USERS = API_BASE_URL + '/tasks'; const RDS_CLOUDINARY_CLOUD_URL = `https://res.cloudinary.com/realdevsquad/image/upload`; const RDS_SSE_ONLINE_URL = 'https://online.realdevsquad.com/online-members'; diff --git a/online-members/online-members.html b/online-members/online-members.html index d217dcd6..486b1824 100644 --- a/online-members/online-members.html +++ b/online-members/online-members.html @@ -9,6 +9,7 @@ + From a8e09385735c1b042778630709b302ea74cd5dc5 Mon Sep 17 00:00:00 2001 From: Randhir Kumar Singh <97341921+heyrandhir@users.noreply.github.com> Date: Thu, 6 Apr 2023 18:54:58 +0530 Subject: [PATCH 13/36] adds filter modal --- users/constants.js | 3 +- users/index.html | 12 ++-- users/script.js | 174 ++++++++++++++++++++++++++++++++------------- users/style.css | 11 +++ 4 files changed, 143 insertions(+), 57 deletions(-) diff --git a/users/constants.js b/users/constants.js index d5337da4..bce2be2a 100644 --- a/users/constants.js +++ b/users/constants.js @@ -1,4 +1,5 @@ -const RDS_API_USERS = `${API_BASE_URL}/users/`; +const RDS_API_USERS = `${API_BASE_URL}/users`; +const RDS_API_SKILLS = `${API_BASE_URL}/tags`; const USER_LIST_ELEMENT = 'user-list'; const LOADER_ELEMENT = 'loader'; const TILE_VIEW_BTN = 'tile-view-btn'; diff --git a/users/index.html b/users/index.html index f5b0fd21..40bc0304 100644 --- a/users/index.html +++ b/users/index.html @@ -38,14 +38,10 @@

Filters

- - +

Availability

+ +

Skills

+