Revision e4330db2

b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
1347 1347
            }
1348 1348
            return synnefo.config.ui_console_url + '?' + $.param(url_params);
1349 1349
        },
1350
      
1350
        
1351
        set_firewall: function(nic, value, success_cb, error_cb) {
1352
          var success = function() { success_cb() }
1353
          var error = function() { error_cb() }
1354
          var data = {'nic': nic.id, 'profile': value, 'display': true};
1355
          var url = this.url() + "/action";
1356
          //var params = {skip_api_error: false, display: true};
1357
          this.call('firewallProfile', success, error, data);
1358
        },
1359

  
1351 1360
        connect_floating_ip: function(ip, cb) {
1352 1361
          this.set({'status': 'CONNECTING'});
1353 1362
          synnefo.storage.ports.create({
......
1452 1461
                                         },  
1453 1462
                                         error, 'destroy', params);
1454 1463
                    break;
1464
                case 'firewallProfile':
1465
                    this.__make_api_call(this.get_action_url(), // vm actions url
1466
                                         "create",
1467
                                         {firewallProfile:{nic:params.nic, profile:params.profile}}, // payload
1468
                                         function() {
1469
                                             success.apply(this, arguments);
1470
                                             snf.api.trigger("call");
1471
                                         },  
1472
                                         error, 'start', params);
1473
                    break;
1455 1474
                default:
1456 1475
                    throw "Invalid VM action ("+action_name+")";
1457 1476
            }
b/snf-cyclades-app/synnefo/ui/static/snf/js/neutron.js
399 399
        ],
400 400
      },
401 401

  
402
      set_firewall: function(value, callback, error, options) {
403
        // MOCK CALL
404
        window.setTimeout(_.bind(function() {
405
          var vm = this.get('vm');
406
          var attachments = [];
407
          attachments.push({id: this.id, firewallProfile: value});
408
          vm.set({attachments: attachments});
409
        }, this),  2000);
410
        window.setTimeout(_.bind(function() {
411
          callback();
412
        }), 300);
413
      },
414

  
415 402
      disconnect: function(cb) {
416 403
        var network = this.get('network');
417 404
        var vm = this.get('vm');
b/snf-cyclades-app/synnefo/ui/static/snf/js/sync.js
107 107
    // appends global ajax handlers
108 108
    // handles changed-since url parameter based on api path
109 109
    api.sync = function(method, model, options) {
110

  
110
        
111 111
        var type = methodMap[method];
112 112
        
113 113
        if (model && (model.skipMethods || []).indexOf(method) >= 0) {
b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_networks_view.js
332 332
      set_firewall: function() {
333 333
        var value = this.get_selected_value();
334 334
        this.firewall_apply.addClass("in-progress");
335
        var vm = this.model.get('vm');
336
        if (!vm) { return }
335 337
        this.model.set({'pending_firewall': value});
336
        this.model.set_firewall(value, this.set_firewall_complete, 
337
                                       this.set_firewall_complete);
338
        vm.set_firewall(this.model, value, this.set_firewall_success,
339
                        this.set_firewall_error)
338 340
        this.in_progress = true;
339 341
      },
340 342
      
343
      set_firewall_success: function() {
344
        this.set_firewall_complete();
345
      },
346

  
347
      set_firewall_error: function() {
348
        this.model.set({'pending_firewall': undefined});
349
        this.set_firewall_complete();
350
      },
351

  
341 352
      set_firewall_complete: function() {
342 353
        this.in_progress = false;
343 354
        this.toggle_firewall({}, false, _.bind(function() {
......
945 956
          complete: function() {
946 957
            synnefo.storage.quotas.fetch();
947 958
            self.reset_creating();
948
          },
949
          skip_api_error: true
959
          }
950 960
        });
951 961
      },
952 962
      

Also available in: Unified diff