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