modify a lot,and FileSummary and others
This commit is contained in:
parent
3e9b53aea6
commit
d42eb0fe0f
|
@ -17,7 +17,7 @@ Including another URLconf
|
|||
from django.urls import path
|
||||
from .views import ShowIssueQuestionView, ShowAnnotationView, ShowNavigationView
|
||||
from .views import AddAnnotationView, AddArticleView, AddQuestionView, AddIssueAnswerView, AddCommentView
|
||||
from .views import UpdateAnnotationView, UpdateArticleView, UpdateQuestionView, UpdateAnswerView, UpdateCommentView
|
||||
from .views import UpdateAnnotationView, UpdateArticleView, UpdateQuestionView, UpdateAnswerView, UpdateCommentView,RightView
|
||||
from .views import AddVoteView, AcceptAnswerView, ShowMethodInfo, GetHotestIssuesView, Get_CodeReading_Content_View, AddQuestionAnswerView, GetAddtabParasView,ModifyAnnotationView
|
||||
|
||||
app_name = "operations"
|
||||
|
@ -42,5 +42,6 @@ urlpatterns = [
|
|||
path('get_codereading_content/', Get_CodeReading_Content_View.as_view(),name='get_codereading_content'),
|
||||
path('add_question_answer/',AddQuestionAnswerView.as_view(), name='add_question_answer/'),
|
||||
path('get_addtab_paras/', GetAddtabParasView.as_view(),name='get_addtab_paras/'),
|
||||
path('modify_anno/', ModifyAnnotationView.as_view(),name='modify_anno/')
|
||||
path('modify_anno/', ModifyAnnotationView.as_view(),name='modify_anno/'),
|
||||
path('right/',RightView.as_view(),name='right/')
|
||||
]
|
||||
|
|
|
@ -16,7 +16,7 @@ from .models import Vote
|
|||
from users.models import User
|
||||
from .forms import NewArticleForm
|
||||
from projects.models import File
|
||||
from projects.models import Language, Project, FileAnnoIssueSummary
|
||||
from projects.models import Language, Project, FileSummary
|
||||
from django.template.loader import render_to_string
|
||||
import base64
|
||||
|
||||
|
@ -721,7 +721,6 @@ class GetHotestIssuesView(View):
|
|||
# html_str = render_to_string('projects/filesub/hotest_issue.html', {'issues':issues})
|
||||
# return HttpResponse(json.dumps({"status": "success", "html_str": html_str}), content_type='application/json')
|
||||
|
||||
|
||||
class Get_CodeReading_Content_View(View):
|
||||
def post(self,request):
|
||||
logging.info("Get_CodeReading_Content_View ")
|
||||
|
@ -733,16 +732,26 @@ class Get_CodeReading_Content_View(View):
|
|||
return HttpResponse(json.dumps({"status": "success", "html_str": html_str}), content_type='application/json')
|
||||
# 根据path确定它是不是文件
|
||||
# (目前的判断方法是查看File_Anno_Issue_Summary表中是否有parentDir为传入的path,如果有说明是文件夹)
|
||||
isDir = (len(FileAnnoIssueSummary.objects.filter(project_id=project_id,parent_path=path))>0)
|
||||
isDir = (len(FileSummary.objects.filter(project_id=project_id,parent_path=path))>0)
|
||||
if isDir:
|
||||
html_str = get_dir_info(project_id,path)
|
||||
return HttpResponse(json.dumps({"status": "success", "html_str": html_str,"is_dir":"1"}), content_type='application/json')
|
||||
else:
|
||||
html_str = get_code(project_id,path)
|
||||
html_str = get_code(request,project_id,path)
|
||||
return HttpResponse(json.dumps({"status": "success", "html_str": html_str,"is_dir":"0"}), content_type='application/json')
|
||||
# html_str = html_str.replace('style="background-color: white;"',"")
|
||||
|
||||
def get_code(project_id,path):
|
||||
def get_self_annos_by_fileid(user_id,file_id):
|
||||
self_anno_map = {}
|
||||
try:
|
||||
annos = Annotation.objects.filter(file_id=file_id,user_id=user_id)
|
||||
for anno in annos:
|
||||
self_anno_map[anno.linenum]=anno.content
|
||||
return self_anno_map
|
||||
except:
|
||||
return self_anno_map
|
||||
|
||||
def get_code(request,project_id,path):
|
||||
project = Project.objects.filter(id=project_id).first()
|
||||
file = File.objects.filter(path=path, project_id=project_id).first()
|
||||
fileid = file.pk
|
||||
|
@ -762,6 +771,11 @@ def get_code(project_id,path):
|
|||
for i in questions:
|
||||
questions_count[str(i['linenum'])] = i['nums']
|
||||
|
||||
if request.user.is_authenticated:
|
||||
self_annos = get_self_annos_by_fileid(request.user.pk,fileid)
|
||||
else:
|
||||
self_annos = {}
|
||||
|
||||
html_str = render_to_string('projects/filesub/code-reading.html', locals())
|
||||
return html_str
|
||||
|
||||
|
@ -836,7 +850,7 @@ def get_dir_info(project_id,path):
|
|||
# 获取当前文件的注释总数以及问题总数
|
||||
# 不需要累计的,只需要当前的即可了
|
||||
file_id = File.objects.get(project_id=project_id,path=path).pk
|
||||
anno_issue_summarys = FileAnnoIssueSummary.objects.filter(project_id=project_id,parent_path=path)
|
||||
anno_issue_summarys = FileSummary.objects.filter(project_id=project_id,parent_path=path)
|
||||
|
||||
#当前文件夹下所有的file_ids以及fileid与filename的映射
|
||||
file_ids = []
|
||||
|
@ -873,6 +887,11 @@ def get_dir_info(project_id,path):
|
|||
anno_num = len(Annotation.objects.filter(file_id=file_id))
|
||||
question_num = len(Question.objects.filter(file_id=file_id))
|
||||
|
||||
current_file_summary = FileSummary.objects.get(project_id=project_id,current_path=path)
|
||||
line_sum = current_file_summary.line_num
|
||||
method_sum = current_file_summary.method_num
|
||||
file_sum = current_file_summary.file_num
|
||||
|
||||
html_str = render_to_string('projects/filesub/dir_info.html', locals())
|
||||
return html_str
|
||||
|
||||
|
@ -910,3 +929,61 @@ class GetAddtabParasView(View):
|
|||
|
||||
project_id = Project.objects.get(name=projectName).pk
|
||||
return HttpResponse(json.dumps({"status": "success", "project_id": project_id,"path":path,"filename":filename}), content_type='application/json')
|
||||
|
||||
# FIXME
|
||||
# 可能len(all_symbol)==3对于除了java外其他编程语言会有问题
|
||||
def getMethodNum(project_path,file_path):
|
||||
navigation_url = settings.OPENGROK_NAVIGATION_URL
|
||||
|
||||
navigation_url = navigation_url +project_path + file_path
|
||||
response = requests.get(navigation_url).text
|
||||
project_id = Project.objects.get(name=project_path)
|
||||
file_id = File.objects.get(project_id=project_id,path=file_path).pk
|
||||
|
||||
response = response.replace("]],[","]]|[")
|
||||
if response:
|
||||
all_symbols = response.split("|")
|
||||
if len(all_symbols)==3:
|
||||
symbol = json.loads(all_symbols[2])
|
||||
return len(symbol[2])
|
||||
return 0;
|
||||
|
||||
def getFileLineNum(project_path,file_path):
|
||||
path ="/opt/opengrok/source/"+project_path+file_path
|
||||
return len(open(path,'rU').readlines())
|
||||
|
||||
class RightView(View):
|
||||
|
||||
def get_file_right_content(self,project_path,file_path,file_id):
|
||||
# 获取方法个数
|
||||
method_num = getMethodNum(project_path,file_path);
|
||||
# 获得文件的行数
|
||||
filelinenum = getFileLineNum(project_path,file_path)
|
||||
# 获得注释个数
|
||||
try:
|
||||
anno_num = len(Annotation.objects.filter(file_id=file_id))
|
||||
except:
|
||||
anno_num = 0
|
||||
# 获得问题个数
|
||||
try:
|
||||
issue_num = len(Issue.objects.filter(file_id=file_id))
|
||||
except:
|
||||
issue_num = 0
|
||||
# 获得观看数
|
||||
view_num = 0
|
||||
# 观看数应该放在File_id中
|
||||
html_str = render_to_string('projects/filesub/file-right.html', locals())
|
||||
return html_str
|
||||
|
||||
def post(self, request):
|
||||
print(1111)
|
||||
# 先判断他是文件还是文件夹
|
||||
project_id = request.POST.get('project_id', '')
|
||||
file_path = request.POST.get('path', '')
|
||||
|
||||
project_path = Project.objects.get(id=project_id).path
|
||||
file = File.objects.get(project_id=project_id,path=file_path)
|
||||
|
||||
html_str = self.get_file_right_content(project_path,file_path,file.pk)
|
||||
return HttpResponse(json.dumps({"status": "success", "html_str": html_str}), content_type='application/json')
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 2.0.6 on 2018-07-31 21:15
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('projects', '0009_fileannoissuesummary_parent_path'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='FileSummary',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('anno_num', models.IntegerField(default=0, verbose_name='注释总数')),
|
||||
('isuue_num', models.IntegerField(default=0, verbose_name='问题总数')),
|
||||
('parent_path', models.CharField(default='', max_length=255, verbose_name='父文件夹路径')),
|
||||
('line_num', models.IntegerField(default=0, verbose_name='代码总数')),
|
||||
('method_num', models.IntegerField(default=0, verbose_name='方法总数')),
|
||||
('file_num', models.IntegerField(default=0, verbose_name='文件总数')),
|
||||
('file', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.File', verbose_name='文件')),
|
||||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.Project', verbose_name='文件')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '文件汇总',
|
||||
'verbose_name_plural': '文件汇总',
|
||||
'db_table': 'File_Summary',
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.0.6 on 2018-07-31 22:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('projects', '0010_filesummary'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='filesummary',
|
||||
name='current_path',
|
||||
field=models.CharField(default='', max_length=255, verbose_name='文件路径'),
|
||||
),
|
||||
]
|
|
@ -133,7 +133,19 @@ class FileAnnoIssueSummary(models.Model):
|
|||
verbose_name = "文件注释问题总数"
|
||||
verbose_name_plural = verbose_name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class FileSummary(models.Model):
|
||||
project = models.ForeignKey(
|
||||
Project, verbose_name='文件', on_delete=models.CASCADE)
|
||||
file = models.ForeignKey(File, verbose_name='文件', on_delete=models.CASCADE)
|
||||
anno_num = models.IntegerField(default=0, verbose_name='注释总数')
|
||||
isuue_num = models.IntegerField(default=0, verbose_name='问题总数')
|
||||
parent_path = models.CharField(default="",max_length=255, verbose_name='父文件夹路径')
|
||||
line_num = models.IntegerField(default=0, verbose_name='代码总数')
|
||||
method_num = models.IntegerField(default=0, verbose_name='方法总数')
|
||||
file_num = models.IntegerField(default=0, verbose_name='文件总数')
|
||||
current_path = models.CharField(default="",max_length=255, verbose_name='文件路径')
|
||||
|
||||
class Meta:
|
||||
db_table = 'File_Summary'
|
||||
verbose_name = "文件汇总"
|
||||
verbose_name_plural = verbose_name
|
||||
|
|
|
@ -172,8 +172,8 @@ class FileListlView(View):
|
|||
'hot_objs': hot_blobs,
|
||||
})
|
||||
|
||||
|
||||
from django.http import HttpResponse
|
||||
class ScannerProjectView(View):
|
||||
def get(self,request):
|
||||
scanner_project.get_anno_issue_summary("/opt/opengrok/source/Notes", 1)
|
||||
|
||||
return HttpResponse("Scanner Done!!")
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.0.6 on 2018-07-31 21:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0002_emailverifyrecord'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='avatar',
|
||||
field=models.ImageField(default='avatar/users/default.png', upload_to='avatar/'),
|
||||
),
|
||||
]
|
|
@ -22,6 +22,7 @@ import linecache
|
|||
|
||||
|
||||
# Create your views here.
|
||||
# 搜索自定义django auther
|
||||
class CustomBackend(ModelBackend): #通过邮箱登陆
|
||||
def authenticate(self, email=None, password=None, **kwargs):
|
||||
try:
|
||||
|
@ -143,7 +144,6 @@ class UserInfoAnnoView(View):
|
|||
all_files = all_annos.order_by('-update_time')
|
||||
else:
|
||||
all_files = all_annos.order_by('-voteup')
|
||||
print(all_annos)
|
||||
# 根据anno获取到评论的数目
|
||||
comment_nums = []
|
||||
for anno in all_annos:
|
||||
|
@ -181,7 +181,6 @@ class LoginView(View):
|
|||
email = request.POST.get('email', '')
|
||||
pass_word = request.POST.get('password', '')
|
||||
user = authenticate(email=email, password=pass_word)
|
||||
print(user)
|
||||
# 如果本地用户没有获取到,前往trustie获取用户
|
||||
if user is not None:
|
||||
if user.is_active:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from operations.models import Annotation,Issue
|
||||
from projects.models import File,Project
|
||||
from django.db.models import Count
|
||||
from projects.models import FileAnnoIssueSummary
|
||||
from projects.models import FileSummary
|
||||
import os
|
||||
|
||||
|
||||
|
@ -11,9 +11,13 @@ fileid_issue_sum = {}
|
|||
fileid_parentpath = {}
|
||||
filepath_id, fileid_annonum,fileid_issuenum=None,None,None
|
||||
|
||||
fileid_method_sum = {}
|
||||
fileid_file_sum = {}
|
||||
fileid_line_sum = {}
|
||||
|
||||
|
||||
def get_anno_issue_summary(project_path,project_id):
|
||||
global project_name, filepath_id, fileid_annonum, fileid_issuenum
|
||||
global project_name, filepath_id, fileid_annonum, fileid_issuenum,fileid_parentpath,fileid_method_sum,fileid_file_sum,fileid_line_sum,fileid_anno_sum,fileid_issue_sum
|
||||
|
||||
project_name = project_path[project_path.rfind('/')+1:]
|
||||
print(project_name)
|
||||
|
@ -24,18 +28,28 @@ def get_anno_issue_summary(project_path,project_id):
|
|||
|
||||
# print(filepath_id)
|
||||
projectAnnoNum,projectIssueNum=deepSearch(project_path)
|
||||
projectMethods,projectFiles,projectLines = deepSearchForMethod(project_path)
|
||||
|
||||
root_fileid = filepath_id[""]
|
||||
fileid_anno_sum[root_fileid]=projectAnnoNum
|
||||
fileid_issue_sum[root_fileid]=projectIssueNum
|
||||
fileid_parentpath[root_fileid]="self"
|
||||
|
||||
fileid_file_sum[root_fileid]=projectFiles
|
||||
fileid_method_sum[root_fileid]=projectMethods
|
||||
fileid_line_sum[root_fileid]=projectLines
|
||||
|
||||
save(project_id)
|
||||
|
||||
|
||||
def save(project_id):
|
||||
for file_id in filepath_id.values():
|
||||
print(file_id)
|
||||
obj = FileAnnoIssueSummary()
|
||||
try:
|
||||
obj = FileSummary.objects.get(file_id=file_id)
|
||||
except:
|
||||
print(111)
|
||||
obj = FileSummary()
|
||||
obj.file = File.objects.get(pk=file_id)
|
||||
obj.project = Project.objects.get(pk=project_id)
|
||||
|
||||
|
@ -44,12 +58,15 @@ def save(project_id):
|
|||
obj.anno_num = fileid_anno_sum[file_id]
|
||||
obj.isuue_num = fileid_issue_sum[file_id]
|
||||
obj.parent_path = fileid_parentpath[file_id]
|
||||
|
||||
obj.file_num = fileid_file_sum[file_id]
|
||||
obj.line_num = fileid_line_sum[file_id]
|
||||
obj.method_num = fileid_method_sum[file_id]
|
||||
obj.current_path = obj.file.path
|
||||
obj.save()
|
||||
|
||||
|
||||
def deepSearch(current_path):
|
||||
global fileid_anno_sum,fileid_issue_sum
|
||||
global fileid_anno_sum,fileid_issue_sum,fileid_parentpath
|
||||
|
||||
index=current_path.find(project_name)
|
||||
files = os.listdir(current_path)
|
||||
|
@ -60,8 +77,8 @@ def deepSearch(current_path):
|
|||
filePath = current_path + os.path.sep + files[i]
|
||||
# print(filePath)
|
||||
relative_path = filePath[index+len(project_name):]
|
||||
#相对路径是否在filepath_id中,可能会有这样的情况,
|
||||
#路径没有对应的file_id,也就是当前路劲没有收录
|
||||
# 相对路径是否在filepath_id中,可能会有这样的情况,
|
||||
# 路径没有对应的file_id,也就是当前路劲没有收录
|
||||
if relative_path not in filepath_id:
|
||||
continue
|
||||
file_id = filepath_id[relative_path]
|
||||
|
@ -132,3 +149,77 @@ def getFileIssueInfo(project_id):
|
|||
else:
|
||||
fileid_issuenum[issue.file_id] = 1
|
||||
return fileid_issuenum
|
||||
|
||||
|
||||
def deepSearchForMethod(current_path):
|
||||
global fileid_method_sum,fileid_line_sum,fileid_file_sum
|
||||
|
||||
index=current_path.find(project_name)
|
||||
files = os.listdir(current_path)
|
||||
|
||||
currentFiles = 0
|
||||
currentLines = 0
|
||||
currentMethods = 0
|
||||
|
||||
for i in range(len(files)):
|
||||
filePath = current_path + os.path.sep + files[i]
|
||||
# print(filePath)
|
||||
relative_path = filePath[index+len(project_name):]
|
||||
# 相对路径是否在filepath_id中,可能会有这样的情况,
|
||||
# 路径没有对应的file_id,也就是当前路劲没有收录
|
||||
if relative_path not in filepath_id:
|
||||
continue
|
||||
file_id = filepath_id[relative_path]
|
||||
|
||||
# 获取当前文件/文件夹下的问题和注释总数
|
||||
if os.path.isdir(filePath):
|
||||
methods,filenum,lines= deepSearchForMethod(filePath)
|
||||
|
||||
fileid_method_sum[file_id] = methods
|
||||
currentMethods += fileid_method_sum[file_id]
|
||||
fileid_file_sum[file_id] = filenum
|
||||
currentFiles += fileid_file_sum[file_id]
|
||||
fileid_line_sum[file_id] = lines
|
||||
currentLines += fileid_line_sum[file_id]
|
||||
|
||||
else:
|
||||
fileid_method_sum[file_id] = getFileMethodCount(project_name,relative_path)
|
||||
currentMethods += fileid_method_sum[file_id]
|
||||
|
||||
fileid_file_sum[file_id] = 1
|
||||
currentFiles += fileid_file_sum[file_id]
|
||||
|
||||
fileid_line_sum[file_id] = getFileLineNum(project_name,relative_path)
|
||||
currentLines += fileid_line_sum[file_id]
|
||||
|
||||
return currentMethods,currentFiles,currentLines
|
||||
|
||||
import json
|
||||
from django.conf import settings
|
||||
import requests
|
||||
# 获取单个文件的Method个数
|
||||
# 这个和之前的不一样,之前的是通过遍历数据库表,例如Annotation表和Issue表
|
||||
# 但是这个在数据库表中并无记录
|
||||
def getFileMethodCount(project_path,file_path):
|
||||
try:
|
||||
navigation_url = settings.OPENGROK_NAVIGATION_URL
|
||||
navigation_url = navigation_url +project_path + file_path
|
||||
response = requests.get(navigation_url).text
|
||||
project_id = Project.objects.get(name=project_path)
|
||||
file_id = File.objects.get(project_id=project_id,path=file_path).pk
|
||||
response = response.replace("]],[","]]|[")
|
||||
if response:
|
||||
all_symbols = response.split("|")
|
||||
if len(all_symbols)==3:
|
||||
symbol = json.loads(all_symbols[2])
|
||||
return len(symbol[2])
|
||||
return 0;
|
||||
except:
|
||||
return 0;
|
||||
|
||||
def getFileLineNum(project_path,file_path):
|
||||
path ="/opt/opengrok/source/"+project_path+file_path
|
||||
try:
|
||||
return len(open(path,'rU').readlines())
|
||||
except:
|
||||
return 0;
|
|
@ -37,6 +37,9 @@ p, input, table {
|
|||
color: #575757;
|
||||
}
|
||||
|
||||
.fontcolor-white{
|
||||
color: white;
|
||||
}
|
||||
.color-grey-des {
|
||||
color: #808080;
|
||||
}
|
||||
|
@ -498,11 +501,13 @@ a:hover {
|
|||
}
|
||||
|
||||
.panel-right {
|
||||
|
||||
color: #EBEBEB;
|
||||
font-size:13px;
|
||||
display: block;
|
||||
float: left;
|
||||
flex: 1;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
.middle-area {
|
||||
|
@ -1137,6 +1142,14 @@ pre.prettyprint {
|
|||
color: black;
|
||||
}
|
||||
|
||||
.path_info img{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.path_info i{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.filePathInfo {
|
||||
background-color: #26292b!important;
|
||||
width: 100%;
|
||||
|
@ -1213,9 +1226,10 @@ color: #FFF !important;
|
|||
.info-nav{
|
||||
color: #FFF;
|
||||
}
|
||||
.path_infonav span{
|
||||
/* .path_infonav span{
|
||||
color: #FFF;
|
||||
}
|
||||
} */
|
||||
|
||||
/* nav-right */
|
||||
|
||||
.navbar-right {
|
||||
|
|
|
@ -42,7 +42,6 @@ function show_annotation(file_id, line_num) {
|
|||
$("#ItemcommentPanel").remove()
|
||||
var html="<div id='ItemcommentPanel'>"+data.html_str+"</div>"
|
||||
$("#linestatus_"+file_id+"_"+line_num).append(html);
|
||||
|
||||
}else{
|
||||
alert(data.msg)
|
||||
}
|
||||
|
@ -604,7 +603,9 @@ function mouseCoords(ev) {
|
|||
}
|
||||
|
||||
var tabSet = new Set();
|
||||
var issue_map = new Map();
|
||||
// var issue_map = new Map();
|
||||
var right_map = new Map();
|
||||
var tree_nodes = new Map();
|
||||
|
||||
function path_predeal(path){
|
||||
// path = path.replace('.', '');
|
||||
|
@ -620,6 +621,9 @@ function open_tab(path) {
|
|||
path_input=path
|
||||
path = path_predeal(path)
|
||||
|
||||
$('#jstree').jstree("deselect_all", true);
|
||||
$('#jstree').jstree("select_node", tree_nodes[path]);
|
||||
|
||||
var tabcontent = document.getElementsByClassName("codereading");
|
||||
for (var i = 0; i < tabcontent.length; i++) {
|
||||
tabcontent[i].style.display = "none";
|
||||
|
@ -636,11 +640,18 @@ function open_tab(path) {
|
|||
document.getElementById("tab_" + path).className += " active";
|
||||
|
||||
document.getElementsByClassName("filename")[0].innerHTML = path_input;
|
||||
if(!issue_map.has(path)){
|
||||
window.setTimeout(function () { $("#hotest_issue").html(issue_map[path]) }, 3000);
|
||||
|
||||
if(!right_map.has(path)){
|
||||
window.setTimeout(function () { $("#right_panel").html(right_map[path]) }, 3000);
|
||||
}else{
|
||||
$("#hotest_issue").html(issue_map[path]);
|
||||
$("#right_panel").html(right_map[path]);
|
||||
}
|
||||
|
||||
// if(!issue_map.has(path)){
|
||||
// window.setTimeout(function () { $("#hotest_issue").html(issue_map[path]) }, 3000);
|
||||
// }else{
|
||||
// $("#hotest_issue").html(issue_map[path]);
|
||||
// }
|
||||
show_navigation();
|
||||
}
|
||||
// 添加一个新的标签页,
|
||||
|
@ -649,12 +660,15 @@ function open_tab(path) {
|
|||
// 并调用open_tab
|
||||
function add_tab(project_id,path,filename) {
|
||||
|
||||
var tree_node = $("#jstree").jstree("get_selected");
|
||||
|
||||
var path_before = path
|
||||
//需要将path处理一下,因为css样式中/以及.是不行的
|
||||
tmp_index = path.indexOf("#");
|
||||
if(tmp_index != -1){
|
||||
path = path.substring(0,tmp_index)
|
||||
}
|
||||
|
||||
var path_input = path;
|
||||
path = path_predeal(path)
|
||||
|
||||
|
@ -751,13 +765,33 @@ function add_tab(project_id,path,filename) {
|
|||
|
||||
open_tab(path_input);
|
||||
|
||||
// 现在Hotest Question 模块先不用了
|
||||
// // 填充hotest_question
|
||||
// $.ajax({
|
||||
// cache: false,
|
||||
// type: "POST",
|
||||
// url: '/operations/get_hotest_issues/',
|
||||
// data: { 'project_id': project_id, 'path': path_input,"question_num":5 },
|
||||
// dataType: 'json',
|
||||
// async: true,
|
||||
// beforeSend: function (xhr, settings) {
|
||||
// xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
// },
|
||||
// success: function (data) {
|
||||
// if (data.status === 'success') {
|
||||
// issue_map[path] = data.html_str;
|
||||
// }
|
||||
// else {
|
||||
// issue_map[path] = ""
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
// 填充hotest_question
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
url: '/operations/get_hotest_issues/',
|
||||
data: { 'project_id': project_id, 'path': path_input,"question_num":5 },
|
||||
url: '/operations/right/',
|
||||
data: { 'project_id': project_id, 'path': path_input},
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
beforeSend: function (xhr, settings) {
|
||||
|
@ -765,14 +799,15 @@ function add_tab(project_id,path,filename) {
|
|||
},
|
||||
success: function (data) {
|
||||
if (data.status === 'success') {
|
||||
issue_map[path] = data.html_str;
|
||||
right_map[path] = data.html_str;
|
||||
}
|
||||
else {
|
||||
issue_map[path] = ""
|
||||
right_map[path] = ""
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
tree_nodes[path]=tree_node
|
||||
tabSet.add(path);
|
||||
}
|
||||
}
|
||||
|
@ -853,6 +888,96 @@ function add_dir_annotation(item, file_id, line_num){
|
|||
}
|
||||
}
|
||||
|
||||
function show_dir_annotation(file_id){
|
||||
ev = window.event;
|
||||
var mousePos = mouseCoords(ev);
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
url: '/operations/show_annotation/',
|
||||
data: { 'file_id': file_id, 'line_num': 0 },
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
beforeSend: function (xhr, settings) {
|
||||
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.status === "success") {
|
||||
console.log(1111)
|
||||
//console.log("linestatus_"+line_num);
|
||||
//$("#loadCommentpanel").html(data.html_str);
|
||||
//$("#commentPanel").css("top", mousePos.y);
|
||||
//$("#commentPanel").css("left", mousePos.x+35);
|
||||
//$("#loadCommentpanel").show();
|
||||
//console.log(data.html_str);
|
||||
$("#ItemcommentPanel").remove()
|
||||
var html="<div id='ItemcommentPanel' style='margin-top: 70px;'>"+data.html_str+"</div>"
|
||||
$("#dir_anno_"+file_id).append(html);
|
||||
}else{
|
||||
alert(data.msg)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function show_dir_issue_question(file_id){
|
||||
ev = window.event;
|
||||
var mousePos = mouseCoords(ev)
|
||||
//发送问题id,返回问题内容
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
url: '/operations/show_issue_question/',
|
||||
data: { 'file_id': file_id, 'line_num': 0, 'issue_ids': "[]"},
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
beforeSend: function (xhr, settings) {
|
||||
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
},
|
||||
success: function (data) {
|
||||
if(data.status=='success'){
|
||||
var html="<div id='ItemquestionPanel' style='margin-top:70px;'>"+data.html_str+"</div>";
|
||||
$("#dir_question_"+file_id).append(html);
|
||||
// $("#loadQuestionpanel").html(data.html_str);
|
||||
if (data.issueAnswers) {
|
||||
//字符串转换成整型数组
|
||||
var dataStrArr = issueid_str.substring(1, issueid_str.length - 1).split(",")
|
||||
var issue_ids = dataStrArr.map(function (data) {
|
||||
return +data;
|
||||
});
|
||||
//
|
||||
issueAnswers = JSON.parse(data.issueAnswers);
|
||||
issueStandardAnswers = JSON.parse(data.issueStandardAnswers);
|
||||
|
||||
let count = 0;
|
||||
for (let i = 0; i < issue_ids.length; i++) {
|
||||
issue_id = issue_ids[i]
|
||||
|
||||
if (issue_id == issueAnswers[count].fields.issue) {
|
||||
var radios = document.getElementsByName("issue_" + issue_id)
|
||||
user_answer = issueAnswers[0].fields.content;
|
||||
standard_answer = issueStandardAnswers[0].fields.choice_position;
|
||||
if (user_answer == standard_answer) {
|
||||
radios[user_answer - 1].parentNode.style.color = "green";
|
||||
} else {
|
||||
radios[parseInt(user_answer) - 1].parentNode.style.color = "red";
|
||||
radios[parseInt(standard_answer) - 1].parentNode.style.color = "green";
|
||||
}
|
||||
document.getElementById("submit_onechoice_" + issue_id).style.display = "None";
|
||||
count = count + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
//$("#questionPanel").css("top", mousePos.y);
|
||||
//$("#questionPanel").css("left", mousePos.x - 400);
|
||||
//$("#loadQuestionpanel").show();
|
||||
}else{
|
||||
alert(data.msg)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function submint_dir_annotation(file_id, line_num, content) {
|
||||
|
||||
|
@ -875,7 +1000,9 @@ function submint_dir_annotation(file_id, line_num, content) {
|
|||
$("#dir_anno_" + +file_id).html(parseInt(value) + 1);
|
||||
}
|
||||
}
|
||||
alert(data.msg);
|
||||
$(".addno-panel").hide();
|
||||
$(".source-addno-panel").remove();
|
||||
show_dir_annotation(file_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -901,7 +1028,9 @@ function submint_dir_question(file_id, line_num, content) {
|
|||
$("#dir_question_" + +file_id).html(parseInt(value) + 1);
|
||||
}
|
||||
}
|
||||
alert(data.msg);
|
||||
$(".addno-panel").hide();
|
||||
$(".source-addno-panel").remove();
|
||||
show_dir_issue_question(file_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -951,6 +1080,9 @@ window.onload = function () {
|
|||
},
|
||||
success: function (data) {
|
||||
if (data.status === 'success') {
|
||||
// 展开当前标签对应的节点
|
||||
// $('#jstree').jstree("deselect_all", true);
|
||||
// $('#jstree').jstree("select_node", "j1_1355554");
|
||||
add_tab(data.project_id, data.path, data.filename)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
<span class="fl font-20 colorFFF">目录信息</span>
|
||||
<p class="fr">
|
||||
<span class="fl mr15 mt7">
|
||||
<img src="/static/image/annotation.png" class="mr3">
|
||||
<span class="font-12" id="dir_anno_{{file_id}}">{{anno_num}}</span>
|
||||
<img src="/static/image/annotation.png" onclick="show_dir_annotation({{file_id}})" class="mr3">
|
||||
<span class="font-12 fontcolor-white" id="dir_anno_{{file_id}}">{{anno_num}}</span>
|
||||
</span>
|
||||
<span class="fl mr15 mt7">
|
||||
<img src="/static/image/question.png" class="mr3">
|
||||
<span class="font-12" id="dir_question_{{file_id}}">{{question_num}}</span>
|
||||
<img src="/static/image/question.png" onclick="show_dir_issue_question({{file_id}})" class="mr3">
|
||||
<span class="font-12 fontcolor-white" id="dir_question_{{file_id}}">{{question_num}}</span>
|
||||
</span>
|
||||
|
||||
<span class="fl mt7" onclick="show_next_addnoPanel({{file_id}})">
|
||||
|
@ -29,6 +29,20 @@
|
|||
</p>
|
||||
</div>
|
||||
<div class="filePathInfo">
|
||||
<div class="clearfix filePathline">
|
||||
<span>
|
||||
<label>代码行数</label>
|
||||
<label>{{line_sum}}</label>
|
||||
</span>
|
||||
<span>
|
||||
<label>方法数</label>
|
||||
<label>{{method_sum}}</label>
|
||||
</span>
|
||||
<span>
|
||||
<label>文件数</label>
|
||||
<label>{{file_sum}}</label>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clearfix filePathline">
|
||||
<span>
|
||||
<label>标注文件数</label>
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<!-- 这个是文件的信息 -->
|
||||
<div class="middle-right-item">
|
||||
<p class="right-item-title">File Infomation</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">methods</span>
|
||||
<span class="panel-right">{{method_num}}</span>
|
||||
</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">lines</span>
|
||||
<span class="panel-right">{{filelinenum}}</span>
|
||||
</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">view</span>
|
||||
<span class="panel-right">{{view_num}}</span>
|
||||
</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">annotation</span>
|
||||
<span class="panel-right">{{anno_num}}</span>
|
||||
</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">questions</span>
|
||||
<span class="panel-right">{{issue_num}}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- 相关文档链接 -->
|
||||
<!-- <div class="middle-right-item">
|
||||
<p class="right-item-title">Relatvie Links</p>
|
||||
</div> -->
|
|
@ -128,41 +128,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fl middle-right">
|
||||
<div class="middle-right-item">
|
||||
<p class="right-item-title">Project Infomation</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">Created</span>
|
||||
<span class="panel-right">2018年4月22日 11:19</span>
|
||||
</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">Views</span>
|
||||
<span class="panel-right">392</span>
|
||||
</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">Active</span>
|
||||
<span class="panel-right">2018年4月22日 11:19</span>
|
||||
</p>
|
||||
<p class="clearfix">
|
||||
<span class="panel-left">Source</span>
|
||||
<span class="panel-right color-blue">GitHub/MiNote
|
||||
<br/>OSSEAN/Minote</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="middle-right-item">
|
||||
<p class="right-item-title">Project Description</p>
|
||||
<p class="right-description">This method was deprecated in API level 23 as of JDK version 1.1</p>
|
||||
<div class="des clearfix">
|
||||
<span>style</span>
|
||||
<span>script</span>
|
||||
<span>script</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="middle-right-item" id="hotest_issue">
|
||||
|
||||
</div>
|
||||
<div class="fl middle-right" id="right_panel">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue