-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/vliz-be-opsci/rocrate-maker…
- Loading branch information
Showing
2 changed files
with
56 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"64e266dfae2b4f34abf0de11ec077e99": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\test_rocrate_vliz", "ro_profile": "233ec883a63a4cf8965fb7fab08fe7c5", "uuid": "64e266dfae2b4f34abf0de11ec077e99", "remote_url": "", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\64e266dfae2b4f34abf0de11ec077e99"}, "5c64534759534c869ef98422b4ac2ca8": {"storage_path": "C:/Users/cedric/Desktop/no importante\\testuicrate", "ro_profile": "233ec883a63a4cf8965fb7fab08fe7c5", "uuid": "5c64534759534c869ef98422b4ac2ca8", "remote_url": "", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\5c64534759534c869ef98422b4ac2ca8"}, "cb291365244a4720b530158493386535": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\test_osd_good_profile", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "cb291365244a4720b530158493386535", "remote_url": "https://github.com/vliz-be-opsci/test_OSD_datacrate", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\cb291365244a4720b530158493386535"}, "fc7aa54fd2274e9eaea4a997a550ffd2": {"storage_path": "C:/Users/cedric/Desktop/no importante\\test_osd_home_pc", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "fc7aa54fd2274e9eaea4a997a550ffd2", "remote_url": "https://github.com/vliz-be-opsci/test_OSD_datacrate.git", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\fc7aa54fd2274e9eaea4a997a550ffd2"}, "eab2ad566ca04102a2fe2eddee5624f0": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2014", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "eab2ad566ca04102a2fe2eddee5624f0", "remote_url": "https://github.com/ocean-sampling-day/OSD2014", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\eab2ad566ca04102a2fe2eddee5624f0"}, "48b9f7113eb6409e825d4a2541e2c925": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2018", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "48b9f7113eb6409e825d4a2541e2c925", "remote_url": "https://github.com/ocean-sampling-day/OSD2018", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\48b9f7113eb6409e825d4a2541e2c925"}, "782c733125b543019ef859a04a85d7f2": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2019", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "782c733125b543019ef859a04a85d7f2", "remote_url": "https://github.com/ocean-sampling-day/OSD2019", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\782c733125b543019ef859a04a85d7f2"}} | ||
{"64e266dfae2b4f34abf0de11ec077e99": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\test_rocrate_vliz", "ro_profile": "233ec883a63a4cf8965fb7fab08fe7c5", "uuid": "64e266dfae2b4f34abf0de11ec077e99", "remote_url": "", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\64e266dfae2b4f34abf0de11ec077e99"}, "5c64534759534c869ef98422b4ac2ca8": {"storage_path": "C:/Users/cedric/Desktop/no importante\\testuicrate", "ro_profile": "233ec883a63a4cf8965fb7fab08fe7c5", "uuid": "5c64534759534c869ef98422b4ac2ca8", "remote_url": "", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\5c64534759534c869ef98422b4ac2ca8"}, "cb291365244a4720b530158493386535": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\test_osd_good_profile", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "cb291365244a4720b530158493386535", "remote_url": "https://github.com/vliz-be-opsci/test_OSD_datacrate", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\cb291365244a4720b530158493386535"}, "fc7aa54fd2274e9eaea4a997a550ffd2": {"storage_path": "C:/Users/cedric/Desktop/no importante\\test_osd_home_pc", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "fc7aa54fd2274e9eaea4a997a550ffd2", "remote_url": "https://github.com/vliz-be-opsci/test_OSD_datacrate.git", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\fc7aa54fd2274e9eaea4a997a550ffd2"}, "eab2ad566ca04102a2fe2eddee5624f0": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2014", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "eab2ad566ca04102a2fe2eddee5624f0", "remote_url": "https://github.com/ocean-sampling-day/OSD2014", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\eab2ad566ca04102a2fe2eddee5624f0"}, "48b9f7113eb6409e825d4a2541e2c925": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2018", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "48b9f7113eb6409e825d4a2541e2c925", "remote_url": "https://github.com/ocean-sampling-day/OSD2018", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\48b9f7113eb6409e825d4a2541e2c925"}, "782c733125b543019ef859a04a85d7f2": {"storage_path": "C:/Users/cedricd/Desktop/test_rocrate_api\\OSD2019", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "782c733125b543019ef859a04a85d7f2", "remote_url": "https://github.com/ocean-sampling-day/OSD2019", "workspace_path": "C:\\Users\\cedricd\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\782c733125b543019ef859a04a85d7f2"}, "d628dc396f3647398c23233959cac09e": {"storage_path": "C:/Users/cedric/Desktop/no importante\\osd2014home", "ro_profile": "3b1020e07f6640b4bb97766e62c7708a", "uuid": "d628dc396f3647398c23233959cac09e", "remote_url": "https://github.com/ocean-sampling-day/OSD2014", "workspace_path": "C:\\Users\\cedric\\Documents\\GitHub\\rocrate-maker-fast-api\\backend\\app\\webtop-work-space\\spaces\\d628dc396f3647398c23233959cac09e"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,148 +1,73 @@ | ||
import React from 'react'; | ||
import $ from 'jquery'; | ||
import GitCommit from '../components/git_commit.js'; | ||
import GitHistory from '../components/git_history.js'; | ||
import React, {useState, useEffect, useRef} from 'react'; | ||
import axios from 'axios'; | ||
import {useParams} from 'react-router-dom'; | ||
import ReactLoading from 'react-loading'; | ||
import {BASE_URL_SERVER} from '../App.js'; | ||
import GitCommit from '../components/git_commit.js'; | ||
import GitHistory from '../components/git_history.js'; | ||
|
||
$(document).ready(function() { | ||
$(".btn").click(function() { | ||
console.log("button clicked"); | ||
console.log("actionbutton clicked"); | ||
$(":button").each(function(){ | ||
$(this).removeClass("btn-success"); | ||
$(this).addClass("btn-primary"); | ||
}); | ||
$(this).removeClass("btn-primary"); | ||
$(this).addClass("btn-success"); | ||
}); | ||
}); | ||
|
||
export default class GitPage extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
message: "commit", | ||
Loading: false, | ||
SpaceId: "", | ||
behind: "", | ||
ahead: "" | ||
} | ||
this.updateMessage = this.updateMessage.bind(this); | ||
this.setLoading = this.setLoading.bind(this); | ||
this.setSpaceId = this.setSpaceId.bind(this); | ||
this.setbehind = this.setbehind.bind(this); | ||
this.setahead = this.setahead.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
const SpaceId = window.location.href.split("/spaces/")[1].split("/git")[0]; | ||
this.setSpaceId(SpaceId); | ||
//perform axiosrequest that will get the git status of the space | ||
axios.get(BASE_URL_SERVER+`apiv1/spaces/${SpaceId}/git/status`) | ||
.then(response => { | ||
if(response.data.behind > 0){ | ||
this.setbehind("disabled"); | ||
} | ||
if(response.data.ahead > 0){ | ||
this.setahead("disabled"); | ||
} | ||
}) | ||
} | ||
|
||
setSpaceId(id) { | ||
this.setState({ | ||
SpaceId: id | ||
}) | ||
} | ||
|
||
setbehind(behind){ | ||
this.setState({ | ||
behind: behind | ||
}) | ||
} | ||
function NewGitPage() { | ||
|
||
setahead(ahead){ | ||
this.setState({ | ||
ahead: ahead | ||
}) | ||
} | ||
//define all constants first | ||
const [Loading, setLoading] = useState(false); | ||
const {SpaceId} = useParams(); | ||
const [message, setMessage] = useState("commit"); | ||
//All the functions here | ||
|
||
updateMessage(message) { | ||
this.setState({ | ||
message: message | ||
}); | ||
//function that will send axios request to server to push git commit | ||
const sendPush = () => { | ||
console.log('pushing to git repo'); | ||
setLoading(true); | ||
axios.post(BASE_URL_SERVER+`apiv1/spaces/${SpaceId}/git/push`,{}) | ||
.then(response => {this.setLoading(false);window.location.reload();}) | ||
.catch(error => { | ||
setLoading(false); | ||
alert(error); | ||
}); | ||
} | ||
|
||
setLoading(load) { | ||
this.setState({ | ||
Loading: load | ||
}); | ||
//function that will send axios request to server to pull git commit | ||
const getPull = () => { | ||
console.log('pulling from git repo'); | ||
setLoading(true); | ||
axios.post(BASE_URL_SERVER+`apiv1/spaces/${SpaceId}/git/pull`,{}) | ||
.then(response => {this.setLoading(false);window.location.href = `/spaces/${SpaceId}/all_files`;}) | ||
.catch(error => { | ||
setLoading(false); | ||
console.log(error); | ||
alert(error); | ||
}); | ||
} | ||
|
||
|
||
|
||
sendPush(){ | ||
console.log('pushing to git repo'); | ||
console.log(this.state.SpaceId); | ||
//axios request | ||
this.setLoading(true); | ||
axios.post(BASE_URL_SERVER+`apiv1/spaces/${this.state.SpaceId}/git/push`,{}) | ||
.then(response => {this.setLoading(false);window.location.reload();}) | ||
.catch(error => { | ||
this.setLoading(false); | ||
alert(error); | ||
}); | ||
//component to determine whether to display the history or the commit component | ||
const Displaygit = () => { | ||
if(message == "commit"){ | ||
return <GitCommit />; | ||
} | ||
if(message == "history"){ | ||
return <GitHistory />; | ||
} | ||
} | ||
|
||
getPull(){ | ||
console.log('pulling from git repo'); | ||
this.setLoading(true); | ||
axios.post(BASE_URL_SERVER+`apiv1/spaces/${this.state.SpaceId}/git/pull`,{}) | ||
.then(response => {this.setLoading(false);window.location.href = `/spaces/${this.state.SpaceId}/all_files`;}) | ||
.catch(error => { | ||
this.setLoading(false); | ||
console.log(error); | ||
alert(error); | ||
}); | ||
} | ||
|
||
render() { | ||
const message = this.state.message; | ||
let todisplay; | ||
if(message == "commit"){ | ||
todisplay = <GitCommit />; | ||
console.log(todisplay); | ||
} | ||
if(message == "history"){ | ||
todisplay = <GitHistory />; | ||
console.log(todisplay); | ||
} | ||
if(this.state.Loading){ | ||
return( | ||
if(Loading){ | ||
return( | ||
<div class="busy"> | ||
<p>View differences: | ||
<ReactLoading type='bars' color='#006582' height={'20vw'} width={'20vw'} /> | ||
</p> | ||
</div> | ||
) | ||
} | ||
if(this.state.Loading == false){ | ||
) | ||
}else{ | ||
return ( | ||
<div> | ||
<div> | ||
<hr /> | ||
<button onClick={() => this.getPull()} id="pull_btn" type="button" style={{width:"23%",margin:"10px"}} class={"button_vliz "+ this.behind}>Pull</button> | ||
<button onClick={() => this.updateMessage("commit")} id="commit_btn" type="button" style={{width:"23%",margin:"10px"}} class="button_vliz" >Commit</button> | ||
<button onClick={() => this.sendPush()} id="push_btn" type="button" style={{width:"23%",margin:"10px"}} class="button_vliz">Push</button> | ||
<button onClick={() => this.updateMessage("history")} id="history_btn" type="button" style={{width:"23%",margin:"10px"}} class="button_vliz">History</button> | ||
<hr /> | ||
{todisplay} | ||
</div> | ||
</div> | ||
); | ||
} | ||
<> | ||
<button onClick={() => getPull()} id="pull_btn" type="button" style={{width:"23%",margin:"10px"}} class="button_vliz">Pull</button> | ||
<button onClick={() => setMessage("commit")} id="commit_btn" type="button" style={{width:"23%",margin:"10px"}} class="button_vliz" >Commit</button> | ||
<button onClick={() => sendPush()} id="push_btn" type="button" style={{width:"23%",margin:"10px"}} class="button_vliz">Push</button> | ||
<button onClick={() => setMessage("history")} id="history_btn" type="button" style={{width:"23%",margin:"10px"}} class="button_vliz">History</button> | ||
<hr></hr> | ||
<Displaygit /> | ||
</> | ||
) | ||
} | ||
} | ||
} | ||
|
||
export default NewGitPage |