<file_sep>import React from 'react';
import './homepage.stylesheet.scss';
import { Switch ,Route, Link } from 'react-router-dom';
import Counter from './counter.component';

//Logos
import meditation from './assets/lifelogo.png';
import sprints from './assets/sprints.svg';
import money from './assets/money.svg';

//Bootstrap
import { Container, Row, Col, Button } from 'react-bootstrap';
//Documentation
//https://react-bootstrap.github.io/components/buttons/
class Home extends React.Component{


    constructor(props){
        super(props);
        this.componentDidMount = this.componentDidMount.bind(this);

        /*
            Redirects
        */
        this.redirectCounter = this.redirectCounter.bind(this);
        this.redirectSprint = this.redirectSprint.bind(this);
    }

    redirectCounter(){
        console.log(window.location.origin);
        this.props.history.push("/counter");
    }

    redirectSprint(){
        this.props.history.push("/sprint");
    }

    componentDidMount(){
        
    }

    render(){
        return (
            
            <Container>
                <Row>
                    <h1 class="header">Life</h1>
                </Row>
                <Row>
                    <Col>
                        <h3>Spritual</h3>
                    </Col>
                    <Col>
                        <Button variant="light" onClick={this.redirectCounter}>
                            <img class="logo" src={meditation} alt="counter" />
                        </Button>
                    </Col>
                </Row>
                <Row>
                    <Col>
                        <h3>Sprint-Management</h3>
                    </Col>
                    <Col>
                        <Button variant="light" onClick={this.redirectSprint}>
                            <img class="logo" src={sprints} alt="sprint" />
                        </Button>
                    </Col>
                </Row>
                <Row>
                    <Col>
                        <h3>Money-Management</h3>
                    </Col>
                    <Col>
                        <Button variant="light">
                            <img class="logo" src={money} alt="Money" />
                        </Button>
                    </Col>
                </Row>
            </Container>
             
        );
    }

}

export default Home;<file_sep>var constants = {

    server: '192.168.0.100',
    //server: 'localhost',
    port: 3030

};

module.exports = constants;<file_sep>import logo from './logo.svg';
import './App.css';
import { Switch ,Route, Link } from 'react-router-dom';
/*
  App Components
*/
import Counter from './components/counter.component';
import Home from './components/homepage.component';
//import Sprint from './components/sprint/sprint.component';
import SprintBasic from './components/sprint/sprintbasic.component';

function App() {
  return (
    <div className="App">
      <Switch>
          <Route exact path='/' component={Home}/>
          <Route exact path='/counter' component={Counter} />
          <Route exact path='/sprint' component={SprintBasic} />
      </Switch>
    </div>
  );
}

export default App;
<file_sep>import React from 'react';
import './sprint.component.scss';
import { Button,Container,Row } from 'react-bootstrap';
import {SprintCreate} from './sprintcreate.component';

class Sprint extends React.Component{

    constructor(){
        super();
        this.state = {
            addtask:false,
            tasks: []
        }
        this.handleAddTask = this.handleAddTask.bind(this);
        this.insertNewTask = this.insertNewTask.bind(this);
    }

    handleAddTask(){
        this.setState({
            addtask: !this.state.addtask
        });
    }

    insertNewTask(){
        alert('comming');
        /*var task = {
            'title':'test',
            'desc':'test1',
            'progress':0.0,
            'completed':false
        }
        
        var temp = this.state.tasks.push(task);
        this.setState({
            tasks : temp,
            addtask:false
        });*/
    }


    render(){
        return(
            <Container>
                <Row>
                    <h1>Sprint</h1>
                </Row>
                <Row>
                    <SprintCreate 
                        title="Sprint create"
                        addtask={this.state.addtask}
                        tasks={this.state.tasks}
                        handleAddTask={this.handleAddTask}
                        insertNewTask={this.insertNewTask}
                    />
                </Row>
                
            </Container>
        );
    }

}

export default Sprint;<file_sep>import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { SafeAreaView, StyleSheet, Text, View, Image } from 'react-native';

export default function App() {

  let PlayFairDisplayItalic = require('./assets/fonts/PlayfairDisplay-Italic.ttf')


  return (
    <SafeAreaView>
      <View style={styles.container}>
        <View style={styles.headerview}>
          <Image style={styles.logo} source={require('./assets/lifelogo.png')} />
          <Text style={styles.projectname}>Life</Text>
        </View>
      
        <View>
          <Text>Body</Text>
        </View>
      </View>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    color:'black',
    flexDirection:'column',
    justifyContent:'flex-start'
  },
  headerview: {
    backgroundColor:'#244068',
    flexDirection:'row'
  },
  logo: {
    height: 50,
    width: 50
  },
  projectname: {
    color:'black',
    fontWeight: 'bold',
    fontSize: 30,
    fontFamily:'PlayFairDisplayItalic',
    alignContent:'center'
  }
});
<file_sep>#alpine image
FROM node:alpine


#working directory
WORKDIR /usr/app


#installation dependencies
#COPY ./package.json ./
#RUN npm install
#COPY ./index.js ./
#COPY src ./
COPY ./ ./
RUN rm -rf node_modules
RUN npm install

