Commit 9d524495 authored by Maria Arsuaga Rios's avatar Maria Arsuaga Rios
Browse files

Revert "FTS-442:Make more intuitive the interface for configuring Cloud storages"

This reverts commit cc100415.
parent c6bb9b48
......@@ -18,9 +18,9 @@
var template_cloud_storage_entry = null;
/**
* Save a new dropbox storage, or change it
* Save a new storage, or change it
*/
function saveDropboxStorage(form)
function saveStorage(form)
{
var msg = {
storage_name: form.find("input[name='storage-name']").val(),
......@@ -40,28 +40,6 @@ function saveDropboxStorage(form)
});
}
/**
* Save a new S3 storage, or change it
*/
function saveS3Storage(form)
{
var msg = {
storage_name: form.find("input[name='storage-name']").val(),
service_api_url: form.find("input[name='service-api']").val(),
};
console.log(msg);
return $.ajax({
url: "/config/cloud_storage?",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(msg)
});
}
/**
* Delete a storage
*/
......@@ -86,9 +64,9 @@ function deleteStorage(storage_name, div)
}
/**
* Save a dropbox user
* Save a user
*/
function saveDropboxUser(storage_name, form)
function saveUser(storage_name, form)
{
var msg = {
user_dn: form.find("input[name='user-dn']").val(),
......@@ -110,29 +88,6 @@ function saveDropboxUser(storage_name, form)
});
}
/**
* Save a S3 user
*/
function saveS3User(storage_name, form)
{
var msg = {
user_dn: form.find("input[name='user-dn']").val(),
vo_name: form.find("input[name='vo-name']").val(),
access: form.find("input[name='access']").val(),
password: form.find("input[name='password']").val(),
};
console.log(msg);
return $.ajax({
url: "/config/cloud_storage/" + encodeURIComponent(storage_name),
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(msg)
});
}
/**
* Delete a user
*/
......@@ -166,9 +121,9 @@ function deleteUser(storage_name, form)
/**
* Refresh the storage list
*/
function refreshDropboxCloudStorage()
function refreshCloudStorage()
{
var parent = $("#storage-dropbox-list");
var parent = $("#storage-list");
$.ajax({
headers: {
......@@ -199,11 +154,11 @@ function refreshDropboxCloudStorage()
});
// Attach to add a user
var addUserFrm = div.find(".frm-add-dropbox-user");
var addUserBtn = addUserFrm.find(".btn-add-dropbox-user");
var addUserFrm = div.find(".frm-add-user");
var addUserBtn = addUserFrm.find(".btn-add-user");
addUserBtn.click(function(event) {
event.preventDefault();
saveUser(storage.storage_name, addDropboxUserFrm)
saveUser(storage.storage_name, addUserFrm)
.done(function(data, textStatus, jqXHR) {
refreshCloudStorage();
})
......@@ -235,77 +190,6 @@ function refreshDropboxCloudStorage()
});
}
/**
* Refresh the S3 storage list
*/
function refreshS3CloudStorage()
{
var parent = $("#storage-S3-list");
$.ajax({
headers: {
Accept : "application/json",
},
url: "/config/cloud_storage?",
})
.done(function(data, textStatus, jqXHR) {
parent.empty();
$.each(data, function(index, storage) {
var div = $(template_cloud_storage_entry(storage));
// Attach to the delete button
var deleteBtn = div.find(".btn-delete");
deleteBtn.click(function(event) {
event.preventDefault();
deleteStorage(storage.storage_name, div);
});
// Attach to the save button
var saveBtn = div.find(".btn-save");
saveBtn.click(function(event) {
event.preventDefault();
saveStorage(div)
.fail(function(jqXHR) {
errorMessage(jqXHR);
});
});
// Attach to add a user
var addUserFrm = div.find(".frm-add-s3-user");
var addUserBtn = addUserFrm.find(".btn-add-s3-user");
addUserBtn.click(function(event) {
event.preventDefault();
saveUser(storage.storage_name, addS3UserFrm)
.done(function(data, textStatus, jqXHR) {
refreshCloudStorage();
})
.fail(function(jqXHR) {
errorMessage(jqXHR);
});
});
// Attach to remove and modify a user
div.find(".user-entry").each(function() {
var tr = $(this);
var deleteUserBtn = tr.find(".btn-delete-user");
deleteUserBtn.click(function(event) {
event.preventDefault();
deleteUser(storage.storage_name, tr);
});
var saveUserBtn = tr.find(".btn-save-user");
saveUserBtn.click(function(event) {
event.preventDefault();
saveUser(storage.storage_name, tr)
});
});
parent.append(div);
});
})
.fail(function(jqXHR) {
errorMessage(jqXHR);
});
}
/**
* Compile templates embedded into the HTML
*/
......@@ -322,16 +206,15 @@ function compileTemplates()
function setupCloudStorage()
{
compileTemplates();
refreshDropboxCloudStorage();
refreshS3CloudStorage();
refreshCloudStorage();
// Bind to form
$("#add-cloud-frm").submit(function(event) {
event.preventDefault();
saveStorage($("#add-cloud-frm"))
.done(function(data, textStatus, jqXHR) {
$("#add-cloud-frm").trigger("reset");
refreshDropboxCloudStorage();
refreshS3CloudStorage();
refreshCloudStorage();
})
.fail(function(jqXHR) {
errorMessage(jqXHR);
......
......@@ -17,6 +17,7 @@
<dd>The name should have the form S3:hostname (i.e. S3:s3.example.com). App key and secret are not used.</dd>
<dt>Grant access to a set of VO and/or users</dt>
<dd>Empty user with a value in VO grant access to all members from that VO.
Access token = access key, access secret = secret key. Leave request fields empty.
</dd>
</dl>
......@@ -60,7 +61,7 @@
</div>
</div>
</div>
<table class="tableDropbox">
<table class="table">
<thead>
<tr>
<th></th>
......@@ -76,8 +77,8 @@
{{#each users}}
<tr class="user-entry">
<td>
<a><i class="glyphicon glyphicon-trash btn-delete-dropbox-user"></i></a>
<a><i class="glyphicon glyphicon-floppy-disk btn-save-dropbox-user"></i></a>
<a><i class="glyphicon glyphicon-trash btn-delete-user"></i></a>
<a><i class="glyphicon glyphicon-floppy-disk btn-save-user"></i></a>
</td>
<td>
<input type="hidden" name="user-dn" value="{{user_dn}}"/>
......@@ -102,10 +103,10 @@
</tr>
{{/each}}
</tbody>
<tbody class="frm-add-dropbox-user">
<tbody class="frm-add-user">
<tr>
<td>
<a><i class="glyphicon glyphicon-plus btn-add-dropbox-user"></i></a>
<a><i class="glyphicon glyphicon-plus btn-add-user"></i></a>
</td>
<td>
<input name="user-dn" type="text" class="form-control" value=""/>
......@@ -127,60 +128,6 @@
</td>
</tr>
</tbody>
</table>
<table class="tableS3">
<thead>
<tr>
<th></th>
<th>User</th>
<th>VO</th>
<th>Access Key</th>
<th>Secret Key</th>
</tr>
</thead>
<tbody>
{{#each users}}
<tr class="user-entry">
<td>
<a><i class="glyphicon glyphicon-trash btn-delete-s3-user"></i></a>
<a><i class="glyphicon glyphicon-floppy-disk btn-save-s3-user"></i></a>
</td>
<td>
<input type="hidden" name="user-dn" value="{{user_dn}}"/>
{{user_dn}}
</td>
<td>
<input type="hidden" name="vo-name" value="{{vo_name}}"/>
{{vo_name}}
</td>
<td>
<input type="text" name="access-key" class="form-control" value="{{access-key}}"/>
</td>
<td>
<input type="text" name="secret-key" class="form-control" value="{{secret-key}}"/>
</td>
</tr>
{{/each}}
</tbody>
<tbody class="frm-add-s3-user">
<tr>
<td>
<a><i class="glyphicon glyphicon-plus btn-add-s3-user"></i></a>
</td>
<td>
<input name="user-dn" type="text" class="form-control" value=""/>
</td>
<td>
<input name="vo-name" type="text" class="form-control" value=""/>
</td>
<td>
<input name="access-key" type="text" class="form-control" value=""/>
</td>
<td>
<input name="secret-key" type="text" class="form-control" value=""/>
</td>
</tr>
</tbody>
</table>
<div class="panel-footer">
<button class="btn btn-success btn-save">Save</button>
......@@ -190,8 +137,6 @@
</script>
</div>
<form class="panel panel-success" id="add-cloud-frm">
<div class="panel-heading">
<h3 class="panel-title">
......
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