|
|
|
@ -8,7 +8,7 @@ import '../shixunchildCss/Challenges.css';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
const $ = window.$;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//12.20,14:11
|
|
|
|
|
class Challengesjupyter extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
@ -48,54 +48,33 @@ class Challengesjupyter extends Component {
|
|
|
|
|
isopentitletype:"Less",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.getjianjiesize()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
//console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getjianjiesize=()=>{
|
|
|
|
|
let {ChallengesDataList}=this.state;
|
|
|
|
|
let boxoffsetHeigh;
|
|
|
|
|
let box=document.getElementById("shixunchallengesid");
|
|
|
|
|
|
|
|
|
|
if(box){
|
|
|
|
|
boxoffsetHeigh=box.offsetHeight
|
|
|
|
|
if(ChallengesDataList === undefined || ChallengesDataList&&ChallengesDataList.description=== ""||ChallengesDataList&&ChallengesDataList.description===null||ChallengesDataList&&ChallengesDataList.description===undefined){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
if(this.state.isopentitletype==="greater"){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
if(boxoffsetHeigh>=300){
|
|
|
|
|
this.setState({
|
|
|
|
|
opentitletype:true,
|
|
|
|
|
isopentitletype:"greater",
|
|
|
|
|
boxoffsetHeigh:boxoffsetHeigh
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
isopentitletype:"Less",
|
|
|
|
|
boxoffsetHeigh:boxoffsetHeigh
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
componentDidUpdate = (prevProps,prevState) => {
|
|
|
|
|
|
|
|
|
|
//防止陷入无限循环
|
|
|
|
|
if(prevState.ChallengesDataList!=this.state.ChallengesDataList){
|
|
|
|
|
if(this.state.isopentitletype==="greater"){
|
|
|
|
|
let boxoffsetHeigh;
|
|
|
|
|
let box=document.getElementById("shixunchallengesid");
|
|
|
|
|
if(box){
|
|
|
|
|
boxoffsetHeigh=box.offsetHeight
|
|
|
|
|
if(boxoffsetHeigh<300){
|
|
|
|
|
this.setState({
|
|
|
|
|
isopentitletype:"Less",
|
|
|
|
|
boxoffsetHeigh:boxoffsetHeigh
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
isopentitletype:"greater",
|
|
|
|
|
opentitletype:true,
|
|
|
|
|
boxoffsetHeigh:boxoffsetHeigh
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
this.getjianjiesize()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -105,9 +84,9 @@ class Challengesjupyter extends Component {
|
|
|
|
|
setTimeout(this.ChallengesList(), 1000);
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
|
let ChallengesURL = `/jupyters/get_info_with_tpm.json`;
|
|
|
|
|
let datas={
|
|
|
|
|
identifier:id,
|
|
|
|
|
}
|
|
|
|
|
let datas={
|
|
|
|
|
identifier:id,
|
|
|
|
|
}
|
|
|
|
|
axios.get(ChallengesURL, {params: datas}).then((response) => {
|
|
|
|
|
if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
@ -115,26 +94,26 @@ class Challengesjupyter extends Component {
|
|
|
|
|
booljupyterurls:true,
|
|
|
|
|
})
|
|
|
|
|
}, 600)
|
|
|
|
|
}else{
|
|
|
|
|
if(response.data.status===0){
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.setState({
|
|
|
|
|
jupyter_url:response.data.url,
|
|
|
|
|
jupyter_port:response.data.port,
|
|
|
|
|
booljupyterurls:true,
|
|
|
|
|
})
|
|
|
|
|
}, 800)
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
if(response.data.status===0){
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.setState({
|
|
|
|
|
jupyter_url:response.data.url,
|
|
|
|
|
jupyter_port:response.data.port,
|
|
|
|
|
booljupyterurls:true,
|
|
|
|
|
})
|
|
|
|
|
}, 800)
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.setState({
|
|
|
|
|
booljupyterurls:true,
|
|
|
|
|
})
|
|
|
|
|
}, 600)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.setState({
|
|
|
|
|
booljupyterurls:true,
|
|
|
|
|
})
|
|
|
|
|
}, 600)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).catch((error) => {
|
|
|
|
@ -145,10 +124,6 @@ class Challengesjupyter extends Component {
|
|
|
|
|
}, 600)
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
setTimeout(this.getjianjiesize(), 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('message', (e) => {
|
|
|
|
|
console.log("触发了jupytermessage");
|
|
|
|
@ -163,8 +138,6 @@ class Challengesjupyter extends Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
setTimeout(this.getjianjiesize(), 1000);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatamakedowns = () => {
|
|
|
|
@ -218,13 +191,13 @@ class Challengesjupyter extends Component {
|
|
|
|
|
|
|
|
|
|
modifyjupyter=()=>{
|
|
|
|
|
let id=this.props.match.params.shixunId;
|
|
|
|
|
var jupyter_port="";
|
|
|
|
|
try{
|
|
|
|
|
jupyter_port= parseInt(this.state.jupyter_port);
|
|
|
|
|
}catch (e) {
|
|
|
|
|
jupyter_port=this.state.jupyter_port;
|
|
|
|
|
var jupyter_port="";
|
|
|
|
|
try{
|
|
|
|
|
jupyter_port= parseInt(this.state.jupyter_port);
|
|
|
|
|
}catch (e) {
|
|
|
|
|
jupyter_port=this.state.jupyter_port;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const url=`/jupyters/save_with_tpm.json`;
|
|
|
|
|
const data={
|
|
|
|
|
identifier:id,
|
|
|
|
@ -234,7 +207,6 @@ class Challengesjupyter extends Component {
|
|
|
|
|
.then((result) => {
|
|
|
|
|
if (result.data.status === 0) {
|
|
|
|
|
this.props.showNotification(`应用成功`);
|
|
|
|
|
console.log("触发了jupytermessage调用了应用成功");
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
})
|
|
|
|
@ -245,15 +217,12 @@ class Challengesjupyter extends Component {
|
|
|
|
|
opentitletype:!this.state.opentitletype
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onclki=(bool)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
enlarge:bool
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
let{ChallengesDataList,booljupyterurls,enlarge}=this.state;
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
@ -263,8 +232,6 @@ class Challengesjupyter extends Component {
|
|
|
|
|
const business = this.props&&this.props.current_user&&this.props.current_user.business?this.props.current_user.business:false;
|
|
|
|
|
//管理员
|
|
|
|
|
const admin = this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false;
|
|
|
|
|
//用户
|
|
|
|
|
const login = this.props&&this.props.current_user&&this.props.current_user.login?this.props.current_user.login:"";
|
|
|
|
|
|
|
|
|
|
let mysidentity =false;
|
|
|
|
|
try {
|
|
|
|
@ -286,39 +253,17 @@ class Challengesjupyter extends Component {
|
|
|
|
|
</a>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
|
.markdown-body img{
|
|
|
|
|
min-height: 200px;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
{ChallengesDataList === undefined || ChallengesDataList&&ChallengesDataList.description=== ""||ChallengesDataList&&ChallengesDataList.description===null||ChallengesDataList&&ChallengesDataList.description===undefined?<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
|
{this.state.opentitletype===true?<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
|
#shixunchallengesid{
|
|
|
|
|
max-height: 300px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>:""}
|
|
|
|
|
{ChallengesDataList === undefined || ChallengesDataList&&ChallengesDataList.description=== ""||ChallengesDataList&&ChallengesDataList.description===null||ChallengesDataList&&ChallengesDataList.description===undefined?"":this.state.isopentitletype==="greater"&&this.state.opentitletype===true?
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
|
#shixunchallengesid{
|
|
|
|
|
max-height:260px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>:""}
|
|
|
|
|
}
|
|
|
|
|
</style>:""}
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
|
|
<div className={"pd20"} id={"shixunchallengesid"}>
|
|
|
|
|
<p id="ReactMarkdown" style={{overflow:'hidden'}}>
|
|
|
|
@ -385,9 +330,8 @@ class Challengesjupyter extends Component {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction:row-reverse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
@ -396,29 +340,33 @@ class Challengesjupyter extends Component {
|
|
|
|
|
""
|
|
|
|
|
:
|
|
|
|
|
(
|
|
|
|
|
admin===true||business===true||mysidentity===true?
|
|
|
|
|
<div className={"shixunjianjiecballenges edu-back-white sortinxdirection mt20"}>
|
|
|
|
|
<div className="renwuxiangssi sortinxdirection">
|
|
|
|
|
<div><p className="renwuxiangqdiv">任务详情</p></div>
|
|
|
|
|
<div><p className="renwuxiangqdivtest ml1 shixunbingbaocun">(请将实训题目写在下方并保存)</p></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="renwuxiangssit xaxisreverseorder">
|
|
|
|
|
{
|
|
|
|
|
enlarge===true?
|
|
|
|
|
<i className="iconfont icon-suoxiao2 font-20 ml2 ysliconfont" style={{
|
|
|
|
|
marginLeft: '30px',
|
|
|
|
|
}} onClick={()=>this.onclki(false)}></i>
|
|
|
|
|
:
|
|
|
|
|
<i className="iconfont icon-fangda font-20 ml2 ysliconfont" style={{
|
|
|
|
|
marginLeft: '30px',
|
|
|
|
|
}} onClick={()=>this.onclki(true)}></i>
|
|
|
|
|
}
|
|
|
|
|
{/*<div className="challenbaocun" ><p*/}
|
|
|
|
|
{/* className="challenbaocuntest">导入</p>*/}
|
|
|
|
|
{/*</div>*/}
|
|
|
|
|
admin===true||business===true||mysidentity===true?
|
|
|
|
|
<div className={enlarge?"shixunjianjiecballenges edu-back-white intermediatecenter fangdaone":"shixunjianjiecballenges edu-back-white mt20"}>
|
|
|
|
|
|
|
|
|
|
<div className={"sortinxdirection"} >
|
|
|
|
|
<div className="renwuxiangssi sortinxdirection">
|
|
|
|
|
<div><p className="renwuxiangqdiv">任务详情</p></div>
|
|
|
|
|
<div><p className="renwuxiangqdivtest ml1 shixunbingbaocun">(请将实训题目写在下方并保存)</p></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="renwuxiangssit xaxisreverseorder">
|
|
|
|
|
{
|
|
|
|
|
enlarge===true?
|
|
|
|
|
<i className="iconfont icon-suoxiao2 font-20 ml2 ysliconfont" style={{
|
|
|
|
|
marginLeft: '30px',
|
|
|
|
|
}} onClick={()=>this.onclki(false)}></i>
|
|
|
|
|
:
|
|
|
|
|
<i className="iconfont icon-fangda font-20 ml2 ysliconfont" style={{
|
|
|
|
|
marginLeft: '30px',
|
|
|
|
|
}} onClick={()=>this.onclki(true)}></i>
|
|
|
|
|
}
|
|
|
|
|
{/*<div className="challenbaocun" onClick={() => this.modifyjupyter(this.state)}><p*/}
|
|
|
|
|
{/* className="challenbaocuntest">导入</p>*/}
|
|
|
|
|
{/*</div>*/}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
:
|
|
|
|
|
|
|
|
|
|
:
|
|
|
|
|
""
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -450,25 +398,25 @@ class Challengesjupyter extends Component {
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
{
|
|
|
|
|
admin===true||business===true||mysidentity===true?
|
|
|
|
|
<div>
|
|
|
|
|
<div className="pb47">
|
|
|
|
|
{
|
|
|
|
|
this.state.jupyter_url===null || this.state.jupyter_url===undefined?
|
|
|
|
|
(
|
|
|
|
|
booljupyterurls===false?
|
|
|
|
|
<LoadingSpin></LoadingSpin>
|
|
|
|
|
:""
|
|
|
|
|
)
|
|
|
|
|
:
|
|
|
|
|
admin===true||business===true||mysidentity===true?
|
|
|
|
|
<div>
|
|
|
|
|
<div className="pb47">
|
|
|
|
|
{
|
|
|
|
|
this.state.jupyter_url===null || this.state.jupyter_url===undefined?
|
|
|
|
|
(
|
|
|
|
|
booljupyterurls===false?
|
|
|
|
|
<LoadingSpin></LoadingSpin>
|
|
|
|
|
:""
|
|
|
|
|
)
|
|
|
|
|
:
|
|
|
|
|
<iframe src={this.state.jupyter_url} className={enlarge?"fangdatwo":""}
|
|
|
|
|
sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="frame"
|
|
|
|
|
name="framename" width="100%" height="700" frameBorder="0"
|
|
|
|
|
sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="frame"
|
|
|
|
|
name="framename" width="100%" height="700" frameBorder="0"
|
|
|
|
|
></iframe>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
:""
|
|
|
|
|
</div>
|
|
|
|
|
:""
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|