mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
start page settings done
This commit is contained in:
@@ -62,4 +62,13 @@ module.exports = ( app ) => {
|
||||
res.send( 'ok' );
|
||||
}
|
||||
} );
|
||||
|
||||
app.post( '/admin/pages/uploadImages', multer.array( 'image', 1 ), ( req, res ) => {
|
||||
if ( req.query.image.includes( '/' ) || req.query.image.includes( '.' ) || req.query.template.includes( '/' ) || req.query.template.includes( '.' ) ) {
|
||||
res.status( 400 ).send( 'fp_wrong' );
|
||||
} else {
|
||||
fs.writeFileSync( path.join( __dirname + '/../ui/home/templates/' + req.query.template + '/' + req.query.image + '.jpg' ), req.files[ 0 ].buffer );
|
||||
res.send( 'ok' );
|
||||
}
|
||||
} );
|
||||
};
|
||||
@@ -20,4 +20,8 @@ module.exports = ( app, settings ) => {
|
||||
app.get( '/startPage/mainStyle', ( req, res ) => {
|
||||
res.sendFile( path.join( __dirname + '/../ui/home/main.css' ) );
|
||||
} );
|
||||
|
||||
app.get( '/startPage/assets/:image', ( req, res ) => {
|
||||
res.sendFile( path.join( __dirname + '/../assets/' + settings.startPage + '/assets/' + req.param.image ) );
|
||||
} );
|
||||
};
|
||||
@@ -138,10 +138,10 @@
|
||||
}
|
||||
},
|
||||
saveImage( image ) {
|
||||
if ( this.$refs[ image ].file ) {
|
||||
if ( this.$refs[ image ][ 0 ].file ) {
|
||||
console.log( 'saving image' );
|
||||
let fd = new FormData();
|
||||
fd.append( 'image', this.$refs[ image ].file );
|
||||
fd.append( 'name', image );
|
||||
fd.append( 'image', this.$refs[ image ][ 0 ].file );
|
||||
let fetchOptions = {
|
||||
method: 'post',
|
||||
body: fd,
|
||||
@@ -150,13 +150,15 @@
|
||||
if ( res.status === 200 ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
this.$refs.notification.createNotification( 'There was an error uploading the image', 5, 'error', 'normal' );
|
||||
}
|
||||
} ).catch( err => {
|
||||
console.error( err );
|
||||
} );
|
||||
return true;
|
||||
} else {
|
||||
console.log( this.$refs[ image ][ 0 ] );
|
||||
console.log( image );
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user