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

[web] andualem added CRUD operations #299

Open
wants to merge 2 commits into
base: main
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
13 changes: 4 additions & 9 deletions starter-project-web-vue2/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ module.exports = {
root: true,
env: {
browser: true,
node: true
node: true,
},
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false
requireConfigFile: false,
},
extends: [
'@nuxtjs',
'plugin:nuxt/recommended',
'prettier'
],
plugins: [
],
extends: ['@nuxtjs', 'plugin:nuxt/recommended', 'prettier'],
plugins: [],
rules: {
'vue/multi-word-component-names': 'off',
},
Expand Down
4 changes: 2 additions & 2 deletions starter-project-web-vue2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

6. Add a file called index.vue in your pages folder. This page will be used to display a list of blogs.

7. Add a file called _id.vue in your pages folder. This page will be used to display a single blog.
7. Add a file called \_id.vue in your pages folder. This page will be used to display a single blog.

8. Add any components you want to use in your pages to your components folder. (ex. the component used to display a single blog on the list page.)

Expand Down Expand Up @@ -45,7 +45,7 @@

### End to End Testing

. . .
. . .

## Build Setup

Expand Down
2 changes: 1 addition & 1 deletion starter-project-web-vue2/assets/variables.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* No CSS *//*# sourceMappingURL=variables.css.map */
/* No CSS */ /*# sourceMappingURL=variables.css.map */
4 changes: 2 additions & 2 deletions starter-project-web-vue2/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
};
extends: ['@commitlint/config-conventional'],
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-dialog max-width="600px">
<template v-slot:activator="{ on }">
<template #activator="{ on }">
<v-btn color="primary" dark v-on="on">
<v-icon left> mdi-plus </v-icon>
Add Blog</v-btn
Expand All @@ -15,7 +15,7 @@
<v-text-field v-model="blogTitle" label="Title" />
<v-textarea v-model="blogContent" label="Content" />
<v-spacer></v-spacer>
<v-btn @click="onSubmit" class="success mx-0 mt-3">Add Blog</v-btn>
<v-btn class="success mx-0 mt-3" @click="onSubmit">Add Blog</v-btn>
</v-form>
</v-card-text>
</v-card>
Expand Down
10 changes: 5 additions & 5 deletions starter-project-web-vue2/components/abraham/AbrahamBlogPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
<v-container v-if="edit_area" class="px-0 black--text">
<p class="edit-post">Edit Post</p>
<v-text-field
v-model="blog_title"
outlined
class="text-black"
:value="current.title"
label="Title"
v-model="blog_title"
/>
<v-text-field
v-model="blog_content"
outlined
class="text-black"
:value="current.body"
label="Content"
v-model="blog_content"
/>
<v-btn @click="update" class="pa-2 mb-2 mx-7 mt-3" dark>Save</v-btn>
<v-btn class="pa-2 mb-2 mx-7 mt-3" dark @click="update">Save</v-btn>
</v-container>

<v-row
Expand Down Expand Up @@ -49,12 +49,12 @@
</v-card-text>
</v-col>
<v-col cols="1">
<v-btn left text @click="editArea(blog)" class="grey--text">
<v-btn left text class="grey--text" @click="editArea(blog)">
<v-icon> mdi-pencil </v-icon>
</v-btn>
</v-col>
<v-col cols="1">
<v-btn @click="deleteBlog(blog.id)" left text class="grey--text">
<v-btn left text class="grey--text" @click="deleteBlog(blog.id)">
<v-icon> mdi-delete </v-icon>
</v-btn>
</v-col>
Expand Down
6 changes: 3 additions & 3 deletions starter-project-web-vue2/components/abraham/UserAuthForm.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<v-form v-model="valid" class="pa-5 py-0 mx-auto grey lighten-5 mb-6">
<v-text-field
v-if="hasNamee"
v-model="userInfo.name"
label="Name"
:rules="[required('name')]"
v-if="hasNamee"
/>

<v-text-field
Expand All @@ -18,9 +18,9 @@
label="Password"
:type="showPassword ? 'text' : 'password'"
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
@click:append="showPassword = !showPassword"
counter="true"
:rules="[required('password'), minLength('password', 3)]"
@click:append="showPassword = !showPassword"
/>

