1import{a as ce,b as pe}from"./chunk-N7OHRZLZ.js";import{b as ae,c as oe,d as ge}from"./chunk-YEQDNBIG.js";import{a as K,b as X,c as Z,d as ee,e as te,f as ne}from"./chunk-UGQICUYY.js";import{a as re,b as se}from"./chunk-ZVKVS6QM.js";import{a as ie}from"./chunk-OVNK2ETZ.js";import"./chunk-6UHQPIVE.js";import{a as le,b as de}from"./chunk-ZXSNIZ6S.js";import{a as z,b as H}from"./chunk-5T5T7ANT.js";import"./chunk-JEL6HJ7P.js";import{ja as Q,qa as U}from"./chunk-YQOD7X2Z.js";import"./chunk-563YFTIG.js";import"./chunk-36JN3LZY.js";import{ra as W,sa as Y}from"./chunk-WPHW6CRH.js";import{K as G,h as I,o as $}from"./chunk-76O7YCWW.js";import"./chunk-YYIIKC2W.js";import"./chunk-3WYGUSDH.js";import"./chunk-LU7SZU5X.js";import{A as V,v as F}from"./chunk-PO2RDVKE.js";import{Ac as T,Bc as A,E as S,Ec as R,Fc as k,Gc as j,J as P,L as B,Mb as C,Pb as u,Rb as _,Sb as D,Tc as L,Ub as E,Uc as J,Vb as w,Wb as c,Xb as l,Yb as s,Zb as b,db as r,ec as N,ha as x,jc as y,lc as p,n as O,oa as f,pa as h,ub as q,y as v,zc as m}from"./chunk-3URBZWPM.js";import"./chunk-ODN5LVDJ.js";var me=[{ws_id:"WS1001",ids:[],entity_type:"Organisation"},{ws_id:"CreateTrainingProvider",ids:[],entity_type:"TrainingProvider"},{ws_id:"UpdateTrainingProvider",ids:[],entity_type:"TrainingProvider"}];var d=(function(n){return n.ORG_DYNAMO="org_dynamo",n.ORG_OPEN="org_opensearch",n.CENTRE_DYNAMO="centre_dynamo",n.CENTRE_OPEN="centre_opensearch",n})(d||{}),ue=[{header:"Organisation (Dynamo)",id:d.ORG_DYNAMO},{header:"Organisation (OpenSearch)",id:d.ORG_OPEN},{header:"Centre (Dynamo)",id:d.CENTRE_DYNAMO},{header:"Centre (OpenSearch)",id:d.CENTRE_OPEN}];function _e(n,o){n&1&&(l(0,"div",1),b(1,"p-progress-spinner",2),s())}function fe(n,o){if(n&1&&(l(0,"p-message",7),m(1),s()),n&2){let t=p(2);c("severity",t.messages.type),r(),T(t.messages.message)}}function he(n,o){if(n&1&&(l(0,"p-tab",12),m(1),s()),n&2){let t=o.$implicit,i=o.$index;c("value",i),C("data-auto",t.header.toLowerCase()),r(),T(t.header)}}function Ce(n,o){if(n&1&&(l(0,"pre"),m(1),L(2,"json"),s()),n&2){let t=p(2).$implicit;r(),T(J(2,1,t.dataToDisplay))}}function be(n,o){if(n&1&&b(0,"app-information-display",14),n&2){let t=p(2).$implicit;c("data",t.dataToDisplay)}}function ye(n,o){if(n&1&&u(0,Ce,3,3,"pre")(1,be,1,1,"app-information-display",14),n&2){let t=p(3);_(t.orgJsonDisplay?0:1)}}function xe(n,o){if(n&1&&(l(0,"p-message",13),m(1),s()),n&2){let t=p().$implicit;r(),A("No ",t.header==null?null:t.header.toLowerCase()," data found")}}function Te(n,o){if(n&1&&(l(0,"p-tabpanel",12),u(1,ye,2,1)(2,xe,2,1,"p-message",13),s()),n&2){let t=o.$implicit,i=o.$index;c("value",i),r(),_(t.dataToDisplay?1:2)}}function Me(n,o){if(n&1){let t=N();l(0,"section")(1,"p-card",3)(2,"div",4)(3,"p-button",5),y("onClick",function(){f(t);let e=p();return h(e.requeueOrgButton.action())}),s(),l(4,"p-button",6),y("onClick",function(){f(t);let e=p();return h(e.requeueTpButton.action())}),s(),l(5,"p-button",5),y("onClick",function(){f(t);let e=p();return h(e.createTpButton.action())}),s()(),u(6,fe,2,2,"p-message",7),l(7,"div",8)(8,"p-toggleswitch",9),j("ngModelChange",function(e){f(t);let a=p();return k(a.orgJsonDisplay,e)||(a.orgJsonDisplay=e),h(e)}),s(),l(9,"label",10),m(10,"Display as raw JSON"),s()(),l(11,"p-tabs",11)(12,"p-tablist"),E(13,he,2,3,"p-tab",12,D),s(),l(15,"p-tabpanels"),E(16,Te,3,2,"p-tabpanel",12,D),s()()()()}if(n&2){let t=p();r(),c("header",t.selectedOrg.name),r(2),c("label",t.requeueOrgButton.label)("loading",t.requeueOrgButton.loading),C("data-auto",t.requeueOrgButton.label.toLowerCase()),r(),c("label",t.requeueTpButton.label)("loading",t.requeueTpButton.loading),C("data-auto",t.requeueTpButton.label.toLowerCase()),r(),c("label",t.createTpButton.label)("loading",t.createTpButton.loading),C("data-auto",t.createTpButton.label.toLowerCase()),r(),_(t.messages.active?6:-1),r(2),R("ngModel",t.orgJsonDisplay),r(3),c("value",0),r(2),w(t.orgTabsData),r(3),w(t.orgTabsData)}}var Ze=(()=>{let o=class o{constructor(){this._organisationService=x(U),this._tpService=x(Q),this._qService=x(ie),this.subscriptions=[],this.orgJsonDisplay=!1,this.suggestions=[],this.orgTabsData=ue,this.requeueOrgButton={label:"Requeue organisation from CRM",action:()=>this.sendThroughQueue("WS1001"),loading:!1},this.requeueTpButton={label:"Requeue training provider from CRM",action:()=>this.sendThroughQueue("UpdateTrainingProvider"),loading:!1},this.createTpButton={label:"Create training provider in web",action:()=>this.sendThroughQueue("CreateTrainingProvider"),loading:!1},this.messages={active:!1,type:"success",message:""}}ngOnDestroy(){this.subscriptions.forEach(i=>
1i.unsubscribe())}filterMethod(i){this._organisationService.search(i.query,void 0).pipe(P(1)).subscribe({next:e=>{this.suggestions=e},error:e=>{console.error(e)}})}orgSelected(i){this.isLoading=!0,this.hasSearched=!0,this._getAllOrgData(i.value.id)}_getAllOrgData(i){this._resetAllContent(),this._removeMessages(),this.subscriptions.push(this._getDynamoData(i).pipe(B(e=>(this.selectedOrg=e.org,this._updateTabData(d.CENTRE_DYNAMO,e.centre),this._updateTabData(d.ORG_DYNAMO,e.org),e.centre?.pathAlias?this._getElasticData(e.org.accountNumber,e.centre.pathAlias):this._getElasticData(e.org?.accountNumber)))).subscribe({next:e=>{(Array.isArray(e.org)&&e.org.length>0||e.org?.hits?.length>0)&&this._updateTabData(d.ORG_OPEN,e.org),e.centre&&(Array.isArray(e.centre)&&e.centre.length>0||e.centre.hits?.length>0)&&this._updateTabData(d.CENTRE_OPEN,e.centre),this.isLoading=!1},error:()=>{this.isLoading=!1}}))}_getDynamoData(i){let e={org:this._organisationService.getOrganisation(i).pipe(S(()=>O(null))),centre:this._tpService.getTrainingProvider(i).pipe(S(()=>O(null)))};return v(e)}_getElasticData(i,e){let a={org:this._organisationService.getOrganisationFromElastic(i)};return e&&(a.centre=this._tpService.getCentreByPath(e)),v(a)}sendThroughQueue(i){let e=i==="WS1001"?this.requeueOrgButton:i==="UpdateTrainingProvider"?this.requeueTpButton:this.createTpButton;this._removeMessages();let a=me.find(g=>g.ws_id=i);a&&(e.loading=!0,a.ids=[this.selectedOrg.organisationId],this.subscriptions.push(this._qService.queueItem(a.ws_id,a.ids,a.entity_type).subscribe({next:g=>{g.error?this._addMessage("error","Message could not be queued"):this._addMessage("success",g.statusMessage),e.loading=!1},error:()=>{this._addMessage("error","Message could not be queued"),e.loading=!1}})))}_updateTabData(i,e){let a=this.orgTabsData.find(g=>g.id===i);a&&(a.dataToDisplay=e)}_resetAllContent(){this._removeMessages(),this.selectedOrg=null;for(let i in d)this._updateTabData(d[i],null)}_removeMessages(){this.messages.active=!1}_addMessage(i,e){this.messages.active=!0,this.messages.type=i,this.messages.message=e}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=q({type:o,selectors:[["app-organisation-management"]],decls:8,vars:4,consts:[["delay","300","data-auto","organisation-search","name","organisation-search","autoHighlight","true","placeholder","Search by organisation name","fluid","",3,"completeMethod","onSelect","suggestions","showClear"],[1,"flex","justify-center"],["ariaLabel","loading",1,"flex"],[1,"mt-2","mb-2",3,"header"],[1,"mb-5","flex","justify-between","flex-wrap","gap-2"],[3,"onClick","label","loading"],["variant","outlined","severity","contrast",3,"onClick","label","loading"],[3,"severity"],[1,"flex","justify-end-safe","mt-3","mb-3"],["inputId","orgJsonToggle","data-auto","orgJsonToggle",3,"ngModelChange","ngModel"],["for","jsonToggle",1,"ml-3"],[1,"mt-5",3,"value"],[3,"value"],["severity","warn"],[3,"data"]],template:function(e,a){e&1&&(l(0,"section")(1,"h4"),m(2,"Search for an organisation"),s(),b(3,"br"),l(4,"p-autocomplete",0),y("completeMethod",function(M){return a.filterMethod(M)})("onSelect",function(M){return a.orgSelected(M)}),s(),b(5,"br"),s(),u(6,_e,2,0,"div",1),u(7,Me,18,13,"section")),e&2&&(r(4),c("suggestions",a.suggestions)("showClear",!0),r(2),_(a.isLoading?6:-1),r(),_(!a.isLoading&&a.hasSearched?7:-1))},dependencies:[V,oe,ae,se,re,Y,W,H,z,ne,te,ee,Z,K,X,pe,ce,ge,de,le,G,I,$,F],styles:["[_ngcontent-%COMP%]:root{--aat-ui-grey-25: #bfbfbf;--aat-ui-grey-55: #737373;--aat-slate: #3a5066;--aat-ui-grey-05: #f2f2f2}.main[_ngcontent-%COMP%]{display:flex}.main__content[_ngcontent-%COMP%]{flex-basis:85%;max-width:80%;margin:auto}.data-container[_ngcontent-%COMP%]{background-color:#eee;display:flex;flex-direction:column}.data-container__beside[_ngcontent-%COMP%]{flex-direction:row}.data-container__beside--content[_ngcontent-%COMP%]{flex-grow:1;margin:10px}.data-container__content[_ngcontent-%COMP%]{background-color:#fff;max-width:90%;min-width:85%;margin:15px auto;padding:15px;font-size:smaller}.data-container__content--json-toggle[_ngcontent-%COMP%]{margin:10px 0;display:flex;justify-content:flex-end}.data-container__content--json-display[_ngcontent-%COMP%]{border:thin solid rgb(238.425,238.425,238.425);padding:5px}.data-container__content--box[_ngcontent-%COMP%]{padding:15px;border-bottom:thin solid rgb(238.425,238.425,238.425)}.data-container__double-panel[_ngcontent-%COMP%]{display:grid;grid-template-columns:48% 48%}.data-container__loader[_ngcontent-%COMP%]{background-color:#fff}.button-container[_ngcontent-%COMP%]{display:flex;justify-content:space-between;padding:10px}.button-container--single[_ngcontent-%COMP%]{justify-content:flex-end}"]});let n=o;return n})();export{Ze as OrganisationManagementComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.