From b999385535dd2950193882e3025a777ef430c204 Mon Sep 17 00:00:00 2001
From: dimitrc <dimitrc@stud.ntnu.no>
Date: Fri, 12 Nov 2021 13:15:25 +0100
Subject: [PATCH 1/8] added Top and fixed some warnings

---
 Backend/CSAMS/Controllers/TopController.cs    | 107 +-----------
 React/test-http/package.json                  |   1 +
 React/test-http/src/App.js                    |   6 +
 .../src/components/Navbar/MenuItems.js        |   7 +-
 .../src/components/ReviewerComments.js        |   2 +-
 React/test-http/src/components/Top.js         | 164 ++++++++++++++++++
 6 files changed, 178 insertions(+), 109 deletions(-)
 create mode 100644 React/test-http/src/components/Top.js

diff --git a/Backend/CSAMS/Controllers/TopController.cs b/Backend/CSAMS/Controllers/TopController.cs
index c0a59786a..65686320b 100644
--- a/Backend/CSAMS/Controllers/TopController.cs
+++ b/Backend/CSAMS/Controllers/TopController.cs
@@ -31,111 +31,8 @@ namespace CSAMS.Controllers
 
 
 
-        /*
-
-        [HttpGet("Top/{N}/{Type}/{IsProject}")]
-        public async Task<ActionResult<TopModel[]>> GetTopReviews(int N, string Type, Boolean IsProject)
-        {
-
-           // var test = await _context.Assignments.ToArrayAsync();
-            var fields = await _context.Fields.ToArrayAsync();
-           // TopModel[][] child = new TopModel[test.ToList().Count][];
-
-            Console.WriteLine($"N is {N} and Type is {Type}");
-
-            var t = _context.UserReviews.Include(r => r.Review).Include(r => r.Assignment)
-                  .AsEnumerable()
-                  // .GroupBy(r => r.AssignmentID)
-                  // .Select(r => TopProjects(r.ToArray(), fields, IsProject))
-                  .Where(p => p != null)
-
-                  .ToArray();
-            if (IsProject == true)
-            {
-                if (Type == "Top")
-                {
-                    return t
-                           .GroupBy(r => r.AssignmentID)
-                          .Select(r => TopProjects(r.ToArray(), fields, IsProject,0))
-                       .Where(r => r != null)
-                       
-                         .OrderByDescending(p => p.Grade)
-                         .Take(N)
-                         .ToArray();
-                    ;
-                }
-                else if (Type == "Bottom")
-                {
-                    Console.WriteLine(t.Length);
-                    var x = t
-                        .GroupBy(r => r.AssignmentID)
-                       .Select(r => TopProjects(r.ToArray(), fields, IsProject, 0))
-                       .Where(r => r != null)
-                       .OrderBy(p => p.Grade)
-                       .Take(N)
-
-                       .ToArray();
-                    return x;
-                }
-                else
-                {
-                    return t
-                          .GroupBy(r => r.AssignmentID)
-                          .Select(r => TopProjects(r.ToArray(), fields, IsProject, 0))
-                       .Where(r => r != null)
-                         .Take(2)
-                         .ToArray();
-                    ;
-                }
-            }
-            else////////////////////////////
-            {
-                var average = GetMiddle(_context.UserReviews.Include(r => r.Review).ToArray(), fields);
-
-                if (Type == "Top")
-                {
-                    return t
-                        
-                           .GroupBy(r => r.UserReviewer)
-                          .Select(r => TopProjects(r.ToArray(), fields, IsProject, average))
-                            
-                       .Where(r => r != null)
-                     
-                         .OrderBy(p=>p.Grade)
-                       
-                         .Take(N)
-                         
-                         .ToArray();
-                    ;
-                }
-                else if (Type == "Bottom")
-                {
-                    return t
-                        .GroupBy(r => r.UserReviewer)
-                       .Select(r => TopProjects(r.ToArray(), fields, IsProject, average))
-                       .Where(r => r != null)
-                       .OrderByDescending(p => p.Grade)
-                       .Take(N)
-                       .ToArray();
-
-                }
-                else
-                {
-                    return t
-                          .GroupBy(r => r.ReviewID)
-                          .Select(r => TopProjects(r.ToArray(), fields, IsProject, average))
-                       .Where(r => r != null)
-                         .Take(2)
-                         .ToArray();
-                    ;
-                }
-            }
-
-
-        }
-
-        */
-        [HttpGet("Top/{N}/{Type}/{IsProject}")]
+     
+       // [HttpGet("Top/{N}/{Type}/{IsProject}")]
         public static TopModel TopProjects(UserReviews[] userReviews, Fields[] fields, Boolean IsProject,float average)
         {
 
diff --git a/React/test-http/package.json b/React/test-http/package.json
index cb2dfa65b..1566c63f9 100644
--- a/React/test-http/package.json
+++ b/React/test-http/package.json
@@ -9,6 +9,7 @@
     "axios": "^0.21.4",
     "components": "^0.1.0",
     "react": "^17.0.2",
+    "react-bootstrap": "^2.0.2",
     "react-boxplot": "^3.1.0",
     "react-dom": "^17.0.2",
     "react-dropdown": "^1.9.2",
diff --git a/React/test-http/src/App.js b/React/test-http/src/App.js
index 306680882..05cfee288 100644
--- a/React/test-http/src/App.js
+++ b/React/test-http/src/App.js
@@ -15,6 +15,7 @@ import Statistics from './components/Statistics';
 import PostForm from './components/PostForm';
 import ReviewerComments from './components/ReviewerComments';
 import ShowBoxplot from './components/ShowBoxplot';
+import Top from './components/Top';
 
 function App() {
     return (
@@ -59,6 +60,11 @@ function App() {
             <Route path='/Statistics' >
                 <Statistics />
             </Route>
+            <Route path='/Top' >
+                <Top />
+            </Route>
+
+
 
             <Route path='/ShowBoxplot' >
                 <ShowBoxplot values={[88,
diff --git a/React/test-http/src/components/Navbar/MenuItems.js b/React/test-http/src/components/Navbar/MenuItems.js
index 02d325ab6..13a2259d1 100644
--- a/React/test-http/src/components/Navbar/MenuItems.js
+++ b/React/test-http/src/components/Navbar/MenuItems.js
@@ -36,10 +36,11 @@ export const MenuItems = [
 
     },
     {
-        title: 'Sign up',
-        url: '#',
-        cName: 'nav-links-mobile'
+        title:'Top',
+        url: 'http://localhost:3000/Top/top',
+        cName:'nav-links'
     },
+
     {
         title: 'Boxplot',
         url: 'http://localhost:3000/ShowBoxplot',
diff --git a/React/test-http/src/components/ReviewerComments.js b/React/test-http/src/components/ReviewerComments.js
index 5baee7b26..e432b9410 100644
--- a/React/test-http/src/components/ReviewerComments.js
+++ b/React/test-http/src/components/ReviewerComments.js
@@ -30,7 +30,7 @@ class ReviewerComments extends Component {
 
     render() {
         const { posts, errorMsg } = this.state
-        if (errorMsg == '') {
+        if (errorMsg ==='') {
             console.log(errorMsg)
             let n = 0
             return (
diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
new file mode 100644
index 000000000..3cab39950
--- /dev/null
+++ b/React/test-http/src/components/Top.js
@@ -0,0 +1,164 @@
+import React, { Component } from 'react'
+import axios from 'axios'
+import { Button} from 'react-bootstrap';
+import ReactDOM from 'react-dom';
+class Top extends Component {
+    constructor(props) {
+        super(props)
+
+        this.state = {
+            posts: [],
+            errorMsg: '',
+            N:'',
+            Type:'',
+            IsProject:'',
+            site:'https://localhost:44344/api/Top/top',
+            Submited:false
+        }
+    }
+  
+    changeHandler=(e)=>{
+        this.setState({[e.target.name]:e.target.value})
+        
+        }
+       
+        Capitalize(str){
+            if(str.width>1)
+            return str.charAt(0).toUpperCase() + str.toLowerCase().toslice(1); 
+            return str
+            }
+
+doSomething(){
+   // this.forceUpdate()
+            console.log(this.state)
+           
+           
+            axios
+                .get(this.state.site)
+                .then(response => {
+                    console.log(response)
+                    this.setState({ posts: response.data })
+                    this.setState({site:'https://localhost:44344/api/Top/top'})
+                })
+                .catch(error => {
+                    console.log(error)
+                    this.setState({ errorMsg: 'Error retrieving data' })
+                })
+               // this.setState({Submited:false})
+           }
+        
+
+        submitHandler = (e) => {
+            this.setState({[e.target.name]:e.target.value})
+            this.forceUpdate()
+
+            this.setState({Type:this.Capitalize(this.state.Type)})
+            this.setState({Type:this.Capitalize(this.state.IsProject)})     
+            if(this.state.N<1||this.state.N>300){
+                this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
+            }
+            this.setState({Type:this.Capitalize(this.state.Type)})
+            if(this.state.Type!=='Top'||this.state.Type!=='Bottom'){
+                this.setState({ errorMsg2: ' Error in imput field 2' })
+            }
+            this.setState({IsProject:this.Capitalize(this.state.IsProject)})
+            console.log(this.state+" WTF!!!")
+            if(this.state.IsProject==='Projects' || this.Capitalize(this.state.IsProject)==='True'){
+                this.setState({IsProject:'true'})
+            }else if(this.state.IsProject==='Reviewers' || this.Capitalize(this.state.IsProject)==='False'){
+                this.setState({IsProject:'false'})
+            }
+            else{
+                this.setState({ errorMsg2: ' Error in imput field 3' })
+            }
+            this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject})
+          this.setState({Submited:true})
+          
+            e.preventDefault()
+            this.doSomething()
+ 
+        }
+    //clickHandler() { }
+   
+    render() {
+        const { posts, errorMsg,errorMsg2,N,Type,IsProject } = this.state
+        let n = 0
+
+        let message
+        if(this.state.Submited===false){
+            message=<div>Please enter N,Top or Bottom and Projects or Reviewers</div>
+        } else{
+            console.log(this.state)
+        message=  <div style={{ textAlign: 'center' }}>
+    <tr style={{ display: 'flex', justifyContent: 'center' }}>
+      <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Grade</td>
+     <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Assignment name</td>
+     <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Assignment ID</td>
+     <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Reviewer ID</td>
+
+</tr>
+
+{posts.map(row => (
+    
+    <tr key={row.id} style={{ display: 'flex', justifyContent: 'center' }}>
+        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.grade}</td>
+        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.assingmentName}</td>
+        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.assingmentID}</td>
+        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.reviewerID}</td>
+    </tr>
+))}
+
+{errorMsg ? <div>{errorMsg}</div> : null}
+{errorMsg2 ? <div>{errorMsg2}</div> : null}
+
+
+</div>
+        }
+
+
+        return (
+
+            <div style={{border: 'outset',textAlign:'center'}}>
+           
+           
+           <View style={styles.buttonStyleContainer}>
+            <Button
+             title={"Top"}
+             style={styles.buttonStyle}
+             onPress={() => {
+               this.setState({ IsProject: Top });
+             }}
+              color="#841584"
+            />
+              <Button
+                 title={"Bottom"}
+                onPress={() => {
+                this.setState({ IsProject: Bottom });
+             }}
+             color="green"
+           />
+
+         </View>
+           
+            <form onSubmit={this.submitHandler}>
+                <div>
+                    <input type='text' name='N' value={N} onChange={this.changeHandler} placeholder='N'/>
+                </div>
+                <div>
+                    <input type='text' name='Type' value={Type}  onChange={this.changeHandler} placeholder='Enter:Top or Bottom'/>
+                </div>
+                <div>
+                    <input type='text' name='IsProject' value={IsProject}  onChange={this.changeHandler} placeholder='Groupby: Projects or Reviewers'/>
+                </div>
+                <button type='submit'>Submit </button>
+            </form>
+            <div>{message}</div>
+        <div>Here???</div>
+           
+          
+        </div>
+        )
+    }
+
+}
+export default Top
-- 
GitLab


From b6de0f201b2a9742c50e7bfa3f7810ace1ebbe5e Mon Sep 17 00:00:00 2001
From: dimitrc <dimitrc@stud.ntnu.no>
Date: Fri, 12 Nov 2021 14:41:44 +0100
Subject: [PATCH 2/8] ffs

---
 React/test-http/src/components/Top.js | 124 ++++++++++++++++++--------
 1 file changed, 86 insertions(+), 38 deletions(-)

diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
index 3cab39950..35568ba10 100644
--- a/React/test-http/src/components/Top.js
+++ b/React/test-http/src/components/Top.js
@@ -1,7 +1,6 @@
 import React, { Component } from 'react'
 import axios from 'axios'
-import { Button} from 'react-bootstrap';
-import ReactDOM from 'react-dom';
+
 class Top extends Component {
     constructor(props) {
         super(props)
@@ -13,7 +12,11 @@ class Top extends Component {
             Type:'',
             IsProject:'',
             site:'https://localhost:44344/api/Top/top',
-            Submited:false
+            Submited:false,
+            TopsClicked:false,
+            BottomsClicked:false,
+           ProjectsClicked:false,
+           ReviewersClicked:false
         }
     }
   
@@ -29,10 +32,10 @@ class Top extends Component {
             }
 
 doSomething(){
-   // this.forceUpdate()
+        this.forceUpdate()
             console.log(this.state)
            
-           
+           if(this.state.Submited===true){
             axios
                 .get(this.state.site)
                 .then(response => {
@@ -46,40 +49,51 @@ doSomething(){
                 })
                // this.setState({Submited:false})
            }
-        
+        }
+           dosomethingmore(){
+            this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject})
+            this.setState({Submited:true})
 
+            }
         submitHandler = (e) => {
             this.setState({[e.target.name]:e.target.value})
-            this.forceUpdate()
+            
 
             this.setState({Type:this.Capitalize(this.state.Type)})
             this.setState({Type:this.Capitalize(this.state.IsProject)})     
             if(this.state.N<1||this.state.N>300){
                 this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
             }
-            this.setState({Type:this.Capitalize(this.state.Type)})
-            if(this.state.Type!=='Top'||this.state.Type!=='Bottom'){
-                this.setState({ errorMsg2: ' Error in imput field 2' })
-            }
-            this.setState({IsProject:this.Capitalize(this.state.IsProject)})
-            console.log(this.state+" WTF!!!")
-            if(this.state.IsProject==='Projects' || this.Capitalize(this.state.IsProject)==='True'){
-                this.setState({IsProject:'true'})
-            }else if(this.state.IsProject==='Reviewers' || this.Capitalize(this.state.IsProject)==='False'){
-                this.setState({IsProject:'false'})
-            }
-            else{
-                this.setState({ errorMsg2: ' Error in imput field 3' })
-            }
-            this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject})
-          this.setState({Submited:true})
-          
+            // this.setState({Type:this.Capitalize(this.state.Type)})
+            // if(this.state.Type!=='Top'||this.state.Type!=='Bottom'){
+            //     this.setState({ errorMsg2: ' Error in imput field 2' })
+            // }
+            // this.setState({IsProject:this.Capitalize(this.state.IsProject)})
+        
+            // if(this.state.IsProject==='Projects' || this.Capitalize(this.state.IsProject)==='True'){
+            //     this.setState({IsProject:'true'})
+            // }else if(this.state.IsProject==='Reviewers' || this.Capitalize(this.state.IsProject)==='False'){
+            //     this.setState({IsProject:'false'})
+            // }
+            // else{
+            //     this.setState({ errorMsg2: ' Error in imput field 3' })
+            // }
+           // this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject})
+         // this.setState({Submited:true})
+             this.dosomethingmore()
             e.preventDefault()
             this.doSomething()
+            this.forceUpdate()
  
         }
     //clickHandler() { }
    
+        onChangeValue(event){
+            this.setState({Type:EventTarget.value})
+            console.log(this.state)
+        }
+
+
     render() {
         const { posts, errorMsg,errorMsg2,N,Type,IsProject } = this.state
         let n = 0
@@ -87,7 +101,7 @@ doSomething(){
         let message
         if(this.state.Submited===false){
             message=<div>Please enter N,Top or Bottom and Projects or Reviewers</div>
-        } else{
+        } else {
             console.log(this.state)
         message=  <div style={{ textAlign: 'center' }}>
     <tr style={{ display: 'flex', justifyContent: 'center' }}>
@@ -121,24 +135,58 @@ doSomething(){
             <div style={{border: 'outset',textAlign:'center'}}>
            
            
-           <View style={styles.buttonStyleContainer}>
-            <Button
+           <div >
+               Top or Bottom:
+
+               
+               <button
              title={"Top"}
-             style={styles.buttonStyle}
-             onPress={() => {
-               this.setState({ IsProject: Top });
+           
+             onClick={() => {
+               this.setState({ Type: 'Top' });
+               this.setState({TopClicked:true });
              }}
               color="#841584"
-            />
-              <Button
-                 title={"Bottom"}
-                onPress={() => {
-                this.setState({ IsProject: Bottom });
+              
+            >Top</button>
+         <button
+             title={"Bottom"}
+           
+             onClick={() => {
+               this.setState({ Type: 'Bottom' });
+               this.setState({BottomClicked:true });
+               console.log(this.state)
              }}
-             color="green"
-           />
+              color="#841584"
+            >Bottom</button>
+    
+      </div>
 
-         </View>
+      <div >
+               Projects or Reviewers:
+
+               
+               <button
+             title={"Projects"}
+           
+             onClick={() => {
+               this.setState({ IsProject: 'true' });
+               this.setState({ProjectsClicked:true });
+             }}
+              color="#841584"
+            >Projects</button>
+         <button
+             title={"Reviewers"}
+           
+             onClick={() => {
+               this.setState({IsProject:'false' });
+               this.setState({ReviewersClicked:true });
+               console.log(this.state)
+             }}
+              color="#841584"
+            >Reviewers</button>
+    
+      </div>
            
             <form onSubmit={this.submitHandler}>
                 <div>
-- 
GitLab


From 6414ffe4706d8ed1dc966337089afd9af6f73e3e Mon Sep 17 00:00:00 2001
From: dimitrc <dimitrc@stud.ntnu.no>
Date: Fri, 12 Nov 2021 14:58:29 +0100
Subject: [PATCH 3/8] Almost working

---
 React/test-http/src/components/Top.js | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
index 35568ba10..bd01eb4b3 100644
--- a/React/test-http/src/components/Top.js
+++ b/React/test-http/src/components/Top.js
@@ -32,7 +32,7 @@ class Top extends Component {
             }
 
 doSomething(){
-        this.forceUpdate()
+      
             console.log(this.state)
            
            if(this.state.Submited===true){
@@ -59,8 +59,8 @@ doSomething(){
             this.setState({[e.target.name]:e.target.value})
             
 
-            this.setState({Type:this.Capitalize(this.state.Type)})
-            this.setState({Type:this.Capitalize(this.state.IsProject)})     
+          //  this.setState({Type:this.Capitalize(this.state.Type)})
+         //   this.setState({IsProject:this.Capitalize(this.state.IsProject)})     
             if(this.state.N<1||this.state.N>300){
                 this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
             }
@@ -78,12 +78,13 @@ doSomething(){
             // else{
             //     this.setState({ errorMsg2: ' Error in imput field 3' })
             // }
-           // this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject})
-         // this.setState({Submited:true})
-             this.dosomethingmore()
+            this.setState({Submited:true})
+            this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject},()=>{ this.doSomething()})
+          
+           
             e.preventDefault()
-            this.doSomething()
-            this.forceUpdate()
+           // this.doSomething()
+          
  
         }
     //clickHandler() { }
@@ -154,7 +155,7 @@ doSomething(){
            
              onClick={() => {
                this.setState({ Type: 'Bottom' });
-               this.setState({BottomClicked:true });
+               this.setState({TopClicked:false });
                console.log(this.state)
              }}
               color="#841584"
@@ -180,7 +181,7 @@ doSomething(){
            
              onClick={() => {
                this.setState({IsProject:'false' });
-               this.setState({ReviewersClicked:true });
+               this.setState({ProjectsClicked:false });
                console.log(this.state)
              }}
               color="#841584"
-- 
GitLab


From d27feb2871a7d8906a9f868fad212deb3b429ac3 Mon Sep 17 00:00:00 2001
From: dimitrc <dimitrc@stud.ntnu.no>
Date: Sat, 13 Nov 2021 16:43:46 +0100
Subject: [PATCH 4/8] new shinny (purple) buttons

---
 React/test-http/src/App.css           | 10 +++
 React/test-http/src/components/Top.js | 90 +++++++++++++++------------
 2 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/React/test-http/src/App.css b/React/test-http/src/App.css
index 1f94ff5ea..998170fe6 100644
--- a/React/test-http/src/App.css
+++ b/React/test-http/src/App.css
@@ -93,6 +93,16 @@
   color: white;
   background-color: rgb(110,94,254);
 }
+
+.blackButton{
+  background-color: rgb(69, 39, 116);
+  color: black;
+}
+
+.whiteButton{
+  background-color: white;
+  color: black;
+}
 /* 
 .paginationDisabled a {
   color: grey;
diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
index bd01eb4b3..70c9d1a12 100644
--- a/React/test-http/src/components/Top.js
+++ b/React/test-http/src/components/Top.js
@@ -9,14 +9,14 @@ class Top extends Component {
             posts: [],
             errorMsg: '',
             N:'',
-            Type:'',
-            IsProject:'',
+            Type:'Top',
+            IsProject:false,
             site:'https://localhost:44344/api/Top/top',
             Submited:false,
             TopsClicked:false,
-            BottomsClicked:false,
            ProjectsClicked:false,
-           ReviewersClicked:false
+          
+         
         }
     }
   
@@ -37,7 +37,7 @@ doSomething(){
            
            if(this.state.Submited===true){
             axios
-                .get(this.state.site)
+                .get(this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject)
                 .then(response => {
                     console.log(response)
                     this.setState({ posts: response.data })
@@ -50,36 +50,17 @@ doSomething(){
                // this.setState({Submited:false})
            }
         }
-           dosomethingmore(){
-            this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject})
-            this.setState({Submited:true})
-
-            }
+           
         submitHandler = (e) => {
             this.setState({[e.target.name]:e.target.value})
             
-
-          //  this.setState({Type:this.Capitalize(this.state.Type)})
-         //   this.setState({IsProject:this.Capitalize(this.state.IsProject)})     
+   
             if(this.state.N<1||this.state.N>300){
                 this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
             }
-            // this.setState({Type:this.Capitalize(this.state.Type)})
-            // if(this.state.Type!=='Top'||this.state.Type!=='Bottom'){
-            //     this.setState({ errorMsg2: ' Error in imput field 2' })
-            // }
-            // this.setState({IsProject:this.Capitalize(this.state.IsProject)})
-        
-            // if(this.state.IsProject==='Projects' || this.Capitalize(this.state.IsProject)==='True'){
-            //     this.setState({IsProject:'true'})
-            // }else if(this.state.IsProject==='Reviewers' || this.Capitalize(this.state.IsProject)==='False'){
-            //     this.setState({IsProject:'false'})
-            // }
-            // else{
-            //     this.setState({ errorMsg2: ' Error in imput field 3' })
-            // }
-            this.setState({Submited:true})
-            this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject},()=>{ this.doSomething()})
+         
+            this.setState({Submited:true},()=>{ this.doSomething()})
+           // this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject},()=>{ this.doSomething()})
           
            
             e.preventDefault()
@@ -93,9 +74,20 @@ doSomething(){
             this.setState({Type:EventTarget.value})
             console.log(this.state)
         }
+        changeColorIs(){
+            this.setState({ProjectsClicked: !this.state.ProjectsClicked})
+        }
 
+        changeColorType(){
+            this.setState({TopsClicked: !this.state.TopsClicked})
+            console.log(this.state+"COLOR CHANGE!!")
+        }
 
     render() {
+        let btn_classtype = this.state.TopsClicked ? "blackButton" : "whiteButton";
+        let btn_classIs = this.state.ProjectsClicked ? "blackButton" : "whiteButton";
+        let btn_classIs2 = this.state.ProjectsClicked ? "whiteButton" : "blackButton" ;
+        let btn_classtype2 = this.state.TopsClicked ? "whiteButton" : "blackButton" ;
         const { posts, errorMsg,errorMsg2,N,Type,IsProject } = this.state
         let n = 0
 
@@ -105,22 +97,25 @@ doSomething(){
         } else {
             console.log(this.state)
         message=  <div style={{ textAlign: 'center' }}>
+          
     <tr style={{ display: 'flex', justifyContent: 'center' }}>
       <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Grade</td>
      <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Assignment name</td>
      <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Assignment ID</td>
      <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Reviewer ID</td>
 
-</tr>
+        </tr>
+       
 
 {posts.map(row => (
-    
+   
     <tr key={row.id} style={{ display: 'flex', justifyContent: 'center' }}>
         <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.grade}</td>
         <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.assingmentName}</td>
         <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.assingmentID}</td>
         <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.reviewerID}</td>
     </tr>
+   
 ))}
 
 {errorMsg ? <div>{errorMsg}</div> : null}
@@ -140,26 +135,35 @@ doSomething(){
                Top or Bottom:
 
                
-               <button
+               <button 
+            className={btn_classtype2}
+     
              title={"Top"}
            
              onClick={() => {
                this.setState({ Type: 'Top' });
-               this.setState({TopClicked:true });
+              // this.setState({TopClicked:false });
+              this.setState({TopsClicked: !this.state.TopsClicked})
+               console.log(this.state.TopsClicked +"Top")
              }}
               color="#841584"
-              
             >Top</button>
-         <button
+
+         <button 
+            className={btn_classtype}
+     
              title={"Bottom"}
            
              onClick={() => {
                this.setState({ Type: 'Bottom' });
-               this.setState({TopClicked:false });
-               console.log(this.state)
+              // this.setState({TopClicked:false });
+              this.setState({TopsClicked: !this.state.TopsClicked})
+               console.log(this.state.TopsClicked +"BOTTOM")
              }}
               color="#841584"
             >Bottom</button>
+
+      
     
       </div>
 
@@ -168,20 +172,24 @@ doSomething(){
 
                
                <button
+                className={btn_classIs2}
              title={"Projects"}
            
              onClick={() => {
                this.setState({ IsProject: 'true' });
-               this.setState({ProjectsClicked:true });
+              // this.setState({ProjectsClicked:true });
+               this.setState({ProjectsClicked: !this.state.ProjectsClicked})
              }}
               color="#841584"
             >Projects</button>
          <button
+           className={btn_classIs}
              title={"Reviewers"}
            
              onClick={() => {
                this.setState({IsProject:'false' });
-               this.setState({ProjectsClicked:false });
+             //  this.setState({ProjectsClicked:false });
+               this.setState({ProjectsClicked: !this.state.ProjectsClicked})
                console.log(this.state)
              }}
               color="#841584"
@@ -193,12 +201,12 @@ doSomething(){
                 <div>
                     <input type='text' name='N' value={N} onChange={this.changeHandler} placeholder='N'/>
                 </div>
-                <div>
+                {/* <div>
                     <input type='text' name='Type' value={Type}  onChange={this.changeHandler} placeholder='Enter:Top or Bottom'/>
                 </div>
                 <div>
                     <input type='text' name='IsProject' value={IsProject}  onChange={this.changeHandler} placeholder='Groupby: Projects or Reviewers'/>
-                </div>
+                </div> */}
                 <button type='submit'>Submit </button>
             </form>
             <div>{message}</div>
-- 
GitLab


From 2f775660ae19b3a1b8d0c45b91ca2d0b7a295408 Mon Sep 17 00:00:00 2001
From: dimitrc <dimitrc@stud.ntnu.no>
Date: Sun, 14 Nov 2021 18:33:05 +0100
Subject: [PATCH 5/8] errors not working

---
 React/test-http/src/components/Top.js        | 99 ++++++++++++--------
 React/test-http/src/components/TopInsides.js | 59 ++++++++++++
 2 files changed, 118 insertions(+), 40 deletions(-)
 create mode 100644 React/test-http/src/components/TopInsides.js

diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
index 70c9d1a12..9addd16f3 100644
--- a/React/test-http/src/components/Top.js
+++ b/React/test-http/src/components/Top.js
@@ -1,5 +1,6 @@
 import React, { Component } from 'react'
 import axios from 'axios'
+import TopInsides from './TopInsides'
 
 class Top extends Component {
     constructor(props) {
@@ -10,11 +11,12 @@ class Top extends Component {
             errorMsg: '',
             N:'',
             Type:'Top',
-            IsProject:false,
+            IsProject:true,
             site:'https://localhost:44344/api/Top/top',
             Submited:false,
             TopsClicked:false,
            ProjectsClicked:false,
+           Backup:false
           
          
         }
@@ -33,7 +35,7 @@ class Top extends Component {
 
 doSomething(){
       
-            console.log(this.state)
+          //  console.log(this.state)
            
            if(this.state.Submited===true){
             axios
@@ -41,7 +43,11 @@ doSomething(){
                 .then(response => {
                     console.log(response)
                     this.setState({ posts: response.data })
-                    this.setState({site:'https://localhost:44344/api/Top/top'})
+                  //  this.setState({site:'https://localhost:44344/api/Top/top'})
+                  this.setState({ errorMsg: '' })
+                  this.setState({ errorMsg2: '' })
+                  
+                 // TopInsides(this.state.posts,this.state.Backup)
                 })
                 .catch(error => {
                     console.log(error)
@@ -50,15 +56,15 @@ doSomething(){
                // this.setState({Submited:false})
            }
         }
-           
+         
         submitHandler = (e) => {
             this.setState({[e.target.name]:e.target.value})
-            
+            this.setState({IsProject:this.state.IsProject})
    
             if(this.state.N<1||this.state.N>300){
                 this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
             }
-         
+            this.setState({Backup:this.state.IsProject})
             this.setState({Submited:true},()=>{ this.doSomething()})
            // this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject},()=>{ this.doSomething()})
           
@@ -72,7 +78,7 @@ doSomething(){
    
         onChangeValue(event){
             this.setState({Type:EventTarget.value})
-            console.log(this.state)
+            //console.log(this.state)
         }
         changeColorIs(){
             this.setState({ProjectsClicked: !this.state.ProjectsClicked})
@@ -80,7 +86,7 @@ doSomething(){
 
         changeColorType(){
             this.setState({TopsClicked: !this.state.TopsClicked})
-            console.log(this.state+"COLOR CHANGE!!")
+           // console.log(this.state+"COLOR CHANGE!!")
         }
 
     render() {
@@ -88,42 +94,53 @@ doSomething(){
         let btn_classIs = this.state.ProjectsClicked ? "blackButton" : "whiteButton";
         let btn_classIs2 = this.state.ProjectsClicked ? "whiteButton" : "blackButton" ;
         let btn_classtype2 = this.state.TopsClicked ? "whiteButton" : "blackButton" ;
-        const { posts, errorMsg,errorMsg2,N,Type,IsProject } = this.state
-        let n = 0
+        const { posts, errorMsg,errorMsg2,N, } = this.state
+      
+
+ 
+      
+    
+           
+
+
+
+
+
 
         let message
         if(this.state.Submited===false){
             message=<div>Please enter N,Top or Bottom and Projects or Reviewers</div>
         } else {
-            console.log(this.state)
-        message=  <div style={{ textAlign: 'center' }}>
+            console.log(this.state+"HERE!!")
+        message= 
+         <div style={{ textAlign: 'center' }}>
           
-    <tr style={{ display: 'flex', justifyContent: 'center' }}>
-      <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Grade</td>
-     <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Assignment name</td>
-     <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Assignment ID</td>
-     <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Reviewer ID</td>
+         {/* <tr style={{ display: 'flex', justifyContent: 'center' }}>
+              <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Grade</td>
+             <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Assignment name</td>
+             <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Assignment ID</td>
+             <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Reviewer ID</td>
+         </tr> */}
+       
+              {TopInsides(posts,this.state.Backup)}
+    {/* {posts.map(row => (
+        
+         <tr key={row.id} style={{ display: 'flex', justifyContent: 'center' }}>
+               <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.grade}</td>          
+              <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.assingmentName}</td>
+              <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.assingmentID}</td>
+              <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n++ % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.reviewerID}</td>
+          </tr>
+   
+            ))} */}
 
-        </tr>
        
 
-{posts.map(row => (
-   
-    <tr key={row.id} style={{ display: 'flex', justifyContent: 'center' }}>
-        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.grade}</td>
-        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.assingmentName}</td>
-        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.assingmentID}</td>
-        <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.reviewerID}</td>
-    </tr>
    
-))}
 
-{errorMsg ? <div>{errorMsg}</div> : null}
-{errorMsg2 ? <div>{errorMsg2}</div> : null}
 
-
-</div>
-        }
+    </div>
+    }
 
 
         return (
@@ -143,8 +160,8 @@ doSomething(){
              onClick={() => {
                this.setState({ Type: 'Top' });
               // this.setState({TopClicked:false });
-              this.setState({TopsClicked: !this.state.TopsClicked})
-               console.log(this.state.TopsClicked +"Top")
+             if(this.state.TopsClicked===true){ this.setState({TopsClicked: !this.state.TopsClicked})}
+               console.log(this.state.Type +"Top")
              }}
               color="#841584"
             >Top</button>
@@ -157,8 +174,8 @@ doSomething(){
              onClick={() => {
                this.setState({ Type: 'Bottom' });
               // this.setState({TopClicked:false });
-              this.setState({TopsClicked: !this.state.TopsClicked})
-               console.log(this.state.TopsClicked +"BOTTOM")
+              if(this.state.TopsClicked===false){ this.setState({TopsClicked: !this.state.TopsClicked})}
+               console.log(this.state.Type +"BOTTOM")
              }}
               color="#841584"
             >Bottom</button>
@@ -178,7 +195,8 @@ doSomething(){
              onClick={() => {
                this.setState({ IsProject: 'true' });
               // this.setState({ProjectsClicked:true });
-               this.setState({ProjectsClicked: !this.state.ProjectsClicked})
+              if(this.state.ProjectsClicked===true){ this.setState({ProjectsClicked: !this.state.ProjectsClicked})}
+               
              }}
               color="#841584"
             >Projects</button>
@@ -189,7 +207,7 @@ doSomething(){
              onClick={() => {
                this.setState({IsProject:'false' });
              //  this.setState({ProjectsClicked:false });
-               this.setState({ProjectsClicked: !this.state.ProjectsClicked})
+             if(this.state.ProjectsClicked===false){ this.setState({ProjectsClicked: !this.state.ProjectsClicked})}
                console.log(this.state)
              }}
               color="#841584"
@@ -210,8 +228,9 @@ doSomething(){
                 <button type='submit'>Submit </button>
             </form>
             <div>{message}</div>
-        <div>Here???</div>
-           
+      
+            {errorMsg ? <div style={{border: 'solid', borderColor:'red'}} >{errorMsg}</div> : null}
+        {errorMsg2 ? <div style={{border: 'solid', borderColor:'red'}} >{errorMsg2}</div> : null}
           
         </div>
         )
diff --git a/React/test-http/src/components/TopInsides.js b/React/test-http/src/components/TopInsides.js
new file mode 100644
index 000000000..131757e99
--- /dev/null
+++ b/React/test-http/src/components/TopInsides.js
@@ -0,0 +1,59 @@
+import React from 'react'
+
+export default function TopInsides(posts, IsProject) {
+    let n = 0
+    let message
+    let toppings
+  
+
+        if(IsProject==='true'||IsProject===true){
+            console.log(IsProject+"   IS TRUE")
+            message=    posts.map(row => (
+                
+                    <tr key={row.id} style={{ display: 'flex', justifyContent: 'center' }}>
+                          <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.grade}</td>          
+                         <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.assingmentName}</td>
+                         <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n++ % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.assingmentID}</td>
+                     
+                     </tr>
+              
+                       ))
+        
+                       toppings=  <tr style={{ display: 'flex', justifyContent: 'center' }}>
+                       <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Grade</td>
+                      <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Assignment name</td>
+                      <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Assignment ID</td>
+                     
+                  </tr>
+        
+         }else if(IsProject==='false'||IsProject===false){
+            console.log(IsProject+"   IS FALSE")
+            message=   posts.map(row => (
+                
+                <tr key={row.id} style={{ display: 'flex', justifyContent: 'center' }}>
+                      <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.grade}</td>          
+                 
+                     <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n++ % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.reviewerID}</td>
+                 </tr>
+          
+                   ))
+                toppings=  <tr style={{ display: 'flex', justifyContent: 'center' }}>
+                <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Grade</td>
+             
+               <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Reviewer ID</td>
+           </tr>
+                
+                }
+             
+                console.log(IsProject+"   IS IT THO PROJECT?")
+            return (
+                <div>
+                    {toppings}
+                   { message}
+                </div>
+            )
+
+
+    }
+   
+    
-- 
GitLab


From c615bf540f5e265bcc76bcc317037643970ef229 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20H=C3=A6gdahl?= <jonas.haegd@gmail.com>
Date: Sun, 14 Nov 2021 19:05:01 +0100
Subject: [PATCH 6/8] Fix bugs

---
 Backend/CSAMS/Controllers/TopController.cs |   8 +-
 React/test-http/src/components/Top.js      | 325 ++++++++++-----------
 2 files changed, 158 insertions(+), 175 deletions(-)

diff --git a/Backend/CSAMS/Controllers/TopController.cs b/Backend/CSAMS/Controllers/TopController.cs
index 65686320b..f252bdbdc 100644
--- a/Backend/CSAMS/Controllers/TopController.cs
+++ b/Backend/CSAMS/Controllers/TopController.cs
@@ -144,7 +144,13 @@ namespace CSAMS.Controllers
 
                   .ToArray();
             var toAverege = _context.UserReviews.Include(r => r.Review).ToArray();
-           return OuterTopProjects(N, Type, IsProject, userdata, fields, toAverege);
+            
+            var ret = OuterTopProjects(N, Type, IsProject, userdata, fields, toAverege);
+
+            if (ret.Length == 0)
+                return BadRequest("0 length");
+
+            return ret;
         }
 
 
diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
index 9addd16f3..da2a5243b 100644
--- a/React/test-http/src/components/Top.js
+++ b/React/test-http/src/components/Top.js
@@ -9,230 +9,207 @@ class Top extends Component {
         this.state = {
             posts: [],
             errorMsg: '',
-            N:'',
-            Type:'Top',
-            IsProject:true,
-            site:'https://localhost:44344/api/Top/top',
-            Submited:false,
-            TopsClicked:false,
-           ProjectsClicked:false,
-           Backup:false
-          
-         
+            N: '',
+            Type: 'Top',
+            IsProject: true,
+            site: 'https://localhost:44344/api/Top/top',
+            Submited: false,
+            TopsClicked: false,
+            ProjectsClicked: false,
+            Backup: false
+
+
         }
     }
-  
-    changeHandler=(e)=>{
-        this.setState({[e.target.name]:e.target.value})
-        
-        }
-       
-        Capitalize(str){
-            if(str.width>1)
-            return str.charAt(0).toUpperCase() + str.toLowerCase().toslice(1); 
-            return str
-            }
-
-doSomething(){
-      
-          //  console.log(this.state)
-           
-           if(this.state.Submited===true){
+
+    changeHandler = (e) => {
+        this.setState({ [e.target.name]: e.target.value })
+
+    }
+
+    Capitalize(str) {
+        if (str.width > 1)
+            return str.charAt(0).toUpperCase() + str.toLowerCase().toslice(1);
+        return str
+    }
+
+    doSomething() {
+
+        //  console.log(this.state)
+
+        if (this.state.Submited === true) {
             axios
-                .get(this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject)
+                .get(this.state.site + '/' + this.state.N + '/' + this.state.Type + '/' + this.state.IsProject)
                 .then(response => {
                     console.log(response)
                     this.setState({ posts: response.data })
-                  //  this.setState({site:'https://localhost:44344/api/Top/top'})
-                  this.setState({ errorMsg: '' })
-                  this.setState({ errorMsg2: '' })
-                  
-                 // TopInsides(this.state.posts,this.state.Backup)
+                    //  this.setState({site:'https://localhost:44344/api/Top/top'})
+                    this.setState({ errorMsg: '' })
+                    this.setState({ errorMsg2: '' })
+
+                    // TopInsides(this.state.posts,this.state.Backup)
                 })
                 .catch(error => {
                     console.log(error)
+                    this.setState({posts: []})
                     this.setState({ errorMsg: 'Error retrieving data' })
                 })
-               // this.setState({Submited:false})
-           }
-        }
-         
-        submitHandler = (e) => {
-            this.setState({[e.target.name]:e.target.value})
-            this.setState({IsProject:this.state.IsProject})
-   
-            if(this.state.N<1||this.state.N>300){
-                this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
-            }
-            this.setState({Backup:this.state.IsProject})
-            this.setState({Submited:true},()=>{ this.doSomething()})
-           // this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject},()=>{ this.doSomething()})
-          
-           
-            e.preventDefault()
-           // this.doSomething()
-          
- 
-        }
-    //clickHandler() { }
-   
-        onChangeValue(event){
-            this.setState({Type:EventTarget.value})
-            //console.log(this.state)
-        }
-        changeColorIs(){
-            this.setState({ProjectsClicked: !this.state.ProjectsClicked})
+            // this.setState({Submited:false})
         }
+    }
+
+    submitHandler = (e) => {
+        e.preventDefault()
+        console.log('test')
+        this.setState({ [e.target.name]: e.target.value })
+        this.setState({ IsProject: this.state.IsProject })
 
-        changeColorType(){
-            this.setState({TopsClicked: !this.state.TopsClicked})
-           // console.log(this.state+"COLOR CHANGE!!")
+        if (this.state.N < 1 || this.state.N > 300) {
+            this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
         }
+        this.setState({ Backup: this.state.IsProject })
+        this.setState({ Submited: true }, () => { this.doSomething() })
+        // this.setState({site:this.state.site+'/'+this.state.N+'/'+this.state.Type+'/'+this.state.IsProject},()=>{ this.doSomething()})
 
-    render() {
-        let btn_classtype = this.state.TopsClicked ? "blackButton" : "whiteButton";
-        let btn_classIs = this.state.ProjectsClicked ? "blackButton" : "whiteButton";
-        let btn_classIs2 = this.state.ProjectsClicked ? "whiteButton" : "blackButton" ;
-        let btn_classtype2 = this.state.TopsClicked ? "whiteButton" : "blackButton" ;
-        const { posts, errorMsg,errorMsg2,N, } = this.state
-      
 
- 
-      
-    
-           
+        // this.doSomething()
 
 
+    }
+    //clickHandler() { }
 
+    onChangeValue(event) {
+        this.setState({ Type: EventTarget.value })
+        //console.log(this.state)
+    }
+    changeColorIs() {
+        this.setState({ ProjectsClicked: !this.state.ProjectsClicked })
+    }
 
+    changeColorType() {
+        this.setState({ TopsClicked: !this.state.TopsClicked })
+        // console.log(this.state+"COLOR CHANGE!!")
+    }
 
+    render() {
+        let btn_classtype = this.state.TopsClicked ? "blackButton" : "whiteButton";
+        let btn_classIs = this.state.ProjectsClicked ? "blackButton" : "whiteButton";
+        let btn_classIs2 = this.state.ProjectsClicked ? "whiteButton" : "blackButton";
+        let btn_classtype2 = this.state.TopsClicked ? "whiteButton" : "blackButton";
+        const { posts, errorMsg, errorMsg2, N, } = this.state
 
         let message
-        if(this.state.Submited===false){
-            message=<div>Please enter N,Top or Bottom and Projects or Reviewers</div>
+        if (this.state.Submited === false) {
+            message = <div>Please enter N,Top or Bottom and Projects or Reviewers</div>
         } else {
-            console.log(this.state+"HERE!!")
-        message= 
-         <div style={{ textAlign: 'center' }}>
-          
-         {/* <tr style={{ display: 'flex', justifyContent: 'center' }}>
+            console.log(this.state)
+            message =
+                <div style={{ textAlign: 'center' }}>
+
+                    {/* <tr style={{ display: 'flex', justifyContent: 'center' }}>
               <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Grade</td>
              <td style={{ border: "1px solid rgb(0, 0, 0)", width: 300 }}>Assignment name</td>
              <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Assignment ID</td>
              <td style={{ border: "1px solid rgb(0, 0, 0)", width: 200 }}>Reviewer ID</td>
          </tr> */}
-       
-              {TopInsides(posts,this.state.Backup)}
-    {/* {posts.map(row => (
-        
+
+                    {TopInsides(posts, this.state.Backup)}
+                    {/* {posts.map(row => (
          <tr key={row.id} style={{ display: 'flex', justifyContent: 'center' }}>
                <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.grade}</td>          
               <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 300 }}>{row.assingmentName}</td>
               <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.assingmentID}</td>
               <td style={{ border: "1px solid rgb(0, 0, 0)", backgroundColor: (n++ % 2) === 1 ? '#aae' : '#dde', width: 200 }}>{row.reviewerID}</td>
           </tr>
-   
             ))} */}
+                </div>
+        }
 
-       
 
-   
+        return (
 
+            <div style={{ border: 'outset', textAlign: 'center' }}>
 
-    </div>
-    }
+                <div >
+                    Top or Bottom:
+               <button
+                        className={btn_classtype2}
 
+                        title={"Top"}
 
-        return (
+                        onClick={() => {
+                            this.setState({ Type: 'Top' });
+                            // this.setState({TopClicked:false });
+                            if (this.state.TopsClicked === true) { this.setState({ TopsClicked: !this.state.TopsClicked }) }
+                            console.log(this.state.Type + "Top")
+                        }}
+                        color="#841584"
+                    >Top</button>
+
+                    <button
+                        className={btn_classtype}
+
+                        title={"Bottom"}
+
+                        onClick={() => {
+                            this.setState({ Type: 'Bottom' });
+                            // this.setState({TopClicked:false });
+                            if (this.state.TopsClicked === false) { this.setState({ TopsClicked: !this.state.TopsClicked }) }
+                            console.log(this.state.Type + "BOTTOM")
+                        }}
+                        color="#841584"
+                    >Bottom</button>
+
+                </div>
+
+                <div >
+                    Projects or Reviewers:
 
-            <div style={{border: 'outset',textAlign:'center'}}>
-           
-           
-           <div >
-               Top or Bottom:
-
-               
-               <button 
-            className={btn_classtype2}
-     
-             title={"Top"}
-           
-             onClick={() => {
-               this.setState({ Type: 'Top' });
-              // this.setState({TopClicked:false });
-             if(this.state.TopsClicked===true){ this.setState({TopsClicked: !this.state.TopsClicked})}
-               console.log(this.state.Type +"Top")
-             }}
-              color="#841584"
-            >Top</button>
-
-         <button 
-            className={btn_classtype}
-     
-             title={"Bottom"}
-           
-             onClick={() => {
-               this.setState({ Type: 'Bottom' });
-              // this.setState({TopClicked:false });
-              if(this.state.TopsClicked===false){ this.setState({TopsClicked: !this.state.TopsClicked})}
-               console.log(this.state.Type +"BOTTOM")
-             }}
-              color="#841584"
-            >Bottom</button>
-
-      
-    
-      </div>
-
-      <div >
-               Projects or Reviewers:
-
-               
                <button
-                className={btn_classIs2}
-             title={"Projects"}
-           
-             onClick={() => {
-               this.setState({ IsProject: 'true' });
-              // this.setState({ProjectsClicked:true });
-              if(this.state.ProjectsClicked===true){ this.setState({ProjectsClicked: !this.state.ProjectsClicked})}
-               
-             }}
-              color="#841584"
-            >Projects</button>
-         <button
-           className={btn_classIs}
-             title={"Reviewers"}
-           
-             onClick={() => {
-               this.setState({IsProject:'false' });
-             //  this.setState({ProjectsClicked:false });
-             if(this.state.ProjectsClicked===false){ this.setState({ProjectsClicked: !this.state.ProjectsClicked})}
-               console.log(this.state)
-             }}
-              color="#841584"
-            >Reviewers</button>
-    
-      </div>
-           
-            <form onSubmit={this.submitHandler}>
-                <div>
-                    <input type='text' name='N' value={N} onChange={this.changeHandler} placeholder='N'/>
+                        className={btn_classIs2}
+                        title={"Projects"}
+
+                        onClick={() => {
+                            this.setState({ IsProject: 'true' });
+                            // this.setState({ProjectsClicked:true });
+                            if (this.state.ProjectsClicked === true) { this.setState({ ProjectsClicked: !this.state.ProjectsClicked }) }
+
+                        }}
+                        color="#841584"
+                    >Projects</button>
+                    <button
+                        className={btn_classIs}
+                        title={"Reviewers"}
+
+                        onClick={() => {
+                            this.setState({ IsProject: 'false' });
+                            //  this.setState({ProjectsClicked:false });
+                            if (this.state.ProjectsClicked === false) { this.setState({ ProjectsClicked: !this.state.ProjectsClicked }) }
+                            console.log(this.state)
+                        }}
+                        color="#841584"
+                    >Reviewers</button>
+
                 </div>
-                {/* <div>
+
+                <form onSubmit={this.submitHandler}>
+                    <div>
+                        <input type='text' name='N' value={N} onChange={this.changeHandler} placeholder='N' />
+                    </div>
+                    {/* <div>
                     <input type='text' name='Type' value={Type}  onChange={this.changeHandler} placeholder='Enter:Top or Bottom'/>
                 </div>
                 <div>
                     <input type='text' name='IsProject' value={IsProject}  onChange={this.changeHandler} placeholder='Groupby: Projects or Reviewers'/>
                 </div> */}
-                <button type='submit'>Submit </button>
-            </form>
-            <div>{message}</div>
-      
-            {errorMsg ? <div style={{border: 'solid', borderColor:'red'}} >{errorMsg}</div> : null}
-        {errorMsg2 ? <div style={{border: 'solid', borderColor:'red'}} >{errorMsg2}</div> : null}
-          
-        </div>
+                    <button type='submit'>Submit </button>
+                </form>
+                <div>{message}</div>
+
+                {errorMsg ? <div style={{ border: 'solid', borderColor: 'red' }} >{errorMsg}</div> : null}
+                {errorMsg2 ? <div style={{ border: 'solid', borderColor: 'red' }} >{errorMsg2}</div> : null}
+
+            </div>
         )
     }
 
-- 
GitLab


From 71db4b67f02d510817b3e66c5071272b535996d9 Mon Sep 17 00:00:00 2001
From: dimitrc <dimitrc@stud.ntnu.no>
Date: Sun, 14 Nov 2021 19:14:11 +0100
Subject: [PATCH 7/8] please pull?

---
 React/test-http/src/components/Top.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
index 9addd16f3..c57c122b1 100644
--- a/React/test-http/src/components/Top.js
+++ b/React/test-http/src/components/Top.js
@@ -44,8 +44,10 @@ doSomething(){
                     console.log(response)
                     this.setState({ posts: response.data })
                   //  this.setState({site:'https://localhost:44344/api/Top/top'})
+                if(postMessage.length>1) {
                   this.setState({ errorMsg: '' })
                   this.setState({ errorMsg2: '' })
+                }
                   
                  // TopInsides(this.state.posts,this.state.Backup)
                 })
@@ -59,7 +61,7 @@ doSomething(){
          
         submitHandler = (e) => {
             this.setState({[e.target.name]:e.target.value})
-            this.setState({IsProject:this.state.IsProject})
+           // this.setState({IsProject:this.state.IsProject})
    
             if(this.state.N<1||this.state.N>300){
                 this.setState({ errorMsg2: ' Error in imput field 1. Provide possitive number (within reason)' })
-- 
GitLab


From 7301acebe451b83b307be65d6f513148b6dc6a9d Mon Sep 17 00:00:00 2001
From: dimitrc <dimitrc@stud.ntnu.no>
Date: Sun, 14 Nov 2021 19:27:44 +0100
Subject: [PATCH 8/8] finished

---
 React/test-http/src/components/Top.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/React/test-http/src/components/Top.js b/React/test-http/src/components/Top.js
index 7eb8734e3..9650ce97f 100644
--- a/React/test-http/src/components/Top.js
+++ b/React/test-http/src/components/Top.js
@@ -45,7 +45,7 @@ class Top extends Component {
                     this.setState({ posts: response.data })
 
                   //  this.setState({site:'https://localhost:44344/api/Top/top'})
-                if(postMessage.length>1) {
+                if(this.state.posts.length>1) {
                   this.setState({ errorMsg: '' })
                   this.setState({ errorMsg2: '' })
                 }
-- 
GitLab