<v-btn @click="submitForm(userInfo)">{{ buttonText }}</v-btn>
Expand All @@ -30,6 +30,7 @@
<script>
import validations from '@/utils/validations'
export default {
props: ['submitForm', 'buttonText', 'hasNamee'],
data() {
return {
valid: false,
Expand All @@ -42,7 +43,6 @@ export default {
...validations,
}
},
props: ['submitForm', 'buttonText', 'hasNamee'],
}
</script>

Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
14 changes: 5 additions & 9 deletions starter-project-web-vue2/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ module.exports = {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js'
'^vue$': 'vue/dist/vue.common.js',
},
moduleFileExtensions: [
'js',
'vue',
'json'
],
moduleFileExtensions: ['js', 'vue', 'json'],
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest'
'.*\\.(vue)$': 'vue-jest',
},
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/components/**/*.vue',
'<rootDir>/pages/**/*.vue'
'<rootDir>/pages/**/*.vue',
],
testEnvironment: 'jsdom'
testEnvironment: 'jsdom',
}
50 changes: 12 additions & 38 deletions starter-project-web-vue2/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,20 @@
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar
:clipped-left="clipped"
fixed
app
>
<v-app-bar :clipped-left="clipped" fixed app>
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
<v-btn
icon
@click.stop="miniVariant = !miniVariant"
>
<v-btn icon @click.stop="miniVariant = !miniVariant">
<v-icon>mdi-{{ `chevron-${miniVariant ? 'right' : 'left'}` }}</v-icon>
</v-btn>
<v-btn
icon
@click.stop="clipped = !clipped"
>
<v-btn icon @click.stop="clipped = !clipped">
<v-icon>mdi-application</v-icon>
</v-btn>
<v-btn
icon
@click.stop="fixed = !fixed"
>
<v-btn icon @click.stop="fixed = !fixed">
<v-icon>mdi-minus</v-icon>
</v-btn>
<v-toolbar-title v-text="title" />
<v-spacer />
<v-btn
icon
@click.stop="rightDrawer = !rightDrawer"
>
<v-btn icon @click.stop="rightDrawer = !rightDrawer">
<v-icon>mdi-menu</v-icon>
</v-btn>
</v-app-bar>
Expand All @@ -62,27 +46,17 @@
<Nuxt />
</v-container>
</v-main>
<v-navigation-drawer
v-model="rightDrawer"
:right="right"
temporary
fixed
>
<v-navigation-drawer v-model="rightDrawer" :right="right" temporary fixed>
<v-list>
<v-list-item @click.native="right = !right">
<v-list-item-action>
<v-icon light>
mdi-repeat
</v-icon>
<v-icon light> mdi-repeat </v-icon>
</v-list-item-action>
<v-list-item-title>Switch drawer (click me)</v-list-item-title>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-footer
:absolute="!fixed"
app
>
<v-footer :absolute="!fixed" app>
<span>&copy; {{ new Date().getFullYear() }}</span>
</v-footer>
</v-app>
Expand All @@ -91,7 +65,7 @@
<script>
export default {
name: 'DefaultLayout',
data () {
data() {
return {
clipped: false,
drawer: false,
Expand All @@ -100,14 +74,14 @@ export default {
{
icon: 'mdi-apps',
title: 'Welcome',
to: '/'
to: '/',
},
],
miniVariant: false,
right: true,
rightDrawer: false,
title: 'Practice'
title: 'Practice',
}
}
},
}
</script>
30 changes: 11 additions & 19 deletions starter-project-web-vue2/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,22 @@ export default {
titleTemplate: '%s - starter-project-web-vue2',
title: 'starter-project-web-vue2',
htmlAttrs: {
lang: 'en'
lang: 'en',
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
{ name: 'format-detection', content: 'telephone=no' },
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},

// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
css: [],

// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
],
plugins: [],

// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
Expand All @@ -41,10 +37,7 @@ export default {
],

// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@nuxtjs/axios',
'@nuxtjs/auth-next',
],
modules: ['@nuxtjs/axios', '@nuxtjs/auth-next'],

// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
vuetify: {
Expand All @@ -59,15 +52,14 @@ export default {
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3
}
}
}
success: colors.green.accent3,
},
},
},
},

// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
},
build: {},

auth: {
strategies: {
Expand Down
9 changes: 2 additions & 7 deletions starter-project-web-vue2/pages/abraham/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
</template>

<script>
import axios from 'axios'

export default {
data() {
return {
Expand All @@ -28,17 +26,14 @@ export default {
},
}
try {
const res = await axios.get(
const res = await this.$axios.get(
`https://blog-app-backend.onrender.com/api/articles/${this.$route.params.id}`,
config
)
console.log(res)

this.content = res.data.content
this.title = res.data.title
} catch (err) {
console.log(err)
}
} catch (err) {}
},
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions starter-project-web-vue2/pages/abraham/login.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-container>
<h1>LogIn</h1>
<UserAuthForm buttonText="Login" :submitForm="loginUser" />
<UserAuthForm button-text="Login" :submit-form="loginUser" />
</v-container>
</template>

Expand All @@ -13,7 +13,7 @@ export default {
},
methods: {
async loginUser(loginInfo) {
const res = await this.$auth.loginWith('local', {
await this.$auth.loginWith('local', {
data: loginInfo,
})
},
Expand Down
6 changes: 3 additions & 3 deletions starter-project-web-vue2/pages/abraham/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<v-contair>
<h1>Register</h1>
<UserAuthForm
buttonText="Register"
:submitForm="registerUser"
hasNamee="true"
button-text="Register"
:submit-form="registerUser"
has-namee="true"
/>
</v-contair>
</template>
Expand Down
Loading