u
This commit is contained in:
@@ -14,6 +14,7 @@ class CooperationMindLogLib(object):
|
|||||||
if self.should_handle(json_msg):
|
if self.should_handle(json_msg):
|
||||||
# 避免json解析失败
|
# 避免json解析失败
|
||||||
json_msg = json_msg.replace(',null]', ']')
|
json_msg = json_msg.replace(',null]', ']')
|
||||||
|
print(json_msg)
|
||||||
json_msg_dict = ast.literal_eval(json_msg)
|
json_msg_dict = ast.literal_eval(json_msg)
|
||||||
|
|
||||||
log = CooperationMindLog(
|
log = CooperationMindLog(
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ class ChatConsumer(WebsocketConsumer):
|
|||||||
# Receive message from WebSocket
|
# Receive message from WebSocket
|
||||||
def receive(self, text_data):
|
def receive(self, text_data):
|
||||||
# Send message to room group
|
# Send message to room group
|
||||||
print(text_data)
|
|
||||||
log_dict = self.log_lib.save_log(text_data)
|
log_dict = self.log_lib.save_log(text_data)
|
||||||
async_to_sync(self.channel_layer.group_send)(
|
async_to_sync(self.channel_layer.group_send)(
|
||||||
self.room_group_name,
|
self.room_group_name,
|
||||||
|
|||||||
@@ -123,7 +123,22 @@
|
|||||||
if (client_id === this.client_id) {
|
if (client_id === this.client_id) {
|
||||||
console.log('self msg')
|
console.log('self msg')
|
||||||
} else {
|
} else {
|
||||||
|
const evt = msg_json.evt
|
||||||
|
const data_array = msg_json.data
|
||||||
|
// console.log(msg_json)
|
||||||
|
if ('add_node' === evt) {
|
||||||
|
this._jm.add_node(data_array[0], data_array[1], data_array[2], null, true)
|
||||||
|
} else if ('insert_node_before' === evt) {
|
||||||
|
this._jm.insert_node_before(data_array[0], data_array[1], data_array[2], null, true)
|
||||||
|
} else if ('insert_node_after' === evt) {
|
||||||
|
this._jm.insert_node_after(data_array[0], data_array[1], data_array[2], null, true)
|
||||||
|
} else if ('remove_node' === evt) {
|
||||||
|
this._jm.remove_node(data_array[0], true)
|
||||||
|
} else if ('update_node' === evt) {
|
||||||
|
this._jm.update_node(data_array[0], data_array[1], true)
|
||||||
|
} else if ('move_node' === evt) {
|
||||||
|
this._jm.move_node(data_array[0], data_array[1], data_array[2], data_array[3], true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
+19
-9
@@ -1373,7 +1373,7 @@
|
|||||||
return this.mind.get_node(nodeid);
|
return this.mind.get_node(nodeid);
|
||||||
},
|
},
|
||||||
|
|
||||||
add_node: function (parent_node, nodeid, topic, data) {
|
add_node: function (parent_node, nodeid, topic, data, stop_invoke_event) {
|
||||||
if (this.get_editable()) {
|
if (this.get_editable()) {
|
||||||
var node = this.mind.add_node(parent_node, nodeid, topic, data);
|
var node = this.mind.add_node(parent_node, nodeid, topic, data);
|
||||||
if (!!node) {
|
if (!!node) {
|
||||||
@@ -1382,12 +1382,14 @@
|
|||||||
this.view.show(false);
|
this.view.show(false);
|
||||||
this.view.reset_node_custom_style(node);
|
this.view.reset_node_custom_style(node);
|
||||||
this.expand_node(parent_node);
|
this.expand_node(parent_node);
|
||||||
|
if (!stop_invoke_event) {
|
||||||
this.invoke_event_handle(jm.event_type.edit, {
|
this.invoke_event_handle(jm.event_type.edit, {
|
||||||
evt: 'add_node',
|
evt: 'add_node',
|
||||||
data: [parent_node.id, nodeid, topic, data],
|
data: [node.parent.id, nodeid, topic, data],
|
||||||
node: nodeid
|
node: nodeid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return node;
|
return node;
|
||||||
} else {
|
} else {
|
||||||
logger.error('fail, this mind map is not editable');
|
logger.error('fail, this mind map is not editable');
|
||||||
@@ -1395,7 +1397,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
insert_node_before: function (node_before, nodeid, topic, data) {
|
insert_node_before: function (node_before, nodeid, topic, data, stop_invoke_event) {
|
||||||
if (this.get_editable()) {
|
if (this.get_editable()) {
|
||||||
var beforeid = jm.util.is_node(node_before) ? node_before.id : node_before;
|
var beforeid = jm.util.is_node(node_before) ? node_before.id : node_before;
|
||||||
var node = this.mind.insert_node_before(node_before, nodeid, topic, data);
|
var node = this.mind.insert_node_before(node_before, nodeid, topic, data);
|
||||||
@@ -1403,12 +1405,14 @@
|
|||||||
this.view.add_node(node);
|
this.view.add_node(node);
|
||||||
this.layout.layout();
|
this.layout.layout();
|
||||||
this.view.show(false);
|
this.view.show(false);
|
||||||
|
if (!stop_invoke_event) {
|
||||||
this.invoke_event_handle(jm.event_type.edit, {
|
this.invoke_event_handle(jm.event_type.edit, {
|
||||||
evt: 'insert_node_before',
|
evt: 'insert_node_before',
|
||||||
data: [beforeid, nodeid, topic, data],
|
data: [beforeid, nodeid, topic, data],
|
||||||
node: nodeid
|
node: nodeid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return node;
|
return node;
|
||||||
} else {
|
} else {
|
||||||
logger.error('fail, this mind map is not editable');
|
logger.error('fail, this mind map is not editable');
|
||||||
@@ -1416,7 +1420,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
insert_node_after: function (node_after, nodeid, topic, data) {
|
insert_node_after: function (node_after, nodeid, topic, data, stop_invoke_event) {
|
||||||
if (this.get_editable()) {
|
if (this.get_editable()) {
|
||||||
var afterid = jm.util.is_node(node_after) ? node_after.id : node_after;
|
var afterid = jm.util.is_node(node_after) ? node_after.id : node_after;
|
||||||
var node = this.mind.insert_node_after(node_after, nodeid, topic, data);
|
var node = this.mind.insert_node_after(node_after, nodeid, topic, data);
|
||||||
@@ -1424,12 +1428,14 @@
|
|||||||
this.view.add_node(node);
|
this.view.add_node(node);
|
||||||
this.layout.layout();
|
this.layout.layout();
|
||||||
this.view.show(false);
|
this.view.show(false);
|
||||||
|
if (!stop_invoke_event) {
|
||||||
this.invoke_event_handle(jm.event_type.edit, {
|
this.invoke_event_handle(jm.event_type.edit, {
|
||||||
evt: 'insert_node_after',
|
evt: 'insert_node_after',
|
||||||
data: [afterid, nodeid, topic, data],
|
data: [afterid, nodeid, topic, data],
|
||||||
node: nodeid
|
node: nodeid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return node;
|
return node;
|
||||||
} else {
|
} else {
|
||||||
logger.error('fail, this mind map is not editable');
|
logger.error('fail, this mind map is not editable');
|
||||||
@@ -1437,7 +1443,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
remove_node: function (node) {
|
remove_node: function (node, stop_invoke_event) {
|
||||||
if (!jm.util.is_node(node)) {
|
if (!jm.util.is_node(node)) {
|
||||||
var the_node = this.get_node(node);
|
var the_node = this.get_node(node);
|
||||||
if (!the_node) {
|
if (!the_node) {
|
||||||
@@ -1461,7 +1467,9 @@
|
|||||||
this.layout.layout();
|
this.layout.layout();
|
||||||
this.view.show(false);
|
this.view.show(false);
|
||||||
this.view.restore_location(parent_node);
|
this.view.restore_location(parent_node);
|
||||||
|
if (!stop_invoke_event) {
|
||||||
this.invoke_event_handle(jm.event_type.edit, {evt: 'remove_node', data: [nodeid], node: parentid});
|
this.invoke_event_handle(jm.event_type.edit, {evt: 'remove_node', data: [nodeid], node: parentid});
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
logger.error('fail, this mind map is not editable');
|
logger.error('fail, this mind map is not editable');
|
||||||
@@ -1469,7 +1477,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
update_node: function (nodeid, topic) {
|
update_node: function (nodeid, topic, stop_invoke_event) {
|
||||||
if (this.get_editable()) {
|
if (this.get_editable()) {
|
||||||
if (jm.util.text.is_empty(topic)) {
|
if (jm.util.text.is_empty(topic)) {
|
||||||
logger.warn('fail, topic can not be empty');
|
logger.warn('fail, topic can not be empty');
|
||||||
@@ -1484,7 +1492,6 @@
|
|||||||
}
|
}
|
||||||
node.topic = topic;
|
node.topic = topic;
|
||||||
|
|
||||||
|
|
||||||
this.auto_height_node_before_update(node)
|
this.auto_height_node_before_update(node)
|
||||||
|
|
||||||
this.view.update_node(node);
|
this.view.update_node(node);
|
||||||
@@ -1493,13 +1500,14 @@
|
|||||||
|
|
||||||
this.view.show(false);
|
this.view.show(false);
|
||||||
|
|
||||||
|
if (!stop_invoke_event) {
|
||||||
this.invoke_event_handle(jm.event_type.edit, {
|
this.invoke_event_handle(jm.event_type.edit, {
|
||||||
evt: 'update_node',
|
evt: 'update_node',
|
||||||
data: [nodeid, topic],
|
data: [nodeid, topic],
|
||||||
node: nodeid
|
node: nodeid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.error('fail, this mind map is not editable');
|
logger.error('fail, this mind map is not editable');
|
||||||
return;
|
return;
|
||||||
@@ -1516,19 +1524,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
move_node: function (nodeid, beforeid, parentid, direction) {
|
move_node: function (nodeid, beforeid, parentid, direction, stop_invoke_event) {
|
||||||
if (this.get_editable()) {
|
if (this.get_editable()) {
|
||||||
var node = this.mind.move_node(nodeid, beforeid, parentid, direction);
|
var node = this.mind.move_node(nodeid, beforeid, parentid, direction);
|
||||||
if (!!node) {
|
if (!!node) {
|
||||||
this.view.update_node(node);
|
this.view.update_node(node);
|
||||||
this.layout.layout();
|
this.layout.layout();
|
||||||
this.view.show(false);
|
this.view.show(false);
|
||||||
|
if (!stop_invoke_event) {
|
||||||
this.invoke_event_handle(jm.event_type.edit, {
|
this.invoke_event_handle(jm.event_type.edit, {
|
||||||
evt: 'move_node',
|
evt: 'move_node',
|
||||||
data: [nodeid, beforeid, parentid, direction],
|
data: [nodeid, beforeid, parentid, direction],
|
||||||
node: nodeid
|
node: nodeid
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.error('fail, this mind map is not editable');
|
logger.error('fail, this mind map is not editable');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user