myEvents.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. $( document ).ready(function() {
  2. console.log( "ready!" );
  3. $.ajax({
  4. url: 'http://localhost:3001/require/all',
  5. error: function() {
  6. console.log("Error");
  7. },
  8. dataType: 'text',
  9. success: function(data) {
  10. console.log("success");
  11. },
  12. type: 'GET'
  13. });
  14. });
  15. $('#jstree_demo_div').on("open_node.jstree", function (e, data) {
  16. console.log(data.node);
  17. });
  18. $('#jstree_demo_div').on("select_node.jstree", function (e, data) {
  19. console.log(data);
  20. var x = data.node.data.idx;
  21. var nid = data.node.id;
  22. var nc = data.node.data.nodeclass;
  23. $('#instancenodeid').val(data.node.id);
  24. $('#instancenodeidtype').val(data.node.data.nodeidtype);
  25. $('#instancename').val(data.node.text);
  26. $('#instancenamespace').val(data.node.data.nsindex +":"+data.node.data.nsurl );
  27. $('#instancedisplayname1').val("");
  28. $('#instancedisplayname2').val(data.node.data.displayname);
  29. $('#instancebrowsename2').val(data.node.data.browsename);
  30. $('#instancenodeclass').val(nc);
  31. if(nc == "Object"){
  32. var ul = 'http://127.0.0.1:3001/look/'+x+'/'+nid+'/'+nc+'/';
  33. //$('#instancetypedefinition').val(data.node.data.);
  34. $.ajax({
  35. url: ul+'eventnotifier',
  36. type: 'GET', // http method
  37. success: function (resp, status, xhr) {
  38. var plc = "";
  39. switch(resp.result){
  40. case 0: plc = "0 (None)"; break;
  41. case 1: plc = "1 (EventNotifierSubscribeToEvents)"; break;
  42. case 4: plc = "4 (EventNotifierHistoryRead)"; break;
  43. case 5: plc = "5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)"; break;
  44. case 8: plc = "8 (EventNotifierHistoryWrite)"; break;
  45. case 9: plc = "9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)"; break;
  46. case 12: plc = "12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)"; break;
  47. default: plc = "";
  48. }
  49. $('#instanceeventnotifier').attr('placeholder',plc);
  50. },
  51. error: function (jqXhr, textStatus, errorMessage) {
  52. console.log('Error: ' + errorMessage);
  53. }
  54. });
  55. console.log("obj enabled");
  56. $('#objectattributesbutton').prop('disabled', false);
  57. $('#collapseTwo1').collapse('hide');
  58. $('#variableattributesbutton').prop('disabled',true);
  59. $('#collapseTwo2').collapse('hide');
  60. $('#methodattributesbutton').prop('disabled',true);
  61. }
  62. if(data.node.data.nodeclass == "Variable"){
  63. $('#datatype').val(data.node.data.datatype);
  64. $('#variablevalue').val(data.node.data.value);
  65. $('#variablevaluerank').val(data.node.data.valuerank);
  66. $('#variablearraydimensions').val(data.node.data.arraydimensions);
  67. var aclev = data.node.data.accesslevel;
  68. var plc = "";
  69. switch(aclev){
  70. case 0: plc = "0 (None)"; break;
  71. case 1: plc = "1 (EventNotifierSubscribeToEvents)"; break;
  72. case 4: plc = "4 (EventNotifierHistoryRead)"; break;
  73. case 5: plc = "5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)"; break;
  74. case 8: plc = "8 (EventNotifierHistoryWrite)"; break;
  75. case 9: plc = "9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)"; break;
  76. case 12: plc = "12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)"; break;
  77. default: plc = "";
  78. }
  79. $('#instanceaccesslevel').val(data.node.data.accesslevel);
  80. $('#accesslevelex').val(data.node.data.accesslevelex);
  81. $('#variablehistorizing').val(data.node.data.historizing);
  82. $('#minimumsamplinginterval').val(data.node.data.minsamplinginterval);
  83. $('#variableattributesbutton').prop('disabled', false);
  84. $('#collapseTwo').collapse('hide');
  85. $('#objectattributesbutton').prop('disabled',true);
  86. $('#collapseTwo2').collapse('hide');
  87. $('#methodattributesbutton').prop('disabled',true);
  88. }
  89. if(data.node.data.nodeclass == "Method"){
  90. //$('#writemask').val(data.node.data.accesslevelex);
  91. if(data.node.data.executable == 1){
  92. $('#executablemethodcheck').prop('checked', true);
  93. }else if(data.node.data.executable == 0){
  94. $('#executablemethodcheck').prop('checked', false);
  95. }
  96. $('#methodattributesbutton').prop('disabled',false);
  97. $('#collapseTwo').collapse('hide');
  98. $('#objectattributesbutton').prop('disabled',true);
  99. $('#collapseTwo1').collapse('hide');
  100. $('#variableattributesbutton').prop('disabled',true);
  101. }
  102. });
  103. $('#nodesetfile').on("open", function (e, data) {
  104. console.log('hello');
  105. });
  106. $('#changeinstance').click(function () {
  107. console.log('hello');
  108. });
  109. $('#savenodespecification').click(function () {
  110. console.log('save this');
  111. console.log($('#instancename').val());
  112. console.log($('#instancenamespace').val());
  113. console.log($('#instancenodeclass').val());
  114. console.log($('#instancetypedefinition').val());
  115. console.log($('#instancenodeidtype').val());
  116. console.log($('#instancenodeid').val());
  117. console.log($('#instanceeventnotifier').attr('placeholder'));
  118. console.log($('#instancedisplayname1').val());
  119. console.log($('#instancedisplayname2').val());
  120. console.log($('#instancebrowsename1').val());
  121. });
  122. $('#numericnodeid').click(function () {
  123. console.log("It is number");
  124. $('#instancenodeidtype').text('Numeric')
  125. });
  126. $('#stringnodeid').click(function () {
  127. console.log("It is string");
  128. $('#instancenodeidtype').text('String')
  129. });
  130. $('#guidnodeid').click(function () {
  131. console.log("It is guid");
  132. $('#instancenodeidtype').text('Guid')
  133. });
  134. $('#opaquenodeid').click(function () {
  135. console.log("It is opaque");
  136. $('#instancenodeidtype').text('Opaque')
  137. });
  138. $('#instancebrowsename1').click(function () {
  139. console.log("Add the script");
  140. var sz = parseInt($('#namespaceidxbrowsename').attr("size"));
  141. console.log(sz);
  142. var num_ns = "6";
  143. var nnum = parseInt(num_ns);
  144. if(sz < nnum){
  145. var lin = "<li><a class='dropdown-item' href='#'>"+num_ns+"</a></li>"
  146. $('#namespaceidxbrowsename').append(lin);
  147. $('#namespaceidxbrowsename').attr("size",num_ns);
  148. }
  149. });
  150. $('#subscribeevents').click(function () {
  151. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  152. $('#instanceeventnotifier').attr('placeholder', '13 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  153. }
  154. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  155. $('#instanceeventnotifier').attr('placeholder', '1 (EventNotifierSubscribeToEvents)');
  156. }
  157. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  158. $('#instanceeventnotifier').attr('placeholder', '4 (EventNotifierHistoryRead)');
  159. }
  160. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  161. $('#instanceeventnotifier').attr('placeholder', '8 (EventNotifierHistoryWrite)');
  162. }
  163. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  164. $('#instanceeventnotifier').attr('placeholder', '0 (None)');
  165. }
  166. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  167. $('#instanceeventnotifier').attr('placeholder', '5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)');
  168. }
  169. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  170. $('#instanceeventnotifier').attr('placeholder', '12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  171. }
  172. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  173. $('#instanceeventnotifier').attr('placeholder', '9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)');
  174. }
  175. });
  176. $('#historyread').click(function () {
  177. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  178. $('#instanceeventnotifier').attr('placeholder', '13 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  179. }
  180. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  181. $('#instanceeventnotifier').attr('placeholder', '1 (EventNotifierSubscribeToEvents)');
  182. }
  183. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  184. $('#instanceeventnotifier').attr('placeholder', '4 (EventNotifierHistoryRead)');
  185. }
  186. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  187. $('#instanceeventnotifier').attr('placeholder', '8 (EventNotifierHistoryWrite)');
  188. }
  189. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  190. $('#instanceeventnotifier').attr('placeholder', '0 (None)');
  191. }
  192. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  193. $('#instanceeventnotifier').attr('placeholder', '5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)');
  194. }
  195. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  196. $('#instanceeventnotifier').attr('placeholder', '12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  197. }
  198. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  199. $('#instanceeventnotifier').attr('placeholder', '9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)');
  200. }
  201. });
  202. $('#historywrite').click(function () {
  203. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  204. $('#instanceeventnotifier').attr('placeholder', '13 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  205. }
  206. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  207. $('#instanceeventnotifier').attr('placeholder', '1 (EventNotifierSubscribeToEvents)');
  208. }
  209. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  210. $('#instanceeventnotifier').attr('placeholder', '4 (EventNotifierHistoryRead)');
  211. }
  212. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  213. $('#instanceeventnotifier').attr('placeholder', '8 (EventNotifierHistoryWrite)');
  214. }
  215. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  216. $('#instanceeventnotifier').attr('placeholder', '0 (None)');
  217. }
  218. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  219. $('#instanceeventnotifier').attr('placeholder', '5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)');
  220. }
  221. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  222. $('#instanceeventnotifier').attr('placeholder', '12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  223. }
  224. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  225. $('#instanceeventnotifier').attr('placeholder', '9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)');
  226. }
  227. });