From 0f968643b74d9ad9864012c0abcd9dafadb3ee59 Mon Sep 17 00:00:00 2001 From: Nishant Arora Date: Wed, 11 Jan 2017 21:19:22 +0530 Subject: [PATCH] Added Logo Upload and Design Improvements --- api/admin.js | 44 ++++++++++++++++++++++- client/app/static/admin.jsx | 3 +- client/app/static/app.jsx | 4 +-- client/app/static/home.jsx | 2 +- client/app/static/logo_upload.jsx | 58 ++++++++++++++++++++++++++++++ client/assets/bootstrap.css | 2 +- client/assets/logo.png | Bin 15707 -> 30242 bytes client/assets/style.css | 9 +++-- index.js | 1 + package.json | 1 + 10 files changed, 114 insertions(+), 10 deletions(-) create mode 100644 client/app/static/logo_upload.jsx diff --git a/api/admin.js b/api/admin.js index 6b27bbc..47e60a1 100755 --- a/api/admin.js +++ b/api/admin.js @@ -10,6 +10,7 @@ The above users endpoints are not present in this file as they are all the users endpoints this API has, they are present in a separate file, users.js All those still come under the ADMIN endpoints +POST /logo POST /topics PUT /topics DELETE /topics @@ -17,10 +18,22 @@ DELETE /articles */ +var multer = require('multer'); +var path = require('path'); +var storage = multer.diskStorage({ + destination: function(req, file, cb) { + cb(null, './client/assets'); // Make sure this folder exists + }, + filename: function(req, file, cb) { + cb(null, "logo.png"); + } + }); +var upload = multer({ storage: storage }).single('logo'); + + // Importing the topics model var Topics = require('../models/topic.js'); var Articles = require('../models/article.js'); - var db = require('../db.js'); //this file contains the knex file import. it's equal to knex=require('knex') module.exports = function(app) { @@ -160,4 +173,33 @@ module.exports = function(app) { }); }); + app.post('/logo', function (req, res) { + upload(req, res, function (err) { + if(err) { + res.json({ + error: { + error: true, + message: "There was a problem uploading the logo" + }, + code: 'LOGODIDNTUPLOAD', + data: { + + } + }); + } + else { + res.json({ + error: { + error: false, + message: '' + }, + code: 'LOGOUPLOADED', + data: { + + } + }); + } + }); + }); + } diff --git a/client/app/static/admin.jsx b/client/app/static/admin.jsx index 2874d73..cee9894 100755 --- a/client/app/static/admin.jsx +++ b/client/app/static/admin.jsx @@ -2,6 +2,7 @@ import React from 'react'; import {hashHistory, Link} from 'react-router'; import Alert from 'react-s-alert'; import Loader from './loader.jsx'; +import LogoUpload from './logo_upload.jsx'; class Admin extends React.Component { @@ -286,7 +287,7 @@ class Admin extends React.Component { - + ); } } diff --git a/client/app/static/app.jsx b/client/app/static/app.jsx index a804562..803ed9d 100755 --- a/client/app/static/app.jsx +++ b/client/app/static/app.jsx @@ -25,8 +25,7 @@ class App extends React.Component { var that = this; return(
-