|
@@ -76,7 +76,7 @@ export default {
|
|
|
TopNavigationBar,
|
|
|
ProjectOpenWindow
|
|
|
},
|
|
|
- data: function() {
|
|
|
+ data: function () {
|
|
|
return {
|
|
|
connected: false,
|
|
|
socket: {
|
|
@@ -84,7 +84,7 @@ export default {
|
|
|
// initialize socket.io connection
|
|
|
io: io(window.location.protocol + '//' + window.location.hostname + ':5000'),
|
|
|
// http methods
|
|
|
- post: function(name, value) {
|
|
|
+ post: function (name, value) {
|
|
|
if (!name.startsWith('http'))
|
|
|
name = this.baseurl + name;
|
|
|
|
|
@@ -93,7 +93,7 @@ export default {
|
|
|
body: JSON.stringify(value)
|
|
|
});
|
|
|
},
|
|
|
- upload: function(name, file) {
|
|
|
+ upload: function (name, file) {
|
|
|
const form = new FormData();
|
|
|
form.append('file', file);
|
|
|
|
|
@@ -102,7 +102,7 @@ export default {
|
|
|
body: form
|
|
|
});
|
|
|
},
|
|
|
- media: function(projectId, fileId) {
|
|
|
+ media: function (projectId, fileId) {
|
|
|
return this.baseurl + '/projects/' + projectId + '/data/' + fileId;
|
|
|
}
|
|
|
},
|
|
@@ -116,13 +116,13 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- projects: function() {
|
|
|
+ projects: function () {
|
|
|
if (this.status == null)
|
|
|
return [];
|
|
|
|
|
|
return Object.keys(this.status.projects).map(key => this.status.projects[key]);
|
|
|
},
|
|
|
- currentProject: function() {
|
|
|
+ currentProject: function () {
|
|
|
for (let i = 0; i < this.projects.length; i++)
|
|
|
if (this.projects[i].id === this.window.project)
|
|
|
return this.projects[i];
|
|
@@ -131,25 +131,37 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- resize: function() {
|
|
|
+ resize: function () {
|
|
|
this.window.wide = (document.body.offsetWidth > 1024);
|
|
|
},
|
|
|
- show: function(value) {
|
|
|
+ show: function (value) {
|
|
|
this.window.content = value;
|
|
|
},
|
|
|
- openProject: function(project) {
|
|
|
+ openProject: function (project) {
|
|
|
this.window.project = project.id;
|
|
|
this.show('settings');
|
|
|
},
|
|
|
- closeProject: function() {
|
|
|
+ closeProject: function () {
|
|
|
this.window.project = null;
|
|
|
this.show('projects');
|
|
|
}
|
|
|
},
|
|
|
- created: function() {
|
|
|
- this.socket.io.on('app_status', status => {
|
|
|
- this.status = status;
|
|
|
- this.connected = true;
|
|
|
+ created: function () {
|
|
|
+ this.socket.io.on('app_status', data => {
|
|
|
+ if (data.keys.length === 0) {
|
|
|
+ this.status = data.value;
|
|
|
+ this.connected = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const last = data.keys.pop();
|
|
|
+ let target = this.status;
|
|
|
+
|
|
|
+ for (let key of data.keys) {
|
|
|
+ target = target[key];
|
|
|
+ }
|
|
|
+
|
|
|
+ target[last] = data.value;
|
|
|
});
|
|
|
|
|
|
setInterval(() => this.connected = this.socket.io.connected, 2000);
|
|
@@ -157,7 +169,7 @@ export default {
|
|
|
window.addEventListener('resize', this.resize);
|
|
|
this.resize();
|
|
|
},
|
|
|
- destroyed: function() {
|
|
|
+ destroyed: function () {
|
|
|
window.removeEventListener('resize', this.resize);
|
|
|
}
|
|
|
}
|