@@ -13,9 +13,8 @@ import { ScenarioService } from "src/app/data/scenario.service";
13
13
import { Course } from "src/app/data/course" ;
14
14
import { CourseService } from "src/app/data/course.service" ;
15
15
import { EnvironmentService } from "src/app/data/environment.service" ;
16
- import { combineAll , concatMap , map , filter } from "rxjs/operators" ;
16
+ import { combineAll , concatMap , map , filter , defaultIfEmpty } from "rxjs/operators" ;
17
17
import { Environment } from "src/app/data/environment" ;
18
- import { from , of } from "rxjs" ;
19
18
import { EnvironmentAvailability } from "src/app/data/environmentavailability" ;
20
19
import { ScheduledeventService } from "src/app/data/scheduledevent.service" ;
21
20
import {
@@ -31,6 +30,7 @@ import {
31
30
import { DlDateTimePickerChange } from "angular-bootstrap-datetimepicker" ;
32
31
import { QuicksetValidator } from "src/app/validators/quickset.validator" ;
33
32
import { RbacService } from 'src/app/data/rbac.service' ;
33
+ import { of } from "rxjs" ;
34
34
35
35
@Component ( {
36
36
selector : "new-scheduled-event" ,
@@ -58,6 +58,8 @@ export class NewScheduledEventComponent implements OnInit {
58
58
59
59
public availableEnvironments : EnvironmentAvailability [ ] = [ ] ;
60
60
public checkingEnvironments : boolean = true ;
61
+ public noEnvironmentsAvailable : boolean = false ;
62
+ public unavailableVMTs : string [ ] = [ ]
61
63
public environments : Environment [ ] = [ ] ;
62
64
public keyedEnvironments : Map < string , Environment > = new Map ( ) ;
63
65
public selectedEnvironments : EnvironmentAvailability [ ] = [ ] ;
@@ -563,6 +565,8 @@ export class NewScheduledEventComponent implements OnInit {
563
565
// display those results
564
566
public checkEnvironments ( ) {
565
567
this . checkingEnvironments = true ;
568
+ this . noEnvironmentsAvailable = false ;
569
+ this . unavailableVMTs = [ ] ;
566
570
var templates : Map < string , boolean > = new Map ( ) ;
567
571
568
572
// add all chosen templates to the list
@@ -586,7 +590,7 @@ export class NewScheduledEventComponent implements OnInit {
586
590
. pipe (
587
591
concatMap ( ( e : Environment [ ] ) => {
588
592
this . environments = e ;
589
- return from ( e ) ;
593
+ return e
590
594
} ) ,
591
595
filter ( ( e : Environment ) => {
592
596
// first add to keyed environment, regardless of if we use it or not
@@ -611,11 +615,21 @@ export class NewScheduledEventComponent implements OnInit {
611
615
map ( ( ea : EnvironmentAvailability ) => {
612
616
return of ( ea ) ;
613
617
} ) ,
614
- combineAll ( )
618
+ combineAll ( ) ,
619
+ defaultIfEmpty ( [ ] )
615
620
)
616
621
. subscribe ( ( ea : EnvironmentAvailability [ ] ) => {
617
622
this . availableEnvironments = ea ;
618
623
this . checkingEnvironments = false ;
624
+ this . noEnvironmentsAvailable = ea . length == 0 ? true : false ;
625
+
626
+ ea . forEach ( ( e => {
627
+ Object . keys ( e . available_count ) . forEach ( vmt => {
628
+ templates . delete ( vmt ) ;
629
+ } )
630
+ } ) )
631
+
632
+ this . unavailableVMTs = Array . from ( templates . keys ( ) ) ;
619
633
620
634
if ( this . event ) {
621
635
// we are updating instead of creating new
0 commit comments