storages.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. function storages_list() {
  2. $('#result').html('');
  3. $('#content').html('');
  4. $.ajax({
  5. type : 'get',
  6. dataType : 'json',
  7. contentType : 'application/json; charset=utf-8',
  8. url : '../jaxrs/storages',
  9. xhrFields : {
  10. 'withCredentials' : true
  11. },
  12. crossDomain : true
  13. }).done(function(json) {
  14. $('#result').html(JSON.stringify(json, null, 4));
  15. if (json.type == 'success') {
  16. var str = '<table border="1" width="100%">';
  17. str += '<tr><th>order</th><th>storageServer</th><th>enable</th><th>weight</th><th>operate</th></tr>';
  18. if (json.data) {
  19. $.each(json.data, function(type, item) {
  20. str += '<tr><td colspan="6">' + type + '&nbsp;<a href="#" onclick="storage_create(\'' + type + '\')">add</a></td></tr>';
  21. $.each(item, function(i, o) {
  22. str += '<tr>';
  23. str += '<td>' + o.order + '</td>';
  24. str += '<td>' + o.storageServer + '</td>';
  25. str += '<td>' + o.enable + '</td>';
  26. str += '<td>' + o.weight + '</td>';
  27. str += '<td>';
  28. str += '<a href="#" onclick="storage_edit(\'' + type + '\',\'' + o.storageServer + '\')">edit</a>&nbsp;';
  29. str += '<a href="#" onclick="storage_delete(\'' + type + '\',\'' + o.storageServer + '\')">delete</a>';
  30. str += '</td>';
  31. str += '</tr>';
  32. });
  33. });
  34. }
  35. str += '</table>';
  36. $('#content').html(str);
  37. } else {
  38. failure(json);
  39. }
  40. });
  41. }