Commit d16c5cf1 authored by Celine Noirot's avatar Celine Noirot
Browse files

Merge branch 'master' into 'dev'

Merge branch Master with dev

See merge request !105
parents 88acab04 384a7de2
......@@ -53,8 +53,8 @@
<!-- ###LOGIN_FORM### -->
<form action="###ACTION_URI###" target="_top" method="post" onsubmit="###ON_SUBMIT###" class="form-horizontal">
<fieldset>
<legend>###LEGEND###</legend>
<p>###STATUS_MESSAGE###</p>
<div class="form-group">
<label class="col-sm-offset-1 col-sm-4 control-label" for="user">###USERNAME_LABEL###</label>
<div class="col-sm-6">
......
......@@ -46,11 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div><p>Current space: <b><span id="current_space_id">{$projects[key($projects)].space_id}</span></b></p></div>
<div><p>{$space_purge_msg}</p></div>
{if $projects[key($projects)].is_admin}
<div id="change_space_id_warning"><p><i>Warning, migrating a project from one space to another will update both the files location and the retention limits.</i></p></div>
<div id="change_space_id_form"></div>
<div id="wf_id"></div>
<div id="change_space_id_status"></div>
<div id="change_space_id_footer" align="right"></div>
<div id="migration_form"></div>
{/if}
</div>
<div class="ng6-content-header-right">
......@@ -319,4 +315,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
{/if}
{include file='../template/modals.tpl'}
......@@ -153,7 +153,7 @@ $(function () {
initEditableFields();
initCheckboxes();
initChangeSpaceForm();
updateProjectButtonStatus();
$("[id^=chk_project_]").change(function() {
updateProjectButtonStatus();
......@@ -1030,8 +1030,6 @@ $(function () {
});
});
setChangeSpaceForm();
});
......@@ -1409,7 +1407,7 @@ function initRunTable() {
"sScrollXInner" : "100%",
"order" : [[2, 'desc']],
"columnDefs" : [{ "targets" : 0, "type" : "anti-label" },
{ "targets" : 2, "type" : "date-eu" },
{ "targets" : 2, "type" : "date" },
{ "targets" : [6,7], "type": "formatted-num" }
]
};
......@@ -1509,6 +1507,140 @@ function initCheckboxes() {
});
}
function initChangeSpaceForm() {
var workflow_status_handler = function(workflow_id){
$.ajax({
url : $("#server_url").val() + '/get_workflow_status?display=list&workflow_id=' + workflow_id ,
dataType : 'jsonp',
timeout: 20000 ,
success : function(data){
$("#wfStatusMigration").html("Workflow status : " + data.status);
if (data.status=="completed" ){
$("#current_space_id").html($("#space_id").val());
}
if (data.status=="completed" || data.status=="failed" ){
setTimeout(function(){
$("#myCarouselMigration").carousel('next');
$("#myCarouselMigration").carousel('pause');
$('#wfStatusMigration').html("Workflow status : <span class='tx-nG6-mini-wait'></span>");
},3000);
}
},
error : function(jqXHR, textStatus, errorThrown){
$("#myCarouselMigration").html("Error on get status.");
setTimeout(function(){
$("#myCarouselMigration").carousel('next');
$("#myCarouselMigration").carousel('pause');
$('#wfStatusMigration').html("Workflow status : <span class='tx-nG6-mini-wait'></span>");
},3000);
}
});
};
$('#migration_form').html([
' <div id="myCarouselMigration" class="carousel slide">',
' <div class="carousel-inner">',
' <div class="active item">',
' <p id="warnMigration"><i>Warning, migrating a project from one space to another will update both the files location and the retention limits.</i></p>',
' <div id="wfFormMigration" ></div>',
' <button id="run_change_space" style="float: right;" class="btn btn-info btn-sm"><i class="glyphicon glyphicon-share-alt"></i> Migrate</button>',
' </div>',
' <div class="item">',
' <input id="wfIdMigration" type="hidden"></input>',
' <p id="wfStatusMigration" >Workflow status : <span class="tx-nG6-mini-wait"></span></p>',
' <button id="refresh_workflow_migrate" style="float: right;" class="btn btn-info btn-sm"><i class="glyphicon glyphicon-refresh"></i> Refresh</button>',
' </div>',
' </div>',
' </div>',
' <div id="formMigrationFooter" align="right">',
' </div>'
].join('')
);
$('#myCarouselMigration').on('keydown', 'input', function(e) {
e.stopPropagation();
});
var wfform_options = {
workflowClass: "SwitchSpaceId",
serverURL: $("#server_url").val(),
displayRunButton: false,
displayResetButton: false,
parameters : {
"admin_login" : $("#user_login").val(),
"project_id" : $("#ids").val()
}
};
$("#wfFormMigration").wfform(wfform_options);
//Launch workflow migration
$("#run_change_space").click(function(){
//We show a modal to check if the given SSH user + password is ok
var switch_space_auth_html = [
'<div class="tx-nG6-pi1-login">',
' This functionality is only available if you have an account on the ' + $("#server_name").val() + ' server. <br /> <br /> ',
' <form class="form-horizontal" id="tx-nG6-pi1-login-form" >',
' <div class="input-group" style="margin-left:50px">',
' <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>',
' <input class="form-control" style="width:200px" type="text" id="user_login_val" name="user_login_val" placeholder="Username"/>',
' </div><br/>',
' <div class="input-group" style="margin-left:50px">',
' <span class="input-group-addon"><i class="glyphicon glyphicon-wrench"></i></span>',
' <input class="form-control" style="width:200px" type="password" id="user_pwd_val" name="user_pwd_val" placeholder="Password"/>',
' </div>',
' </form>',
'</div>'
].join('');
$("#modal-label-tmpl").html("Migrate");
$("#modal-body-tmpl").html(switch_space_auth_html);
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>' +
'<button id="modal-btn-migrate" class="btn btn-primary"><i class="glyphicon glyphicon-share-alt"></i> Migrate</button>');
$("#ng6modal").modal();
$("#modal-btn-migrate").click(function(){
//We call the ajax check "check_ssh_user"
var val_url = "index.php?eID=tx_nG6&type=check_ssh_user";
val_url += "&user_login=" + $("#user_login_val").val() + "&user_pwd=" + $("#user_pwd_val").val() + "&project_id=" + $("#current_project_id").val();
$.ajax({
url: val_url,
success: function(val, status, xhr) {
// return codes : 0 = ok, 2 = authentication error, 3 = connexion error, 4 = the user doesn't have the rights
// For no reason I understand, the string returned is "\n\n<ret_code>", so we cast it to int.
val = parseInt(val);
if (val == 0) {
$("#ng6modal").modal('hide');
//Run switch_space_id workflow
$('#wfFormMigration').wfform('run');
$("#myCarouselMigration").carousel('next');
$("#myCarouselMigration").carousel('pause');
} else {
$("#modal-label-tmpl").html("Error");
if (val == 2) {
$("#modal-body-tmpl").html("<div class='tx-nG6-pi1-error'>An error occurred during login. Most likely you didn't enter the username or password correctly. Be certain that you enter them precisely as they are, including upper/lower case.</div>");
} else if (val == 3) {
$("#modal-body-tmpl").html("<div class='tx-nG6-pi1-error'>An error occurred during server connection. Please contact the site administrator.</div>");
} else if(val == 4){
$("#modal-body-tmpl").html("<div class='tx-nG6-pi1-error'>The user you entered doesn't have the rights to perform this action.</div>");
}
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#ng6modal").modal();
}
}
});
});
});
//add status part.
$('#wfFormMigration').on('run.wfform', function(event, running_wf) {
$('#wfIdMigration').val(running_wf.id);
workflow_status_handler(running_wf.id);
});
$("#refresh_workflow_migrate").click(function(){
$('#wfStatusMigration').html("Workflow status : <span class='tx-nG6-mini-wait'></span>");
workflow_status_handler($('#wfIdMigration').val());
})
}
function showEditableFromTD(e) {
e.stopPropagation();
$(this).children('span.editable').editable('show');
......@@ -2187,207 +2319,6 @@ function addFileHandler( event ){
$("#refresh_workflow").bind('click', {'selector' : '#monitoringWorkflow' }, refreshWFStatusHandler);
}
function setChangeSpaceForm(){
var _get_workflow_status = function(workflow_id, callback, error_callback){
$.ajax({
url : $("#server_url").val() + '/get_workflow_status?display=list&workflow_id=' + workflow_id ,
dataType : 'jsonp',
timeout: 20000 ,
success : function(data){
if (callback){
callback(data);
}
},
error : function(jqXHR, textStatus, errorThrown){
if (error_callback){
error_callback(jqXHR, textStatus, errorThrown);
}
}
});
};
var wfform_options = {
workflowClass: "SwitchSpaceId",
serverURL: $("#server_url").val(),
displayRunButton: false,
displayResetButton: false,
parameters : {
"admin_login" : $("#user_login").val(),
"project_id" : $("#ids").val()
}
};
//$("#change_space_id_status").hide();
$('#change_space_id_status').html([
' <div id="myCarousel" class="carousel slide">',
' <div class="carousel-inner">',
' </div>',
' </div>'
].join(''));
$("#change_space_id_form").wfform(wfform_options);
$('#change_space_id_footer').html([
' <button id="run_workflow" class="btn btn-primary"><i class="glyphicon glyphicon-cog"></i> Migrate</button>',
' <button id="refresh_workflow" class="btn btn-default"><i class="glyphicon glyphicon-refresh"></i> Refresh</button>',
].join(''));
//Show the footer, but hide the "refresh"button until the user clicks "Migrate"
$("#change_space_id_footer").show();
$("#refresh_workflow").hide();
//When clicking 'migrate'
$("#run_workflow").click(function(){
var params = simpleQueryParams(location.href),
project_id = params["tx_nG6_pi1[project_id]"];
//We show a modal to check if the given SSH user + password is ok
var switch_space_auth_html = [
'<div class="tx-nG6-pi1-login">',
' This functionality is only available if you have an account on the ' + $("#server_name").val() + ' server. <br /> <br /> ',
' <form class="form-horizontal" id="tx-nG6-pi1-login-form" >',
' <div class="input-group" style="margin-left:50px">',
' <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>',
' <input class="form-control" style="width:200px" type="text" id="user_login_val" name="user_login_val" placeholder="Username"/>',
' </div><br/>',
' <div class="input-group" style="margin-left:50px">',
' <span class="input-group-addon"><i class="glyphicon glyphicon-wrench"></i></span>',
' <input class="form-control" style="width:200px" type="password" id="user_pwd_val" name="user_pwd_val" placeholder="Password"/>',
' </div>',
' </form>',
'</div>'
].join('');
$("#modal-label-tmpl").html("Migrate");
$("#modal-body-tmpl").html(switch_space_auth_html);
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>' +
'<button id="modal-btn-migrate" class="btn btn-primary"><i class="glyphicon glyphicon-trash"></i> Migrate</button>');
$("#ng6modal").modal();
$("#modal-btn-migrate").click(function(){
var params = simpleQueryParams(location.href),
project_id = params["tx_nG6_pi1[project_id]"];
//We call the ajax check "check_ssh_user"
var val_url = "index.php?eID=tx_nG6&type=check_ssh_user";
val_url += "&user_login=" + $("#user_login_val").val() + "&user_pwd=" + $("#user_pwd_val").val() + "&project_id=" + project_id;
$.ajax({
url: val_url,
success: function(val, status, xhr) {
// return codes : 0 = ok, 2 = authentication error, 3 = connexion error, 4 = the user doesn't have the rights
// For no reason I understand, the string returned is "\n\n<ret_code>", so we parse it to int.
val = parseInt(val);
if (val == 0) {
$("#ng6modal").modal('hide');
//Run switch_space_id workflow
$('#change_space_id_form').wfform('run');
} else {
$("#modal-label-tmpl").html("Error");
if (val == 2) {
$("#modal-body-tmpl").html("<div class='tx-nG6-pi1-error'>An error occurred during login. Most likely you didn't enter the username or password correctly. Be certain that you enter them precisely as they are, including upper/lower case.</div>");
} else if (val == 3) {
$("#modal-body-tmpl").html("<div class='tx-nG6-pi1-error'>An error occurred during server connection. Please contact the site administrator.</div>");
} else if(val == 4){
$("#modal-body-tmpl").html("<div class='tx-nG6-pi1-error'>The user you entered doesn't have the rights to perform this action.</div>");
}
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#ng6modal").modal();
}
}
});
});
});
//The status label has to be display just for a few seconds each time we hit "Migrate" or "Refresh"
$("#change_space_id_status").hide();
//When clicking 'refresh'
$("#refresh_workflow").click(function(){
//The workflow's id has been saved in the hidden div <div id="wf_id">
_get_workflow_status($("#wf_id").html(),
//success
function(data) {
if (data.status=="completed"){
$("#change_space_id_status").show();
$("#change_space_id_status").html("Workflow status : " + data.status);
setTimeout(function(){
$("#change_space_id_status").hide();
},5000);
$("#current_space_id").html($("#space_id").val());
$("#refresh_workflow").hide();
$("#run_workflow").show();
$("#workflow_form").show();
}
else{
$("#change_space_id_status").show();
$("#change_space_id_status").html("Workflow status : " + data.status);
setTimeout(function(){
$("#change_space_id_status").hide();
},5000);
}
},
//error
function() {
$("#change_space_id_status").html("erreur requete ajax");
}
);
});
// The 'run' function
$('#change_space_id_form').on('run.wfform', function(event, running_wf) {
$("#run_workflow").hide();
$("#workflow_form").hide();
//We will need the workflow's id to check its status with the "refresh" button
$("#wf_id").hide();
$("#wf_id").html(running_wf.id);
$("#refresh_workflow").show();
_get_workflow_status(running_wf.id,
//success
function(data) {
if (data.status=="completed"){
$("#change_space_id_status").show();
$("#change_space_id_status").html("Workflow status : " + data.status);
setTimeout(function(){
$("#change_space_id_status").hide();
},5000);
$("#current_space_id").html($("#space_id").val());
$("#refresh_workflow").hide();
$("#run_workflow").show();
$("#workflow_form").show();
}
else{
$("#change_space_id_status").show();
$("#change_space_id_status").html("Workflow status : " + data.status);
setTimeout(function(){
$("#change_space_id_status").hide();
},5000);
}
},
//error
function() {
$("#change_space_id_status").html("erreur requete ajax");
}
);
});
}
function addAnalysisHandler(){
$('#setAndRunModalLabel').html("Loading");
$('#setAndRunModalBody').html([
......
......@@ -16,9 +16,8 @@
#
from jflow.workflow import Workflow
from ng6.project import Project
from ng6.config_reader import NG6ConfigReader
from workflows.types import ng6adminlogin, uniqproject, ng6space
class AddProject (Workflow):
......@@ -27,10 +26,13 @@ class AddProject (Workflow):
return "Add a brand new project"
def define_parameters(self, function="process"):
ng6conf = NG6ConfigReader()
space_choices = ng6conf.get_available_spaces()
self.add_parameter("admin_login", "The login of a ng6 administrator", required = True, type = ng6adminlogin)
self.add_parameter("project_name", "Give a name to your project (has to be unique)", flag = "--name", required = True, type = uniqproject)
self.add_parameter("project_description", "Give a description to your project", flag = "--description", required = True)
self.add_parameter("space", "Where to store data", flag = "--space", default="default", type=ng6space)
self.add_parameter("space", "Where to store data", flag = "--space", default="shortterm", type=ng6space, choices = space_choices)
def process(self):
project = Project(self.project_name, self.project_description, self.admin_login, None, self.space)
......
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