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(
-