Skip to content
Snippets Groups Projects
Commit a0893049 authored by Abbas Jafari's avatar Abbas Jafari :speech_balloon:
Browse files

Merge branch 'fixes/warningFix' into 'master'

small issue fixes

See merge request it2810-h21/team-54/project-3!14
parents 62d36355 52434cea
Branches
No related tags found
No related merge requests found
......@@ -14,8 +14,7 @@
}
.header {
position: fixed;
width: 100%;
background-color: rgb(1, 0, 34);
min-height: 5vh;
display: flex;
......@@ -26,7 +25,7 @@
color: white;
font-size: large;
margin: auto;
z-index: 10;
}
#textfield1, #textfield2, #checkbox1 {
......@@ -57,9 +56,9 @@
}
}
table {
position: absolute;
margin-top: 5vh;
table-layout:fixed;
width: 100%;
text-align: center;
......
import React, { Component } from 'react'
import React from 'react'
import { MoviesStoreImplementation } from "./MoviesStore";
import { inject, observer } from 'mobx-react';
import * as services from './services';
......@@ -45,13 +45,13 @@ class Header extends React.Component<MoviesProps, MyState> {
handleChange = (event: any) => {
let element = event.target.id
if (element == 'textfield1') {
if (element === 'textfield1') {
this.setState({ inputTitle: event.target.value })
}
if (element == 'textfield2') {
if (element === 'textfield2') {
this.setState({ inputGenre: event.target.value })
}
else if (element == 'checkbox1') {
else if (element === 'checkbox1') {
this.setState({ checkbox1_checked: event.target.checked })
}
}
......
import React, {useEffect, useState} from 'react';
import React, {useEffect} from 'react';
import PrintTable from "./PrintTable";
import InfiniteScroll from "react-infinite-scroller";
import { MoviesStore, MoviesStoreImplementation } from "./MoviesStore";
......
// Returns list of movies
function PrintTable(props: any) {
return (
<table>
<div id="tableContainer"><table>
<thead>
<tr>
<th>Title</th>
......@@ -14,7 +14,7 @@ function PrintTable(props: any) {
</thead>
<tbody>{
props.data.map((row: any) => {
return <tr>
return <tr key={row.title}>
<td>{row.title}</td>
<td>{row.genre}</td>
<td>{row.year}</td>
......@@ -23,7 +23,7 @@ function PrintTable(props: any) {
<td><img className="thumbnails" src = {row.cover_image} alt={row.title}></img></td>
</tr>;
})
}</tbody></table>
}</tbody></table></div>
)
}
......
......@@ -12,7 +12,7 @@ var _connection = connect();
user: 'abbasj_abbas',
password: 'abbas2021',
database: 'abbasj_project3',
connectionLimit: 20
connectionLimit: 10
})
return connection;
......
......@@ -129,7 +129,7 @@ const Mutation = new GraphQLObjectType({
cover_image: { type: GraphQLString }
},
async resolve(parent: any, args: any) {
const response = await sendQuery('INSERT INTO movie VALUES ({$args.id}, {$args.title}, {$args.genre}, {$args.rating_dice_throw}, {$args.year}, {$args.director_first_name}, {$args.director_last_name}, {$args.description}, {$args.cover_image})');
const response = await sendQuery('INSERT INTO movie VALUES (${args.id}, ${args.title}, ${args.genre}, ${args.rating_dice_throw}, ${args.year}, ${args.director_first_name}, ${args.director_last_name}, ${args.description}, ${args.cover_image})');
return response[0];
}
},
......@@ -139,7 +139,7 @@ const Mutation = new GraphQLObjectType({
id: {type: GraphQLInt}
},
async resolve(parent: any, args: any) {
const response = await sendQuery('DELETE FROM movie WHERE id = {$args.id}');
const response = await sendQuery('DELETE FROM movie WHERE id = ${args.id}');
return response[0];
}
},
......@@ -157,7 +157,7 @@ const Mutation = new GraphQLObjectType({
cover_image: { type: GraphQLString }
},
async resolve(parent: any, args: any) {
const response = await sendQuery('UPDATE movie SET title = {$args.title}, genre = {$args.genre}, rating_dice_throw = {$args.rating_dice_throw}, year = {$args.year}, director_first_name = {$args.director_first_name}, director_last_name = {$args.director_last_name} , description = {$args.description}, cover_image = {$args.cover_image} WHERE id = {$args.id}');
const response = await sendQuery('UPDATE movie SET title = ${args.title}, genre = ${args.genre}, rating_dice_throw = ${args.rating_dice_throw}, year = ${args.year}, director_first_name = ${args.director_first_name}, director_last_name = ${args.director_last_name} , description = ${args.description}, cover_image = ${args.cover_image} WHERE id = ${args.id}');
return response[0];
}
},
......@@ -168,7 +168,7 @@ const Mutation = new GraphQLObjectType({
rating_dice_throw: { type: GraphQLInt }
},
async resolve(parent: any, args: any) {
const response = await sendQuery('UPDATE movie SET rating_dice_throw = {$args.rating_dice_throw} WHERE id = {$args.id}');
const response = await sendQuery('UPDATE movie SET rating_dice_throw = ${args.rating_dice_throw} WHERE id = ${args.id}');
return response[0];
}
}
......
......@@ -76,7 +76,9 @@ const RootQuery = new GraphQLObjectType({
let query = '';
if(typeof args.title!='undefined' && typeof args.genre!='undefined'){
console.log("resolve")
query = getSearchQuery(args.title, args.genre, args.order)}
query = getSearchQuery(args.title, args.genre)}
if(args.order) {query += ' ORDER BY year DESC;';}
const response = await sendQuery(query);
return response[0];
}
......@@ -88,7 +90,7 @@ function getQuery(key: string, value: string){
return 'SELECT * FROM movie WHERE ' + key + ' = "' + value + '"'
}
function getSearchQuery(title: string, genre: string, order: boolean): string {
function getSearchQuery(title: string, genre: string): string {
let query = 'SELECT * FROM movie'
if (title != '') {
query = query + ' WHERE title LIKE "%' + title + '%"'
......@@ -102,9 +104,6 @@ function getSearchQuery(title: string, genre: string, order: boolean): string {
if (genre != '') {
query = query + ' genre LIKE "%' + genre + '%"'
}
if (order) {
query = query + ' ORDER BY year DESC'
}
console.log(query)
return query
}
......@@ -127,7 +126,7 @@ const Mutation = new GraphQLObjectType({
cover_image: { type: GraphQLString }
},
async resolve(parent: any, args: any) {
const response = await sendQuery('INSERT INTO movie VALUES ({$args.id}, {$args.title}, {$args.genre}, {$args.rating_dice_throw}, {$args.year}, {$args.director_first_name}, {$args.director_last_name}, {$args.description}, {$args.cover_image})');
const response = await sendQuery('INSERT INTO movie VALUES (${args.id}, ${args.title}, ${args.genre}, ${args.rating_dice_throw}, ${args.year}, ${args.director_first_name}, ${args.director_last_name}, ${args.description}, ${args.cover_image})');
return response[0];
}
},
......@@ -137,7 +136,7 @@ const Mutation = new GraphQLObjectType({
id: {type: GraphQLInt}
},
async resolve(parent: any, args: any) {
const response = await sendQuery('DELETE FROM movie WHERE id = {$args.id}');
const response = await sendQuery('DELETE FROM movie WHERE id = ${args.id}');
return response[0];
}
},
......@@ -155,7 +154,7 @@ const Mutation = new GraphQLObjectType({
cover_image: { type: GraphQLString }
},
async resolve(parent: any, args: any) {
const response = await sendQuery('UPDATE movie SET title = {$args.title}, genre = {$args.genre}, rating_dice_throw = {$args.rating_dice_throw}, year = {$args.year}, director_first_name = {$args.director_first_name}, director_last_name = {$args.director_last_name} , description = {$args.description}, cover_image = {$args.cover_image} WHERE id = {$args.id}');
const response = await sendQuery('UPDATE movie SET title = ${args.title}, genre = ${args.genre}, rating_dice_throw = ${args.rating_dice_throw}, year = ${args.year}, director_first_name = ${args.director_first_name}, director_last_name = ${args.director_last_name} , description = ${args.description}, cover_image = ${args.cover_image} WHERE id = ${args.id}');
return response[0];
}
},
......@@ -166,7 +165,7 @@ const Mutation = new GraphQLObjectType({
rating_dice_throw: { type: GraphQLInt }
},
async resolve(parent: any, args: any) {
const response = await sendQuery('UPDATE movie SET rating_dice_throw = {$args.rating_dice_throw} WHERE id = {$args.id}');
const response = await sendQuery('UPDATE movie SET rating_dice_throw = ${args.rating_dice_throw} WHERE id = ${args.id}');
return response[0];
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment