attachment.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. attachment_parameter = {};
  2. function attachment_listWithWork_init() {
  3. $('#result').html('');
  4. str = '<table border="1" width="100%">';
  5. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  6. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  7. str += '</table>';
  8. $('#content').html(str);
  9. $('#get').click(function() {
  10. attachment_listWithWork($('#workId').val());
  11. });
  12. }
  13. function attachment_listWithWork(workId) {
  14. $('#result').html('');
  15. $.ajax({
  16. type : 'get',
  17. dataType : 'json',
  18. url : '../jaxrs/attachment/list/work/' + workId,
  19. xhrFields : {
  20. 'withCredentials' : true
  21. },
  22. crossDomain : true
  23. }).always(function(json) {
  24. $('#result').html(JSON.stringify(json, null, 4));
  25. });
  26. }
  27. function attachment_listWithWorkCompleted_init() {
  28. $('#result').html('');
  29. str = '<table border="1" width="100%">';
  30. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  31. str += '<tr><td>workCompletedId:</td><td><input type="text" id="workCompletedId" style="width:95%"/></td></tr>';
  32. str += '</table>';
  33. $('#content').html(str);
  34. $('#get').click(function() {
  35. attachment_listWithWorkCompleted($('#workCompletedId').val());
  36. });
  37. }
  38. function attachment_listWithWorkCompleted(workCompletedId) {
  39. $('#result').html('');
  40. $.ajax({
  41. type : 'get',
  42. dataType : 'json',
  43. url : '../jaxrs/attachment/list/workcompleted/' + workCompletedId,
  44. xhrFields : {
  45. 'withCredentials' : true
  46. },
  47. crossDomain : true
  48. }).always(function(json) {
  49. $('#result').html(JSON.stringify(json, null, 4));
  50. });
  51. }
  52. function attachment_getWithWork_init() {
  53. $('#result').html('');
  54. str = '<table border="1" width="100%">';
  55. str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp;<a href="#" id="delete">delete</a></td></tr>';
  56. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  57. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  58. str += '</table>';
  59. $('#content').html(str);
  60. $('#get').click(function() {
  61. attachment_getWithWork($('#id').val(), $('#workId').val());
  62. });
  63. $('#delete').click(function() {
  64. attachment_deleteWithWork($('#id').val(), $('#workId').val());
  65. });
  66. }
  67. function attachment_getWithWorkCompleted_init() {
  68. $('#result').html('');
  69. str = '<table border="1" width="100%">';
  70. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  71. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  72. str += '<tr><td>workCompletedId:</td><td><input type="text" id="workCompletedId" style="width:95%"/></td></tr>';
  73. str += '</table>';
  74. $('#content').html(str);
  75. $('#get').click(function() {
  76. attachment_getWithWorkCompleted($('#id').val(), $('#workCompletedId').val());
  77. });
  78. }
  79. function attachment_getWithWork(id, workId) {
  80. $('#result').html('');
  81. $.ajax({
  82. type : 'get',
  83. dataType : 'json',
  84. url : '../jaxrs/attachment/' + id + '/work/' + workId,
  85. xhrFields : {
  86. 'withCredentials' : true
  87. },
  88. crossDomain : true
  89. }).always(function(json) {
  90. $('#result').html(JSON.stringify(json, null, 4));
  91. });
  92. }
  93. function attachment_deleteWithWork(id, workId) {
  94. $('#result').html('');
  95. $.ajax({
  96. type : 'delete',
  97. dataType : 'json',
  98. url : '../jaxrs/attachment/' + id + '/work/' + workId,
  99. xhrFields : {
  100. 'withCredentials' : true
  101. },
  102. crossDomain : true
  103. }).always(function(json) {
  104. $('#result').html(JSON.stringify(json, null, 4));
  105. });
  106. }
  107. function attachment_getWithWorkCompleted(id, workCompletedId) {
  108. $('#result').html('');
  109. $.ajax({
  110. type : 'get',
  111. dataType : 'json',
  112. url : '../jaxrs/attachment/' + id + '/workcompleted/' + workCompletedId,
  113. xhrFields : {
  114. 'withCredentials' : true
  115. },
  116. crossDomain : true
  117. }).always(function(json) {
  118. $('#result').html(JSON.stringify(json, null, 4));
  119. });
  120. }
  121. function attachment_download_init() {
  122. $('#result').html('');
  123. str = '<table border="1" width="100%">';
  124. str += '<tr><td colspan="2"><a href="#" id="upload">get</a></td></tr>';
  125. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  126. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  127. str += '<tr><td>stream:</td><td><select id="stream"><option value="stream">stream</option><option value="inline">inline</option></select></td></tr>';
  128. str += '</table>';
  129. $('#content').html(str);
  130. $('#upload').click(function() {
  131. attachment_upload($('#id').val(), $('#workId').val(), $('#stream').val());
  132. });
  133. }
  134. function attachment_download(id, workId, stream) {
  135. url = '../servlet/attachment/download/' + id + '/work/' + workId;
  136. if (stream === 'stream') {
  137. url += '/stream';
  138. }
  139. window.open(url, '_blank');
  140. }
  141. function attachment_upload_init() {
  142. $('#result').html('');
  143. str = '<table border="1" width="100%">';
  144. str += '<tr><td colspan="2"><a href="#" id="upload">upload</a></td></tr>';
  145. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  146. str += '<tr><td>file:</td><td><input type="file" id="file" style="width:95%"/></td></tr>';
  147. str += '</table>';
  148. $('#content').html(str);
  149. $('#upload').click(function() {
  150. attachment_upload($('#workId').val());
  151. });
  152. }
  153. function attachment_upload(workId) {
  154. var formData = new FormData();
  155. formData.append('file', $('#file')[0].files[0]);
  156. $.ajax({
  157. type : 'post',
  158. dataType : 'json',
  159. url : '../servlet/attachment/upload/work/' + workId,
  160. xhrFields : {
  161. 'withCredentials' : true
  162. },
  163. cache : false,
  164. processData : false,
  165. contentType : false,
  166. data : formData
  167. }).always(function(json) {
  168. $('#result').html(JSON.stringify(json, null, 4));
  169. });
  170. }
  171. function attachment_update_init() {
  172. $('#result').html('');
  173. str = '<table border="1" width="100%">';
  174. str += '<tr><td colspan="2"><a href="#" id="upload">get</a></td></tr>';
  175. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  176. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  177. str += '<tr><td>file:</td><td><input type="file" id="file" style="width:95%"/></td></tr>';
  178. str += '</table>';
  179. $('#content').html(str);
  180. $('#upload').click(function() {
  181. attachment_upload($('#id').val(), $('#workId').val());
  182. });
  183. }
  184. function attachment_update(id, workId) {
  185. var formData = new FormData();
  186. formData.append('file', $('#file')[0].files[0]);
  187. $.ajax({
  188. type : 'post',
  189. dataType : 'json',
  190. url : '../servlet/attachment/update/' + id + '/work/' + workId,
  191. xhrFields : {
  192. 'withCredentials' : true
  193. },
  194. cache : false,
  195. processData : false,
  196. contentType : false,
  197. data : formData
  198. }).always(function(res) {
  199. $('#result').html(JSON.stringify(json, null, 4));
  200. });
  201. }