-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP][DO NOT MERGE]Album feature #339
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var fields = []; | ||
fields.push({ | ||
label: "Album Name", | ||
name:"album-name", | ||
placeholder: "E.g: FOB,SPONS", | ||
editable: true, | ||
type: "select", | ||
options: ["FOB", "SPONSORS"], | ||
value: "", | ||
typeahead: false, | ||
none: true, | ||
}); | ||
fields.push({ | ||
label: "Image", | ||
name:"image", | ||
editable: true, | ||
type: "image", | ||
required: true, | ||
value: "", | ||
typeahead: false, | ||
none: true, | ||
width: 800, | ||
height: 400, | ||
id: 1 | ||
}); | ||
fields.push({ | ||
label: "Title", | ||
name:"title", | ||
editable: true, | ||
type: "textarea", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Titles probably shouldn't be multiline. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cons of making in multi-line ? |
||
required: false, | ||
value: "", | ||
typeahead: false, | ||
none: true | ||
}); | ||
fields.push({ | ||
label: "Sub-title", | ||
name:"subtitle", | ||
editable: true, | ||
type: "textarea", | ||
required: false, | ||
value: "", | ||
typeahead: false, | ||
none: true | ||
}); | ||
module.exports = fields; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline thingy. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
$(document).ready(function() { | ||
$("#submit-button").on('click', function() { | ||
if(!$("#field-image").val()) { | ||
swal({ | ||
title: "Please fill image", | ||
type: "error" | ||
}); | ||
} else { | ||
$.ajax({ | ||
type: 'POST', | ||
url: '/api/images', | ||
data: { | ||
album: $('#field-album-name').val(), | ||
title: $('#field-title').val(), | ||
subtitle: $('#field-subtitle').val() || "", | ||
image: $("#field-image").val(), | ||
path: $("#image-editor-1").attr("value") | ||
} | ||
}).done(function (data) { | ||
swal({ | ||
title: "Successful", | ||
type: "success", | ||
confirmButtonText: "OK", | ||
}); | ||
}).fail(function (err) { | ||
swal({ | ||
title: "Some error occurred", | ||
text: JSON.stringify(err), | ||
type: "error", | ||
confirmButtonText: "OK", | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var express = require("express"); | ||
var router = express.Router(); | ||
var mongoose = require('mongoose'); | ||
var Schema = mongoose.Schema; | ||
var fs = require("fs"); | ||
|
||
var imageSchema = new Schema({ | ||
albumname: String, | ||
title: String, | ||
subtitle: String, | ||
img: String | ||
}); | ||
var model = mongoose.model('images', imageSchema); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too many blank lines? |
||
|
||
router.post("/", function(req, res, next) { | ||
var album = (req.body.album).trim(); | ||
var title = (req.body.title).trim(); | ||
var subtitle = (req.body.subtitle).trim(); | ||
var imagePath = (req.body.path).trim(); | ||
var imageName = imagePath.split("/")[4]; | ||
|
||
var imageModel = new model({ | ||
albumname: album, | ||
title: title, | ||
subtitle: subtitle, | ||
img: imageName | ||
}); | ||
imageModel.save(); | ||
return res.json(req.body); | ||
}); | ||
var permission = { | ||
read_one: 0, | ||
read_all: 0, | ||
insert: 1, | ||
update: 2, | ||
delete: 2 | ||
}; | ||
module.exports = { | ||
route: '/images', | ||
router: router, | ||
model: model, | ||
permission: permission | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var fq = require('fuzzquire'); | ||
var middleware = fq("authentication").middleware; | ||
var fields = fq("forms/add-images"); | ||
|
||
var applyStateChanges = function (req, superuser) { | ||
req.stateparams.title = { | ||
text: 'Images', | ||
route: '/images', | ||
}; | ||
if (superuser) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Braces around the if block. |
||
req.stateparams.submenu = [{ | ||
route: "/addimages/new", | ||
label: "Add new images for an album", | ||
} | ||
]; | ||
return req; | ||
}; | ||
router.get("/", middleware.authenticate, middleware.elevate, function(req, res, next) { | ||
if(req.user.privilege.level == 2) { | ||
req = applyStateChanges(req, true); | ||
req.stateparams.pagetitle = 'Add Images for Album.'; | ||
res.renderState('add-images/home', { | ||
user: req.user, | ||
title: 'Add Images for Album.' | ||
}); | ||
} else if (req.user.privilege.level == 1) { | ||
req = applyStateChanges(req, false); | ||
res.redirect('/'); | ||
} | ||
}); | ||
router.get("/new", middleware.authenticate, middleware.elevate, function(req, res, next) { | ||
if(req.user.privilege.level == 2) { | ||
res.renderState('add-images/album', { | ||
user:req.user, | ||
title: 'Add Images for Album', | ||
fields: fields | ||
}); | ||
} else if( req.user.privilege.level == 1) { | ||
req = applyStateChanges(req, false); | ||
res.redirect('/'); | ||
} | ||
}); | ||
module.exports = router; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
include ../mixins/form | ||
script(type="text/javascript" src="/static/lib/jquery.uploadPreview.min.js") | ||
.immersive-wrapper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure about using immersive-wrapper here? Use generic div instead, as immersive CSS might sometime later cause this particular page to look out of place from the rest of the portals. |
||
#add-images-album-wrapper | ||
- var form = { fields: fields, method: "PUT", action: "/api/users/me"}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidental remnant of copy-paste in the |
||
+formMixin(form) | ||
#submit-button | ||
button Submit | ||
script(src="/static/scripts/add-images.js") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.immersive-wrapper | ||
| Hi this is hello code. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,10 @@ mixin imgUpload(data) | |
input(type="file" required=data.required id="field-#{data.name}" name="field-#{data.name}" class="cropit-image-input") | ||
div(class="cropit-preview", id="cropit-preview-#{data.id}") | ||
div.status | ||
i.icon-check.response(id="export-img-#{data.id}") | ||
i.icon-check.response(id="export-img-#{data.id}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace. |
||
label(for="field-#{data.name}" id="label-#{data.name}") | ||
i.icon-add_a_photo | ||
script(src="/static/scripts/image-upload-mixin.js") | ||
script. | ||
imgCropInit({ | ||
input: "field-#{data.name}", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You sure about using a "select" here? Also, I suggest we keep such identifier names consistent by enforcing lowercase and hyphen separated strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. They don't have any other option , neither can they write it on their own.