提交 0cac8d66 编写于 作者: baltery's avatar baltery

[Update] 修改index api

上级 76ef9b29
...@@ -16,27 +16,36 @@ from common.utils import lazyproperty ...@@ -16,27 +16,36 @@ from common.utils import lazyproperty
__all__ = ['IndexApi'] __all__ = ['IndexApi']
class MonthLoginMetricMixin: class DatesLoginMetricMixin:
@lazyproperty
def days(self):
query_params = self.request.query_params
if query_params.get('monthly'):
return 30
return 7
@lazyproperty @lazyproperty
def session_month(self): def sessions_queryset(self):
month_ago = timezone.now() - timezone.timedelta(days=30) days = timezone.now() - timezone.timedelta(days=self.days)
session_month = Session.objects.filter(date_start__gt=month_ago) sessions_queryset = Session.objects.filter(date_start__gt=days)
return session_month return sessions_queryset
@lazyproperty @lazyproperty
def session_month_dates(self): def session_dates_list(self):
dates = self.session_month.dates('date_start', 'day') now = timezone.now()
dates = [(now - timezone.timedelta(days=i)).date() for i in range(self.days)]
dates.reverse()
# dates = self.sessions_queryset.dates('date_start', 'day')
return dates return dates
def get_month_metrics_date(self): def get_dates_metrics_date(self):
month_metrics_date = [d.strftime('%m-%d') for d in self.session_month_dates] or ['0'] dates_metrics_date = [d.strftime('%m-%d') for d in self.session_dates_list] or ['0']
return month_metrics_date return dates_metrics_date
@staticmethod @staticmethod
def get_cache_key(date, tp): def get_cache_key(date, tp):
date_str = date.strftime("%Y%m%d") date_str = date.strftime("%Y%m%d")
key = "SESSION_MONTH_{}_{}_{}".format(current_org.id, tp, date_str) key = "SESSION_DATE_{}_{}_{}".format(current_org.id, tp, date_str)
return key return key
def __get_data_from_cache(self, date, tp): def __get_data_from_cache(self, date, tp):
...@@ -69,9 +78,9 @@ class MonthLoginMetricMixin: ...@@ -69,9 +78,9 @@ class MonthLoginMetricMixin:
self.__set_data_to_cache(date, tp, count) self.__set_data_to_cache(date, tp, count)
return count return count
def get_month_metrics_total_count_login(self): def get_dates_metrics_total_count_login(self):
data = [] data = []
for d in self.session_month_dates: for d in self.session_dates_list:
count = self.get_date_login_count(d) count = self.get_date_login_count(d)
data.append(count) data.append(count)
if len(data) == 0: if len(data) == 0:
...@@ -88,9 +97,9 @@ class MonthLoginMetricMixin: ...@@ -88,9 +97,9 @@ class MonthLoginMetricMixin:
self.__set_data_to_cache(date, tp, count) self.__set_data_to_cache(date, tp, count)
return count return count
def get_month_metrics_total_count_active_users(self): def get_dates_metrics_total_count_active_users(self):
data = [] data = []
for d in self.session_month_dates: for d in self.session_dates_list:
count = self.get_date_user_count(d) count = self.get_date_user_count(d)
data.append(count) data.append(count)
return data return data
...@@ -105,90 +114,81 @@ class MonthLoginMetricMixin: ...@@ -105,90 +114,81 @@ class MonthLoginMetricMixin:
self.__set_data_to_cache(date, tp, count) self.__set_data_to_cache(date, tp, count)
return count return count
def get_month_metrics_total_count_active_assets(self): def get_dates_metrics_total_count_active_assets(self):
data = [] data = []
for d in self.session_month_dates: for d in self.session_dates_list:
count = self.get_date_asset_count(d) count = self.get_date_asset_count(d)
data.append(count) data.append(count)
return data return data
@lazyproperty @lazyproperty
def month_total_count_active_users(self): def dates_total_count_active_users(self):
count = len(set(self.session_month.values_list('user', flat=True))) count = len(set(self.sessions_queryset.values_list('user', flat=True)))
return count return count
@lazyproperty @lazyproperty
def month_total_count_inactive_users(self): def dates_total_count_inactive_users(self):
total = current_org.get_org_members().count() total = current_org.get_org_members().count()
active = self.month_total_count_active_users active = self.dates_total_count_active_users
count = total - active count = total - active
if count < 0: if count < 0:
count = 0 count = 0
return count return count
@lazyproperty @lazyproperty
def month_total_count_disabled_users(self): def dates_total_count_disabled_users(self):
return current_org.get_org_members().filter(is_active=False).count() return current_org.get_org_members().filter(is_active=False).count()
@lazyproperty @lazyproperty
def month_total_count_active_assets(self): def dates_total_count_active_assets(self):
return len(set(self.session_month.values_list('asset', flat=True))) return len(set(self.sessions_queryset.values_list('asset', flat=True)))
@lazyproperty @lazyproperty
def month_total_count_inactive_assets(self): def dates_total_count_inactive_assets(self):
total = Asset.objects.all().count() total = Asset.objects.all().count()
active = self.month_total_count_active_assets active = self.dates_total_count_active_assets
count = total - active count = total - active
if count < 0: if count < 0:
count = 0 count = 0
return count return count
@lazyproperty @lazyproperty
def month_total_count_disabled_assets(self): def dates_total_count_disabled_assets(self):
return Asset.objects.filter(is_active=False).count() return Asset.objects.filter(is_active=False).count()
# 以下是从week中而来
class WeekSessionMetricMixin: def get_dates_login_times_top5_users(self):
session_week = None users = self.sessions_queryset.values_list('user', flat=True)
@lazyproperty
def session_week(self):
week_ago = timezone.now() - timezone.timedelta(weeks=1)
session_week = Session.objects.filter(date_start__gt=week_ago)
return session_week
def get_week_login_times_top5_users(self):
users = self.session_week.values_list('user', flat=True)
users = [ users = [
{'user': user, 'total': total} {'user': user, 'total': total}
for user, total in Counter(users).most_common(5) for user, total in Counter(users).most_common(5)
] ]
return users return users
def get_week_total_count_login_users(self): def get_dates_total_count_login_users(self):
return len(set(self.session_week.values_list('user', flat=True))) return len(set(self.sessions_queryset.values_list('user', flat=True)))
def get_week_total_count_login_times(self): def get_dates_total_count_login_times(self):
return self.session_week.count() return self.sessions_queryset.count()
def get_week_login_times_top10_assets(self): def get_dates_login_times_top10_assets(self):
assets = self.session_week.values("asset")\ assets = self.sessions_queryset.values("asset") \
.annotate(total=Count("asset"))\ .annotate(total=Count("asset")) \
.annotate(last=Max("date_start")).order_by("-total")[:10] .annotate(last=Max("date_start")).order_by("-total")[:10]
for asset in assets: for asset in assets:
asset['last'] = str(asset['last']) asset['last'] = str(asset['last'])
return list(assets) return list(assets)
def get_week_login_times_top10_users(self): def get_dates_login_times_top10_users(self):
users = self.session_week.values("user") \ users = self.sessions_queryset.values("user") \
.annotate(total=Count("user")) \ .annotate(total=Count("user")) \
.annotate(last=Max("date_start")).order_by("-total")[:10] .annotate(last=Max("date_start")).order_by("-total")[:10]
for user in users: for user in users:
user['last'] = str(user['last']) user['last'] = str(user['last'])
return list(users) return list(users)
def get_week_login_record_top10_sessions(self): def get_dates_login_record_top10_sessions(self):
sessions = self.session_week.order_by('-date_start')[:10] sessions = self.sessions_queryset.order_by('-date_start')[:10]
for session in sessions: for session in sessions:
session.avatar_url = User.get_avatar_url("") session.avatar_url = User.get_avatar_url("")
sessions = [ sessions = [
...@@ -223,7 +223,7 @@ class TotalCountMixin: ...@@ -223,7 +223,7 @@ class TotalCountMixin:
return Session.objects.filter(is_finished=False).count() return Session.objects.filter(is_finished=False).count()
class IndexApi(TotalCountMixin, WeekSessionMetricMixin, MonthLoginMetricMixin, APIView): class IndexApi(TotalCountMixin, DatesLoginMetricMixin, APIView):
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
http_method_names = ['get'] http_method_names = ['get']
...@@ -254,52 +254,52 @@ class IndexApi(TotalCountMixin, WeekSessionMetricMixin, MonthLoginMetricMixin, A ...@@ -254,52 +254,52 @@ class IndexApi(TotalCountMixin, WeekSessionMetricMixin, MonthLoginMetricMixin, A
'total_count_online_sessions': self.get_total_count_online_sessions(), 'total_count_online_sessions': self.get_total_count_online_sessions(),
}) })
if _all or query_params.get('month_metrics'): if _all or query_params.get('dates_metrics'):
data.update({ data.update({
'month_metrics_date': self.get_month_metrics_date(), 'dates_metrics_date': self.get_dates_metrics_date(),
'month_metrics_total_count_login': self.get_month_metrics_total_count_login(), 'dates_metrics_total_count_login': self.get_dates_metrics_total_count_login(),
'month_metrics_total_count_active_users': self.get_month_metrics_total_count_active_users(), 'dates_metrics_total_count_active_users': self.get_dates_metrics_total_count_active_users(),
'month_metrics_total_count_active_assets': self.get_month_metrics_total_count_active_assets(), 'dates_metrics_total_count_active_assets': self.get_dates_metrics_total_count_active_assets(),
}) })
if _all or query_params.get('month_total_count_users'): if _all or query_params.get('dates_total_count_users'):
data.update({ data.update({
'month_total_count_active_users': self.month_total_count_active_users, 'dates_total_count_active_users': self.dates_total_count_active_users,
'month_total_count_inactive_users': self.month_total_count_inactive_users, 'dates_total_count_inactive_users': self.dates_total_count_inactive_users,
'month_total_count_disabled_users': self.month_total_count_disabled_users, 'dates_total_count_disabled_users': self.dates_total_count_disabled_users,
}) })
if _all or query_params.get('month_total_count_assets'): if _all or query_params.get('dates_total_count_assets'):
data.update({ data.update({
'month_total_count_active_assets': self.month_total_count_active_assets, 'dates_total_count_active_assets': self.dates_total_count_active_assets,
'month_total_count_inactive_assets': self.month_total_count_inactive_assets, 'dates_total_count_inactive_assets': self.dates_total_count_inactive_assets,
'month_total_count_disabled_assets': self.month_total_count_disabled_assets, 'dates_total_count_disabled_assets': self.dates_total_count_disabled_assets,
}) })
if _all or query_params.get('week_total_count'): if _all or query_params.get('dates_total_count'):
data.update({ data.update({
'week_total_count_login_users': self.get_week_total_count_login_users(), 'dates_total_count_login_users': self.get_dates_total_count_login_users(),
'week_total_count_login_times': self.get_week_total_count_login_times(), 'dates_total_count_login_times': self.get_dates_total_count_login_times(),
}) })
if _all or query_params.get('week_login_times_top5_users'): if _all or query_params.get('dates_login_times_top5_users'):
data.update({ data.update({
'week_login_times_top5_users': self.get_week_login_times_top5_users(), 'dates_login_times_top5_users': self.get_dates_login_times_top5_users(),
}) })
if _all or query_params.get('week_login_times_top10_assets'): if _all or query_params.get('dates_login_times_top10_assets'):
data.update({ data.update({
'week_login_times_top10_assets': self.get_week_login_times_top10_assets(), 'dates_login_times_top10_assets': self.get_dates_login_times_top10_assets(),
}) })
if _all or query_params.get('week_login_times_top10_users'): if _all or query_params.get('dates_login_times_top10_users'):
data.update({ data.update({
'week_login_times_top10_users': self.get_week_login_times_top10_users(), 'dates_login_times_top10_users': self.get_dates_login_times_top10_users(),
}) })
if _all or query_params.get('week_login_record_top10_sessions'): if _all or query_params.get('dates_login_record_top10_sessions'):
data.update({ data.update({
'week_login_record_top10_sessions': self.get_week_login_record_top10_sessions() 'dates_login_record_top10_sessions': self.get_dates_login_record_top10_sessions()
}) })
return JsonResponse(data, status=200) return JsonResponse(data, status=200)
......
...@@ -15,7 +15,7 @@ class TimezoneMiddleware: ...@@ -15,7 +15,7 @@ class TimezoneMiddleware:
self.get_response = get_response self.get_response = get_response
def __call__(self, request): def __call__(self, request):
tzname = request.META.get('TZ') tzname = request.META.get('HTTP_X_TZ')
if tzname: if tzname:
timezone.activate(pytz.timezone(tzname)) timezone.activate(pytz.timezone(tzname))
else: else:
......
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-2 border-bottom white-bg dashboard-header" style="margin-left:15px;height: 346px"> <div class="col-sm-2 border-bottom white-bg dashboard-header" style="margin-left:15px;height: 346px">
<small>{% trans 'In the past week, a total of ' %}<span class="text-info" id="week_total_count_login_users"></span>{% trans ' users have logged in ' %}<span class="text-success" id="week_total_count_login_times"></span>{% trans ' times asset.' %}</small> <small>{% trans 'In the past week, a total of ' %}<span class="text-info" id="dates_total_count_login_users"></span>{% trans ' users have logged in ' %}<span class="text-success" id="dates_total_count_login_times"></span>{% trans ' times asset.' %}</small>
<ul class="list-group clear-list m-t" id="week_login_times_top5_users"> <ul class="list-group clear-list m-t" id="dates_login_times_top5_users">
</ul> </ul>
</div> </div>
<div class="col-sm-7" id="month_metrics_echarts" style="margin-left: -15px;height: 346px;padding: 15px 0 15px 0;"></div> <div class="col-sm-7" id="dates_metrics_echarts" style="margin-left: -15px;height: 346px;padding: 15px 0 15px 0;"></div>
<div class="col-sm-3 white-bg" id="top1" style="margin-left: -15px;height: 346px"> <div class="col-sm-3 white-bg" id="top1" style="margin-left: -15px;height: 346px">
<div class="statistic-box"> <div class="statistic-box">
<h4> <h4>
...@@ -73,12 +73,12 @@ ...@@ -73,12 +73,12 @@
</p> </p>
<div class="row text-center"> <div class="row text-center">
<div class="col-sm-6"> <div class="col-sm-6">
<div id="month_total_count_users_pie" style="width: 140px; height: 140px;"> <div id="dates_total_count_users_pie" style="width: 140px; height: 140px;">
</div> </div>
<h5>{% trans 'User' %}</h5> <h5>{% trans 'User' %}</h5>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div id="month_total_count_assets_pie" style="width: 140px; height: 140px;"></div> <div id="dates_total_count_assets_pie" style="width: 140px; height: 140px;"></div>
<h5>{% trans 'Asset' %}</h5> <h5>{% trans 'Asset' %}</h5>
</div> </div>
</div> </div>
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<h3><i class="fa fa-inbox"></i>{% trans 'Top 10 assets in a week'%}</h3> <h3><i class="fa fa-inbox"></i>{% trans 'Top 10 assets in a week'%}</h3>
<small><i class="fa fa-map-marker"></i>{% trans 'Login frequency and last login record.' %}</small> <small><i class="fa fa-map-marker"></i>{% trans 'Login frequency and last login record.' %}</small>
</div> </div>
<div class="ibox-content inspinia-timeline" id="week_login_times_top10_assets"> <div class="ibox-content inspinia-timeline" id="dates_login_times_top10_assets">
</div> </div>
</div> </div>
</div> </div>
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
</div> </div>
<div class="ibox-content"> <div class="ibox-content">
<div> <div>
<div class="feed-activity-list" id="week_login_record_top10_sessions"> <div class="feed-activity-list" id="dates_login_record_top10_sessions">
</div> </div>
</div> </div>
</div> </div>
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
<h3><i class="fa fa-user"></i>{% trans 'Top 10 users in a week' %}</h3> <h3><i class="fa fa-user"></i>{% trans 'Top 10 users in a week' %}</h3>
<small><i class="fa fa-map-marker"></i>{% trans 'User login frequency and last login record.' %}</small> <small><i class="fa fa-map-marker"></i>{% trans 'User login frequency and last login record.' %}</small>
</div> </div>
<div class="ibox-content inspinia-timeline" id="week_login_times_top10_users"> <div class="ibox-content inspinia-timeline" id="dates_login_times_top10_users">
</div> </div>
</div> </div>
</div> </div>
...@@ -178,7 +178,7 @@ function requireMonthMetricsECharts(data){ ...@@ -178,7 +178,7 @@ function requireMonthMetricsECharts(data){
'echarts/chart/line' 'echarts/chart/line'
], ],
function (ec) { function (ec) {
var monthMetricsECharts = ec.init(document.getElementById('month_metrics_echarts')); var monthMetricsECharts = ec.init(document.getElementById('dates_metrics_echarts'));
var option = { var option = {
title : { title : {
text: "{% trans 'Monthly data overview' %}", text: "{% trans 'Monthly data overview' %}",
...@@ -204,7 +204,7 @@ function requireMonthMetricsECharts(data){ ...@@ -204,7 +204,7 @@ function requireMonthMetricsECharts(data){
{ {
type : 'category', type : 'category',
boundaryGap : false, boundaryGap : false,
data : data['month_metrics_date'], data : data['dates_metrics_date'],
} }
], ],
yAxis : [ yAxis : [
...@@ -218,21 +218,21 @@ function requireMonthMetricsECharts(data){ ...@@ -218,21 +218,21 @@ function requireMonthMetricsECharts(data){
type:'line', type:'line',
smooth: true, smooth: true,
itemStyle: {normal: {areaStyle: {type: 'default'}}}, itemStyle: {normal: {areaStyle: {type: 'default'}}},
data: data['month_metrics_total_count_login'] data: data['dates_metrics_total_count_login']
}, },
{ {
name: "{% trans 'Active users' %}", name: "{% trans 'Active users' %}",
type: 'line', type: 'line',
smooth: true, smooth: true,
itemStyle: {normal: {areaStyle: {type: 'default'}}}, itemStyle: {normal: {areaStyle: {type: 'default'}}},
data: data['month_metrics_total_count_active_users'] data: data['dates_metrics_total_count_active_users']
}, },
{ {
name:"{% trans 'Active assets' %}", name:"{% trans 'Active assets' %}",
type:'line', type:'line',
smooth:true, smooth:true,
itemStyle: {normal: {areaStyle: {type: 'default'}}}, itemStyle: {normal: {areaStyle: {type: 'default'}}},
data: data['month_metrics_total_count_active_assets'] data: data['dates_metrics_total_count_active_assets']
} }
] ]
}; };
...@@ -249,7 +249,7 @@ function requireMonthTotalCountUsersPie(data){ ...@@ -249,7 +249,7 @@ function requireMonthTotalCountUsersPie(data){
'echarts/chart/pie' 'echarts/chart/pie'
], ],
function (ec) { function (ec) {
var monthTotalCountUsersPie = ec.init(document.getElementById('month_total_count_users_pie')); var monthTotalCountUsersPie = ec.init(document.getElementById('dates_total_count_users_pie'));
var option = { var option = {
tooltip : { tooltip : {
trigger: 'item', trigger: 'item',
...@@ -310,9 +310,9 @@ function requireMonthTotalCountUsersPie(data){ ...@@ -310,9 +310,9 @@ function requireMonthTotalCountUsersPie(data){
} }
}, },
data:[ data:[
{value:data['month_total_count_active_users'], name:"{% trans 'Monthly active users' %}"}, {value:data['dates_total_count_active_users'], name:"{% trans 'Monthly active users' %}"},
{value:data['month_total_count_disabled_users'], name:"{% trans 'Disable user' %}"}, {value:data['dates_total_count_disabled_users'], name:"{% trans 'Disable user' %}"},
{value:data['month_total_count_inactive_users'], name:"{% trans 'Month not logged in user' %}"} {value:data['dates_total_count_inactive_users'], name:"{% trans 'Month not logged in user' %}"}
] ]
} }
] ]
...@@ -329,7 +329,7 @@ function requireMonthTotalCountAssetsPie(data){ ...@@ -329,7 +329,7 @@ function requireMonthTotalCountAssetsPie(data){
'echarts/chart/pie' 'echarts/chart/pie'
], ],
function (ec) { function (ec) {
var monthTotalCountAssetsPie = ec.init(document.getElementById('month_total_count_assets_pie')); var monthTotalCountAssetsPie = ec.init(document.getElementById('dates_total_count_assets_pie'));
var option = { var option = {
tooltip : { tooltip : {
trigger: 'item', trigger: 'item',
...@@ -389,9 +389,9 @@ function requireMonthTotalCountAssetsPie(data){ ...@@ -389,9 +389,9 @@ function requireMonthTotalCountAssetsPie(data){
} }
}, },
data:[ data:[
{value:data['month_total_count_active_assets'], name:"{% trans 'Month is logged into the host' %}"}, {value:data['dates_total_count_active_assets'], name:"{% trans 'Month is logged into the host' %}"},
{value:data['month_total_count_disabled_assets'], name:"{% trans 'Disable host' %}"}, {value:data['dates_total_count_disabled_assets'], name:"{% trans 'Disable host' %}"},
{value:data['month_total_count_inactive_assets'], name:"{% trans 'Month not logged on host' %}"} {value:data['dates_total_count_inactive_assets'], name:"{% trans 'Month not logged on host' %}"}
] ]
} }
] ]
...@@ -431,14 +431,14 @@ function renderMonthMetricsECharts(){ ...@@ -431,14 +431,14 @@ function renderMonthMetricsECharts(){
var success = function (data) { var success = function (data) {
requireMonthMetricsECharts(data) requireMonthMetricsECharts(data)
}; };
renderRequestApi('month_metrics=1', success) renderRequestApi('dates_metrics=1', success)
} }
function renderMonthTotalCountUsersPie(){ function renderMonthTotalCountUsersPie(){
var success = function (data) { var success = function (data) {
requireMonthTotalCountUsersPie(data) requireMonthTotalCountUsersPie(data)
}; };
renderRequestApi('month_total_count_users=1', success) renderRequestApi('dates_total_count_users=1', success)
} }
...@@ -446,15 +446,15 @@ function renderMonthTotalCountAssetsPie(){ ...@@ -446,15 +446,15 @@ function renderMonthTotalCountAssetsPie(){
var success = function (data) { var success = function (data) {
requireMonthTotalCountAssetsPie(data) requireMonthTotalCountAssetsPie(data)
}; };
renderRequestApi('month_total_count_assets=1', success) renderRequestApi('dates_total_count_assets=1', success)
} }
function renderWeekTotalCount(){ function renderWeekTotalCount(){
var success = function (data) { var success = function (data) {
$('#week_total_count_login_users').html(data['week_total_count_login_users']); $('#dates_total_count_login_users').html(data['dates_total_count_login_users']);
$('#week_total_count_login_times').html(data['week_total_count_login_times']) $('#dates_total_count_login_times').html(data['dates_total_count_login_times'])
}; };
renderRequestApi('week_total_count=1', success) renderRequestApi('dates_total_count=1', success)
} }
function renderWeekLoginTimesTop5Users(){ function renderWeekLoginTimesTop5Users(){
...@@ -468,14 +468,14 @@ function renderWeekLoginTimesTop5Users(){ ...@@ -468,14 +468,14 @@ function renderWeekLoginTimesTop5Users(){
"<span class=\"label \">{INDEX}</span> {USER}" + "<span class=\"label \">{INDEX}</span> {USER}" +
"</li>"; "</li>";
$.each(data['week_login_times_top5_users'], function(index, value){ $.each(data['dates_login_times_top5_users'], function(index, value){
html += html_cell.replace('{TOTAL}', value['total']) html += html_cell.replace('{TOTAL}', value['total'])
.replace('{USER}', value['user']) .replace('{USER}', value['user'])
.replace('{INDEX}', index+1) .replace('{INDEX}', index+1)
}); });
$('#week_login_times_top5_users').html(html) $('#dates_login_times_top5_users').html(html)
}; };
renderRequestApi('week_login_times_top5_users=1', success) renderRequestApi('dates_login_times_top5_users=1', success)
} }
function renderWeekLoginTimesTop10Assets(){ function renderWeekLoginTimesTop10Assets(){
...@@ -497,7 +497,7 @@ function renderWeekLoginTimesTop10Assets(){ ...@@ -497,7 +497,7 @@ function renderWeekLoginTimesTop10Assets(){
"</div>" + "</div>" +
"</div>"; "</div>";
var assets = data['week_login_times_top10_assets']; var assets = data['dates_login_times_top10_assets'];
if (assets.length !== 0){ if (assets.length !== 0){
$.each(assets, function(index, value){ $.each(assets, function(index, value){
html += html_cell html += html_cell
...@@ -509,9 +509,9 @@ function renderWeekLoginTimesTop10Assets(){ ...@@ -509,9 +509,9 @@ function renderWeekLoginTimesTop10Assets(){
else{ else{
html += "<p class=\"text-center\">{% trans '(No)' %}</p>" html += "<p class=\"text-center\">{% trans '(No)' %}</p>"
} }
$('#week_login_times_top10_assets').html(html) $('#dates_login_times_top10_assets').html(html)
}; };
renderRequestApi('week_login_times_top10_assets=1', success) renderRequestApi('dates_login_times_top10_assets=1', success)
} }
function renderWeekLoginTimesTop10Users(){ function renderWeekLoginTimesTop10Users(){
...@@ -533,7 +533,7 @@ function renderWeekLoginTimesTop10Users(){ ...@@ -533,7 +533,7 @@ function renderWeekLoginTimesTop10Users(){
"</div>" + "</div>" +
"</div>"; "</div>";
var users = data['week_login_times_top10_users']; var users = data['dates_login_times_top10_users'];
if (users.length !== 0){ if (users.length !== 0){
$.each(users, function(index, value){ $.each(users, function(index, value){
html += html_cell.replaceAll('{USER}', value['user']) html += html_cell.replaceAll('{USER}', value['user'])
...@@ -544,9 +544,9 @@ function renderWeekLoginTimesTop10Users(){ ...@@ -544,9 +544,9 @@ function renderWeekLoginTimesTop10Users(){
else{ else{
html += "<p class=\"text-center\">{% trans '(No)' %}</p>" html += "<p class=\"text-center\">{% trans '(No)' %}</p>"
} }
$('#week_login_times_top10_users').html(html) $('#dates_login_times_top10_users').html(html)
}; };
renderRequestApi('week_login_times_top10_users=1', success) renderRequestApi('dates_login_times_top10_users=1', success)
} }
function renderWeekLoginRecordTop10Sessions(){ function renderWeekLoginRecordTop10Sessions(){
...@@ -564,7 +564,7 @@ function renderWeekLoginRecordTop10Sessions(){ ...@@ -564,7 +564,7 @@ function renderWeekLoginRecordTop10Sessions(){
"</div>" + "</div>" +
"</div>"; "</div>";
var users = data['week_login_record_top10_sessions']; var users = data['dates_login_record_top10_sessions'];
if (users.length !== 0){ if (users.length !== 0){
$.each(users, function(index, value){ $.each(users, function(index, value){
console.log(value['is_finished']) console.log(value['is_finished'])
...@@ -579,10 +579,10 @@ function renderWeekLoginRecordTop10Sessions(){ ...@@ -579,10 +579,10 @@ function renderWeekLoginRecordTop10Sessions(){
else{ else{
html += "<p class=\"text-center\">{% trans '(No)' %}</p>" html += "<p class=\"text-center\">{% trans '(No)' %}</p>"
} }
$('#week_login_record_top10_sessions').html(html) $('#dates_login_record_top10_sessions').html(html)
}; };
renderRequestApi('week_login_record_top10_sessions=1', success) renderRequestApi('dates_login_record_top10_sessions=1', success)
} }
function renderData(){ function renderData(){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册