diff --git a/config_example.conf b/config_example.conf
index 94cdea6..fdab046 100644
--- a/config_example.conf
+++ b/config_example.conf
@@ -3,7 +3,7 @@ answer = false
[database]
type = "sqlite3"
logging = true
-connection = "file:/tmp/wifictld.db"
+connection = "/tmp/wifictld.db"
# For Master-Slave cluster
# read_connection = ""
diff --git a/webroot/index.html b/webroot/index.html
index 8da7da1..478f11d 100644
--- a/webroot/index.html
+++ b/webroot/index.html
@@ -10,6 +10,7 @@
+
@@ -40,6 +41,7 @@
+
diff --git a/webroot/js/data.js b/webroot/js/data.js
index 988fc27..40e7b61 100644
--- a/webroot/js/data.js
+++ b/webroot/js/data.js
@@ -18,3 +18,15 @@ store.commit('setEvent', {
state.controller.clients[client.addr] = client;
}
})
+
+VueNativeSock.default.install(Vue, `//${location.host}${location.pathname}ws`, {
+ store: store,
+ reconnection: true,
+ reconnectionDelay: 5000,
+ format: 'json',
+})
+
+
+getJSON(`//${location.host}${location.pathname}data.json`).then(function(data){
+ store.commit('initData',data);
+})
diff --git a/webroot/js/main.js b/webroot/js/main.js
index 1372596..20694f5 100644
--- a/webroot/js/main.js
+++ b/webroot/js/main.js
@@ -1,32 +1,3 @@
-const router = new VueRouter({
- store,
- routes: [
- { path: '/ap', component: ViewAccessPoints, name: "aps" },
- { path: '/ap/clients/:ip', component: ViewClients, name: "ap.clients"},
- { path: '/clients', component: ViewClients, name: "clients" },
- { path: '/', redirect: '/ap' }
- ]
-})
-
-VueNativeSock.default.install(Vue, `//${location.host}${location.pathname}ws`, {
- store: store,
- reconnection: true,
- reconnectionDelay: 5000,
- format: 'json',
-})
-
-const NavbarLogo = {
- template: `
`,
- computed: {
- isOnline () {
- return this.$store.state.socket.isConnected
- }
- }
-};
-
-
const app = new Vue({
el: '#app',
store,
diff --git a/webroot/js/store.js b/webroot/js/store.js
index 78d2520..2005097 100644
--- a/webroot/js/store.js
+++ b/webroot/js/store.js
@@ -99,6 +99,20 @@ const store = new Vuex.Store({
state.socket.eventMSGID[data.msg.id] = data.callback;
}
return ret;
+ },
+ initData (state, data) {
+ data.aps.forEach((ap) => {
+ if(state.controller._ap[ap.ip] === undefined){
+ state.controller.ap.push(ap.ip)
+ state.controller._ap[ap.ip] = null;
+ }
+ })
+ data.clients.forEach((client) => {
+ if (state.controller.clients[client.addr] === undefined) {
+ state.controller._clients.push(client.addr)
+ }
+ state.controller.clients[client.addr] = client;
+ })
}
}
})
diff --git a/webroot/js/utils.js b/webroot/js/utils.js
new file mode 100644
index 0000000..c1b1189
--- /dev/null
+++ b/webroot/js/utils.js
@@ -0,0 +1,23 @@
+function get(url) {
+ return new Promise(function (resolve, reject) {
+ var req = new XMLHttpRequest();
+ req.open('GET', url);
+
+ req.onload = function onload() {
+ if (req.status === 200) {
+ resolve(req.response);
+ } else {
+ reject(Error(req.statusText));
+ }
+ };
+
+ req.onerror = function onerror() {
+ reject(Error('Network Error'));
+ };
+
+ req.send();
+ });
+}
+function getJSON(url) {
+ return get(url).then(JSON.parse);
+}
diff --git a/webroot/js/view.js b/webroot/js/view.js
new file mode 100644
index 0000000..e08ac14
--- /dev/null
+++ b/webroot/js/view.js
@@ -0,0 +1,21 @@
+const NavbarLogo = {
+ template: `
`,
+ computed: {
+ isOnline () {
+ return this.$store.state.socket.isConnected
+ }
+ }
+};
+
+
+const router = new VueRouter({
+ store,
+ routes: [
+ { path: '/ap', component: ViewAccessPoints, name: "aps" },
+ { path: '/ap/clients/:ip', component: ViewClients, name: "ap.clients"},
+ { path: '/clients', component: ViewClients, name: "clients" },
+ { path: '/', redirect: '/ap' }
+ ]
+})