Revision db82ea7a

b/snf-cyclades-app/synnefo/ui/static/snf/js/glance_models.js
42 42
            return this.get('owner') || 'Unknown';
43 43
        },
44 44

  
45
        is_snapshot: function() {
46
          return this.get('checksum').indexOf('arch') === 0;
47
        },
45 48

  
46 49
        display_size: function() {
47 50
            return this.get_readable_size();
......
49 52

  
50 53
        display_users: function() {
51 54
            try {
52
              return this.get_meta('users').split(' ').join(", ");
55
              if (this.get_meta('users')) {
56
                return this.get_meta('users').split(' ').join(", ");
57
              } else {
58
                return "";
59
              }
53 60
            } catch(err) { console.log(err); return ''}
54 61
        }
55 62
        
......
61 68

  
62 69
        type_selections: {'personal':'My images', 
63 70
                          'shared': 'Shared with me', 
64
                          'public': 'Public'},
65
        type_selections_order: ['system', 'personal', 'shared', 'public'],
71
                          'public': 'Public',
72
                          'snapshot': 'Snapshots'},
73
        type_selections_order: ['system', 'personal', 'shared', 'public', 'snapshot'],
66 74
        display_metadata: ['size', 'users', 'osfamily', 'status', 'created_at', 'updated_at', 
67 75
            'filename', 'format', 'root_partition'],
68 76
        meta_labels: {'OS':'OS', 'osfamily':'OS Family', 'GUI':'GUI'},
......
115 123
            }
116 124

  
117 125
            img = models.GlanceImages.__super__.parse_meta.call(this, img);
126
            if (img.checksum && img.checksum.indexOf('arch') == 0) {
127
              img.OS = 'snapshot';
128
              img.metadata.OS = 'snapshot';
129
            }
118 130
            return img;
119 131
        },
120 132

  
133
        active: function() {
134
            return this.filter(function(img) {
135
              return img.get('status') != "DELETED" && !img.is_snapshot()
136
            });
137
        },
138

  
139
        active_snapshots: function() {
140
            return this.filter(function(img) {
141
              return img.get('status') != "DELETED" && img.is_snapshot()
142
            });
143
        },
144

  
121 145
        get_system_images: function() {
122 146
            return _.filter(this.active(), function(i) { 
123 147
                return _.include(_.keys(snf.config.system_images_owners), 
......
142 166
                               i.get_owner_uuid() != snf.user.get_username() &&
143 167
                               !i.is_public();
144 168
            });
145
        }
169
        },
170

  
171
        get_snapshot_images: function() {
172
            return this.active_snapshots()
173
        },
146 174

  
147 175
    })
148 176
        

Also available in: Unified diff