Commit f262c408 authored by Alain Takoudjou's avatar Alain Takoudjou

Ask confirm before delete sr or instance folder

parent 0ea58389
......@@ -243,12 +243,12 @@ overflow-y: scroll;
color: #4c6172;
text-shadow: 0px 1px 1px #fff;
}
.dsblebutton{color:#9C9C9C; padding: 5px 10px;display: inline;background: #eee;
font-weight: bold; border:1px solid #000; margin-top:10px;}
.button {
padding: 5px 10px;
display: inline;
background: #eee;
border: none;
color: #000;
cursor: pointer;
font-weight: bold;
......
......@@ -3,33 +3,48 @@ String.prototype.toHtmlChar = function(){
var c = {'<':'&lt;', '>':'&gt;', '&':'&amp;', '"':'&quot;', "'":'&#039;',
'#':'&#035;' };
return this.replace( /[<&>'"#]/g, function(s) { return c[s]; } );
}
};
String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
};
/****************************************/
function setInput($elt) {
if(!$elt){var $elt = $('input[type="text"], input[type="password"]');}
if(!$elt){$elt = $('input[type="text"], input[type="password"]');}
$elt.addClass("idleField");
$elt.focus(function() {
$(this).removeClass("idleField").addClass("focusField");
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
$elt.focus(function() {
$(this).removeClass("idleField").addClass("focusField");
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
});
$elt.blur(function() {
$(this).removeClass("focusField").addClass("idleField");
if ($.trim(this.value) == ''){
this.value = (this.defaultValue ? this.defaultValue : '');
if ($.trim(this.value) === ''){
this.value = (this.defaultValue ? this.defaultValue : '');
}
});
}
/*******************Bind remove all button*******************/
function bindRemove(){
$("a#removeSr").click(function(){
if(!window.confirm("Do you really want to remove all software release?")){
return false;
}
location.href = $SCRIPT_ROOT + '/removeSoftware';
});
$("a#removeIst").click(function(){
if(!window.confirm("Do you really want to remove all computer partition?")){
return false;
}
location.href = $SCRIPT_ROOT + '/removeInstance';
});
}
/**************************/
(function ($, document, window) {
$.extend($.fn, {
......
......@@ -23,20 +23,20 @@ $(document).ready( function() {
}
var repo_url = $("input#repo").val();
var email = "";
var name = ""
var name = "";
/* /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/ */
if($("input#repo").val() == "" || !repo_url.match(/^[\w\d\.\/:~@_-]+$/)){
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\._-]+$/)){
if($("input#name").val() === '' || !$("input#name").val().match(/^[\w\d\._-]+$/)){
$("#error").Popup("Invalid project name", {type:'alert', duration:3000});
return false;
}
if($("input#user").val() !== ""){
name = $("input#user").val();
}
if($("input#email").val() != "" && $("input#email").val() != "Enter your email adress..."){
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})+$/)){
$("#error").Popup("Please enter a valid email adress!", {type:'alert', duration:3000});
return false;
......@@ -75,8 +75,8 @@ $(document).ready( function() {
cloneRequest = $.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/cloneRepository',
data: {repo: repo_url, name: ($("input#workdir").val() + "/"
+ $("input#name").val()), email:email,
data: {repo: repo_url, name: ($("input#workdir").val() + "/" +
$("input#name").val()), email:email,
user:name},
success: function(data){
if(data.code == 1){
......@@ -97,7 +97,7 @@ $(document).ready( function() {
error: function(request,error) {
$("#error").Popup("unable to clone your project, please check your internet connection", {type:'error', duration:3000});
$("#imgwaitting").hide();
$("#clone").empty();
$("#clone").empty();
$("#clone").append("Clone");
}
});
......
......@@ -39,6 +39,9 @@ $(document).ready( function() {
return false;
}
if(send) return;
if(!window.confirm("Do you really want to delete this software release?")){
return;
}
send = false;
var elt = $("option:selected", $("#softwarelist"));
$.ajax({
......
......@@ -15,6 +15,7 @@ $(document).ready( function() {
send = true;
var param = {clogin:$("input#clogin").val(), cpwd:$("input#cpwd").val()};
var url = $SCRIPT_ROOT + "/doLogin";
$("#login").removeClass("button").addClass("dsblebutton");
$.post(url, param, function(data) {
if (data.code==1){
location.href = $SCRIPT_ROOT + '/';
......@@ -23,9 +24,11 @@ $(document).ready( function() {
$("#error").Popup(data.result, {type:'alert', duration:3000});
}
})
.error(function() {$("#error").Popup("Cannot send your account identifier please try again!!",
.error(function() {
$("#error").Popup("Cannot send your account identifier please try again!!",
{type:'alert', duration:3000});})
.complete(function() {
$("#login").removeClass('dsblebutton').addClass('button');
send = false;
});
return false;
......
......@@ -25,6 +25,7 @@
<script type="text/javascript">
$(document).ready(function() {
setInput();
bindRemove();
});
</script>
{% if request.path != '/login' %}
......@@ -68,14 +69,14 @@
<li><a href="{{ url_for('runSoftwareProfile') }}" id="softrun">Run</a></li>
<li><a href="{{ url_for('viewSoftwareLog') }}">Build log</a></li>
<li><a href="{{ url_for('inspectSoftware') }}">Inspect</a></li>
<li><a href="{{ url_for('removeSoftware') }}">Remove all</a></li>
<li><a id="removeSr" href="#">Remove all</a></li>
<li class="space"><span class="title_instance">Instance</span></li>
<li><a href="{{ url_for('editInstanceProfile') }}">Edit</a></li>
<li><a href="{{ url_for('runInstanceProfile') }}" id="instrun">Run</a></li>
<li><a href="{{ url_for('viewInstanceLog') }}">Build log</a></li>
<li><a href="{{ url_for('inspectInstance') }}">Inspect</a></li>
<li><a href="{{ url_for('removeInstance') }}">Remove all</a></li>
<li><a id="removeIst" href="#">Remove all</a></li>
</ul>
</div>
<div class="clear"></div>
......
......@@ -105,13 +105,13 @@ def inspectSoftware():
#remove content of compiled software release
@login_required()
def removeSoftware():
file_config = os.path.join(app.config['etc_dir'], ".softdata")
if isSoftwareRunning(app.config) or isInstanceRunning(app.config):
flash('Software installation or instantiation in progress, cannot remove')
elif os.path.exists(file_config):
elif os.path.exists(app.config['software_root']):
svcStopAll(app.config)
shutil.rmtree(app.config['software_root'])
os.remove(file_config)
for link in os.listdir(app.config['software_link']):
os.remove(os.path.join(app.config['software_link'], link))
flash('Software removed')
return redirect(url_for('inspectSoftware'))
......
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