UNPKG

graphdb-workbench

Version:
2 lines 4.46 kB
export const __webpack_id__=456;export const __webpack_ids__=[456,5759,17620,70884,81837];export const __webpack_modules__={456:(e,t,n)=>{n.r(t);var r=n(17620),o=(n(14874),n(70884),n(81837));function a(e,t,n,a,l,i,s,g){const d=[];e.initialized=!1,e.loadingEndpoints=!1,e.selectedGraphqlEndpoint=void 0,e.graphqlEndpoints=[],e.configuration=void 0,e.getActiveRepositoryNoError=()=>n.getActiveRepository(),e.onGraphqlEndpointChange=e=>{h(e)};const p=e=>{const t={endpoint:e.replace(/^\//,""),headers:c,selectedLanguage:a.getLanguage(),defaultQuery:"query Object {\n object(limit: 100) {\n id\n }\n}"};return new r.GraphqlPlaygroundConfig(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 n=p(t.value);e.configuration=new r.GraphqlPlaygroundConfig(n)},y=()=>{e.selectedGraphqlEndpoint=void 0,e.graphqlEndpoints=[],e.configuration=void 0};d.push(e.$watch(e.getActiveRepositoryObject,e=>{e&&q()})),d.push(e.$on("language-changed",(e,t)=>{o.GraphqlPlaygroundDirectiveUtil.getGraphqlPlaygroundComponentAsync("#graphql-playground").then(e=>{e.setLanguage(t.locale)})})),e.$on("$destroy",()=>{d.forEach(e=>e())});const q=()=>{(()=>{e.loadingEndpoints=!0;const r=n.getActiveRepository();return i.getEndpointsAsSelectMenuOptions(r).then(n=>{n.length?(n=>{e.graphqlEndpoints=n,e.selectedGraphqlEndpoint=(()=>{const n=t.search().endpointId;if(n){const t=u(e.graphqlEndpoints,n);if(t)return t}const r=s.getSelectedEndpoint();if(r){const t=u(e.graphqlEndpoints,r.endpointId);if(t)return t}return e.graphqlEndpoints.find(e=>e.data.default)||e.graphqlEndpoints[0]})(),e.configuration=p(e.selectedGraphqlEndpoint.value)})(n):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",a),a.$inject=["$scope","$location","$repositories","$languageService","toastr","GraphqlService","GraphqlContextService","AuthTokenService"]},5759:(e,t,n)=>{n.r(t),n.d(t,{GraphQLPlaygroundComponent:()=>r});class r{constructor(e){this.graphQLPlaygroundComponent=e}setLanguage(e){this.graphQLPlaygroundComponent.setLanguage(e)}}},17620:(e,t,n)=>{n.r(t),n.d(t,{GraphqlPlaygroundConfig:()=>r});class r{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,n)=>{n.r(t);var r=n(5759);function o(e,t,n,o){return{restrict:"E",templateUrl:"js/angular/core/directives/graphql-playground/templates/graphql-playground.html",scope:{configuration:"="},link:(a,l,i)=>{a.getGraphQLPlaygroundComponent=()=>new r.GraphQLPlaygroundComponent(s()[0]),a.abortQuery=r=>{const a=e.getActiveRepository(),l=r.detail.headers["X-GraphDB-Track-Alias"];o.info(t.instant("graphql.playground.message.abort_query")),n.deleteQuery(l,a)};const s=()=>l.find("graphql-playground-component")}}}angular.module("graphdb.framework.core.directives.graphql-playground",[]).directive("graphqlPlayground",o),o.$inject=["$repositories","$translate","MonitoringRestService","toastr"]},81837:(e,t,n)=>{n.r(t),n.d(t,{GraphqlPlaygroundDirectiveUtil:()=>r});class r{static getGraphqlPlaygroundDirectiveController(e){const t=angular.element(document.querySelector(e));return angular.element(t).isolateScope()}static getGraphqlPlaygroundComponent=e=>{const t=r.getGraphqlPlaygroundDirectiveController(e);if(t)return t.getGraphQLPlaygroundComponent()};static getGraphqlPlaygroundComponentAsync=(e,t=1)=>new Promise((n,o)=>{let a=r.getGraphqlPlaygroundComponent(e);a&&n(a);let l=1e3*t|1e3;const i=setInterval(()=>{a=r.getGraphqlPlaygroundComponent(e),a?(clearInterval(i),n(a)):(l-=100,l<0&&(clearInterval(i),console.log("GraphQL Playground component is not found",e),o(new Error("Element is not found: "+e))))},100)})}}}; //# sourceMappingURL=456.6118cb99d130f4c0410c.bundle.js.map