@@ -35,10 +35,10 @@ import {
3535export class IndexComponent implements OnInit , OnDestroy {
3636 env = environment ;
3737
38- nsSub = new Subscription ( ) ;
39- pollSub = new Subscription ( ) ;
38+ namespaceSubscription = new Subscription ( ) ;
39+ pollingSubscription = new Subscription ( ) ;
4040
41- currNamespace : string | string [ ] ;
41+ currentNamespace : string | string [ ] ;
4242 config = defaultConfig ;
4343 inferenceServices : InferenceServiceIR [ ] = [ ] ;
4444
@@ -67,100 +67,104 @@ export class IndexComponent implements OnInit, OnDestroy {
6767
6868 ngOnInit ( ) : void {
6969 // Reset the poller whenever the selected namespace changes
70- this . nsSub = this . ns . getSelectedNamespace2 ( ) . subscribe ( ns => {
71- this . currNamespace = ns ;
72- this . poll ( ns ) ;
73- this . newEndpointButton . namespaceChanged ( ns , $localize `Endpoint` ) ;
74- } ) ;
70+ this . namespaceSubscription = this . ns
71+ . getSelectedNamespace2 ( )
72+ . subscribe ( ns => {
73+ this . currentNamespace = ns ;
74+ this . poll ( ns ) ;
75+ this . newEndpointButton . namespaceChanged ( ns , $localize `Endpoint` ) ;
76+ } ) ;
7577 }
7678
7779 ngOnDestroy ( ) {
78- this . nsSub . unsubscribe ( ) ;
79- this . pollSub . unsubscribe ( ) ;
80+ this . namespaceSubscription . unsubscribe ( ) ;
81+ this . pollingSubscription . unsubscribe ( ) ;
8082 }
8183
8284 public poll ( ns : string | string [ ] ) {
83- this . pollSub . unsubscribe ( ) ;
85+ this . pollingSubscription . unsubscribe ( ) ;
8486 this . inferenceServices = [ ] ;
8587
8688 const request = this . backend . getInferenceServices ( ns ) ;
8789
88- this . pollSub = this . poller . exponential ( request ) . subscribe ( svcs => {
89- this . inferenceServices = this . processIncomingData ( svcs ) ;
90- } ) ;
90+ this . pollingSubscription = this . poller
91+ . exponential ( request )
92+ . subscribe ( svcs => {
93+ this . inferenceServices = this . processIncomingData ( svcs ) ;
94+ } ) ;
9195 }
9296
9397 // action handling functions
9498 public reactToAction ( a : ActionEvent ) {
95- const svc = a . data as InferenceServiceIR ;
99+ const inferenceService = a . data as InferenceServiceIR ;
96100
97101 switch ( a . action ) {
98102 case 'delete' :
99- this . deleteClicked ( svc ) ;
103+ this . deleteClicked ( inferenceService ) ;
100104 break ;
101105 case 'copy-link' :
102- console . log ( `Copied to clipboard: ${ svc . status . url } ` ) ;
103- this . clipboard . copy ( svc . status . url ) ;
104- const config : SnackBarConfig = {
106+ console . log ( `Copied to clipboard: ${ inferenceService . status . url } ` ) ;
107+ this . clipboard . copy ( inferenceService . status . url ) ;
108+ const snackConfig : SnackBarConfig = {
105109 data : {
106- msg : `Copied: ${ svc . status . url } ` ,
110+ msg : `Copied: ${ inferenceService . status . url } ` ,
107111 snackType : SnackType . Info ,
108112 } ,
109113 } ;
110- this . snack . open ( config ) ;
114+ this . snack . open ( snackConfig ) ;
111115 break ;
112116 case 'name:link' :
113117 /*
114118 * don't allow the user to navigate to the details page of a server
115119 * that is being deleted
116120 */
117- if ( svc . ui . status . phase === STATUS_TYPE . TERMINATING ) {
121+ if ( inferenceService . ui . status . phase === STATUS_TYPE . TERMINATING ) {
118122 a . event . stopPropagation ( ) ;
119123 a . event . preventDefault ( ) ;
120- const config : SnackBarConfig = {
124+ const snackConfig : SnackBarConfig = {
121125 data : {
122126 msg : $localize `Endpoint is being deleted, cannot show details.` ,
123127 snackType : SnackType . Info ,
124128 } ,
125129 } ;
126- this . snack . open ( config ) ;
130+ this . snack . open ( snackConfig ) ;
127131 return ;
128132 }
129133 break ;
130134 }
131135 }
132136
133- private deleteClicked ( svc : InferenceServiceIR ) {
134- const config = generateDeleteConfig ( svc ) ;
137+ private deleteClicked ( inferenceService : InferenceServiceIR ) {
138+ const dialogConfig = generateDeleteConfig ( inferenceService ) ;
135139
136- const dialogRef = this . confirmDialog . open ( 'Endpoint' , config ) ;
140+ const dialogRef = this . confirmDialog . open ( 'Endpoint' , dialogConfig ) ;
137141 const applyingSub = dialogRef . componentInstance . applying$ . subscribe (
138142 applying => {
139143 if ( ! applying ) {
140144 return ;
141145 }
142146
143- this . backend . deleteInferenceService ( svc ) . subscribe (
144- res => {
147+ this . backend . deleteInferenceService ( inferenceService ) . subscribe (
148+ dialogResponse => {
145149 dialogRef . close ( DIALOG_RESP . ACCEPT ) ;
146150 } ,
147151 err => {
148- config . error = err ;
152+ dialogConfig . error = err ;
149153 dialogRef . componentInstance . applying$ . next ( false ) ;
150154 } ,
151155 ) ;
152156 } ,
153157 ) ;
154158
155- dialogRef . afterClosed ( ) . subscribe ( res => {
159+ dialogRef . afterClosed ( ) . subscribe ( dialogResponse => {
156160 applyingSub . unsubscribe ( ) ;
157161
158- if ( res !== DIALOG_RESP . ACCEPT ) {
162+ if ( dialogResponse !== DIALOG_RESP . ACCEPT ) {
159163 return ;
160164 }
161165
162- svc . ui . status . phase = STATUS_TYPE . TERMINATING ;
163- svc . ui . status . message = $localize `Preparing to delete Endpoint...` ;
166+ inferenceService . ui . status . phase = STATUS_TYPE . TERMINATING ;
167+ inferenceService . ui . status . message = $localize `Preparing to delete Endpoint...` ;
164168 } ) ;
165169 }
166170
@@ -169,49 +173,56 @@ export class IndexComponent implements OnInit, OnDestroy {
169173 private processIncomingData ( svcs : InferenceServiceK8s [ ] ) {
170174 const svcsCopy : InferenceServiceIR [ ] = JSON . parse ( JSON . stringify ( svcs ) ) ;
171175
172- for ( const svc of svcsCopy ) {
173- this . parseInferenceService ( svc ) ;
176+ for ( const inferenceService of svcsCopy ) {
177+ this . parseInferenceService ( inferenceService ) ;
174178 }
175179
176180 return svcsCopy ;
177181 }
178182
179- private parseInferenceService ( svc : InferenceServiceIR ) {
180- svc . ui = { actions : { } } ;
181- svc . ui . status = getK8sObjectUiStatus ( svc ) ;
182- svc . ui . actions . copy = this . getCopyActionStatus ( svc ) ;
183- svc . ui . actions . delete = this . getDeletionActionStatus ( svc ) ;
184-
185- const predictorType = getPredictorType ( svc . spec . predictor ) ;
186- const predictor = getPredictorExtensionSpec ( svc . spec . predictor ) ;
187- svc . ui . predictorType = predictorType ;
188- svc . ui . runtimeVersion = predictor . runtimeVersion ;
189- svc . ui . storageUri = predictor . storageUri ;
190- svc . ui . protocolVersion = predictor . protocolVersion || 'v1' ;
191- svc . ui . link = {
192- text : svc . metadata . name ,
193- url : `/details/${ svc . metadata . namespace } /${ svc . metadata . name } ` ,
183+ private parseInferenceService ( inferenceService : InferenceServiceIR ) {
184+ inferenceService . ui = { actions : { } } ;
185+ inferenceService . ui . status = getK8sObjectUiStatus ( inferenceService ) ;
186+ inferenceService . ui . actions . copy =
187+ this . getCopyActionStatus ( inferenceService ) ;
188+ inferenceService . ui . actions . delete =
189+ this . getDeletionActionStatus ( inferenceService ) ;
190+
191+ const predictorType = getPredictorType ( inferenceService . spec . predictor ) ;
192+ const predictor = getPredictorExtensionSpec (
193+ inferenceService . spec . predictor ,
194+ ) ;
195+ inferenceService . ui . predictorType = predictorType ;
196+ inferenceService . ui . runtimeVersion = predictor . runtimeVersion ;
197+ inferenceService . ui . storageUri = predictor . storageUri ;
198+ inferenceService . ui . protocolVersion = predictor . protocolVersion || 'v1' ;
199+ inferenceService . ui . link = {
200+ text : inferenceService . metadata . name ,
201+ url : `/details/${ inferenceService . metadata . namespace } /${ inferenceService . metadata . name } ` ,
194202 } ;
195203 }
196204
197- private getCopyActionStatus ( svc : InferenceServiceIR ) {
198- if ( svc . ui . status . phase !== STATUS_TYPE . READY ) {
205+ private getCopyActionStatus ( inferenceService : InferenceServiceIR ) {
206+ if ( inferenceService . ui . status . phase !== STATUS_TYPE . READY ) {
199207 return STATUS_TYPE . UNAVAILABLE ;
200208 }
201209
202210 return STATUS_TYPE . READY ;
203211 }
204212
205- private getDeletionActionStatus ( svc : InferenceServiceIR ) {
206- if ( svc . ui . status . phase !== STATUS_TYPE . TERMINATING ) {
213+ private getDeletionActionStatus ( inferenceService : InferenceServiceIR ) {
214+ if ( inferenceService . ui . status . phase !== STATUS_TYPE . TERMINATING ) {
207215 return STATUS_TYPE . READY ;
208216 }
209217
210218 return STATUS_TYPE . TERMINATING ;
211219 }
212220
213221 // util functions
214- public inferenceServiceTrackByFn ( index : number , svc : InferenceServiceK8s ) {
215- return `${ svc . metadata . name } /${ svc . metadata . creationTimestamp } ` ;
222+ public inferenceServiceTrackByFn (
223+ index : number ,
224+ inferenceService : InferenceServiceK8s ,
225+ ) {
226+ return `${ inferenceService . metadata . name } /${ inferenceService . metadata . creationTimestamp } ` ;
216227 }
217228}
0 commit comments