Skip to content
Snippets Groups Projects
Select Git revision
  • a77aa034bd292d95b53799208adf10381fe8dbd5
  • master default protected
  • MAM-56-prepare-update-for-sip-version-3
  • TMSS-1777
  • SDC-545_update_SIP
  • lofar_repo
  • 2.7.1
  • 2.8.0
8 results

siplib.py

Blame
  • 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;