Skip to content

Commit

Permalink
Merge pull request #8 from bmf-san/0.0.4
Browse files Browse the repository at this point in the history
0.0.4
  • Loading branch information
bmf-san authored Oct 18, 2020
2 parents 2876d96 + bab9732 commit 18e389d
Show file tree
Hide file tree
Showing 19 changed files with 785 additions and 49 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ references:
- ".git"
restore_docker_compose_cache: &restore_docker_compose_cache
restore_cache:
key: v1-docker-{{ .Branch }}-{{ checksum "docker-compose.ci.yml" }}
paths: ~/caches/images.tar
key: v1-docker-{{ .Branch }}-{{ checksum "docker-compose-ci.yml" }}
load_docker_image: &load_docker_image
run:
name: Load docker image
Expand All @@ -37,9 +36,10 @@ references:
save_docker_compose_cache: &save_docker_compose_cache
save_cache:
key: v1-docker-{{ .Branch }}-{{ checksum "docker-compose.ci.yml" }}
paths: ~/caches/images.tar
paths:
- ~/caches/images.tar

version: 2
version: 2.1
jobs:
build:
working_directory: ~/workspace
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- *run_docker_compose
- run:
name: Run lint
command: npm run lint
command: make lint
test:
machine: true
steps:
Expand All @@ -78,7 +78,7 @@ jobs:
- *run_docker_compose
- run:
name: Run tests
command: npm run test:unit
command: make test
workflows:
version: 2
build_and_test:
Expand Down
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,34 @@ help:

docker-compose-build: ## Build containers by docker-compose.
ifeq ($(env), ci)
docker-compose -f docker-compose.ci.yml build
docker-compose -f docker-compose-ci.yml build
else
docker-compose -f docker-compose.yml build
endif

docker-compose-up: ## Run containers by docker-compose.
ifeq ($(env), ci)
docker-compose -f docker-compose.ci.yml up
docker-compose -f docker-compose-ci.yml up
else
docker-compose -f docker-compose.yml up
endif

docker-compose-up-d: ## Run containers in the background by docker-compose.
ifeq ($(env), ci)
docker-compose -f docker-compose.ci.yml up -d
docker-compose -f docker-compose-ci.yml up -d
else
docker-compose -f docker-compose.yml up -d
endif

docker-compose-pull: ## Pull images by docker-compose.
ifeq ($(env), ci)
docker-compose -f docker-compose.ci.yml pull
docker-compose -f docker-compose-ci.yml pull
else
docker-compose -f docker-compose.yml pull
endif
endif

lint: ## Run lint.
docker exec -it gobel-admin-client npm run lint

test: ## Run tests.
docker exec -it gobel-admin-client npm run test:unit
13 changes: 13 additions & 0 deletions app/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:14.3.0-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install -g @vue/cli

RUN npm install

COPY . .

RUN npm run prod-build
15 changes: 0 additions & 15 deletions app/Dockerfile.prod

This file was deleted.

33 changes: 18 additions & 15 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<div id="nav">
<router-link to="/">Home</router-link>
<router-link to="/posts">Posts</router-link>
<router-link to="/categories">Categories</router-link>
<router-link to="/tags">Tags</router-link>
<router-link to="/comments">Comments</router-link>
<!-- TODO: It may be necessary to introduce a store pattern to adjust the display conditions -->
<button @click="signout()">Signout</button>
</div>
Expand Down
8 changes: 8 additions & 0 deletions app/src/consts/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const PENDING = "pending";
const APPROVAL = "approval";

export default Object.freeze({
STATUS_PENDING: PENDING,
STATUS_APPROVAL: APPROVAL,
STATUSES: [PENDING, APPROVAL]
});
2 changes: 1 addition & 1 deletion app/src/consts/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const PUBLISH = "publish";
const DRAFT = "draft";

