dev_aliyun_beta
commit
d66fe97179
@ -0,0 +1,66 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-dashboards-index-page').length > 0) {
|
||||
// 月新增用户
|
||||
var monthChart = echarts.init(document.getElementById('month-active-user'));
|
||||
monthChart.setOption({
|
||||
tooltip: {
|
||||
show: "true",
|
||||
trigger: 'item',
|
||||
formatter: '{c0}',
|
||||
backgroundColor: 'rgba(0,0,0,0.7)', // 背景
|
||||
padding: [8, 10], //内边距
|
||||
extraCssText: 'box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);', //添加阴影
|
||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
}
|
||||
},
|
||||
series : [
|
||||
{
|
||||
name: '访问来源',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
data: []
|
||||
}
|
||||
]
|
||||
});
|
||||
monthChart.showLoading();
|
||||
$.get('/admins/dashboards/month_active_user.json').done(function(data){
|
||||
monthChart.setOption({
|
||||
series: [
|
||||
{ data: data.data }
|
||||
]
|
||||
});
|
||||
|
||||
monthChart.hideLoading();
|
||||
});
|
||||
|
||||
|
||||
// 近七天评测次数
|
||||
var evaluateChart = echarts.init(document.getElementById('evaluate-pie'));
|
||||
evaluateChart.setOption({
|
||||
tooltip: {
|
||||
show: "true",
|
||||
trigger: 'item',
|
||||
formatter: '{c0}',
|
||||
backgroundColor: 'rgba(0,0,0,0.7)', // 背景
|
||||
padding: [8, 10], //内边距
|
||||
extraCssText: 'box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);', //添加阴影
|
||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
}
|
||||
},
|
||||
xAxis: { type: 'category', boundaryGap: false, data: [] },
|
||||
yAxis: { type: 'value' },
|
||||
series: [{ data: [], type: 'line', areaStyle: {} }]
|
||||
});
|
||||
evaluateChart.showLoading();
|
||||
$.get('/admins/dashboards/evaluate.json').done(function(data){
|
||||
evaluateChart.setOption({
|
||||
xAxis: { data: data.names },
|
||||
series: [{ data: data.data }]
|
||||
});
|
||||
|
||||
evaluateChart.hideLoading();
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
.admins-dashboards-index-page {
|
||||
.pie-statistic {
|
||||
.pie {
|
||||
height: 300px;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,50 @@
|
||||
class Admins::DashboardsController < Admins::BaseController
|
||||
def index
|
||||
@active_user_count = User.where(last_login_on: today).count
|
||||
@weekly_active_user_count = User.where(last_login_on: current_week).count
|
||||
@month_active_user_count = User.where(last_login_on: current_month).count
|
||||
|
||||
@new_user_count = User.where(created_on: current_month).count
|
||||
end
|
||||
|
||||
def month_active_user
|
||||
count = UserExtension.where(created_at: current_month).group(:identity).count
|
||||
|
||||
data = [
|
||||
{ value: count['teacher'].to_i, name: '老师' },
|
||||
{ value: count['student'].to_i, name: '学生' },
|
||||
{ value: count['professional'].to_i, name: '专业人士' }
|
||||
]
|
||||
|
||||
render_ok(data: data)
|
||||
end
|
||||
|
||||
def evaluate
|
||||
names = []
|
||||
data = []
|
||||
|
||||
7.times do |i|
|
||||
date = i.days.ago
|
||||
names.unshift(date.strftime('%Y-%m-%d'))
|
||||
|
||||
count = Output.where(created_at: date.beginning_of_day..date.end_of_day).count
|
||||
data.unshift(count)
|
||||
end
|
||||
|
||||
render_ok(names: names, data: data)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def today
|
||||
Time.now.beginning_of_day..Time.now.end_of_day
|
||||
end
|
||||
|
||||
def current_week
|
||||
7.days.ago.beginning_of_day..Time.now.end_of_day
|
||||
end
|
||||
|
||||
def current_month
|
||||
30.days.ago.beginning_of_day..Time.now.end_of_day
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,66 @@
|
||||
import React, { Component } from 'react';
|
||||
import axios from 'axios'
|
||||
|
||||
|
||||
import ExerciseNewCommon from '../../../courses/exercise/ExerciseNewCommon'
|
||||
|
||||
class ExerciseBanksEdit extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state = {
|
||||
isPublic: undefined,
|
||||
// isGroup: false
|
||||
}
|
||||
}
|
||||
componentDidMount = () =>{
|
||||
|
||||
|
||||
}
|
||||
|
||||
initData = (responseData) =>{
|
||||
const Id = this.props.match.params.Id
|
||||
|
||||
const crumbData={
|
||||
title:'编辑',
|
||||
is_public: responseData && responseData.data && responseData.data.exercise.is_public,
|
||||
crumbArray:[
|
||||
{to:`/banks/exercise/${Id}`,content:'详情'},
|
||||
{content:'编辑'}
|
||||
]
|
||||
}
|
||||
this.props.initPublic(crumbData);
|
||||
}
|
||||
|
||||
render(){
|
||||
let { workId } = this.props.match.params
|
||||
const common = {
|
||||
// onCancel:this.onCancel,
|
||||
// isGroup: this.isGroup,
|
||||
// doNew: this.doNew,
|
||||
// doEdit: this.doEdit,
|
||||
initData: this.initData
|
||||
}
|
||||
return(
|
||||
<div className="courseForm">
|
||||
<style>
|
||||
{`
|
||||
.courseForm .ant-col-sm-24{
|
||||
text-align:left;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
<ExerciseNewCommon
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
{...common}
|
||||
wrappedComponentRef={(ref) => this.exerciseNewCommonRef = ref}
|
||||
isEdit={true}
|
||||
shixunsUrl={`/exercise_banks/choose_shixun.json`}
|
||||
exercise_url={'exercise_banks'}
|
||||
exercise_url_questions={'exercise_bank_questions'}
|
||||
></ExerciseNewCommon>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default ExerciseBanksEdit;
|
Loading…
Reference in new issue