Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_aliyun_beta
jingquan huang 6 years ago
commit a8f0dde38a

@ -13,6 +13,7 @@
//= require bootstrap-datepicker
//= require bootstrap.viewer
//= require echarts
//= require lib/codemirror
//= require mode/shell/shell

@ -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

@ -12,19 +12,19 @@
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Traffic</h5>
<span class="h2 font-weight-bold mb-0">350,897</span>
<h5 class="card-title text-uppercase text-muted mb-0">当日活跃用户</h5>
<span class="h2 font-weight-bold mb-0"><%= @active_user_count %></span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-danger text-white rounded-circle shadow">
<i class="fas fa-pie-chart"></i>
<div class="icon icon-shape rounded-circle shadow">
<i class="fa fa-users"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-success mr-2"><i class="fa fa-arrow-up"></i> 3.48%</span>
<span class="text-nowrap">Since last month</span>
</p>
<!-- <p class="mt-3 mb-0 text-muted text-sm">-->
<!-- <span class="text-success mr-2"><i class="fa fa-arrow-up"></i> 3.48%</span>-->
<!-- <span class="text-nowrap">Since last month</span>-->
<!-- </p>-->
</div>
</div>
</div>
@ -33,19 +33,19 @@
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">New users</h5>
<span class="h2 font-weight-bold mb-0">2,356</span>
<h5 class="card-title text-uppercase text-muted mb-0">7天内活跃用户数</h5>
<span class="h2 font-weight-bold mb-0"><%= @weekly_active_user_count %></span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-warning text-white rounded-circle shadow">
<i class="fas fa-pie-chart"></i>
<div class="icon icon-shape rounded-circle shadow">
<i class="fa fa-users"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-danger mr-2"><i class="fas fa-arrow-down"></i> 3.48%</span>
<span class="text-nowrap">Since last week</span>
</p>
<!-- <p class="mt-3 mb-0 text-muted text-sm">-->
<!-- <span class="text-danger mr-2"><i class="fas fa-arrow-down"></i> 3.48%</span>-->
<!-- <span class="text-nowrap">Since last week</span>-->
<!-- </p>-->
</div>
</div>
</div>
@ -54,19 +54,19 @@
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Sales</h5>
<span class="h2 font-weight-bold mb-0">924</span>
<h5 class="card-title text-uppercase text-muted mb-0">30天内活跃用户数</h5>
<span class="h2 font-weight-bold mb-0"><%= @month_active_user_count %></span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-yellow text-white rounded-circle shadow">
<i class="fas fa-user"></i>
<div class="icon icon-shape rounded-circle shadow">
<i class="fa fa-users"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-warning mr-2"><i class="fas fa-arrow-down"></i> 1.10%</span>
<span class="text-nowrap">Since yesterday</span>
</p>
<!-- <p class="mt-3 mb-0 text-muted text-sm">-->
<!-- <span class="text-warning mr-2"><i class="fas fa-arrow-down"></i> 1.10%</span>-->
<!-- <span class="text-nowrap">Since yesterday</span>-->
<!-- </p>-->
</div>
</div>
</div>
@ -75,19 +75,19 @@
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Performance</h5>
<span class="h2 font-weight-bold mb-0">49,65%</span>
<h5 class="card-title text-uppercase text-muted mb-0">30天内新增用户数</h5>
<span class="h2 font-weight-bold mb-0"><%= @new_user_count %></span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-info text-white rounded-circle shadow">
<i class="fas fa-pie-chart"></i>
<div class="icon icon-shape rounded-circle shadow">
<i class="fa fa-user-plus"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-success mr-2"><i class="fas fa-arrow-up"></i> 12%</span>
<span class="text-nowrap">Since last month</span>
</p>
<!-- <p class="mt-3 mb-0 text-muted text-sm">-->
<!-- <span class="text-success mr-2"><i class="fas fa-arrow-up"></i> 12%</span>-->
<!-- <span class="text-nowrap">Since last month</span>-->
<!-- </p>-->
</div>
</div>
</div>
@ -95,94 +95,124 @@
</div>
</div>
</div>
<div class="container-fluid mt--7">
<div class="container-fluid mt--7 pie-statistic">
<div class="row mt-5">
<div class="col-xl-8 mb-5 mb-xl-0">
<div class="card shadow">
<div class="card-header border-0">
<div class="row align-items-center">
<div class="col">
<h3 class="mb-0">Page visits</h3>
</div>
<div class="col text-right">
<a href="#!" class="btn btn-sm btn-primary">Test</a>
</div>
<h5 class="mb-0">近7天评测次数</h5>
</div>
</div>
<div class="table-responsive">
<!-- Projects table -->
<table class="table align-items-center table-flush">
<thead class="thead-light">
<tr>
<th scope="col">Test</th>
<th scope="col">Test</th>
<th scope="col">Test</th>
<th scope="col">Test</th>
</tr>
</thead>
<tbody>
<% 5.times do %>
<tr>
<th scope="row">/test/</th>
<td>4,569</td>
<td>340</td>
<td>
<i class="fas fa-arrow-up text-success mr-3"></i> 46,53%
</td>
</tr>
<% end %>
</tbody>
</table>
<div id="evaluate-pie" class="pie"></div>
</div>
</div>
</div>
<div class="col-xl-4">
<div class="card shadow">
<div class="card-header border-0">
<div class="row align-items-center">
<div class="col">
<h3 class="mb-0">Test</h3>
</div>
<div class="col text-right">
<a href="#!" class="btn btn-sm btn-primary">Test</a>
</div>
<h5 class="mb-0">30天内新增用户</h5>
</div>
</div>
<div class="table-responsive">
<!-- Projects table -->
<table class="table align-items-center table-flush">
<thead class="thead-light">
<tr>
<th scope="col">Test</th>
<th scope="col">Test</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<% 5.times do %>
<tr>
<th scope="row">
Test
</th>
<td>
1,480
</td>
<td>
<div class="d-flex align-items-center">
<span class="mr-2">60%</span>
<div>
<div class="progress">
<div class="progress-bar bg-gradient-danger" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;"></div>
</div>
</div>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<div id="month-active-user" class="pie"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--<div class="container-fluid mt--7">-->
<!-- <div class="row mt-5">-->
<!-- <div class="col-xl-8 mb-5 mb-xl-0">-->
<!-- <div class="card shadow">-->
<!-- <div class="card-header border-0">-->
<!-- <div class="row align-items-center">-->
<!-- <div class="col">-->
<!-- <h3 class="mb-0">Page visits</h3>-->
<!-- </div>-->
<!-- <div class="col text-right">-->
<!-- <a href="#!" class="btn btn-sm btn-primary">Test</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="table-responsive">-->
<!-- <table class="table align-items-center table-flush">-->
<!-- <thead class="thead-light">-->
<!-- <tr>-->
<!-- <th scope="col">Test</th>-->
<!-- <th scope="col">Test</th>-->
<!-- <th scope="col">Test</th>-->
<!-- <th scope="col">Test</th>-->
<!-- </tr>-->
<!-- </thead>-->
<!-- <tbody>-->
<%# 5.times do %>
<!-- <tr>-->
<!-- <th scope="row">/test/</th>-->
<!-- <td>4,569</td>-->
<!-- <td>340</td>-->
<!-- <td>-->
<!-- <i class="fas fa-arrow-up text-success mr-3"></i> 46,53%-->
<!-- </td>-->
<!-- </tr>-->
<%# end %>
<!-- </tbody>-->
<!-- </table>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="col-xl-4">-->
<!-- <div class="card shadow">-->
<!-- <div class="card-header border-0">-->
<!-- <div class="row align-items-center">-->
<!-- <div class="col">-->
<!-- <h3 class="mb-0">Test</h3>-->
<!-- </div>-->
<!-- <div class="col text-right">-->
<!-- <a href="#!" class="btn btn-sm btn-primary">Test</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="table-responsive">-->
<!-- <table class="table align-items-center table-flush">-->
<!-- <thead class="thead-light">-->
<!-- <tr>-->
<!-- <th scope="col">Test</th>-->
<!-- <th scope="col">Test</th>-->
<!-- <th scope="col"></th>-->
<!-- </tr>-->
<!-- </thead>-->
<!-- <tbody>-->
<%# 5.times do %>
<!-- <tr>-->
<!-- <th scope="row">-->
<!-- Test-->
<!-- </th>-->
<!-- <td>-->
<!-- 1,480-->
<!-- </td>-->
<!-- <td>-->
<!-- <div class="d-flex align-items-center">-->
<!-- <span class="mr-2">60%</span>-->
<!-- <div>-->
<!-- <div class="progress">-->
<!-- <div class="progress-bar bg-gradient-danger" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;"></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </td>-->
<!-- </tr>-->
<%# end %>
<!-- </tbody>-->
<!-- </table>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!--</div>-->

