attachment.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. contentType : 'application/json; charset=utf-8',
  20. xhrFields : {
  21. 'withCredentials' : true
  22. },
  23. crossDomain : true
  24. }).always(function(json) {
  25. $('#result').html(JSON.stringify(json, null, 4));
  26. });
  27. }
  28. function attachment_listWithWorkCompleted_init() {
  29. $('#result').html('');
  30. str = '<table border="1" width="100%">';
  31. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  32. str += '<tr><td>workCompletedId:</td><td><input type="text" id="workCompletedId" style="width:95%"/></td></tr>';
  33. str += '</table>';
  34. $('#content').html(str);
  35. $('#get').click(function() {
  36. attachment_listWithWorkCompleted($('#workCompletedId').val());
  37. });
  38. }
  39. function attachment_listWithWorkCompleted(workCompletedId) {
  40. $('#result').html('');
  41. $.ajax({
  42. type : 'get',
  43. dataType : 'json',
  44. url : '../jaxrs/attachment/list/workcompleted/' + workCompletedId,
  45. contentType : 'application/json; charset=utf-8',
  46. xhrFields : {
  47. 'withCredentials' : true
  48. },
  49. crossDomain : true
  50. }).always(function(json) {
  51. $('#result').html(JSON.stringify(json, null, 4));
  52. });
  53. }
  54. function attachment_getWithWork_init() {
  55. $('#result').html('');
  56. str = '<table border="1" width="100%">';
  57. str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp;<a href="#" id="delete">delete</a></td></tr>';
  58. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  59. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  60. str += '</table>';
  61. $('#content').html(str);
  62. $('#get').click(function() {
  63. attachment_getWithWork($('#id').val(), $('#workId').val());
  64. });
  65. $('#delete').click(function() {
  66. attachment_deleteWithWork($('#id').val(), $('#workId').val());
  67. });
  68. }
  69. function attachment_getWithWorkCompleted_init() {
  70. $('#result').html('');
  71. str = '<table border="1" width="100%">';
  72. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  73. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  74. str += '<tr><td>workCompletedId:</td><td><input type="text" id="workCompletedId" style="width:95%"/></td></tr>';
  75. str += '</table>';
  76. $('#content').html(str);
  77. $('#get').click(function() {
  78. attachment_getWithWorkCompleted($('#id').val(), $('#workCompletedId').val());
  79. });
  80. }
  81. function attachment_getWithWork(id, workId) {
  82. $('#result').html('');
  83. $.ajax({
  84. type : 'get',
  85. dataType : 'json',
  86. url : '../jaxrs/attachment/' + id + '/work/' + workId,
  87. contentType : 'application/json; charset=utf-8',
  88. xhrFields : {
  89. 'withCredentials' : true
  90. },
  91. crossDomain : true
  92. }).always(function(json) {
  93. $('#result').html(JSON.stringify(json, null, 4));
  94. });
  95. }
  96. function attachment_deleteWithWork(id, workId) {
  97. $('#result').html('');
  98. $.ajax({
  99. type : 'delete',
  100. dataType : 'json',
  101. url : '../jaxrs/attachment/' + id + '/work/' + workId,
  102. contentType : 'application/json; charset=utf-8',
  103. xhrFields : {
  104. 'withCredentials' : true
  105. },
  106. crossDomain : true
  107. }).always(function(json) {
  108. $('#result').html(JSON.stringify(json, null, 4));
  109. });
  110. }
  111. function attachment_getWithWorkCompleted(id, workCompletedId) {
  112. $('#result').html('');
  113. $.ajax({
  114. type : 'get',
  115. dataType : 'json',
  116. url : '../jaxrs/attachment/' + id + '/workcompleted/' + workCompletedId,
  117. contentType : 'application/json; charset=utf-8',
  118. xhrFields : {
  119. 'withCredentials' : true
  120. },
  121. crossDomain : true
  122. }).always(function(json) {
  123. $('#result').html(JSON.stringify(json, null, 4));
  124. });
  125. }
  126. function attachment_download_init() {
  127. $('#result').html('');
  128. str = '<table border="1" width="100%">';
  129. str += '<tr><td colspan="2"><a href="#" id="downloadWithWork">downloadWithWork</a>&nbsp;<a href="#" id="downloadWithWorkCompleted">downloadWithWorkCompleted</a></td></tr>';
  130. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  131. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  132. str += '<tr><td>workCompletedId:</td><td><input type="text" id="workCompletedId" style="width:95%"/></td></tr>';
  133. str += '<tr><td>stream:</td><td><select id="stream"><option value="true">true</option><option value="false">false</option></select></td></tr>';
  134. str += '</table>';
  135. $('#content').html(str);
  136. $('#downloadWithWork').click(function() {
  137. attachment_downloadWithWork($('#id').val(), $('#workId').val(), $('#stream').val());
  138. });
  139. $('#downloadWithWorkCompleted').click(function() {
  140. attachment_downloadWithWorkCompleted($('#id').val(), $('#workCompletedId').val(), $('#stream').val());
  141. });
  142. }
  143. function attachment_downloadWithWork(id, workId, stream) {
  144. url = '../jaxrs/attachment/download/' + id + '/work/' + workId + '/stream/' + stream;
  145. window.open(url, '_blank');
  146. }
  147. function attachment_downloadWithWorkCompleted(id, workCompletedId, stream) {
  148. url = '../jaxrs/attachment/download/' + id + '/workcompleted/' + workCompletedId + '/stream/' + stream;
  149. window.open(url, '_blank');
  150. }
  151. function attachment_upload_init() {
  152. $('#result').html('');
  153. str = '<table border="1" width="100%">';
  154. str += '<tr><td colspan="2"><a href="#" id="upload">upload</a></td></tr>';
  155. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  156. str += '<tr><td>file:</td><td><input type="file" id="file" style="width:95%"/></td></tr>';
  157. str += '<tr><td>site:</td><td><input id="site" style="width:95%"/></td></tr>';
  158. str += '</table>';
  159. $('#content').html(str);
  160. $('#upload').click(function() {
  161. attachment_upload($('#workId').val());
  162. });
  163. }
  164. function attachment_upload(workId) {
  165. var formData = new FormData();
  166. formData.append('file', $('#file')[0].files[0]);
  167. formData.append('site', $('#site').val());
  168. $.ajax({
  169. type : 'post',
  170. dataType : 'json',
  171. url : '../jaxrs/attachment/upload/work/' + workId,
  172. xhrFields : {
  173. 'withCredentials' : true
  174. },
  175. cache : false,
  176. processData : false,
  177. contentType : false,
  178. data : formData
  179. }).always(function(json) {
  180. $('#result').html(JSON.stringify(json, null, 4));
  181. });
  182. }
  183. function attachment_update_init() {
  184. $('#result').html('');
  185. str = '<table border="1" width="100%">';
  186. str += '<tr><td colspan="2"><a href="#" id="update">update</a></td></tr>';
  187. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  188. str += '<tr><td>workId:</td><td><input type="text" id="workId" style="width:95%"/></td></tr>';
  189. str += '<tr><td>file:</td><td><input type="file" id="file" style="width:95%"/></td></tr>';
  190. str += '</table>';
  191. $('#content').html(str);
  192. $('#update').click(function() {
  193. attachment_update($('#id').val(), $('#workId').val());
  194. });
  195. }
  196. function attachment_update(id, workId) {
  197. var formData = new FormData();
  198. formData.append('file', $('#file')[0].files[0]);
  199. $.ajax({
  200. type : 'put',
  201. dataType : 'json',
  202. url : '../jaxrs/attachment/update/' + id + '/work/' + workId,
  203. xhrFields : {
  204. 'withCredentials' : true
  205. },
  206. cache : false,
  207. processData : false,
  208. contentType : false,
  209. data : formData
  210. }).always(function(json) {
  211. $('#result').html(JSON.stringify(json, null, 4));
  212. });
  213. }
  214. function attachment_available_init() {
  215. $('#result').html('');
  216. str = '<table border="1" width="100%">';
  217. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  218. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  219. str += '</table>';
  220. $('#content').html(str);
  221. $('#get').click(function() {
  222. attachment_available($('#id').val());
  223. });
  224. }
  225. function attachment_available(id) {
  226. $.ajax({
  227. type : 'get',
  228. dataType : 'json',
  229. url : '../jaxrs/attachment/' + id + '/available',
  230. contentType : 'application/json; charset=utf-8',
  231. xhrFields : {
  232. 'withCredentials' : true
  233. },
  234. crossDomain : true
  235. }).always(function(json) {
  236. $('#result').html(JSON.stringify(json, null, 4));
  237. });
  238. }