Skip to content

Commit

Permalink
refactor: remove image uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
zeim839 committed Feb 9, 2024
1 parent 93855ce commit 493b1f4
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 520 deletions.
3 changes: 0 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const compression = require('compression')

const { UserModel } = require('./model/users')
const { BlogModel } = require('./model/blog')
const { ImageModel } = require('./model/images')
const { callbacks } = require('./utils/callbacks')

const app = express()
Expand Down Expand Up @@ -66,11 +65,9 @@ app.get(`/${config.admin_route}`, (req, res) => {

const users = await UserModel.find().sort({ isAdmin: -1 }).exec()
const blog = await BlogModel.find()
const images = await ImageModel.find().sort({ date: -1 })
return res.render('admin', {
users: (users) || [],
blog: (blog) || [],
images: (images) || [],
version: config.VERSION
})
})(req, res)
Expand Down
24 changes: 0 additions & 24 deletions model/images.js

This file was deleted.

14 changes: 0 additions & 14 deletions public/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,4 @@ section {
float: right;
}

#delete-button-images{
/* self style */
background-color: red;
color: var(--light-gray);
border: none;
border-radius: 3px;
font-weight: 600;

/* self align */
height: 25px;
width: 75px;
float: right;
}

/* ----------CSS for Delete Buttons ends here----------------- */
7 changes: 1 addition & 6 deletions public/js/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global blogTableSelections, usersTableSelections, imagesTableSelections, alert, XMLHttpRequest */
/* global blogTableSelections, usersTableSelections, alert, XMLHttpRequest */

// uncheck all checkboxes on load and remove all data from selectionsArray(s) and hide Delete-Buttons
document.addEventListener('DOMContentLoaded', () => {
Expand Down Expand Up @@ -90,7 +90,6 @@ const deleteButtonVisibility = (tableId, buttonId) => {
const disableAllDeleteButtons = () => {
deleteButtonVisibility('blog-table', 'delete-button-blog')
deleteButtonVisibility('blog-table', 'delete-button-users')
deleteButtonVisibility('images-table', 'delete-button-images')
}

const deleteHandler = async (route) => { // eslint-disable-line
Expand All @@ -105,10 +104,6 @@ const deleteHandler = async (route) => { // eslint-disable-line
selections = blogTableSelections
itemDesc = 'article'
break
case 'image':
selections = imagesTableSelections
itemDesc = 'image'
break
default:
console.log('deleteHandler: invalid selection')
return
Expand Down
26 changes: 1 addition & 25 deletions public/js/editDb.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global alert, XMLHttpRequest, FormData, IS_NEW, OBJ_ID */
/* global alert, XMLHttpRequest, IS_NEW, OBJ_ID */

const editUser = (event) => { // eslint-disable-line
event.preventDefault()
Expand Down Expand Up @@ -137,27 +137,3 @@ const deleteBlog = () => { // eslint-disable-line

XHR.send()
}

const editImage = (event) => { // eslint-disable-line
event.preventDefault()
const XHR = new XMLHttpRequest()

// Success
XHR.onreadystatechange = () => {
if (XHR.readyState === 4) {
if (XHR.status !== 200) {
alert(JSON.parse(XHR.responseText).error)
return
}

alert('Image saved succesfully')
window.location.reload()
}
}

XHR.open('POST', '/api/image')
XHR.withCredentials = true

const fd = new FormData(document.getElementById('edit-images-form'))
XHR.send(fd)
}
2 changes: 0 additions & 2 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ const usersRoute = require('./users')
const blogRoute = require('./blog')
const contactRoute = require('./contact')
const editRoute = require('./edit')
const imagesRoute = require('./images')

router.use('/users', passport.authenticate('loggedIn', { session: false }), usersRoute)
router.use('/edit', passport.authenticate('loggedIn', { session: false }), editRoute)
router.use('/blog', blogRoute)
router.use('/contact', contactRoute)
router.use('/image', imagesRoute)

module.exports = router
5 changes: 0 additions & 5 deletions routes/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,4 @@ router.get('/user/:id', async (req, res, next) => {
return res.render('edit-user', { data: userExists, isNew: false })
})

// Create new image
router.get('/image', (req, res, next) => {
return res.render('edit-image', { data: null, isNew: true })
})

module.exports = router
115 changes: 0 additions & 115 deletions routes/images.js

This file was deleted.

Loading

0 comments on commit 493b1f4

Please sign in to comment.