myEvents.js 12 KB

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