Commit 3928ec49 authored by Alain Takoudjou's avatar Alain Takoudjou

Webrunner: Add floating Popup for displaying error and info messages

parent bbe5ee4f
......@@ -583,4 +583,57 @@ a.lshare:focus{
a.lshare img{
margin: 5px;
}
\ No newline at end of file
}
#error{
padding: 0px;
position: absolute;
top: -2px;
left:0;
right: 0;
}
#error > div{
background: none repeat scroll 0 0 #afcee4;
border: 1px solid #FFF;
width:500px;
margin: 0 auto;
border-top:none;
border-radius: 0 0 4px 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
text-align: center;
}
#error table{
background: none;
width: 100%;
font-weight: normal;
}
#error table, #error th, #error tr, #error td{
border: none;
padding:0;
}
#error td{
margin:2px;
}
#error td.logo{
width: 36px;
height: 26px;
}
#error td.close{
width: 30px;
height:22px;
}
.alert_message{ background: url(../images/alert.png) center no-repeat; height: 26px;}
.error_message{ background: url(../images/exit.png) center no-repeat; height: 26px;}
.confirm_message{ background: url(../images/confirm.png) center no-repeat; height: 26px;}
.info_message{ background: url(../images/info.png) center no-repeat; height: 26px;}
#error p{
fon-size: 13px;
color: #000;
}
#pClose{background:url(../images/close.png) no-repeat 0px 0px; display:block; width:22px; height:22px; cursor:pointer}
#pClose:hover{background:url(../images/close_hover.png) no-repeat 0px 0px;}
// jQuery Message Popup
// Display a message on the top of page, with floating
//
(function ($, document, window) {
$.extend($.fn, {
Popup: function(msg, option) {
if (option.type == undefined) option.type = "info";
if (option.closebtn == undefined) option.closebtn = false;
if (option.duration == undefined) option.duration = 0;
if (option.load == undefined) option.load = false;
$box = $(this);
$box.empty();
$box.css('top','-1000px');
$box.show();
$box.append('<div><table id="bcontent"><tr>' +
'<td valign="middle" class="logo ' + option.type + '_message"></td>' +
'<td valign="middle"><p>' + msg + '</p></td>' +
'<td valign="middle" class="close"><span id="pClose"></span></td></tr></table></div>');
$(window).scroll(function(){
$box.animate({top:$(window).scrollTop()+"px" },{queue: false, duration: 350});
});
var h = $("#bcontent").height()+5;
$("#pClose").bind("click", function() {
close();
});
if(option.load){
$(window).load(function(){
$box.css('top', + ($(window).scrollTop() - h) +'px');
$box.animate({ top:"+=" + h + "px" }, "slow");
});
}
else{
$box.css('top', + ($(window).scrollTop() - h) +'px');
$box.animate({ top:"+=" + h + "px" }, "slow");
}
if(option.duration != 0){
setTimeout(function(){
close();
}, option.duration);
}
function close(){
$box.animate({ top:"-=" + h + "px" }, "slow", function(){
$box.fadeOut("normal");
});
}
}
});
}(jQuery, document, this));
\ No newline at end of file
......@@ -14,7 +14,7 @@ $(document).ready( function() {
$("#save").click(function(){
if(!edit){
error("Error: Can not load your file, please make sure that you have selected a Software Release");
$("#error").Popup("Can not load your file, please make sure that you have selected a Software Release", {type:'alert', duration:5000});
return false;
}
send = false;
......@@ -24,10 +24,10 @@ $(document).ready( function() {
data: {file: file, content: editor.getSession().getValue()},
success: function(data){
if(data.code == 1){
error("File Saved!");
$("#error").Popup("File Saved!", {type:'confirm', duration:2000});
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
send = false;
}
......@@ -35,12 +35,6 @@ $(document).ready( function() {
return false;
});
function error(msg){
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
$("#flash").append("<ul class='flashes'><li>" + msg + "</li></ul>");
}
function selectFile(file){
edit = false;
$.ajax({
......@@ -53,7 +47,7 @@ $(document).ready( function() {
edit = true;
}
else{
error("Error: Can not load your file, please make sure that you have selected a Software Release");
$("#error").Popup("Can not load your file, please make sure that you have selected a Software Release", {type:'alert', duration:5000});
}
}
});
......
......@@ -12,30 +12,25 @@ $(document).ready( function() {
$("#clone").append("Clone");
send = false;
return;
}
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
}
var repo_url = $("input#repo").val();
var email = "";
var name = ""
/* /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/ */
if($("input#repo").val() == "" || !repo_url.match(/^[\w\d\.\/:~@_-]+$/)){
$("#flash").append("<ul class='flashes'><li>Error: Invalid url for the repository</li></ul>");
if($("input#repo").val() == "" || !repo_url.match(/^[\w\d\.\/:~@_-]+$/)){
$("#error").Popup("Invalid url for the repository", {type:'alert', duration:3000});
return false;
}
if($("input#name").val() == "" || !$("input#name").val().match(/^[\w\d\._-]+$/)){
$("#flash").append("<ul class='flashes'><li>Error: Invalid project name</li></ul>");
$("#error").Popup("Invalid project name", {type:'alert', duration:3000});
return false;
}
if($("input#user").val() != "" && $("input#user").val() != "Enter your name..."){
//$("#flash").append("<ul class='flashes'><li>Error: Please enter your name!</li></ul>");
//return false;
name = $("input#user").val();
}
if($("input#email").val() != "" && $("input#email").val() != "Enter your email adress..."){
if(!$("input#email").val().match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
$("#flash").append("<ul class='flashes'><li>Error: Please enter a valid email adress!</li></ul>");
$("#error").Popup("Please enter a valid email adress!", {type:'alert', duration:3000});
return false;
}
email = $("input#email").val();
......@@ -52,7 +47,7 @@ $(document).ready( function() {
success: function(data){
if(data.code == 1){
$("#file_navigation").fadeIn('normal');
$("#flash").append("<ul class='flashes'><li>Repository is cloned!</li></ul>");
$("#error").Popup("Your repository is cloned!", {type:'confirm', duration:3000});
$("input#repo").val("Enter the url of your repository...");
$("input#name").val("Enter the project name...");
$('#fileTree').fileTree({ root: $("input#workdir").val(), script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false }, function(file) {
......@@ -60,9 +55,9 @@ $(document).ready( function() {
});
}
else{
$("#flash").append("<ul class='flashes'><li>Error: " + data.result + "</li></ul>");
$("#error").Popup(data.result, {type:'error'});
}
$("#imgwaitting").hide()
$("#imgwaitting").hide();
$("#clone").empty();
$("#clone").append("Clone");
send = false;
......
......@@ -35,30 +35,29 @@ $(document).ready( function() {
data: {file:file, truncate:1500},
success: function(data){
if(data.code == 1){
$("#flash").empty();
$("#inline_content").empty();
$("#inline_content").append('<h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">Inspect Software Content: ' +
filename +'</h2>');
$("#inline_content").append('<br/><div class="main_content"><pre id="editor"></pre></div>');
setupEditor();
$(".inline").colorbox({inline:true, width: "847px", onComplete:function(){
editor.getSession().setValue(data.result);
}});
$(".inline").click();
$("#inline_content").empty();
$("#inline_content").append('<h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">Inspect Software Content: ' +
filename +'</h2>');
$("#inline_content").append('<br/><div class="main_content"><pre id="editor"></pre></div>');
setupEditor();
$(".inline").colorbox({inline:true, width: "847px", onComplete:function(){
editor.getSession().setValue(data.result);
}});
$(".inline").click();
}
else{
error("Error: Can not load your file, please make sure that you have selected a Software Release");
$("#error").Popup("Can not load your file, please make sure that you have selected a Software Release", {type:'alert', duration:5000});
}
}
});
}
else{
//Can not displays binary file
error(data.result);
$("#error").Popup(data.result, {type:'alert', duration:5000});
}
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'alert', duration:5000});
}
}
});
......@@ -75,11 +74,4 @@ $(document).ready( function() {
editor.renderer.setHScrollBarAlwaysVisible(false);
editor.setReadOnly(true);
}
function error(msg){
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
$("#flash").append("<ul class='flashes'><li>" + msg + "</li></ul>");
}
});
\ No newline at end of file
......@@ -39,7 +39,7 @@ $(document).ready( function() {
location.href = $SCRIPT_ROOT + '/editSoftwareProfile'
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error'});
}
}
});
......@@ -62,8 +62,6 @@ $(document).ready( function() {
setupFileTree(runnerDir);
}, function(file){ viewFile(file)});
$("input#file").val("");
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#info").empty();
$("#info").append("Please select your file or folder into the box...");
$("#softwarelist").empty();
......@@ -72,9 +70,10 @@ $(document).ready( function() {
'" title="' + data.result[i]["title"] +'" rel="' +
data.result[i]["path"] +'">' + data.result[i]["title"] + '</option>');
}
$("#error").Popup("Operation complete, Selected Software Release has been delete!", {type:'confirm', duration:5000});
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error'});
}
send = false;
}
......@@ -102,7 +101,6 @@ $(document).ready( function() {
data: {file:file, truncate:1500},
success: function(data){
if(data.code == 1){
$("#flash").empty();
$("#inline_content").empty();
$("#inline_content").append('<h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">Inspect Software Content: ' +
filename +'</h2>');
......@@ -114,18 +112,18 @@ $(document).ready( function() {
$(".inline").click();
}
else{
error("Error: Can not load your file, please make sure that you have selected a Software Release");
$("#error").Popup("Can not load your file, please make sure that you have selected a Software Release", {type:'alert', duration:5000});
}
}
});
}
else{
//Can not displays binary file
error(data.result);
$("#error").Popup(data.result, {type:'alert', duration:5000});
}
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'alert', duration:5000});
}
}
});
......@@ -142,11 +140,4 @@ $(document).ready( function() {
editor.renderer.setHScrollBarAlwaysVisible(false);
editor.setReadOnly(true);
}
function error(msg){
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
$("#flash").append("<ul class='flashes'><li>" + msg + "</li></ul>");
}
});
\ No newline at end of file
......@@ -9,16 +9,13 @@ $(document).ready( function() {
}
$("input#subfolder").val("");
$("#create").click(function(){
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
repo_url = $("input#software").val();
if($("input#software").val() == "" || !$("input#software").val().match(/^[\w\d._-]+$/)){
$("#flash").append("<ul class='flashes'><li>Error: Invalid Software name</li></ul>");
$("#error").Popup("Invalid Software name", {type:'alert', duration:3000})
return false;
}
if($("input#subfolder").val() == ""){
$("#flash").append("<ul class='flashes'><li>Error: Select the parent folder of your software!</li></ul>");
$("#error").Popup("Select the parent folder of your software!", {type:'alert', duration:3000})
return false;
}
$.ajax({
......@@ -30,7 +27,8 @@ $(document).ready( function() {
location.href = $SCRIPT_ROOT + '/editSoftwareProfile'
}
else{
$("#flash").append("<ul class='flashes'><li>Error: " + data.result + "</li></ul>");
$("#error").Popup(data.result, {type:'error', duration:5000})
}
}
});
......@@ -42,7 +40,7 @@ $(document).ready( function() {
$("#flash").empty();
$("#flash").fadeIn('normal');
if($("input#path").val() == ""){
$("#flash").append("<ul class='flashes'><li>Error: Select a valid Software Release folder</li></ul>");
$("#error").Popup("Select a valid Software Release folder!", {type:'alert', duration:3000})
return false;
}
$.ajax({
......@@ -54,7 +52,7 @@ $(document).ready( function() {
location.href = $SCRIPT_ROOT + '/editSoftwareProfile'
}
else{
$("#flash").append("<ul class='flashes'><li>Error: " + data.result + "</li></ul>");
$("#error").Popup(data.result, {type:'error', duration:5000})
}
}
});
......
......@@ -21,7 +21,7 @@ $(document).ready( function() {
gitStatus();
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
}
});
......@@ -29,7 +29,7 @@ $(document).ready( function() {
$("#addbranch").click(function(){
if($("input#branchname").val() == "" ||
$("input#branchname").val() == "Enter the branch name..."){
error("Error: Please Enter your branch name");
$("#error").Popup("Please Enter your branch name", {type:'alert', duration:3000});
return false;
}
var project = $("#project").val();
......@@ -44,7 +44,7 @@ $(document).ready( function() {
gitStatus();
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error'});
}
}
});
......@@ -53,7 +53,7 @@ $(document).ready( function() {
$("#commit").click(function(){
if($("input#commitmsg").val() == "" ||
$("input#commitmsg").val() == "Enter message..."){
error("Error: Please Enter the commit message");
$("#error").Popup("Please Enter the commit message", {type:'alert', duration:3000});
return false;
}
if (send){
......@@ -71,14 +71,14 @@ $(document).ready( function() {
success: function(data){
if(data.code == 1){
if (data.result != ""){
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
else
error("Commit done!");
$("#error").Popup("Commit done!", {type:'confirm', duration:3000});
gitStatus();
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
$("#imgwaitting").hide()
$("#commit").empty();
......@@ -155,7 +155,7 @@ $(document).ready( function() {
loadBranch(data.branch);
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
send = false;
}
......@@ -169,11 +169,4 @@ $(document).ready( function() {
"' " + selected + ">" + branch[i] + "</option>");
}
}
function error(msg){
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
$("#flash").append("<ul class='flashes'><li>" + msg + "</li></ul>");
}
});
\ No newline at end of file
......@@ -38,7 +38,7 @@ $(document).ready( function() {
if (send) return false;
if($("input#file").val() == "" ||
$("input#file").val() == "Enter name here..."){
error("Error: Please enter your file or folder name");
$("#error").Popup("Please enter your file or folder name", {type:'alert', duration:3000});
return false;
}
if($("input#subfolder").val() != ""){
......@@ -61,7 +61,7 @@ $(document).ready( function() {
$("input#subfolder").val("");
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
send = false;
}
......@@ -71,7 +71,7 @@ $(document).ready( function() {
$("#save").click(function(){
if(!edit){
error("Please select the file to edit");
$("#error").Popup("Please select the file to edit", {type:'alert', duration:3000});
return false;
}
send = false;
......@@ -83,9 +83,10 @@ $(document).ready( function() {
if(data.code == 1){
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#error").Popup("File saved succefuly!", {type:'confirm', duration:3000});
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
send = false;
}
......@@ -143,12 +144,6 @@ $(document).ready( function() {
}
}
function error(msg){
$("#flash").fadeOut('normal');
$("#flash").empty();
$("#flash").fadeIn('normal');
$("#flash").append("<ul class='flashes'><li>" + msg + "</li></ul>");
}
function selectFile(file){
relativeFile = file.replace(workdir, "");
$("#info").empty();
......@@ -175,7 +170,7 @@ $(document).ready( function() {
edit = true;
}
else{
error(data.result);
$("#error").Popup(data.result, {type:'error', duration:5000});
}
send = false;
}
......
......@@ -13,7 +13,8 @@
<meta name="description" content="" />
<link href="{{ url_for('static', filename='css/styles.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jquery-1.6.2.min.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jquery-1.6.2.min.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/popup.js') }}" type="text/javascript" charset="utf-8"></script>
<script type=text/javascript>
$SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
</script>
......@@ -34,13 +35,18 @@
if ($.trim(this.value) == ''){
this.value = (this.defaultValue ? this.defaultValue : '');
}
});
});
});
if($("input#fmsg").val() != ""){
$("#error").Popup($("input#fmsg").val(), {type:'info', duration:10000, load:true});
}
});
</script>
{% endblock %}
</head>
<body>
<div id="page">
<div id="error"></div>
<div id="page">
<input type="hidden" name="fmsg" value="{{ get_flashed_messages()[0] }}" id="fmsg" />
<div id="logo">
<a href="{{ url_for('home') }}"><img src="{{ url_for('static', filename='images/logo.png') }}" alt="" /></a>
</div>
......@@ -72,18 +78,7 @@
</div>
<div class="clear"></div>
</div>
<div id="main">
<div class="flash" id="flash">
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class="flashes">
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
<div id="main">
<div {% if request.path == '/' %} class="home_content" {%else%} id="content" {% endif %}>
{% if request.path != '/' %}
<div class="main_head">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment