update
This commit is contained in:
+9
-12
@@ -4,7 +4,7 @@ from django.shortcuts import render
|
|||||||
from rest_framework.generics import *
|
from rest_framework.generics import *
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
import json
|
||||||
from server.filters import CooperationMindFilter
|
from server.filters import CooperationMindFilter
|
||||||
from server.models import *
|
from server.models import *
|
||||||
from server.serializers import CooperationMindSerializer
|
from server.serializers import CooperationMindSerializer
|
||||||
@@ -24,7 +24,8 @@ def to_detail(request):
|
|||||||
"""
|
"""
|
||||||
详情页面
|
详情页面
|
||||||
"""
|
"""
|
||||||
return render(request, "html/detail.html")
|
param = {'id': request.GET.get('id')}
|
||||||
|
return render(request, "html/detail.html", param)
|
||||||
|
|
||||||
|
|
||||||
class JsMindLogView(ListAPIView):
|
class JsMindLogView(ListAPIView):
|
||||||
@@ -38,18 +39,14 @@ class JsMindLogView(ListAPIView):
|
|||||||
pagination_class = NewPagination
|
pagination_class = NewPagination
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
pk = request.GET.get('id')
|
||||||
|
if pk is not None:
|
||||||
|
mind = CooperationMind.objects.filter(id=pk).first()
|
||||||
|
# 序列化
|
||||||
|
serializer = CooperationMindSerializer(mind)
|
||||||
|
return build_response(data=serializer.data)
|
||||||
return self.list(request, *args, **kwargs)
|
return self.list(request, *args, **kwargs)
|
||||||
|
|
||||||
# def get(self, request):
|
|
||||||
# qs = self.filter_queryset(self.get_queryset())
|
|
||||||
# page = self.paginate_queryset(qs)
|
|
||||||
# if page:
|
|
||||||
# serializer_obj = self.get_serializer(instance=page, many=True)
|
|
||||||
# return self.get_paginated_response({'code': 0, 'res': "success", 'msg': serializer_obj.data})
|
|
||||||
#
|
|
||||||
# serializer_obj = self.get_serializer(instance=qs, many=True)
|
|
||||||
# return Response({'code': 0, 'res': "success", 'msg': serializer_obj.data}, )
|
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
"""
|
"""
|
||||||
查询思维导图
|
查询思维导图
|
||||||
|
|||||||
+17
-105
@@ -33,29 +33,13 @@
|
|||||||
},
|
},
|
||||||
loadMind: function () {
|
loadMind: function () {
|
||||||
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
|
// 打开已有脑图1、查询数据,组装option 2、实例化jm、show
|
||||||
const mind_name = $('#mind_name').val()
|
let id = $('#mind_id').val()
|
||||||
|
id = {{ id }};
|
||||||
const me = this
|
const me = this
|
||||||
if (mind_name) {
|
$.get('list?id=' + id, function (resp) {
|
||||||
|
let data = resp.data.snapshot_data
|
||||||
$.get('jsmind_op', {'mind_name': mind_name, 'type': 'get_mind_by_name'}, function (resp) {
|
me.init_new_mind(resp.data.coop_mind_name, JSON.parse(data))
|
||||||
me.destory_coop_if_necessary()
|
})
|
||||||
|
|
||||||
// todo 设置返回的 data_log_id
|
|
||||||
me.init_new_mind(mind_name, resp.msg.data)
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
newMind: function () {
|
|
||||||
$('#jsmind_container').empty()
|
|
||||||
const name = this.randomNum(1, 2222)
|
|
||||||
$('#mind_name').val(name)
|
|
||||||
if (!name) {
|
|
||||||
alert('请输入名字')
|
|
||||||
} else {
|
|
||||||
this.destory_coop_if_necessary()
|
|
||||||
this.init_new_mind(name)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// 清除定时任务等
|
// 清除定时任务等
|
||||||
destory_coop_if_necessary() {
|
destory_coop_if_necessary() {
|
||||||
@@ -66,61 +50,11 @@
|
|||||||
init_new_mind: function (name, data) {
|
init_new_mind: function (name, data) {
|
||||||
const mind = {
|
const mind = {
|
||||||
/* 元数据,定义思维导图的名称、作者、版本等信息 */
|
/* 元数据,定义思维导图的名称、作者、版本等信息 */
|
||||||
meta: {
|
meta: {name: name, author: 'hizzgdev@163.com', version: '0.2'},
|
||||||
name: name,
|
|
||||||
author: 'hizzgdev@163.com',
|
|
||||||
version: '0.2'
|
|
||||||
},
|
|
||||||
/* 数据格式声明 */
|
/* 数据格式声明 */
|
||||||
format: 'node_tree',
|
format: 'node_tree',
|
||||||
/* 数据内容 */
|
/* 数据内容 */
|
||||||
data: {
|
data: {id: 'root', topic: 'jsMind'}
|
||||||
id: 'root',
|
|
||||||
topic: 'jsMind',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
id: 'easy',
|
|
||||||
topic: 'Easy',
|
|
||||||
direction: 'left',
|
|
||||||
expanded: false,
|
|
||||||
children: [
|
|
||||||
{id: 'easy1', topic: 'Easy to show'},
|
|
||||||
{id: 'easy2', topic: 'Easy to edit'},
|
|
||||||
{id: 'easy3', topic: 'Easy to store'},
|
|
||||||
{id: 'easy4', topic: 'Easy to embed'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'open',
|
|
||||||
topic: 'Open Source',
|
|
||||||
direction: 'right',
|
|
||||||
expanded: true,
|
|
||||||
children: [
|
|
||||||
{id: 'open1', topic: 'on GitHub'},
|
|
||||||
{id: 'open2', topic: 'BSD License'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'powerful',
|
|
||||||
topic: 'Powerful',
|
|
||||||
direction: 'right',
|
|
||||||
children: [
|
|
||||||
{id: 'powerful1', topic: 'Base on Javascript'},
|
|
||||||
{id: 'powerful2', topic: 'Base on HTML5'},
|
|
||||||
{id: 'powerful3', topic: 'Depends on you'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'other',
|
|
||||||
topic: 'test node',
|
|
||||||
direction: 'left',
|
|
||||||
children: [
|
|
||||||
{id: 'other1', topic: "I'm from local variable"},
|
|
||||||
{id: 'other2', topic: 'I can do everything'}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
@@ -131,34 +65,13 @@
|
|||||||
menuOpts: {
|
menuOpts: {
|
||||||
showMenu: true,
|
showMenu: true,
|
||||||
injectionList: [
|
injectionList: [
|
||||||
{
|
{target: 'edit', text: '编辑节点'},
|
||||||
target: 'edit',
|
{target: 'addChild', text: '添加子节点'},
|
||||||
text: '编辑节点'
|
{target: 'addBrother', text: '添加兄弟节点'},
|
||||||
},
|
{target: 'delete', text: '删除节点'},
|
||||||
{
|
{target: 'screenshot', text: '下载导图'},
|
||||||
target: 'addChild',
|
{target: 'showAll', text: '展开全部节点'},
|
||||||
text: '添加子节点'
|
{target: 'hideAll', text: '收起全部节点'}
|
||||||
},
|
|
||||||
{
|
|
||||||
target: 'addBrother',
|
|
||||||
text: '添加兄弟节点'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: 'delete',
|
|
||||||
text: '删除节点'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: 'screenshot',
|
|
||||||
text: '下载导图'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: 'showAll',
|
|
||||||
text: '展开全部节点'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: 'hideAll',
|
|
||||||
text: '收起全部节点'
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,14 +85,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const xxObj = new xx()
|
const xxObj = new xx()
|
||||||
|
xxObj.loadMind()
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
|
<span id="mind_id" style="display: none;">{{ id }}</span>
|
||||||
<div>
|
<div>
|
||||||
导图名称:<input id='mind_name'>
|
|
||||||
<input type="button" value="新建" onclick="xxObj.newMind()">
|
|
||||||
<input type="button" value="打开已有" onclick="xxObj.loadMind()">
|
|
||||||
<input type="button" value="放大" onclick="zoomIn()">
|
<input type="button" value="放大" onclick="zoomIn()">
|
||||||
<input type="button" value="缩小" onclick="zoomOut()">
|
<input type="button" value="缩小" onclick="zoomOut()">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
<td>${item.create_time}</td>
|
<td>${item.create_time}</td>
|
||||||
<td>${item.update_time}</td>
|
<td>${item.update_time}</td>
|
||||||
<td>
|
<td>
|
||||||
<i class="layui-icon layui-icon-edit" style="font-size: 15px; color: #1E9FFF;cursor: pointer;">编辑</i>
|
<i class="layui-icon layui-icon-edit" style="font-size: 15px; color: #1E9FFF;cursor: pointer;" onclick="window.open('detail?id=${item.id}')">编辑</i>
|
||||||
<i class="layui-icon layui-icon-share" style="font-size: 15px; color: #1E9FFF;cursor: pointer;margin-left: 10px;">复制分享</i>
|
<i class="layui-icon layui-icon-share" style="font-size: 15px; color: #1E9FFF;cursor: pointer;margin-left: 10px;">复制分享</i>
|
||||||
</td>
|
</td>
|
||||||
</tr>`
|
</tr>`
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
this.coop_mind_id = coop_mind_id
|
this.coop_mind_id = coop_mind_id
|
||||||
// this.timerFetch()
|
// this.timerFetch()
|
||||||
}
|
}
|
||||||
this.timerPush()
|
// this.timerPush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Jm.coop.prototype = {
|
Jm.coop.prototype = {
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
}
|
}
|
||||||
// ajax
|
// ajax
|
||||||
const me = this
|
const me = this
|
||||||
Jm.util.ajax.post(this.coop_api_url, param, function (resp) {
|
/*Jm.util.ajax.post(this.coop_api_url, param, function (resp) {
|
||||||
if (type === 1) {
|
if (type === 1) {
|
||||||
// 新建
|
// 新建
|
||||||
me.coop_mind_id = resp.coop_mind_id
|
me.coop_mind_id = resp.coop_mind_id
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
// 操作
|
// 操作
|
||||||
me.coop_mind_log_id = resp.coop_mind_log_id
|
me.coop_mind_log_id = resp.coop_mind_log_id
|
||||||
}
|
}
|
||||||
})
|
})*/
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user