graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 5.02 kB
JavaScript
export const __webpack_esm_id__=456;export const __webpack_esm_ids__=[456,5759,17620,70884,81837];export const __webpack_esm_modules__={456(e,t,n){var r=n(17620),o=(n(14874),n(70884),n(81837)),a=n(57154);function i(e,t,n,i,s,l,d){let g=[];const c=(0,a.service)(a.AuthenticationStorageService),p=(0,a.service)(a.RuntimeConfigurationContextService),h=(0,a.service)(a.ThemeService);e.initialized=!1,e.loadingEndpoints=!1,e.selectedGraphqlEndpoint=void 0,e.graphqlEndpoints=[],e.configuration=void 0,e.getActiveRepositoryNoError=()=>n.getActiveRepository(),e.onGraphqlEndpointChange=e=>{q(e)};const u=e=>{const t={endpoint:e.replace(/^\//,""),headers:m,selectedLanguage:i.getLanguage(),defaultQuery:"query Object {\n object(limit: 100) {\n id\n }\n}"};return new r.$(t)},m=()=>{const e={"X-GraphDB-Track-Alias":`graphql-playground-query-${performance.now()}-${Date.now()}`},t=c.getAuthToken().getValue();return t&&(e.Authorization=t),e},y=(e,t)=>e.find(e=>e.label===t),q=t=>{const n=u(t.value);e.configuration=new r.$(n)},f=()=>{e.selectedGraphqlEndpoint=void 0,e.graphqlEndpoints=[],e.configuration=void 0};g=[e.$watch(e.getActiveRepositoryObject,e=>{e&&v()}),e.$on("language-changed",(e,t)=>{o.A.getGraphqlPlaygroundComponentAsync("#graphql-playground").then(e=>{e.setLanguage(t.locale)})}),p.onThemeModeChanged(()=>{e.graphqlEndpoints&&e.graphqlEndpoints.length&&o.A.getGraphqlPlaygroundComponentAsync("#graphql-playground").then(e=>e.setEditorsTheme(h.getCodeEditorThemeName())).catch(e=>{console.error("Failed to locate the GraphQL Playground instance.",e)})})],e.$on("$destroy",()=>{g.forEach(e=>e())});const v=()=>{(()=>{e.loadingEndpoints=!0;const r=n.getActiveRepository();return l.getEndpointsAsSelectMenuOptions(r).then(n=>{n.length?(n=>{e.graphqlEndpoints=n,e.selectedGraphqlEndpoint=(()=>{const n=t.search().endpointId;if(n){const t=y(e.graphqlEndpoints,n);if(t)return t}const r=d.getSelectedEndpoint();if(r){const t=y(e.graphqlEndpoints,r.endpointId);if(t)return t}return e.graphqlEndpoints.find(e=>e.data.default)||e.graphqlEndpoints[0]})(),e.configuration=u(e.selectedGraphqlEndpoint.value)})(n):f()}).catch(e=>{f(),s.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",i),i.$inject=["$scope","$location","$repositories","$languageService","toastr","GraphqlService","GraphqlContextService"]},5759(e,t,n){n.d(t,{a:()=>r});class r{constructor(e){this.graphQLPlaygroundComponent=e}setLanguage(e){this.graphQLPlaygroundComponent.setLanguage(e)}setEditorsTheme(e){this.graphQLPlaygroundComponent.setEditorsTheme(e)}}},17620(e,t,n){n.d(t,{$:()=>r});class r{constructor(e){this._endpoint=e.endpoint,this._headers=e.headers,this._selectedLanguage=e.selectedLanguage,this._defaultQuery=e.defaultQuery,this._editorsThemeName=e.editorsThemeName}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}get editorsThemeName(){return this._editorsThemeName}set editorsThemeName(e){this._editorsThemeName=e}}},70884(e,t,n){var r=n(5759),o=n(57154);function a(e,t,n,a){return{restrict:"E",templateUrl:"js/angular/core/directives/graphql-playground/templates/graphql-playground.html",scope:{configuration:"="},link:(i,s,l)=>{const d=(0,o.service)(o.ThemeService);i.getGraphQLPlaygroundComponent=()=>new r.a(g()[0]),i.abortQuery=r=>{const o=e.getActiveRepository(),i=r.detail.headers["X-GraphDB-Track-Alias"];a.info(t.instant("graphql.playground.message.abort_query")),n.deleteQuery(i,o)};const g=()=>s.find("graphql-playground-component");i.configuration.editorsThemeName||(i.configuration.editorsThemeName=d.getCodeEditorThemeName())}}}angular.module("graphdb.framework.core.directives.graphql-playground",[]).directive("graphqlPlayground",a),a.$inject=["$repositories","$translate","MonitoringRestService","toastr"]},81837(e,t,n){n.d(t,{A:()=>o});const r=n(304).I.logger;class o{static getGraphqlPlaygroundDirectiveController(e){const t=angular.element(document.querySelector(e));return angular.element(t).isolateScope()}static getGraphqlPlaygroundComponent=e=>{const t=o.getGraphqlPlaygroundDirectiveController(e);if(t)return t.getGraphQLPlaygroundComponent()};static getGraphqlPlaygroundComponentAsync=(e,t=1)=>new Promise((n,a)=>{let i=o.getGraphqlPlaygroundComponent(e);i&&n(i);let s=1e3*t|1e3;const l=setInterval(()=>{i=o.getGraphqlPlaygroundComponent(e),i?(clearInterval(l),n(i)):(s-=100,s<0&&(clearInterval(l),r.info("GraphQL Playground component is not found",e),a(new Error("Element is not found: "+e))))},100)})}}};
//# sourceMappingURL=456.80521b715291cd1192f5.bundle.js.map