update
This commit is contained in:
@@ -22,7 +22,7 @@ class CooperationMindLogLib(object):
|
|||||||
coop_mind_id=json_msg_dict.get('coop_mind_id'),
|
coop_mind_id=json_msg_dict.get('coop_mind_id'),
|
||||||
log_uuid=json_msg_dict.get('log_uuid'),
|
log_uuid=json_msg_dict.get('log_uuid'),
|
||||||
log_content=json_msg,
|
log_content=json_msg,
|
||||||
client_id=json_msg_dict.get('client_id')
|
client_uuid=json_msg_dict.get('client_uuid')
|
||||||
)
|
)
|
||||||
log.save()
|
log.save()
|
||||||
return CooperationMindLogSerializer(log).data
|
return CooperationMindLogSerializer(log).data
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ class CooperationMind(AbstractModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
"""
|
"""
|
||||||
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=64, null=False, blank=False)
|
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False)
|
||||||
creator_user_id = models.BigIntegerField(verbose_name='创建人ID', null=False, blank=False, default=0)
|
creator_user_id = models.BigIntegerField(verbose_name='创建人ID', null=False, blank=False, default=0)
|
||||||
client_uuid = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
client_uuid = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
||||||
snapshot_data = models.TextField(verbose_name='脑图数据', null=True, )
|
snapshot_data = models.TextField(verbose_name='脑图数据', null=True, )
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class JsMindLogView(APIView):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
post_body = request.POST
|
post_body = request.POST
|
||||||
client_uuid = post_body.get('client_id')
|
client_uuid = post_body.get('client_uuid')
|
||||||
type = post_body.get('type')
|
type = post_body.get('type')
|
||||||
if 'snapshot' == type:
|
if 'snapshot' == type:
|
||||||
# 保存快照
|
# 保存快照
|
||||||
|
|||||||
+37
-30
@@ -66,6 +66,7 @@
|
|||||||
if (!page_size) {
|
if (!page_size) {
|
||||||
page_size = me.default_page_size
|
page_size = me.default_page_size
|
||||||
}
|
}
|
||||||
|
me.current_page_num = current_page
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: `get`,
|
type: `get`,
|
||||||
url: `list?page=${current_page}&page_size=${page_size}`,
|
url: `list?page=${current_page}&page_size=${page_size}`,
|
||||||
@@ -85,32 +86,22 @@
|
|||||||
results.forEach(function (item) {
|
results.forEach(function (item) {
|
||||||
const uuid = me.get_uu_id()
|
const uuid = me.get_uu_id()
|
||||||
const content = `
|
const content = `
|
||||||
<div class="card col-3" style="margin: 6px;" id='card_${uuid}'>
|
<div class="card col-3" style="margin: 6px;margin-left: 20px;" id='card_${uuid}'>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">${item.coop_mind_name}</h5>
|
<div class="card-title" style="margin-bottom: 0px;text-overflow:ellipsis;font-weight:bold;line-height: 1rem">${item.coop_mind_name}</div>
|
||||||
<img src="https://img0.baidu.com/it/u=218959243,558802769&fm=253&fmt=auto&app=138&f=JPEG" class="card-img-top" style="height: 100px;">
|
<hr style="margin: 0">
|
||||||
|
<div style="height: 80px;"></div>
|
||||||
<div style="text-align:right;">
|
<div style="text-align:right;">
|
||||||
<a href="#" class="btn btn-info" onclick="window.open('detail?id=${item.id}')">编辑</a>
|
<a href="#" class="btn btn-info" onclick="window.open('detail?id=${item.id}')">编辑</a>
|
||||||
<a href="#" class="btn btn-info" onclick="del_mind(${item.id},'card_${uuid}')">删除</a>
|
<a href="#" class="btn btn-info" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>`
|
||||||
`
|
|
||||||
row.append(content)
|
row.append(content)
|
||||||
idx++
|
|
||||||
if (idx % 3 === 0) {
|
|
||||||
// 3个一行
|
|
||||||
$('main .container-fluid').append(row)
|
|
||||||
// 重置row
|
|
||||||
row = $(`<div class="row"></row>`)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 如果不是3的整数倍,将剩余的添加
|
// 如果不是3的整数倍,将剩余的添加
|
||||||
if (idx % 3 !== 0) {
|
|
||||||
$('main .container-fluid').append(row)
|
$('main .container-fluid').append(row)
|
||||||
}
|
|
||||||
|
|
||||||
me.init_pagination(resp.count, me.default_page_size)
|
me.init_pagination(resp.count, me.default_page_size)
|
||||||
// success end
|
// success end
|
||||||
},
|
},
|
||||||
@@ -119,19 +110,22 @@
|
|||||||
},
|
},
|
||||||
/**分页组件*/
|
/**分页组件*/
|
||||||
init_pagination: function (count, page_size) {
|
init_pagination: function (count, page_size) {
|
||||||
const all_page = (count > page_size && count % page_size > 0) ? (count % page_size) + 1 : count % page_size
|
/**计算页数*/
|
||||||
|
console.log(Math.floor(count / page_size))
|
||||||
|
|
||||||
|
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
|
||||||
const container = $('#pagination_div')
|
const container = $('#pagination_div')
|
||||||
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
|
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
|
||||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||||
|
|
||||||
if (this.current_page_num > 1) {
|
if (this.current_page_num > 1) {
|
||||||
navigation_ul.append(`<li class="page-item disabled"><a class="page-link">上一页</a></li>`)
|
navigation_ul.append(`<li class="page-item disabled"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num-1)">上一页</a></li>`)
|
||||||
}
|
}
|
||||||
for (let i = 0; i < all_page; i++) {
|
for (let i = 0; i < all_page; i++) {
|
||||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="#">${i + 1}</a></li>`)
|
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(${i + 1})">${i + 1}</a></li>`)
|
||||||
}
|
}
|
||||||
if (this.current_page_num < all_page) {
|
if (this.current_page_num < all_page) {
|
||||||
navigation_ul.append(`<li class="page-item"><a class="page-link" href="#">下一页</a></li>`)
|
navigation_ul.append(`<li class="page-item"><a class="page-link" href="javascript:void(0)" onclick="mind.fetch_mind(mind.current_page_num+1)">下一页</a></li>`)
|
||||||
}
|
}
|
||||||
navigation.append(navigation_ul)
|
navigation.append(navigation_ul)
|
||||||
container.empty()
|
container.empty()
|
||||||
@@ -306,11 +300,13 @@
|
|||||||
if (resp.code === 0) {
|
if (resp.code === 0) {
|
||||||
me.fetch_mind()
|
me.fetch_mind()
|
||||||
$('#newMindModal').modal('hide')
|
$('#newMindModal').modal('hide')
|
||||||
// 新页面打开
|
if ($('#exampleCheck1').prop("checked")) {
|
||||||
|
/**新页面打开*/
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
const id = resp.data
|
const id = resp.data
|
||||||
window.open('detail?id=' + id)
|
window.open('detail?id=' + id)
|
||||||
}, 500)
|
}, 500)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
common_alert(resp.msg)
|
common_alert(resp.msg)
|
||||||
}
|
}
|
||||||
@@ -318,8 +314,24 @@
|
|||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
/** 新建后打开复选框勾选事件*/
|
||||||
|
$('#exampleCheck1').change(function () {
|
||||||
|
const checked = $(this).prop("checked")
|
||||||
|
$.cookie('open_aft_create', checked, {expires: 7, path: '/'});
|
||||||
|
})
|
||||||
|
|
||||||
|
/** modal 显示完毕后事件*/
|
||||||
|
$('#newMindModal').on('shown.bs.modal', function () {
|
||||||
|
const cookie_checked_ = $.cookie('open_aft_create')
|
||||||
|
if (cookie_checked_) {
|
||||||
|
$('#exampleCheck1').attr('checked', 'checked')
|
||||||
|
} else {
|
||||||
|
$('#exampleCheck1').removeAttr('checked');
|
||||||
}
|
}
|
||||||
// prototype end
|
})
|
||||||
|
/************************************* jq_listener_init end *******************************************/
|
||||||
|
}
|
||||||
|
/** prototype end **/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -331,7 +343,7 @@
|
|||||||
|
|
||||||
/**如果已经登录则查询列表*/
|
/**如果已经登录则查询列表*/
|
||||||
view.fetch_mind()
|
view.fetch_mind()
|
||||||
window.mindView = view
|
window.mind = view
|
||||||
// js end
|
// js end
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -345,7 +357,7 @@
|
|||||||
<ul class="navbar-nav px-3">
|
<ul class="navbar-nav px-3">
|
||||||
<li class="nav-item text-nowrap">
|
<li class="nav-item text-nowrap">
|
||||||
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
<a id="login_register" class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
|
||||||
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mindView.logout_()" style="display: none;">注销</a>
|
<a id="logout_a" class="nav-link" href="javascript:void(0)" onclick="mind.logout_()" style="display: none;">注销</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -390,14 +402,10 @@
|
|||||||
|
|
||||||
<!-- 右侧内容 start-->
|
<!-- 右侧内容 start-->
|
||||||
<main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-md-4" id="main">
|
<main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-md-4" id="main">
|
||||||
|
|
||||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||||
<h1 class="h2">全部文件</h1>
|
<h5 class="h5">全部文件</h5>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#newMindModal">新建导图</button>
|
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#newMindModal">新建导图</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<!--
|
<!--
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -412,7 +420,6 @@
|
|||||||
-->
|
-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- navigation start-->
|
<!-- navigation start-->
|
||||||
<div id="pagination_div"></div>
|
<div id="pagination_div"></div>
|
||||||
<!-- navigation end-->
|
<!-- navigation end-->
|
||||||
|
|||||||
+10
-10
@@ -26,8 +26,8 @@
|
|||||||
coop_api_url: null,
|
coop_api_url: null,
|
||||||
// websocket 地址
|
// websocket 地址
|
||||||
coop_ws_url: null,
|
coop_ws_url: null,
|
||||||
// 标记当前客户端(同一个IP可能打开多个浏览器,需要用client_id区分)
|
// 标记当前客户端(同一个IP可能打开多个浏览器,需要用client_uuid区分)
|
||||||
client_id: null,
|
client_uuid: null,
|
||||||
// 当前脑图ID
|
// 当前脑图ID
|
||||||
coop_mind_id: null,
|
coop_mind_id: null,
|
||||||
// 上一次操作日志ID
|
// 上一次操作日志ID
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
},
|
},
|
||||||
_init_properties: function (_jm) {
|
_init_properties: function (_jm) {
|
||||||
// 设置属性
|
// 设置属性
|
||||||
this.client_id = Jm.util.uuid.newid()
|
this.client_uuid = Jm.util.uuid.newid()
|
||||||
this.coop_api_url = _jm.options.coop_api_url
|
this.coop_api_url = _jm.options.coop_api_url
|
||||||
this.coop_ws_url = _jm.options.coop_ws_url
|
this.coop_ws_url = _jm.options.coop_ws_url
|
||||||
this.coop_mind_id = _jm.options.coop_mind_id
|
this.coop_mind_id = _jm.options.coop_mind_id
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
* 构建公共参数
|
* 构建公共参数
|
||||||
*/
|
*/
|
||||||
_build_evt_param: function () {
|
_build_evt_param: function () {
|
||||||
return {'client_id': this.client_id, 'log_uuid': Jm.util.uuid.newid(), 'coop_mind_id': this.coop_mind_id}
|
return {'client_uuid': this.client_uuid, 'log_uuid': Jm.util.uuid.newid(), 'coop_mind_id': this.coop_mind_id}
|
||||||
},
|
},
|
||||||
// 调用jsmind接口
|
// 调用jsmind接口
|
||||||
_handle_jsmind_with_ws_message: function (message) {
|
_handle_jsmind_with_ws_message: function (message) {
|
||||||
@@ -137,16 +137,16 @@
|
|||||||
// 处理消息广告方法
|
// 处理消息广告方法
|
||||||
_handle_msg_inner(msg_json, is_batch) {
|
_handle_msg_inner(msg_json, is_batch) {
|
||||||
|
|
||||||
// 校验 client_id
|
// 校验 client_uuid
|
||||||
const client_id = msg_json.client_id
|
const client_uuid = msg_json.client_uuid
|
||||||
if (!client_id) {
|
if (!client_uuid) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const log_content = JSON.parse(msg_json.log_content)
|
const log_content = JSON.parse(msg_json.log_content)
|
||||||
const log_id = msg_json.id
|
const log_id = msg_json.id
|
||||||
if (log_id > this.coop_mind_log_id) {
|
if (log_id > this.coop_mind_log_id) {
|
||||||
// 第一次批量获得日志和被动接收日志,设置coop_mind_log_last_id和coop_mind_log_id 相同,不进行批量保存快照
|
// 第一次批量获得日志和被动接收日志,设置coop_mind_log_last_id和coop_mind_log_id 相同,不进行批量保存快照
|
||||||
if (is_batch || client_id !== this.client_id) {
|
if (is_batch || client_uuid !== this.client_uuid) {
|
||||||
this.coop_mind_log_last_id = log_id
|
this.coop_mind_log_last_id = log_id
|
||||||
} else {
|
} else {
|
||||||
// 设置 coop_mind_log_last_id 便于批量保存快照
|
// 设置 coop_mind_log_last_id 便于批量保存快照
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 回放
|
// 回放
|
||||||
if (client_id === this.client_id) {
|
if (client_uuid === this.client_uuid) {
|
||||||
console.log('self msg')
|
console.log('self msg')
|
||||||
} else {
|
} else {
|
||||||
const evt = log_content.evt
|
const evt = log_content.evt
|
||||||
@@ -229,7 +229,7 @@
|
|||||||
me.timer_push_task = setInterval(function () {
|
me.timer_push_task = setInterval(function () {
|
||||||
const param = {
|
const param = {
|
||||||
'data': Jm.util.json.json2string(me._jm.get_data('node_tree').data),
|
'data': Jm.util.json.json2string(me._jm.get_data('node_tree').data),
|
||||||
'client_id': me.client_id,
|
'client_uuid': me.client_uuid,
|
||||||
'coop_mind_id': me.coop_mind_id,
|
'coop_mind_id': me.coop_mind_id,
|
||||||
'coop_mind_log_id': me.coop_mind_log_id,
|
'coop_mind_log_id': me.coop_mind_log_id,
|
||||||
'type': 'snapshot',
|
'type': 'snapshot',
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ const modal = `
|
|||||||
<div style="text-align:right;">
|
<div style="text-align:right;">
|
||||||
<button type="button" class="btn btn-info" id="new_mind_btn">确认创建</button>
|
<button type="button" class="btn btn-info" id="new_mind_btn">确认创建</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" id="exampleCheck1">
|
||||||
|
<label class="form-check-label" for="exampleCheck1">新建后打开</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<!--end-->
|
<!--end-->
|
||||||
|
|||||||
Reference in New Issue
Block a user