#npm start engine 
CMD ["npm","start"]<file_sep>const mongoose = require('mongoose');
const CONSTANTS = require('./appconstants');
mongoose.connect(`mongodb://${CONSTANTS.DATABASE_SERVER}:${CONSTANTS.DATABASE_PORT}/${CONSTANTS.DATABASE}`,{useNewUrlParser: true, useUnifiedTopology: true});
/**
 * Task schema
 */
var taskSchema = mongoose.Schema({

    name: String,
    desc: String,
    progress: Number,
    completed: Boolean,
    start:{
        type: Date,
        default: Date.now
    },
    end: Date
});
/**
 * Sprint schema
 */
var sprintSchema = mongoose.Schema({
    name:String,
    desc:String,
    start:{
        type:Date,
        default:Date.now
    },
    end:Date,
    tasksCount:Number,
    progress:Number,
    completed:Boolean,
    tasks:[{
        type: mongoose.Schema.Types.ObjectId,
        ref:'Task'
    }]
});

// Task & Sprint
var Task = mongoose.model('task',taskSchema);
var Sprint = mongoose.model('sprint',sprintSchema);

class SprintORM {


        /**
         * Creates the sprint and inserts the tasks. But not working
         */
        async create(data){
        //console.log("comming to data");
        //console.log(mongoose.connection.readyState);

        let promiseTask = function(resolve,reject){
            this.insertAllTasks(data.tasks).then((tasksdata)=>{
                
                var temp = [];
                Object.keys(tasksdata).forEach(element=>{
                    temp.push(tasksdata[element]);
                });
                var sprint = new Sprint(data);
                sprint.save().then(()=>{
                    resolve(sprint);
                }).catch((err)=>{
                    reject(err);
                });
           }).catch((err)=>{
                reject(err);
           });
        }

       return await new Promise(promiseTask);
        
    }

    /**
     * 
     * @param {Sprint} data 
     * This method should be called to create sprint
     * Warning: must insert after tasks once inserted. Otherwise tasks will update use update method.
     */
    insertSprint(data){
        var promiseSprint = function(resolve,reject){
            var sprint = new Sprint(data);
            sprint.save().then(()=>{
                resolve(sprint);
            }).catch((err)=>{
                reject(err);
            });
        }
        return new Promise(promiseSprint);
    }

    /**
     * This method used to get sprint completed tag
     * @param {Sprint} completed 
     */
    async getSprintsByCompleted(completed){
        var records = await Sprint.find().where('completed').in(completed).exec();
        console.log(records);
        return records;

    }

    /**
     * This method will update the sprint
     * @param {Sprint} sprint 
     */
    async updateSprint(sprint){
        const filter = {"_id":sprint._id};
        delete sprint["_id"];
        let doc = await Sprint.findOneAndUpdate(filter,sprint,{new:true});
        return doc;
    }
    

    

    /**
     * This method will insert the tasks array
     * @param {[Task]} tasks 
     */
    //https://www.tutorialkart.com/nodejs/mongoose/insert-multiple-documents-to-mongodb/
     insertAllTasks(tasks){
        var promiseTask = function(resolve,reject){
            Task.collection.insertMany(tasks,function(err,docs){
                if(err){
                    reject(err);
                }else{
                    resolve(docs.insertedIds);
                }
            });
        }
        return new Promise(promiseTask);
    }

    /**
     * This method will single task
     * @param {Task} task 
     */
    singleTask(task){
        var promiseTask = function(resolve,reject){
            var temp = new Task(task);
            temp.save().then(()=>{
                resolve(temp._id);
            }).catch(()=>{
                reject("task not saved");
            });
            return;
        }
        return new Promise(temp);
    }

    /**
     * This method will give array of tasks
     * @param {Task} arr 
     */
    async getTasks(arr){

        Task.findByIdAndUpdate
        var records = await Task.find().where('_id').in(arr).exec();
        console.log(records);
        return records;
    }

    /**
     * This will update single task
     * @param {Task} task 
     */
    async updateTask(task){
        const filter = {"_id":task._id};
        delete task["_id"];
        let doc = await Task.findOneAndUpdate(filter,task,{new:true});
        return doc;
    }

   

}

module.exports = SprintORM;<file_sep>var CONSTANTS = {
    SERVERPORT: 3030,
    DATABASE_SERVER: 'mongodb',
    //DATABASE_SERVER: 'localhost',
    //DATABASE_SERVER: '192.168.0.100',
    DATABASE_PORT: 27017,
    DATABASE:'LifeDev'
    
}

module.exports = CONSTANTS;<file_sep># Life


Life project

test
<file_sep>const express = require('express')
var cors = require('cors')
const app = express()

var bodyParser = require('body-parser')
app.use(cors())
app.use(bodyParser.json())

const SprintORM = require('./src/sprint')
const CONSTANTS = require('./src/appconstants');



/**
 * Introduction Message will be printed
 */
app.get('/',function(req,res){
    res.json({'Message':'Welcome to Life Backend Server'});
});



