QueryTestWidget.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. define([
  17. "dojo/_base/declare",
  18. "dojo/_base/array",
  19. "dijit/registry",
  20. "hpcc/_TabContainerWidget",
  21. "hpcc/WsTopology",
  22. "hpcc/ESPQuery",
  23. "dijit/layout/BorderContainer",
  24. "dijit/layout/TabContainer",
  25. "dijit/layout/ContentPane",
  26. "dojo/text!../templates/QueryTestWidget.html"
  27. ], function (declare, arrayUtil,
  28. registry,
  29. _TabContainerWidget, WsTopology, ESPQuery,
  30. BorderContainer, TabContainer, ContentPane,
  31. template) {
  32. return declare("QueryTestWidget", [_TabContainerWidget], {
  33. templateString: template,
  34. baseClass: "QueryTestWidget",
  35. initalized: false,
  36. soapTab: null,
  37. jsonTab: null,
  38. requestTab: null,
  39. responseTab: null,
  40. requestSchemaTab: null,
  41. responseSchemaTab: null,
  42. wsdlTab: null,
  43. paramXmlTab: null,
  44. formTab: null,
  45. linksTab: null,
  46. postCreate: function (args) {
  47. this.inherited(arguments);
  48. this.soapTab = registry.byId(this.id + "_SOAP");
  49. this.jsonTab = registry.byId(this.id + "_JSON");
  50. this.wsdlTab = registry.byId(this.id + "_WSDL");
  51. this.requestSchemaTab = registry.byId(this.id + "_RequestSchema");
  52. this.responseSchemaTab = registry.byId(this.id + "ResponseSchema");
  53. this.requestTab = registry.byId(this.id + "_Request");
  54. this.responseTab = registry.byId(this.id + "_Response");
  55. this.paramXmlTab = registry.byId(this.id + "_ParamXML");
  56. this.formTab = registry.byId(this.id + "_Form");
  57. this.linksTab = registry.byId(this.id + "_Links");
  58. },
  59. // Hitched actions ---
  60. _onRefresh: function () {
  61. },
  62. // Implementation ---
  63. init: function (params) {
  64. if (this.inherited(arguments))
  65. return;
  66. this.query = ESPQuery.Get(params.QueryId);
  67. this.selectChild(this.soapTab, true);
  68. },
  69. setContent: function (target, type, postfix) {
  70. var context = this;
  71. WsTopology.GetWsEclIFrameURL(type).then(function (response) {
  72. var src = response + encodeURIComponent(context.params.QuerySet + "/" + context.params.QueryId + (postfix ? postfix : ""));
  73. target.set("content", dojo.create("iframe", {
  74. src: src,
  75. style: "border:1px solid lightgray; width: 100%; height: 100%"
  76. }));
  77. });
  78. },
  79. initTab: function () {
  80. var currSel = this.getSelectedChild();
  81. if (!currSel.initalized) {
  82. if (currSel.id === this.id + "_SOAP") {
  83. // .../WsEcl/forms/soap/query/roxie/countydeeds.1
  84. this.setContent(currSel, "forms/soap");
  85. } else if (currSel.id === this.id + "_JSON") {
  86. // .../WsEcl/forms/json/query/roxie/countydeeds.1
  87. this.setContent(currSel, "forms/json");
  88. } else if (currSel.id === this.id + "_WSDL") {
  89. // .../WsEcl/definitions/query/roxie/countydeeds.1/main/countydeeds.1.wsdl?display
  90. this.setContent(currSel, "definitions", "/main/" + this.params.QueryId + ".wsdl?display");
  91. } else if (currSel.id === this.id + "_RequestSchema") {
  92. // .../WsEcl/definitions/query/roxie/countydeeds.1/main/countydeeds.1.xsd?display
  93. this.setContent(currSel, "definitions", "/main/" + this.params.QueryId + ".xsd?display");
  94. } else if (currSel.id === this.id + "_ResponseSchemaBorder") {
  95. var wu = this.query.getWorkunit();
  96. var context = this;
  97. wu.fetchResults(function (response) {
  98. arrayUtil.forEach(response, function (item, idx) {
  99. var responseSchema = new ContentPane({
  100. id: context.id + "ResponseSchema" + item.Name,
  101. title: item.Name,
  102. closable: false
  103. });
  104. context.responseSchemaTab.addChild(responseSchema);
  105. // .../WsEcl/definitions/query/roxie/countydeeds.1/result/jo_orig.xsd?display
  106. context.setContent(responseSchema, "definitions", "/result/" + item.Name + ".xsd?display");
  107. });
  108. });
  109. } else if (currSel.id === this.id + "_Request") {
  110. // .../WsEcl/example/request/query/roxie/countydeeds.1?display
  111. this.setContent(currSel, "example/request", "?display");
  112. } else if (currSel.id === this.id + "_Response") {
  113. // .../WsEcl/example/response/query/roxie/countydeeds.1?display
  114. this.setContent(currSel, "example/response", "?display");
  115. } else if (currSel.id === this.id + "_ParamXML") {
  116. // .../WsEcl/definitions/query/roxie/countydeeds.1/resource/soap/countydeeds.1.xml?display
  117. this.setContent(currSel, "definitions", "/resource/soap/" + this.params.QueryId + ".xml?display");
  118. } else if (currSel.id === this.id + "_Form") {
  119. // .../WsEcl/forms/ecl/query/roxie/countydeeds.1
  120. this.setContent(currSel, "forms/ecl");
  121. } else if (currSel.id === this.id + "_Links") {
  122. // .../WsEcl/links/query/roxie/countydeeds.1
  123. this.setContent(currSel, "links");
  124. } else if (currSel.init) {
  125. currSel.init(this.params);
  126. }
  127. currSel.initalized = true;
  128. }
  129. }
  130. });
  131. });