Revision 2c9bfad1 ui/static/snf/js/models.js

b/ui/static/snf/js/models.js
44 44
                if (this.collection) {
45 45
                    try { this.clear_pending_action();} catch (err) {};
46 46
                    try { this.reset_pending_actions();} catch (err) {};
47
                    try { this.stop_stats_update();} catch (err) {};
47 48
                    this.collection.remove(this.id);
48 49
                }
49 50
            }
......
571 572
            return {'progress': progress, 'size': size, 'copy': size_copied};
572 573
        },
573 574

  
575
        start_stats_update: function() {
576
            var prev_state = this.do_update_stats;
577

  
578
            this.do_update_stats = true;
579

  
580
            // fetcher initialized ??
581
            if (!this.stats_fetcher) {
582
                this.init_stats_intervals();
583
            }
584

  
585
            // fetcher running ???
586
            if (!this.stats_fetcher.running || !prev_state) {
587
                this.stats_fetcher.start();
588
            }
589
        },
590

  
591
        stop_stats_update: function(stop_calls) {
592
            this.do_update_stats = false;
593

  
594
            if (stop_calls) {
595
                this.stats_fetcher.stop();
596
            }
597
        },
598

  
574 599
        // clear and reinitialize update interval
575 600
        init_stats_intervals: function (interval) {
576 601
            this.stats_fetcher = this.get_stats_fetcher(this.stats_update_interval);
577 602
            this.stats_fetcher.start();
578
            this.update_stats(true);
579 603
        },
580 604
        
581 605
        get_stats_fetcher: function(timeout) {
......
683 707
                this.stats_update_interval = data.stats.refresh * 1000;
684 708
                this.stats_fetcher.timeout = this.stats_update_interval;
685 709
                this.stats_fetcher.stop();
686
                this.stats_fetcher.start();
710
                this.stats_fetcher.start(false);
687 711
            }
688 712
        },
689 713

  
......
1356 1380
                vm.clear_pending_action();
1357 1381
            })
1358 1382
        },
1359

  
1360
        stop_stats_update: function() {
1383
        
1384
        stop_stats_update: function(exclude) {
1385
            var exclude = exclude || [];
1361 1386
            this.each(function(vm) {
1362
                vm.do_update_stats = false;
1387
                if (exclude.indexOf(vm) > -1) {
1388
                    return;
1389
                }
1390
                vm.stop_stats_update();
1363 1391
            })
1364 1392
        },
1365 1393
        

Also available in: Unified diff