Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nanda Acidunnafi #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

Buatlah sebuah web app dengan fitur sebagai berikut:

<<<<<<< HEAD
- Manage Movie and Rating Movie
=======
- Manage Movie and Rating Movies
>>>>>>> 67c30d1435ca3170d7f253eac16f47a129e58dea
- Show Movies
- Show Movie Rates detail
- Add Rate to a Movie
Expand Down
2 changes: 2 additions & 0 deletions client/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> 1%
last 2 versions
21 changes: 21 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
19 changes: 19 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# client

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions client/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
11,670 changes: 11,670 additions & 0 deletions client/package-lock.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"axios": "^0.19.2",
"core-js": "^3.6.4",
"vue": "^2.6.11",
"vue-router": "^3.1.5",
"vuex": "^3.1.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.2.0",
"@vue/cli-plugin-router": "~4.2.0",
"@vue/cli-plugin-vuex": "~4.2.0",
"@vue/cli-service": "~4.2.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
}
}
Binary file added client/public/favicon.ico
Binary file not shown.
21 changes: 21 additions & 0 deletions client/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</html>
28 changes: 28 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<div id="app">
<router-view/>
</div>
</template>

<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}

#nav {
padding: 30px;

a {
font-weight: bold;
color: #2c3e50;

&.router-link-exact-active {
color: #42b983;
}
}
}
</style>
Binary file added client/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions client/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
40 changes: 40 additions & 0 deletions client/src/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import store from "../store"
import Movie from '../views/Movie.vue'
import Rate from '../views/Rate.vue'

Vue.use(VueRouter)

const routes = [
{
path: '/',
name: 'Home',
redirect: "/movies"
},
{
path: '/movies',
name: 'Movie',
component: Movie
},
{
path: "/rate",
name: "Rate",
component: Rate,
beforeEnter: (to, from, next) => {
if(!store.state.selectedMovie) {
next("/movies");
} else {
next();
}
}
}
]

const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})

export default router
134 changes: 134 additions & 0 deletions client/src/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import Vue from 'vue'
import Vuex from 'vuex'
import axios from "axios"

const baseUrl = "http://localhost:3000";
Vue.use(Vuex)

export default new Vuex.Store({
state: {
movies: null,
selectedMovie: null,

reviewer: null,
rating: null,

title: null,
year: null,
type: null,
poster: null,
imdb: null

},
mutations: {
getMovies(state, data) {
state.movies = data
},
selectMovie(state, data) {
state.selectedMovie = state.movies[data];
state.title = state.movies[data].title;
state.year = state.movies[data].year;
state.type = state.movies[data].type;
state.poster = state.movies[data].poster;
state.imdb = state.movies[data].imdbID;
},

updateReviewer(state, data) {
state.reviewer = data;
},
updateRating(state, data) {
state.rating = data;
},

updateTitle(state, data) {
state.title = data;
},
updateYear(state, data) {
state.year = data;
},
updateType(state, data) {
state.type = data;
},
updatePoster(state, data) {
state.poster = data;
},
updateImdb(state, data) {
state.imdb = data;
},

addRate(state, data) {
state.selectedMovie.Rates.push(data);
},
clearAddRateForm(state) {
state.reviewer = null;
state.rating = null;
},
updateMovie(state, data) {
state.movies.forEach(el => {
if(el == state.selectedMovie) {
el = data;
state.selectMovie = data;
}
});
},
deleteRate(state, data) {
console.log(state.selectedMovie.Rates, data);
state.selectedMovie.Rates.splice(data, 1);
}
},
actions: {
getMovies({commit}) {
axios.get(`${baseUrl}/movies`)
.then(data => {
commit("getMovies", data.data);
})
.catch(err => {
console.log(err);
});
},
addRate({commit}) {
const id = this.state.selectedMovie.id;
const obj = {
reviewer: this.state.reviewer,
point: this.state.rating
}
axios.post(`${baseUrl}/rate/${id}`, obj)
.then(data => {
commit("addRate", data.data);
commit("clearAddRateForm");
})
.catch(err => {
console.log(err);
});
},
deleteRate({commit}, data) {
const id = data.id;
axios.delete(`${baseUrl}/rate/${id}`)
.then(data => {
commit("deleteRate", data.i);
})
.catch(err => {
console.log(err);
})
},
updateMovie({commit}, data) {
const id = this.state.selectedMovie.id;
const obj = {
title: this.state.title,
year: this.state.year,
type: this.state.type,
poster: this.state.poster,
imdbID: this.state.imdb
}
axios.put(`${baseUrl}/movies/${id}`, obj)
.then(data => {
commit("updateMovie", data.data);
})
.catch(err => {
console.log(err);
})
}
},
modules: {
}
})
Loading