Revision 365af933 snf-cyclades-app/synnefo/ui/static/snf/js/neutron.js

b/snf-cyclades-app/synnefo/ui/static/snf/js/neutron.js
262 262
        return this.api_call(this.path, "create", params, complete, error, success);
263 263
      }
264 264
    });
265
    
266
    // dummy model/collection
267
    models.FixedIP = models.NetworkModel.extend({
268
      storage_attrs: {
269
        'subnet_id': ['subnets', 'subnet']
270
      }
271
    });
272
    models.FixedIPs = models.NetworkCollection.extend({
273
      model: models.FixedIP
274
    });
265 275

  
266 276
    models.Port = models.NetworkModel.extend({
267
      
268 277
      path: 'ports',
269

  
270 278
      initialize: function() {
271 279
        models.Port.__super__.initialize.apply(this, arguments);
280
        var ips = new models.FixedIPs();
281
        this.set({'ips': ips});
282
        this.bind('change:fixed_ips', function() {
283
          var ips = this.get('ips');
284
          //var ips = _.map(ips, function(ip) { ip.id = ip.a})
285
          this.update_ips()
286
        }, this);
287
        this.update_ips();
272 288
        this.set({'pending_firewall': null});
273 289
      },
274 290
      
291
      update_ips: function() {
292
        var ips = _.map(this.get('fixed_ips'), function(ip) {
293
          var type = "v4";
294
          if (ip.ip_address.indexOf(":") >= 0) {
295
            type = "v6";
296
          }
297
          ip.id = ip.ip_address;
298
          ip.type = type;
299
          ip.subnet_id = ip.subnet;
300
          delete ip.subnet;
301
          return ip;
302
        });
303
        this.get('ips').update(ips, {removeMissing: true});
304
      },
305

  
275 306
      model_actions: {
276 307
        'disconnect': [['status', 'network', 'vm'], function() {
277 308
          var network = this.get('network');
......
298 329
            return attachment.firewallProfile
299 330
          } 
300 331
        ],
301

  
332
        
302 333
        'firewall_running': [
303 334
          ['firewall_status', 'pending_firewall'], function(status, pending) {
304 335
              var pending = this.get('pending_firewall');

Also available in: Unified diff