Select Git revision
-
Jörn Künsemöller authoredJörn Künsemöller authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CycleList.js 7.33 KiB
import React, {Component} from 'react';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/js/bootstrap.js';
// Procedures
var headers = new Headers();
headers.append('Content-Type', 'application/json');
var api_url = '/api/'
function tmssGetList(url, component){
console.log('Getting '+ url)
fetch(api_url+url, {headers: headers})
.then(response => response.json())
.then(response => {console.log(response);
component.setState({items:response.results});})
.catch(err => console.log(err))
}
function tmssGet(url, component){
console.log('Getting '+ url)
fetch(api_url+url, {headers: headers})
.then(response => response.json())
.then(response => {console.log(response);
component.setState(response);})
.catch(err => console.log(err))
}
function tmssPost(url, data, callback, callback_arg){
console.log('Posting '+ url)
var datastring = JSON.stringify(data);
fetch(api_url+url, {headers: headers, method: 'POST', body: datastring})
.then(callback(callback_arg))
.catch(err => console.log(err))
}
function tmssPut(url, data){
console.log('Putting '+ url)
var datastring = JSON.stringify(data);
fetch(api_url+url, {headers: headers, method: 'PUT', body: datastring})
.catch(err => console.log(err))
}
function tmssPatch(url, data, component){
console.log('Patching '+ url)
var datastring = JSON.stringify(data);
fetch(api_url+url, {headers: headers, method: 'PATCH', body: datastring})
.then(component.setState(data))
.catch(err => console.log(err))
}
function tmssDelete(url, callback, callback_arg){
console.log('Deleting '+ url)
fetch(api_url+url, {headers: headers, method: 'DELETE'})
.then(callback(callback_arg))
.catch(err => console.log(err))
}
// Components
const Tag = props => (
<span className={props.tag === 'Test' ? 'badge badge-primary' : 'badge badge-secondary'}>{props.tag}</span>
)
class Cycle extends Component {
constructor(props) {
super(props);
this.state = props.cycle;