star function

This commit is contained in:
chenyang
2022-07-23 08:46:47 +08:00
parent 690dcd2418
commit 08038cefd7
7 changed files with 43 additions and 27 deletions
+2 -1
View File
@@ -14,7 +14,8 @@ urlpatterns = [
path('', to_dashboard), # 跳转列表界面 path('', to_dashboard), # 跳转列表界面
path('2_d', to_detail), # 跳转详情界面 path('2_d', to_detail), # 跳转详情界面
path('s_2_d', share_to_detail), # 从分享链接跳转详细界面 path('s_2_d', share_to_detail), # 从分享链接跳转详细界面
path('2_s', to_share), # 到分享界面 path('2_share', to_share), # 到分享界面
path('2_star', to_star), # 到收藏界面
path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志操作 path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志操作
# --------------------------------------------------- # ---------------------------------------------------
+1 -1
View File
@@ -2,5 +2,5 @@ from rest_framework.response import Response
from server.util.constant_util import * from server.util.constant_util import *
def build_response(code=CODE_SUCCESS, msg='', data=''): def build_response(code=CODE_SUCCESS, msg='操作成功', data=''):
return Response({'code': code, 'msg': msg, 'data': data}) return Response({'code': code, 'msg': msg, 'data': data})
+8
View File
@@ -17,6 +17,14 @@ def to_share(request):
return render(request, "html/dashboard.html", param) return render(request, "html/dashboard.html", param)
def to_star(request):
"""
收藏页面
"""
param = {"page": "star"}
return render(request, "html/dashboard.html", param)
def to_detail(request): def to_detail(request):
""" """
详情页面 详情页面
+11 -2
View File
@@ -50,7 +50,10 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format") self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
elif 'share' == src_page: elif 'share' == src_page:
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id')) share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'))
self.queryset = CooperationMind.objects.annotate(share_new=Exists(share), ).filter(share_new=1).values('id', 'coop_mind_name', "client_uuid", "data_format") self.queryset = CooperationMind.objects.annotate(share_col=Exists(share), ).filter(share_col=1, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
elif 'star' == src_page:
star = CooperationMindStar.objects.filter(coop_mind_id=OuterRef('id'))
self.queryset = CooperationMind.objects.annotate(star_col=Exists(star), ).filter(star_col=1, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
else: else:
# 不返回数据 # 不返回数据
self.queryset = CooperationMind.objects.filter(creator_user_id=-100).values('id', 'coop_mind_name', "client_uuid", "data_format") self.queryset = CooperationMind.objects.filter(creator_user_id=-100).values('id', 'coop_mind_name', "client_uuid", "data_format")
@@ -116,6 +119,9 @@ class JsMindLogView(APIView):
class JsMindShareView(LoginRequiredJSONMixin, ListAPIView): class JsMindShareView(LoginRequiredJSONMixin, ListAPIView):
"""
思维导图分享view
"""
serializer_class = CooperationMindShareSerializer serializer_class = CooperationMindShareSerializer
filter_backends = [DjangoFilterBackend] filter_backends = [DjangoFilterBackend]
filter_class = CooperationMindShareFilter filter_class = CooperationMindShareFilter
@@ -142,7 +148,7 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView):
serializer = CooperationMindSerializer(mind) serializer = CooperationMindSerializer(mind)
return build_response(data=serializer.data) return build_response(data=serializer.data)
elif coop_mind_id is not None: elif coop_mind_id is not None:
# 查询分享信息 # 获得分享链接
share = CooperationMindShare.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).first() share = CooperationMindShare.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).first()
if share is None: if share is None:
return build_response(code=CODE_FAILED, msg='分享不存在') return build_response(code=CODE_FAILED, msg='分享不存在')
@@ -204,7 +210,10 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
def post(self, request): def post(self, request):
user = request.user user = request.user
post_body = request.POST post_body = request.POST
# 思维导图id
coop_mind_id = post_body.get('coop_mind_id') coop_mind_id = post_body.get('coop_mind_id')
# 操作类型
op_type = post_body.get('op_type')
if coop_mind_id is None: if coop_mind_id is None:
return build_response(CODE_FAILED, msg="参数错误") return build_response(CODE_FAILED, msg="参数错误")
+13 -12
View File
@@ -22,7 +22,7 @@
this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16) this.uuid = (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
this.current_page_num = 1 this.current_page_num = 1
this.default_page_size = 15 this.default_page_size = 15
this.title_map = new Map([["main", "全部文件"], ["share", "我的分享"]]);// k-v 的形式 this.title_map = new Map([["main", "全部文件"], ["share", "我的分享"], ["star", "我的收藏"]]);// k-v 的形式
} }
DefaultView.prototype = { DefaultView.prototype = {
@@ -43,8 +43,8 @@
} }
// 判断页面 // 判断页面
const src_page = this.get_src_page() const page_tag = this.get_page_tag()
$('#main h5').html(this.title_map.get(src_page)) $('#main h5').html(this.title_map.get(page_tag))
}, },
get_uu_id: function () { get_uu_id: function () {
return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16) return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
@@ -67,7 +67,7 @@
}); });
}, },
/**获得源页面*/ /**获得源页面*/
get_src_page: function () { get_page_tag: function () {
return $('#src_page').html() return $('#src_page').html()
}, },
/**获得导图*/ /**获得导图*/
@@ -82,11 +82,10 @@
me.current_page_num = current_page me.current_page_num = current_page
// 获得跳转源页面 // 获得跳转源页面
const src_page = me.get_src_page() const page_tag = me.get_page_tag()
$.ajax({ $.ajax({
type: `get`, type: `get`,
url: `list?page=${current_page}&page_size=${page_size}&s_p=${src_page}`, url: `list?page=${current_page}&page_size=${page_size}&s_p=${page_tag}`,
headers: {"X-CSRFToken": $.cookie("csrftoken")}, headers: {"X-CSRFToken": $.cookie("csrftoken")},
dataType: "json", dataType: "json",
success: function (resp) { success: function (resp) {
@@ -106,14 +105,16 @@
const uuid = me.get_uu_id() const uuid = me.get_uu_id()
// 添加按钮组 // 添加按钮组
let sub_btn; let sub_btn = '';
if (src_page === 'b9b101e') { if (page_tag === 'b9b101e') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a> sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('2_d?id=${item.id}&s_p=b9b101e')">编辑</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a> <a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>` <a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>`
} else if (src_page === 'share') { } else if (page_tag === 'share') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a> sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>` <a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
} else if (page_tag === 'star') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="">取消收藏</a>`
} }
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'> const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
@@ -490,13 +491,13 @@
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/2_s"> <a class="nav-link" href="/2_share">
<span data-feather="share-2"></span> <span data-feather="share-2"></span>
我的分享 我的分享
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="javascript:void(0);"> <a class="nav-link" href="/2_star">
<span data-feather="star"></span> <span data-feather="star"></span>
我的收藏 我的收藏
</a> </a>
+2 -7
View File
@@ -144,8 +144,7 @@
/**收藏或者取消收藏*/ /**收藏或者取消收藏*/
star: function () { star: function () {
const coop_mind_id = this.coop_mind_id const coop_mind_id = this.coop_mind_id
console.log(coop_mind_id) console.log(`this.from_share:${this.from_share}`)
console.log(this.from_share)
// ajax start // ajax start
$.ajax({ $.ajax({
@@ -155,11 +154,7 @@
data: {'coop_mind_id': coop_mind_id}, data: {'coop_mind_id': coop_mind_id},
dataType: "json", dataType: "json",
success: function (resp) { success: function (resp) {
if (resp.code === 0) { common_alert(resp.msg)
console.log(resp)
} else {
common_alert(resp.msg)
}
}, },
async: false async: false
}); });
+6 -4
View File
@@ -15,11 +15,13 @@ function common_alert(text, class_str) {
// append // append
$('body').append(content) $('body').append(content)
// clean // clean
if (bundle_alert) { setTimeout(function () {
setTimeout(function () { if (bundle_alert) {
$('.alert').alert('close') $('.alert').alert('close')
}, 1500) } else {
} $('.alert').fadeOut('slow')
}
}, 1500)
} }
function primary_alert(text) { function primary_alert(text) {