export default Object.freeze({
STATUS_PUBLIC: PUBLISH,
STATUS_PUBLISH: PUBLISH,
STATUS_PRIVATE: DRAFT,
STATUSES: [PUBLISH, DRAFT]
});
81 changes: 81 additions & 0 deletions app/src/pages/Categories.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<div class="categories">
<h1>Categories</h1>
<Loader v-show="loading" />
<div>
<article v-for="category in categories" :key="category.id">
<router-link :to="{ name: 'EditCategory', params: { id: category.id } }"
><h1>{{ category.name }}</h1></router-link
>
</article>
<Pagination
name="Categories"
:page="page"
:limit="limit"
:pagecount="pagecount"
@click.native="getCategories(page, limit)"
/>
</div>
</div>
</template>

<script>
const defaultPage = 1;
const defaultLimit = 10;
const defaultPageCount = 10;
import Loader from "@/components/Loader.vue";
import Pagination from "@/components/Pagination.vue";
import apiClient from "../modules/apiClient";
export default {
name: "Categories",
components: {
Loader,
Pagination
},
data() {
return {
loading: false,
categories: [],
page: defaultPage,
limit: defaultLimit,
pagecount: defaultPageCount
};
},
created() {
this.getCategories(this.page, this.limit);
},
beforeRouteUpdate(to, from, next) {
this.page = to.query.page;
this.limit = to.query.limit;
this.getCategories(this.page, this.limit);
next();
},
methods: {
async getCategories(page, limit) {
try {
this.loading = true;
await apiClient
.get(`/private/categories?page=${page}&limit=${limit}`, {
headers: {
Authorization: "Bearer " + localStorage.getItem("access_token")
}
})
.then(res => {
this.categories = res.data;
this.page = Number(res.headers["pagination-page"]);
this.limit = Number(res.headers["pagination-limit"]);
this.pagecount = Number(res.headers["pagination-pagecount"]);
this.loading = false;
});
} catch (e) {
console.log(e);
} finally {
this.loading = false;
}
}
}
};
</script>

<style scoped></style>
81 changes: 81 additions & 0 deletions app/src/pages/Comments.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<div class="comments">
<h1>Comments</h1>
<Loader v-show="loading" />
<div>
<article v-for="comment in comments" :key="comment.id">
<router-link :to="{ name: 'EditComment', params: { id: comment.id } }"
><h1>{{ comment.body }}</h1></router-link
><span>{{ comment.status }}</span>
</article>
<Pagination
name="Comments"
:page="page"
:limit="limit"
:pagecount="pagecount"
@click.native="getComments(page, limit)"
/>
</div>
</div>
</template>

<script>
const defaultPage = 1;
const defaultLimit = 10;
const defaultPageCount = 10;
import Loader from "@/components/Loader.vue";
import Pagination from "@/components/Pagination.vue";
import apiClient from "../modules/apiClient";
export default {
name: "Comments",
components: {
Loader,
Pagination
},
data() {
return {
loading: false,
comments: [],
page: defaultPage,
limit: defaultLimit,
pagecount: defaultPageCount
};
},
created() {
this.getComments(this.page, this.limit);
},
beforeRouteUpdate(to, from, next) {
this.page = to.query.page;
this.limit = to.query.limit;
this.getComments(this.page, this.limit);
next();
},
methods: {
async getComments(page, limit) {
try {
this.loading = true;
await apiClient
.get(`/private/comments?page=${page}&limit=${limit}`, {
headers: {
Authorization: "Bearer " + localStorage.getItem("access_token")
}
})
.then(res => {
this.comments = res.data;
this.page = Number(res.headers["pagination-page"]);
this.limit = Number(res.headers["pagination-limit"]);
this.pagecount = Number(res.headers["pagination-pagecount"]);
this.loading = false;
});
} catch (e) {
console.log(e);
} finally {
this.loading = false;
}
}
}
};
</script>

<style scoped></style>
Loading

0 comments on commit 18e389d

Please sign in to comment.