Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
feat(server): Allow possibility to display a user message got from en…
Browse files Browse the repository at this point in the history
…vironment properties
  • Loading branch information
Ben Einaudi committed May 22, 2017
1 parent b534012 commit 54afb3b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions routes/receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ router.get(router.servePagePath + ':id', function (req, res, next) {
res.render('receive', {
isLocal: typeof process.env.OPENSHIFT_NODEJS_IP === "undefined",
jdropitVersion: global.DROP_IT_VERSION,
infoMessage : typeof process.env.USER_INFO_MESSAGE === "undefined" ? "" : process.env.USER_INFO_MESSAGE,
dumbContent : "",
fileName: sender.fileName,
fileSize: sender.fileSize,
Expand Down
3 changes: 2 additions & 1 deletion routes/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ var dumbQuotes = ["Let us ease your file transfers",

/* GET home page. */
router.get('/', function(req, res) {
debug('serving send');
debug('serving view');
res.render('send', {
isLocal : typeof process.env.OPENSHIFT_NODEJS_IP === "undefined",
jdropitVersion : global.DROP_IT_VERSION,
infoMessage : typeof process.env.USER_INFO_MESSAGE === "undefined" ? "" : process.env.USER_INFO_MESSAGE,
dumbContent : dumbQuotes[Math.floor(Math.random() * dumbQuotes.length)]
});
});
Expand Down
13 changes: 13 additions & 0 deletions views/about.pug
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
You should have received a copy of the GNU General Public License
along with just-drop-it. If not, see <http://www.gnu.org/licenses/>.
extends modal_layout
block modal_extra_scripts
script.
function handleInfoMessage() {
if ("#{infoMessage}".length > 0) {
$('#info_message_content').text("#{infoMessage}");
} else {
$('#info_message_header').hide();
$('#info_message_content').hide();
}
}

block modal_title
| About
block modal_body
Expand All @@ -31,6 +42,8 @@ block modal_body
ul
li Arnaud Ruffin
li Benjamin Einaudi
h5#info_message_header Info
p#info_message_content
h5 Contact
p Any question, suggestion or even contribution, please visit our project on&nbsp;
a(title="github" href="https://github.com/Orange-OpenSource/just-drop-it") GitHub
2 changes: 1 addition & 1 deletion views/modal_layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License
along with just-drop-it. If not, see <http://www.gnu.org/licenses/>.
block modal_extra_scripts
div.modal.fade(tabindex="-1" role="dialog" aria-hidden="true")
div.modal-dialog(role="document")
div.modal-content
Expand Down
1 change: 1 addition & 0 deletions views/receive.pug
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ block extra_scripts
window.onload = function(){
receiverHandler = new ReceiverHandler(#{isLocal}, "#{senderId}","#{fileName}",#{fileSize});
enableNotifications();
handleInfoMessage();
}
block content
div.row#transferContainer
Expand Down
1 change: 1 addition & 0 deletions views/send.pug
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ block extra_scripts
window.onload = function(){
sendFile(#{isLocal});
enableNotifications();
handleInfoMessage();
}

block content
Expand Down
20 changes: 13 additions & 7 deletions views/user_messages.pug
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@
along with just-drop-it. If not, see <http://www.gnu.org/licenses/>.
script.
function appendError(message) {
var rowDiv = $("<div>", {role:"alert"}).addClass("alert alert-danger alert-dismissible fade in");
var buttonProperties = {type : "button"};
function _appendMessage(message, alert){
var rowDiv = $("<div>", {role: "alert"})
.addClass("alert")
.addClass(alert? "alert-danger": "alert-info")
.addClass("alert-dismissible fade in");
var buttonProperties = {type: "button"};
buttonProperties["data-dismiss"] = "alert";
buttonProperties["aria-label"] = "Close";
var spanProperties = {};
spanProperties["aria-hidden"] = "true";
rowDiv.append(
$("<button>",buttonProperties)
.addClass("close")
.append($("<span>", spanProperties)
.html("&times;"))
$("<button>", buttonProperties)
.addClass("close")
.append($("<span>", spanProperties)
.html("&times;"))
);
rowDiv.append(message);
var userMessages = $("#userMessages");
userMessages.empty();
userMessages.append(rowDiv);
}
function appendError(message) {
_appendMessage(message, true);
}
div#userMessages

0 comments on commit 54afb3b

Please sign in to comment.