luci2: fix session heartbeat and serialization of cbi section creations
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 17 Sep 2013 17:01:06 +0000 (19:01 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 17 Sep 2013 17:01:06 +0000 (19:01 +0200)
luci2/htdocs/luci2/luci2.js

index a074b44..cdc7c4f 100644 (file)
@@ -1429,7 +1429,7 @@ function LuCI2()
                startHeartbeat: function()
                {
                        this._hearbeatInterval = window.setInterval(function() {
                startHeartbeat: function()
                {
                        this._hearbeatInterval = window.setInterval(function() {
-                               _luci2.session.isAlive(function(alive) {
+                               _luci2.session.isAlive().then(function(alive) {
                                        if (!alive)
                                        {
                                                _luci2.session.stopHeartbeat();
                                        if (!alive)
                                        {
                                                _luci2.session.stopHeartbeat();
@@ -1443,7 +1443,10 @@ function LuCI2()
                stopHeartbeat: function()
                {
                        if (typeof(this._hearbeatInterval) != 'undefined')
                stopHeartbeat: function()
                {
                        if (typeof(this._hearbeatInterval) != 'undefined')
+                       {
                                window.clearInterval(this._hearbeatInterval);
                                window.clearInterval(this._hearbeatInterval);
+                               delete this._hearbeatInterval;
+                       }
                }
        };
 
                }
        };
 
@@ -1759,6 +1762,7 @@ function LuCI2()
                                _luci2.session.isAlive().then(function(access) {
                                        if (access)
                                        {
                                _luci2.session.isAlive().then(function(access) {
                                        if (access)
                                        {
+                                               _luci2.session.startHeartbeat();
                                                _luci2._login_deferred.resolve();
                                        }
                                        else
                                                _luci2._login_deferred.resolve();
                                        }
                                        else
@@ -5296,11 +5300,11 @@ function LuCI2()
                                                        for (var k in this.uci.creates[c][s])
                                                        {
                                                                if (k == '.type')
                                                        for (var k in this.uci.creates[c][s])
                                                        {
                                                                if (k == '.type')
-                                                                       r.type = this.uci.creates[i][k];
+                                                                       r.type = this.uci.creates[c][s][k];
                                                                else if (k == '.create')
                                                                else if (k == '.create')
-                                                                       r.name = this.uci.creates[i][k];
+                                                                       r.name = this.uci.creates[c][s][k];
                                                                else if (k.charAt(0) != '.')
                                                                else if (k.charAt(0) != '.')
-                                                                       r.values[k] = this.uci.creates[i][k];
+                                                                       r.values[k] = this.uci.creates[c][s][k];
                                                        }
 
                                                        _luci2.uci.add(r.config, r.type, r.name, r.values);
                                                        }
 
                                                        _luci2.uci.add(r.config, r.type, r.name, r.values);