queryView.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. queryView_parameter = {};
  2. function queryView_init() {
  3. $('#content').html('');
  4. $('#result').html('');
  5. var str = '<table border="1" width="100%">';
  6. str += '<tr><td colspan="2"><a href="#" id="list">list</a>&nbsp;<a href="#" id="get">get</a>&nbsp;<a href="#" id="execute">execute</a></td></tr>';
  7. str += '<tr><td>applicationFlag:</td><td><input type="text" id="applicationFlag" style="width:95%"/></td></tr>';
  8. str += '<tr><td>flag:</td><td><input type="text" id="flag" style="width:95%"/></td></tr>';
  9. str += '<tr><td colspan="2">date</td></tr>';
  10. str += '<tr><td colspan="2"><textarea id="date" style="width:95%;height:300px"></textarea></td></tr>';
  11. str += '<tr><td colspan="2">sample</td></tr>';
  12. str += '<tr><td colspan="2">{<br>';
  13. str += '"dateRangeType": "none",<br>';
  14. str += '"dateEffectType": "completed",<br>';
  15. str += '"start": "",<br>';
  16. str += '"completed": "",<br>';
  17. str += '"year": "",<br>';
  18. str += '"month": "",<br>';
  19. str += '"date": "",<br>';
  20. str += '"season": 0,<br>';
  21. str += '"week": 0,<br>';
  22. str += '"adjust": 0<br>';
  23. str += '}';
  24. str += '</td></tr>';
  25. str += '<tr><td colspan="2">filter</td></tr>';
  26. str += '<tr><td colspan="2"><textarea id="filter" style="width:95%;height:300px"></textarea></td></tr>';
  27. str += '<tr><td colspan="2">sample</td></tr>';
  28. str += '<tr><td colspan="2">{<br>';
  29. str += '"path": "",<br>';
  30. str += '"value": "",<br>';
  31. str += '"formatType": "",<br>';
  32. str += '"completed": "",<br>';
  33. str += '"logic": "",<br>';
  34. str += '"comparison": ""<br>';
  35. str += '}';
  36. str += '</td></tr>';
  37. str += '<tr><td colspan="2">where application</td></tr>';
  38. str += '<tr><td colspan="2"><textarea id="application" style="width:95%;height:100px"></textarea></td></tr>';
  39. str += '<tr><td colspan="2">where process</td></tr>';
  40. str += '<tr><td colspan="2"><textarea id="process" style="width:95%;height:100px"></textarea></td></tr>';
  41. str += '<tr><td colspan="2">where company</td></tr>';
  42. str += '<tr><td colspan="2"><textarea id="company" style="width:95%;height:100px"></textarea></td></tr>';
  43. str += '<tr><td colspan="2">where department</td></tr>';
  44. str += '<tr><td colspan="2"><textarea id="department" style="width:95%;height:100px"></textarea></td></tr>';
  45. str += '<tr><td colspan="2">where person</td></tr>';
  46. str += '<tr><td colspan="2"><textarea id="person" style="width:95%;height:100px"></textarea></td></tr>';
  47. str += '<tr><td colspan="2">where identity</td></tr>';
  48. str += '<tr><td colspan="2"><textarea id="identity" style="width:95%;height:100px"></textarea></td></tr>';
  49. str += '<tr><td colspan="2">column</td></tr>';
  50. str += '<tr><td colspan="2"><textarea id="column" style="width:95%;height:100px"></textarea></td></tr>';
  51. str += '</table>';
  52. $('#content').html(str);
  53. $('#list').click(function() {
  54. queryView_list($('#applicationFlag').val());
  55. });
  56. $('#get').click(function() {
  57. queryView_get($('#flag').val(), $('#applicationFlag').val());
  58. });
  59. $('#execute').click(function() {
  60. queryView_execute($('#flag').val(), $('#applicationFlag').val());
  61. });
  62. }
  63. function queryView_list(applicationFlag) {
  64. $('#result').html('');
  65. $.ajax({
  66. type : 'get',
  67. dataType : 'json',
  68. url : '../jaxrs/queryview/list/application/flag/' + applicationFlag,
  69. xhrFields : {
  70. 'withCredentials' : true
  71. },
  72. crossDomain : true
  73. }).always(function(json) {
  74. $('#result').html(JSON.stringify(json, null, 4));
  75. });
  76. }
  77. function queryView_get(flag, applicationFlag) {
  78. $('#result').html('');
  79. $.ajax({
  80. type : 'get',
  81. dataType : 'json',
  82. url : '../jaxrs/queryview/flag/' + flag + '/application/flag/' + applicationFlag,
  83. xhrFields : {
  84. 'withCredentials' : true
  85. },
  86. crossDomain : true
  87. }).always(function(json) {
  88. $('#result').html(JSON.stringify(json, null, 4));
  89. });
  90. }
  91. function queryView_execute(flag, applicationFlag) {
  92. $('#result').html('');
  93. var data = {};
  94. if ($('#date').val().length > 0) {
  95. data.date = JSON.parse($('#date').val());
  96. }
  97. if ($('#filter').val().length > 0) {
  98. data.filter = JSON.parse($('#filter').val());
  99. }
  100. if ($('#application').val().length > 0) {
  101. data.application = JSON.parse($('#application').val());
  102. }
  103. if ($('#process').val().length > 0) {
  104. data.process = JSON.parse($('#process').val());
  105. }
  106. if ($('#company').val().length > 0) {
  107. data.company = JSON.parse($('#company').val());
  108. }
  109. if ($('#department').val().length > 0) {
  110. data.department = JSON.parse($('#department').val());
  111. }
  112. if ($('#person').val().length > 0) {
  113. data.person = JSON.parse($('#person').val());
  114. }
  115. if ($('#identity').val().length > 0) {
  116. data.identity = JSON.parse($('#identity').val());
  117. }
  118. if ($('#column').val().length > 0) {
  119. data.column = JSON.parse($('#column').val());
  120. }
  121. $.ajax({
  122. type : 'put',
  123. dataType : 'json',
  124. url : '../jaxrs/queryview/flag/' + flag + '/application/flag/' + applicationFlag + '/execute',
  125. contentType : 'application/json; charset=utf-8',
  126. data : JSON.stringify(data),
  127. xhrFields : {
  128. 'withCredentials' : true
  129. },
  130. crossDomain : true
  131. }).always(function(json) {
  132. $('#result').html(JSON.stringify(json, null, 4));
  133. });
  134. }