UNPKG

graphdb-workbench

Version:
2 lines 4.59 kB
export const __webpack_esm_id__=10376;export const __webpack_esm_ids__=[456,5759,10376,17620,70884,81837];export const __webpack_esm_modules__={456:(e,t,r)=>{var n=r(17620),a=(r(14874),r(70884),r(81837));function o(e,t,r,o,l,i,s,g){const p=[];e.initialized=!1,e.loadingEndpoints=!1,e.selectedGraphqlEndpoint=void 0,e.graphqlEndpoints=[],e.configuration=void 0,e.getActiveRepositoryNoError=()=>r.getActiveRepository(),e.onGraphqlEndpointChange=e=>{h(e)};const d=e=>{const t={endpoint:e.replace(/^\//,""),headers:c,selectedLanguage:o.getLanguage(),defaultQuery:"query Object {\n object(limit: 100) {\n id\n }\n}"};return new n.$(t)},c=()=>{const e={"X-GraphDB-Track-Alias":`graphql-playground-query-${performance.now()}-${Date.now()}`},t=g.getAuthToken();return t&&(e.Authorization=t),e},u=(e,t)=>e.find(e=>e.label===t),h=t=>{const r=d(t.value);e.configuration=new n.$(r)},y=()=>{e.selectedGraphqlEndpoint=void 0,e.graphqlEndpoints=[],e.configuration=void 0};p.push(e.$watch(e.getActiveRepositoryObject,e=>{e&&q()})),p.push(e.$on("language-changed",(e,t)=>{a.A.getGraphqlPlaygroundComponentAsync("#graphql-playground").then(e=>{e.setLanguage(t.locale)})})),e.$on("$destroy",()=>{p.forEach(e=>e())});const q=()=>{(()=>{e.loadingEndpoints=!0;const n=r.getActiveRepository();return i.getEndpointsAsSelectMenuOptions(n).then(r=>{r.length?(r=>{e.graphqlEndpoints=r,e.selectedGraphqlEndpoint=(()=>{const r=t.search().endpointId;if(r){const t=u(e.graphqlEndpoints,r);if(t)return t}const n=s.getSelectedEndpoint();if(n){const t=u(e.graphqlEndpoints,n.endpointId);if(t)return t}return e.graphqlEndpoints.find(e=>e.data.default)||e.graphqlEndpoints[0]})(),e.configuration=d(e.selectedGraphqlEndpoint.value)})(r):y()}).catch(e=>{y(),l.error(getError(e))}).finally(()=>{e.loadingEndpoints=!1})})().finally(()=>{e.initialized=!0})}}angular.module("graphdb.framework.graphql.controllers.graphql-playground-view",["graphdb.framework.core.services.graphql-service","graphdb.framework.core.directives.graphql-playground"]).controller("GraphqlPlaygroundViewCtrl",o),o.$inject=["$scope","$location","$repositories","$languageService","toastr","GraphqlService","GraphqlContextService","AuthTokenService"]},5759:(e,t,r)=>{r.d(t,{a:()=>n});class n{constructor(e){this.graphQLPlaygroundComponent=e}setLanguage(e){this.graphQLPlaygroundComponent.setLanguage(e)}}},10376:(e,t,r)=>{r(456),r(98494),r(99379),angular.module("graphdb.framework.graphql",["ngRoute","graphdb.framework.graphql.controllers.graphql-endpoint-management-view","graphdb.framework.graphql.controllers.graphql-playground-view","graphdb.framework.graphql.controllers.create-graphql-endpoint-view"])},17620:(e,t,r)=>{r.d(t,{$:()=>n});class n{constructor(e){this._endpoint=e.endpoint,this._headers=e.headers,this._selectedLanguage=e.selectedLanguage,this._defaultQuery=e.defaultQuery}get endpoint(){return this._endpoint}set endpoint(e){this._endpoint=e}get headers(){return this._headers}set headers(e){this._headers=e}get selectedLanguage(){return this._selectedLanguage}set selectedLanguage(e){this._selectedLanguage=e}get defaultQuery(){return this._defaultQuery}set defaultQuery(e){this._defaultQuery=e}}},70884:(e,t,r)=>{var n=r(5759);function a(e,t,r,a){return{restrict:"E",templateUrl:"js/angular/core/directives/graphql-playground/templates/graphql-playground.html",scope:{configuration:"="},link:(o,l,i)=>{o.getGraphQLPlaygroundComponent=()=>new n.a(s()[0]),o.abortQuery=n=>{const o=e.getActiveRepository(),l=n.detail.headers["X-GraphDB-Track-Alias"];a.info(t.instant("graphql.playground.message.abort_query")),r.deleteQuery(l,o)};const s=()=>l.find("graphql-playground-component")}}}angular.module("graphdb.framework.core.directives.graphql-playground",[]).directive("graphqlPlayground",a),a.$inject=["$repositories","$translate","MonitoringRestService","toastr"]},81837:(e,t,r)=>{r.d(t,{A:()=>a});const n=r(304).I.logger;class a{static getGraphqlPlaygroundDirectiveController(e){const t=angular.element(document.querySelector(e));return angular.element(t).isolateScope()}static getGraphqlPlaygroundComponent=e=>{const t=a.getGraphqlPlaygroundDirectiveController(e);if(t)return t.getGraphQLPlaygroundComponent()};static getGraphqlPlaygroundComponentAsync=(e,t=1)=>new Promise((r,o)=>{let l=a.getGraphqlPlaygroundComponent(e);l&&r(l);let i=1e3*t|1e3;const s=setInterval(()=>{l=a.getGraphqlPlaygroundComponent(e),l?(clearInterval(s),r(l)):(i-=100,i<0&&(clearInterval(s),n.info("GraphQL Playground component is not found",e),o(new Error("Element is not found: "+e))))},100)})}}}; //# sourceMappingURL=10376.150205002f1b07f84048.bundle.js.map