@ -779,6 +779,12 @@ Rails.application.routes.draw do
namespace :admins do
get '/', to: 'dashboards#index'
resources :dashboards, only: [:index] do
collection do
get :month_active_user
get :evaluate
end
end
resources :files, only: [:create]
resources :daily_school_statistics, only: [:index] do

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -372,7 +372,6 @@ class App extends Component {
path="/interesse" component={Interestpage}
/>
<Route path="/shixuns/new" component={Newshixuns}>
</Route>

@ -595,23 +595,25 @@ class studentsList extends Component{
{ isAdmin && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.deleteDir()}>删除分班</WordsBtn> }
{ isAdmin && !isParent && course_group_id != 0 && <WordsBtn style="blue" className="mr30" onClick={()=>this.renameDir()}>分班重命名</WordsBtn> }
<style>{`
.drop_down_menu li a {
padding: 0px;
font-size: 14px;
}
.drop_down_menu {
width: 93px;
}
.drop_down_menu li {
overflow: visible;
width: 93px;
}
.drop_down_menu, .drop_down_normal {
padding-top: 10px;
padding-bottom: 8px;
}
`}</style>
.drop_down_menu li a {
padding: 0px;
font-size: 14px;
}
.drop_down_menu {
width: 93px;
}
.drop_down_menu li {
overflow: visible;
width:100%;
box-sizing:boder-box;
float:unset;
}
.drop_down_menu, .drop_down_normal {
padding-top: 10px;
padding-bottom: 8px;
}
`}</style>
{ isAdmin &&
<li className="li_line drop_down fr color-blue font-16">
导出<i className="iconfont icon-xiajiantou font-12 ml2"></i>

@ -870,14 +870,14 @@ class CoursesNew extends Component {
})(
<AutoComplete style={{ width: 280 }}
onSearch={this.handleSearchschool}
// onChange={this.handleChangeschools}
onInput={this.handleSearchschool}
className={"fl construction mr10 yslzxueshis2"}
placeholder="请输入并选择课本堂的所属单位"
dataSource={optionschool}
>
{optionschool}
</AutoComplete>
)}
<span className={"newcoursestitle fl"}>
<span className={"newcoursestitle fl"}>
{/*(输入内容出现匹配的下拉菜单←同账号管理的单位信息填写)*/}
</span>
<div id='isschool'></div>

@ -1026,10 +1026,11 @@ class Goldsubject extends Component {
<AutoComplete style={{ width: 280 }}
onSearch={this.handleSearchschool}
// onChange={this.handleChangeschools}
onInput={this.handleSearchschool}
className={"fl construction mr10 yslzxueshis2 "}
placeholder="请输入并选择课本堂的所属单位"
dataSource={optionschool}
>
{optionschool}
</AutoComplete>
)}
<span className={"newcoursestitle fl"}>

@ -1803,27 +1803,49 @@ class PollNew extends Component {
var urlly = `/polls/${poll_id}/poll_questions.json`
var max_choicess = null;
var min_choicess = null;
if (max_choices === 0 && min_choices === 0) {
try {
if (max_choices === 0 && min_choices === 0) {
max_choicess = null;
min_choicess = null;
} else {
max_choicess = max_choices;
min_choicess = min_choices;
}
}catch (e) {
max_choicess = null;
min_choicess = null;
} else {
max_choicess = max_choices;
min_choicess = min_choices;
}
console.log("createquestionsandanswers");
console.log(max_choicess);
console.log(min_choicess);
console.log(length);
axios.post(urlly, {
// console.log("createquestionsandanswers");
// console.log(max_choicess);
// console.log(min_choicess);
// console.log(length);
var datay={};
datay={
question_title: object.question.question_title,
question_type: number,
is_necessary: object.question.is_necessary,
max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option,
question_other_answer: null,
insert_id: insert_id
}).then((result) => {
}
try {
if(number===2){
datay={
question_title: object.question.question_title,
question_type: number,
is_necessary: object.question.is_necessary,
max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option,
question_other_answer: null,
insert_id: insert_id
}
}
}catch (e) {
}
axios.post(urlly, datay).then((result) => {
// try {
if (result !== undefined) {
if (result.data.status === 0) {
@ -1856,27 +1878,50 @@ class PollNew extends Component {
var thiss = this;
var max_choicess = null;
var min_choicess = null;
if (max_choices === 0 && min_choices === 0) {
try {
if (max_choices === 0 && min_choices === 0) {
max_choicess = null;
min_choicess = null;
} else {
max_choicess = max_choices;
min_choicess = min_choices;
}
}catch (e) {
max_choicess = null;
min_choicess = null;
} else {
max_choicess = max_choices;
min_choicess = min_choices;
}
console.log("createquestionsandanswers");
console.log(max_choicess);
console.log(min_choicess);
console.log(length);
axios.put(url, {
// console.log("createquestionsandanswers");
// console.log(max_choicess);
// console.log(min_choicess);
// console.log(length);
var datay={};
datay={
// debug: true,
question_title: object.question.question_title,
question_type: number,
is_necessary: object.question.is_necessary,
max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option,
question_other_answer: null,
}).then((result) => {
};
try {
if(number===2){
datay={
// debug: true,
question_title: object.question.question_title,
question_type: number,
is_necessary: object.question.is_necessary,
max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option,
question_other_answer: null,
};
}
}catch (e) {
}
axios.put(url,datay).then((result) => {
try {
if (result.data.status === 0) {
this.props.showNotification(`编辑题目成功`);

@ -35,6 +35,7 @@ class DetailTop extends Component{
getdatalist=()=>{
let courseslist=[];
let keys=1;
let listtype=false;
if(this.props.courses!=undefined&&this.props.courses.length!=0){
if(this.props.detailInfoList.has_start===true){
this.props.courses.map((item,key)=>{
@ -47,14 +48,31 @@ class DetailTop extends Component{
})
}else{
this.props.courses.map((item,key)=>{
if(this.props.pathtopskey===key+1){
keys=key+1
return(
courseslist.push(item)
)
}
})
this.props.courses.map((item,key)=>{
if(listtype===false){
keys=key+1
if(item.course_status.status===0) {
listtype=true
return (
courseslist.push(item)
)
}
}
})
this.props.courses.map((item,key)=>{
if(listtype===false){
keys=key+1
if(item.course_status.status===2) {
listtype=true
return (
courseslist.push(item)
)
}
}
})
}
}
this.setState({

@ -782,14 +782,14 @@ submittojoinclass=(value)=>{
<style>
{
`
.posi-searchs{
opacity: 1;
position: absolute;
top: -2px;
background: #fff;
z-index:10000;
right: 185px;
}
.posi-searchs{
opacity: 1;
position: absolute;
top: -2px;
background: #fff;
z-index:10000;
right: 185px;
}
`
}
</style>
@ -869,6 +869,11 @@ submittojoinclass=(value)=>{
<li style={{display: this.props.Headertop === undefined ? 'none' : this.props.Headertop.customer_management_url===null || this.props.Headertop.customer_management_url===""? 'none' : 'block'}}>
<a href={this.props.Headertop === undefined ? '' : this.props.Headertop.customer_management_url}>客户管理</a>
</li>
{
this.props.Headertop && this.props.Headertop.college_identifier &&
<li><a href={`/colleges/${this.props.Headertop.college_identifier}/statistics`}>学院统计</a></li>
}
<li><a href={`/account/profile`}>账号管理</a></li>
{/*<li><a onClick={()=>this.educoderlogin()} >登入测试接口</a></li>*/}
{/*<li><a onClick={()=>this.trialapplications()} >试用申请</a> </li>*/}

@ -581,7 +581,7 @@ class TPMBanner extends Component {
return (
shixunsDetails===undefined?"":
<div>
<div className="shixunDetail">
<div className="shixunDetail_top">
{AccountProfiletype===true?<AccountProfile

@ -28,6 +28,8 @@ import TPMRanking_listComponent from './TPMRanking_listContainer'
import TPMCollaboratorsComponent from './TPMCollaboratorsContainer'
import '../page/tpiPage.css'
const $ = window.$
//任务
// const TPMChallengeComponent = Loadable({
// loader: () => import('./TPMChallengeContainer'),
@ -116,6 +118,13 @@ const TPMUpdatepropaede = Loadable({
})
// 版本库添加文件
const AddFile = Loadable({
loader: () => import('./shixunchild/Repository/RepositoryAddFile'),
loading: Loading,
})
const interceptorUrlArray = ['repository.json', 'commits.json', 'propaedeutics.json'
, 'challenges.json', 'discusses.json', 'ranking_list.json', 'collaborators.json']
const cacheInterceptorUrlMap = {}
@ -258,15 +267,18 @@ class TPMIndex extends Component {
// }
render() {
let url = window.location.href;
let flag = url.indexOf("add_file")>-1;
return (
<div className="newMain clearfix">
<TPMBanner
{...this.props}
{...this.state}
></TPMBanner>
{
!flag &&
<TPMBanner
{...this.props}
{...this.state}
></TPMBanner>
}
<Switch {...this.props}>
<Route path="/shixuns/:shixunId/repository/:repoId/commits" render={
@ -279,10 +291,15 @@ class TPMIndex extends Component {
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/add_file" render={
(props) => (<AddFile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props}
/>)
}></Route>
{/* <Route exact path="/shixuns/:shixunId/propaedeutics" component={TPMPropaedeuticsComponent}></Route> */}
<Route exact path="/shixuns/:shixunId/propaedeutics" render={

@ -13,7 +13,9 @@ import axios from 'axios';
import { trace, trace_collapse ,getImageUrl, toPath} from "educoder";
import RepositoryDirectories from './RepositoryDirectories'
import RepositoryAddFile from './RepositoryAddFile'
import { ActionBtn , NoneData } from 'educoder'
const $ = window.$;
// 点击按钮复制功能
@ -47,8 +49,7 @@ class Repository extends Component {
if(this.props.author!=undefined){
userauthority=this.props.author.login===""||this.props.author.user_id===""||this.props.author.login===null||this.props.author.user_id===null;
}
// console.log(commits)
return (
<React.Fragment>
{/* jfinalshop/WebRoot */}
@ -83,7 +84,12 @@ class Repository extends Component {
<a href="/forums/2784" target="_blank"
className=" guideBtn" >Git使用指南</a>
{/* <RepositoryAddFile {...this.props} {...this.state}></RepositoryAddFile> */}
{
this.props.current_user && this.props.current_user.admin ==true ?
<ActionBtn style="orangeLine" className="ml20" to={`/shixuns/${match.params.shixunId}/repository/add_file`}>+添加文件</ActionBtn>:""
}
<div className="fr font-12 color-grey-9 pr">
<label className="fl mt2">网址克隆</label>
<input type="text" id="copy_rep_content" className="fl url-input mt2"
@ -162,12 +168,7 @@ class Repository extends Component {
</style>
{/* 用户、最近提交时间 */}
{
trees === undefined || trees === null ? <div className="alltask">
<div className="edu-tab-con-box clearfix edu-txt-center">
<img className="edu-nodata-img mb20" src={getImageUrl("images/educoder/nodata.png")}/>
<p className="edu-nodata-p mb20">暂时还没有相关数据哦</p>
</div>
</div> :
trees === undefined || trees === null ? <NoneData></NoneData>:
<div>
<div className="edu-back-skyblue padding10-20 clearfix">
<img alt={author.name} className="radius fl mr10"

@ -1,49 +1,194 @@
import React, { Component } from 'react';
import { ActionBtn } from 'educoder'
import { Form , Modal } from 'antd'
import { Form , Modal , Input , Breadcrumb , Button } from 'antd'
import { Link } from 'react-router-dom'
import axios from 'axios'
/**
---------------------------- START
*/
function getModeByMirrorName(mirror_name) {
let mode = 'javascript'
if (mirror_name && mirror_name.length) {
for (let i = 0; i < mirror_name.length; i++) {
let modeVal = mirrorNameModeMap[mirror_name[i]];
if (modeVal) {
mode = modeVal;
break;
}
}
}
return mode;
}
const _extraKeys = {"Alt-/": "autocomplete"};
function createCMOptions(mirror_name) {
let mode = getModeByMirrorName(mirror_name)
let cmOptions = {
lineNumbers: true,
mode: mode,
theme: "railscasts",
indentUnit:4,
matchBrackets: true,
autoRefresh: true,
smartIndent: true,//智能换行
extraKeys: _extraKeys,
autofocus: true,
styleActiveLine: true,
lint: true,
gutters: ["CodeMirror-linenumbers", "breakpoints", "CodeMirror-lint-markers"]
};
return cmOptions;
}
const mirrorNameModeMap = {
'JFinal': 'text/x-java',
'Java': 'text/x-java',
'Kotlin': 'text/x-kotlin',
'C/C++' : 'text/x-c++src',
'MachineLearning': {
name: "python",
version: 3,
singleLineStringErrors: false
},
'Python2.7': {
name: "python",
version: 3,
singleLineStringErrors: false
},
'Python3.6': {
name: "python",
version: 3,
singleLineStringErrors: false
},
}
/**
---------------------------- END
*/
class RepositoryAddFile extends Component {
constructor(props) {
super(props);
this.state={
visible:false
}
}
addFile = () =>{
this.setState({
visible:true
})
componentDidMount(){
let cmOptions = createCMOptions(this.props.mirror_name)
const extend_editor = window.CodeMirror.fromTextArea(window.$('#codemirror-file-edit')[0]
, cmOptions);
// tpi没setValue也可以
extend_editor.setValue('')
extend_editor.refresh();
// 拖拽也需要用 window.editor_CodeMirror.refresh()
window.editor_tempCodeMirror = extend_editor;
this.extend_editor = extend_editor;
}
cancelAdd = () =>{
this.setState({
visible:false
checkPath= (rule, value, callback) =>{
if (value.indexOf("/") > -1 && value.length==1 ) {
callback('请输入正确的文件路径');
}else{
callback();
}
}
handleSubmit = () =>{
this.props.form.validateFieldsAndScroll((err, values) => {
if(!err){
let shixunId = this.props.match.params.shixunId;
let url = `/shixuns/${shixunId}/add_file.json`
axios.post(url,{
path:values.path,
message:values.message,
content:this.extend_editor.getValue()
}).then((result)=>{
if(result){
this.props.history.push(`${result.data.url}`)
}
}).catch((error)=>{
console.log(error);
})
}
})
}
render(){
let { visible } = this.state
const {getFieldDecorator} = this.props.form;
let { shixunId } = this.props.match.params;
return(
<React.Fragment>
<ActionBtn style="orangeLine" className="ml20" onClick={this.addFile}>+添加文件</ActionBtn>
<Modal
className={"RepositioryModal"}
title={'添加文件'}
visible={visible}
closable={false}
footer={null}
destroyOnClose={true}
width="550px"
>
<div className="task-popup-content">
<div className="educontent">
<style>
{`
.formStyle .ant-form-item{
margin-bottom:10px!important;
}
.formStyle .ant-col.ant-form-item-label{
margin-left:-10px;
line-height:30px;
margin-bottom:10px;
}
.breadcrumb .ant-breadcrumb-separator{
margin:0px 2px;
}
/*.filecode .CodeMirror.cm-s-railscasts{
border:1px solid #E5E5E5;
}
.filecode .CodeMirror.cm-s-railscasts .CodeMirror-sizer,.filecode .CodeMirror-gutters,.filecode .CodeMirror-scroll{
background:#fff;
}
.filecode .CodeMirror-linenumber{
text-align:center
}*/
`}
</style>
<p className="mt10 mb10">
<Breadcrumb separator='>' className="breadcrumb">
<Breadcrumb.Item href='/shixuns'>实训项目</Breadcrumb.Item>
<Breadcrumb.Item href={`/shixuns/${shixunId}/repository`}>版本库</Breadcrumb.Item>
<Breadcrumb.Item>添加新文件</Breadcrumb.Item>
</Breadcrumb>
</p>
<Form onSubmit={this.handleSubmit} className="formStyle">
<div className="edu-back-white padding20-30 mb10">
<Form.Item label="文件名">
{getFieldDecorator('path', {
rules: [
{required: true, message: "文件名不能为空"},
{
validator:this.checkPath
}]
})(
<Input placeholder="输入文件路径名src/HelloWord.java" className="winput-300-35 fl"/>
)}
</Form.Item>
</div>
<div className="edu-back-white padding30">
<p className="ant-form-item-label">
<label>内容</label>
</p>
<div className="mt10 mb25 repoCMWrapper filecode">
<textarea className="" id="codemirror-file-edit" style={{display:'none'}} name="content"></textarea>
</div>
<Form.Item label="提交信息">
{getFieldDecorator('message', {
rules: [{required: true, message: "请输入提交信息"}],
})(
<textarea className="winput-100-130 fl"></textarea>
)}
</Form.Item>
</div>
<div className="clearfix mt30 edu-txt-center mb10">
<a className="task-btn color-white mr30" onClick={this.cancelAdd}>取消</a>
<a className="task-btn task-btn-orange">提交</a>
<div className="clearfix mt30 edu-txt-right mb30">
<Button type="primary" className="defalutSubmitbtn fr ml20" onClick={this.handleSubmit}>提交</Button>
<Link className="defalutCancelbtn fr" to={`/shixuns/${shixunId}/repository`}>取消</Link>
</div>
</Modal>
</React.Fragment>
</Form>
</div>
)
}
}

Loading…
Cancel
Save