-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding posts count to dashboard (#2476)
* Revert "Merge branch 'master' into postsCount" This reverts commit 9208611, reversing changes made to dec2f47. * commit b4 revert * This reverts commit 4108258. * All commits rebased Make functions more precise Fixed PR commit before rebasing added files back after aborting rebase commit after rebase final fix update package.json of posts commit b4 rebase commit 2 fixed before rebase * deleted tatus file * fix PR with adding .js extension
- Loading branch information
1 parent
203766c
commit d7241b0
Showing
5 changed files
with
60 additions
and
25 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
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,10 @@ | ||
import { getPostsCount } from '../post/index.js'; | ||
import { getFeedCount } from '../feed/index.js'; | ||
import { getGitHubData } from '../github-stats.js'; | ||
|
||
window.addEventListener('load', (event) => { | ||
getGitHubData('Seneca-CDOT', 'telescope'); | ||
getGitHubData('Seneca-CDOT', 'satellite'); | ||
getFeedCount(); | ||
getPostsCount(); | ||
}); |
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,14 @@ | ||
const apiUrl = new URL(location).origin; | ||
|
||
const fetchPostsCount = () => | ||
fetch(`${apiUrl}/v1/posts`, { method: 'HEAD' }).then((res) => res.headers.get('x-total-count')); | ||
|
||
export const getPostsCount = async () => { | ||
try { | ||
const numberOfPosts = await fetchPostsCount(); | ||
const totalPostsEl = document.getElementById('totalPosts'); | ||
totalPostsEl.innerText = numberOfPosts ?? 'N/A'; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; |