Revision 3b463c5a snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js

b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js
531 531
            }, this));
532 532

  
533 533
            this.predefined = this.$(".predefined-list");
534
            this.update_predefined_flavors();
535 534
        },
536 535

  
537 536
        handle_image_change: function(data) {
......
539 538
            this.update_valid_predefined();
540 539
            this.current_flavor = undefined;
541 540
            this.update_flavors_data();
541
            this.update_predefined_flavors();
542 542
            this.reset_flavors();
543 543
            this.update_layout();
544 544
        },
......
578 578
        select_valid_flavor: function() {
579 579
            var found = false;
580 580
            var self = this;
581

  
582
            _.each(["cpu", "mem", "disk"], function(t) {
583
              var el = $(".flavor-options."+t);
584
              var all = el.find(".flavor-opts-list li").length;
585
              var disabled = el.find(".flavor-opts-list li.disabled").length;
586
              if (disabled >= all) {
587
                el.find("h4").addClass("error");
588
              } else {
589
                el.find("h4").removeClass("error");
590
              }
591
            })
592

  
581 593
            _.each(this.flavors, function(flv) {
582 594
                if (self.flavor_is_valid(flv)) {
583 595
                    found = flv;
......
925 937
            this.update_disabled_flavors();
926 938
            this.validate();
927 939
            this.validate_selected_flavor();
940
            this.update_quota_display();
941
        },
942
        
943
        update_quota_display: function() {
944
          if (!snf.user.quota || !snf.user.quota.data) { return };
945

  
946
          _.each(["disk", "ram", "cpu"], function(type) {
947
            var available_dsp = snf.user.quota.get_available_readable(type);
948
            var available = snf.user.quota.get_available(type);
949
            var content = "({0} left)".format(available_dsp);
950
            if (available <= 0) { content = "(None left)" }
951
            
952
            if (type == "ram") { type = "mem" }
953
            $(".flavor-options."+type+" h4 .available").text(content);
954
            if (available <= 0) {
955
              $(".flavor-options."+type+" h4 .available").addClass("error");
956
            } else {
957
              $(".flavor-options."+type+" h4 .available").removeClass("error");
958
            }
959
          })
928 960
        },
929 961

  
930 962
        reset: function() {

Also available in: Unified diff