@@ -14,7 +14,7 @@ import { DeploymentList, DeploymentListService } from './deployment-list.servic
1414export class DeploymentListComponent implements OnInit {
1515 services : string [ ] = [ ] ;
1616 deployments : string [ ] = [ ] ;
17- filterActive : boolean = false
17+ filterList : string [ ] = [ ] ;
1818
1919 constructor (
2020 private route : ActivatedRoute ,
@@ -27,43 +27,29 @@ export class DeploymentListComponent implements OnInit {
2727 . subscribe ( ( data : { dl : DeploymentList } ) => {
2828 this . deployments = data . dl . deployments ;
2929 this . services = data . dl . services ;
30+ this . filterList = [ ]
3031 } ) ;
3132 }
3233
3334 filter ( event : any , serviceName : string ) {
34- console . log ( "Filter: " + serviceName + ": " + event . target . checked )
3535 if ( event . target . checked ) {
36- this . ds . getDeploymentList ( serviceName ) . subscribe ( ( data : DeploymentList ) => {
37- if ( data . deployments . length != 0 ) {
38- if ( this . filterActive ) {
39- // merge if filter is active
40- this . deployments = [ ...this . deployments , ...data . deployments ] ;
41- } else {
42- this . deployments = data . deployments
43- }
44- this . deployments . sort ( function ( a , b ) { return ( a [ "Time" ] > b [ "Time" ] ) ? - 1 : ( ( b [ "Time" ] > a [ "Time" ] ) ? 1 : 0 ) ; } ) ;
45- this . filterActive = true
46- }
47- } ) ;
36+ this . filterList . push ( serviceName )
4837 } else {
49- var newDeployments = [ ] ;
50- for ( let deployment of this . deployments ) {
51- if ( deployment [ "ServiceName" ] != serviceName ) {
52- newDeployments . push ( deployment )
53- }
54- }
55- if ( newDeployments . length != this . deployments . length ) {
56- this . deployments = newDeployments
57- }
58- if ( newDeployments . length == 0 ) {
59- this . filterActive = false
60- this . ds . getDeploymentList ( "" ) . subscribe ( ( data : DeploymentList ) => {
61- if ( data . deployments . length != 0 ) {
62- this . deployments = data . deployments
38+ this . filterList = this . filterList . filter ( a => a !== serviceName )
39+ }
40+
41+ this . ds . getDeploymentList ( serviceName ) . subscribe ( ( data : DeploymentList ) => {
42+ if ( data . deployments . length != 0 ) {
43+ this . deployments = data . deployments . filter ( ( deployment ) => {
44+ if ( this . filterList . length === 0 ) { return true }
45+ for ( var i = 0 ; i < this . filterList . length ; i ++ ) {
46+ if ( this . filterList [ i ] == deployment [ "ServiceName" ] ) {
47+ return true
48+ }
6349 }
64- } ) ;
50+ return false
51+ } )
6552 }
66- }
53+ } ) ;
6754 }
68-
6955}
0 commit comments