/**
 * Sprint & Tasks insert
 */
app.post("/totalsprint",function(req,res){
    
    var body = req.body;
    body.taskcount = body.tasks.length;
    body.start = new Date

    body.tasks.forEach((task) => {
        task.start= new Date
    });
    var sprint = new SprintORM();
    sprint.create(body).then((data)=>{
        res.status(201).json(body);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});



/**
 * Creates the sprint
 */
app.post("/sprint",(req,res)=>{
    var body = req.body;
    body.taskcount = body.tasks.length;
    body.start = new Date

    var sprint = new SprintORM();
    sprint.insertSprint(body).then((data)=>{
        res.status(200).json(body);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});

/**
 * Retrives the sprints which are open. 
 */
app.get("/sprint/open",(req,res)=>{
    res.setHeader('Content-Type','application/json');
    var sprint = new SprintORM();
    sprint.getSprintsByCompleted(false).then((records)=>{
        res.status(200).json(records);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});

/**
 * Retrives the sprints which are close.
 */
app.get("/sprint/close",(req,res)=>{
    res.setHeader('Content-Type','application/json');
    var sprint = new SprintORM();
    sprint.getSprintsByCompleted(true).then((records)=>{
        res.status(200).json(records);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});

/**
 * sprint which updated
 */
app.put("/sprint/update",(req,res)=>{
    var body = req.body;
    var sprint = new SprintORM();
    sprint.updateSprint(body).then((sprint)=>{
        res.status(200).json(sprint);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});

/**
 * Tasks will be created
 */
app.post("/tasks",(req,res)=>{
    var body = req.body;
    body.tasks.forEach((task)=>{
        task.start = new Date
    });
    var sprint = new SprintORM();
   sprint.insertAllTasks(body.tasks).then((data)=>{
        res.status(200).json(body);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});

/**
 * Retrives the tasks
 */
app.get("/tasks",(req,res)=>{
    var body = req.body;
    var sprint = new SprintORM();
    sprint.getTasks(body.tasks).then((records)=>{
        res.status(200).json(records);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});

/**
 * update the task
 */
app.put("/task/update",(req,res)=>{
    var body = req.body;
    var sprint = new SprintORM();
    sprint.updateTask(body).then((task)=>{
        res.status(200).json(task);
    }).catch((err)=>{
        res.status(500).json(err);
    });
});



app.listen(CONSTANTS.SERVERPORT);<file_sep>import React from 'react';
import './counter.stylesheet.scss';


class Counter extends React.Component{


    constructor(props){
        super(props);
        this.state = {
            counter: 5,
            value:0
        }
        this.negative = this.negative.bind(this);
        this.positive = this.positive.bind(this);
        this.changeCounterValue = this.changeCounterValue.bind(this);
    }

    negative(){
        var updatedValue = this.state.value-this.state.counter;
        if(updatedValue < 0){
            this.setState({
                value: 0
            });
        }else{
            this.setState({
                value: updatedValue
            });
        }
    }

    positive(){
        
        var updatedValue = this.state.value+this.state.counter;
        this.setState({
            value: updatedValue
        });
    }

    changeCounterValue(e){
        console.log(e);
        var  updatedValue = parseInt(e.target.value);
        if(Number.isNaN(updatedValue) || updatedValue == undefined || updatedValue < 0){
            updatedValue = 5;
        }
        this.setState({
            counter: updatedValue
        });
    }



    render(){
        return (
            <div class='row'>
                <div class='col-md-12'>
                    <h1>Counter</h1>
                    
                <form>
                    <div class="form-group">
                        <button type="button" onClick={this.negative} class="btn btn-light" >-</button>
                        <input type="number" onChange={this.changeCounterValue} value={this.state.counter} min="0" max="1000" step="1"/>
                        <button type="button" onClick={this.positive} class="btn btn-light">+</button>
                    </div>
    
                </form>
                </div>
                <div class='col-md-12'>
                    <p>{this.state.value}</p>
                </div>
            </div>
            
            
        );
    }

}

export default Counter;<file_sep>import React from 'react';
import { Button,Container,Row, Form } from 'react-bootstrap';
import {TaskCreate} from './taskcreate.component';
export const SprintCreate = props => (
    <Container>
        <Row>
        <h1>{props.title}</h1>
        </Row>
        <Row>
            <Form>
                <Form.Group>
                    <Form.Label>Name </Form.Label>
                    <Form.Control type="text" placeholder="Enter Sprint Name" />
                </Form.Group>
                <Form.Group>
                    <Form.Label>Enter Description</Form.Label>
                    <Form.Control as="textarea" rows={3}  />
                </Form.Group>
                <Form.Group>
                    
                    <Button onClick={props.handleAddTask}>
                        +
                    </Button>
                    {props.addtask ?
                     <TaskCreate title='Task' 
                     insertNewTask={props.insertNewTask} />
                     :
                     <p>{JSON.stringify(props)}</p>
                    }
                </Form.Group>
                {props.addtask ? 
                '' : 
                <Button variant="primary" type="submit">
                    Submit
                </Button>
                }
            </Form>
        </Row>
    </Container>
);