Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
v1.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangZisu committed Dec 21, 2018
1 parent 709e34b commit 7e4e912
Show file tree
Hide file tree
Showing 12 changed files with 300 additions and 99 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Perilla Frontend
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

[![GitHub license](https://img.shields.io/github/license/ZhangZisu/perilla-frontend.svg?style=for-the-badge)](https://github.com/ZhangZisu/perilla-frontend/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/ZhangZisu/perilla-frontend.svg?style=for-the-badge)](https://github.com/ZhangZisu/perilla-frontend)

[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/made-with-vue.svg)](https://forthebadge.com)

[![Greenkeeper badge](https://badges.greenkeeper.io/ZhangZisu/perilla-frontend.svg)](https://greenkeeper.io/)
[![GitHub license](https://img.shields.io/github/license/ZhangZisu/perilla-frontend.svg?style=flat-square)](https://github.com/ZhangZisu/perilla-frontend/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/ZhangZisu/perilla-frontend.svg?style=flat-square)](https://github.com/ZhangZisu/perilla-frontend)
[![Greenkeeper badge](https://badges.greenkeeper.io/ZhangZisu/perilla-frontend.svg?style=flat-square)](https://greenkeeper.io/)

## Deployment

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "perilla-frontend",
"version": "1.2.9",
"version": "1.2.10",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
6 changes: 6 additions & 0 deletions src/components/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
</v-list-tile-avatar>
<v-list-tile-title v-text="$t('create_group')"/>
</v-list-tile>
<v-list-tile to="/entry">
<v-list-tile-avatar>
<v-icon>local_library</v-icon>
</v-list-tile-avatar>
<v-list-tile-title v-text="$t('entry_list')"/>
</v-list-tile>
</v-list>
</v-menu>
</template>
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"after": "After",
"all": "All",
"all_progress": "All progress",
"all_user_data_will_be_removed_and_cannot_be_recovered": "All user data will be removed and cannot be recovered",
"apply": "Apply",
"article": "Article",
"base_url": "Base URL",
Expand Down Expand Up @@ -56,6 +57,7 @@
"edit_problem": "Editing problem {0}",
"editor": "Editor",
"email": "Email",
"entry_list": "Entry list",
"error": "Error",
"export_to_pdf": "Export to PDF",
"fetching": "Fetching",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"after": "之后",
"all": "全部",
"all_progress": "全部进度",
"all_user_data_will_be_removed_and_cannot_be_recovered": "所有用户数据将被删除且无法恢复",
"apply": "应用",
"article": "文章",
"base_url": "基础URL",
Expand Down Expand Up @@ -56,6 +57,7 @@
"edit_problem": "编辑问题{0}",
"editor": "编辑器",
"email": "邮箱",
"entry_list": "访问实例列表",
"error": "错误",
"export_to_pdf": "导出PDF",
"fetching": "获取中",
Expand Down
6 changes: 6 additions & 0 deletions src/routes/entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { RouteConfig } from 'vue-router'

export const entryRoutes: RouteConfig[] = [
{
path: '/entry',
name: 'entryList',
component: () =>
import(/* webpackChunkName: "entry" */ '@/views/entry/list.vue')
},
{
path: '/entry/show/:id',
name: 'entryView',
Expand Down
46 changes: 25 additions & 21 deletions src/views/article/list.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<template>
<v-container fluid>
<v-layout align-center justify-center>
<v-data-table :rows-per-page-items="[5, 10, 15, 25, 50]" class="fullwidth" :headers="headers" :items="articles" :pagination.sync="pagination" :total-items="total" :loading="loading">
<template slot="items" slot-scope="props">
<tr>
<td>
<router-link :to="'/article/show/' + props.item.id">
{{ props.item.id }}
</router-link>
</td>
<td class="text-xs-right">{{ props.item.title }}</td>
<td class="text-xs-right">
<v-chip v-for="(tag, i) in props.item.tags" :key="i">{{ tag }}</v-chip>
</td>
<td class="text-xs-right">{{ new Date(props.item.updated).toLocaleString() }}</td>
<td class="text-xs-right">{{ props.item.creator }}</td>
</tr>
</template>
<template slot="actions-prepend">
<v-btn flat v-text="$t('new')" to="/article/new" color="primary" />
<v-btn flat v-text="$t('condition')" @click="showCondDialog = true"/>
</template>
</v-data-table>
<v-flex sm12>
<v-card>
<v-data-table :rows-per-page-items="[5, 10, 15, 25, 50]" class="fullwidth" :headers="headers" :items="articles" :pagination.sync="pagination" :total-items="total" :loading="loading">
<template slot="items" slot-scope="props">
<tr>
<td>
<router-link :to="'/article/show/' + props.item.id">
{{ props.item.id }}
</router-link>
</td>
<td class="text-xs-right">{{ props.item.title }}</td>
<td class="text-xs-right">
<v-chip v-for="(tag, i) in props.item.tags" :key="i">{{ tag }}</v-chip>
</td>
<td class="text-xs-right">{{ new Date(props.item.updated).toLocaleString() }}</td>
<td class="text-xs-right">{{ props.item.creator }}</td>
</tr>
</template>
<template slot="actions-prepend">
<v-btn flat v-text="$t('new')" to="/article/new" color="primary" />
<v-btn flat v-text="$t('condition')" @click="showCondDialog = true"/>
</template>
</v-data-table>
</v-card>
</v-flex>
</v-layout>
<v-dialog v-model="showCondDialog" max-width="500px">
<v-card>
Expand Down
18 changes: 17 additions & 1 deletion src/views/entry/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn v-text="$t('remove')" color="warning" @click="remove"/>
<v-btn v-text="$t('save')" color="primary" @click="update"/>
</v-card-actions>
</v-card>
Expand All @@ -29,7 +30,7 @@
import { request } from '@/helpers/http'
import zMarkdownEditor from '@/components/zmarkdowneditor.vue'
import { EntryType } from '@/helpers/misc'
import { showToast } from '@/swal'
import { showToast, showDialog } from '@/swal'
export default {
name: 'adminEdit',
Expand Down Expand Up @@ -85,6 +86,21 @@ export default {
}).finally(() => {
this.$store.commit('toggleLoading', false)
})
},
async remove () {
if (!await showDialog('warning', 'think_twice', this.$t('all_user_data_will_be_removed_and_cannot_be_recovered'))) return
this.$store.commit('toggleLoading', true)
request({
url: '/api/entry',
method: 'DELETE',
params: { entry: this.id }
}).then(() => {
showToast('success', 'succeeded')
}).catch(e => {
showToast('error', 'error', e.message)
}).finally(() => {
this.$store.commit('toggleLoading', false)
})
}
}
}
Expand Down
154 changes: 154 additions & 0 deletions src/views/entry/list.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<template>
<v-container fluid>
<v-layout align-center justify-center>
<v-flex sm12>
<v-card>
<v-data-table :rows-per-page-items="[5, 10, 15, 25, 50]" class="fullwidth" :headers="headers" :items="entries" :pagination.sync="pagination" :total-items="total" :loading="loading">
<template slot="items" slot-scope="props">
<tr>
<td>
<router-link :to="'/entry/show/' + props.item._id">
{{ props.item._id }}
</router-link>
</td>
<td class="text-xs-right">{{ props.item.email }}</td>
<td class="text-xs-right">{{ $t(EntryType[props.item.type]) }}</td>
<td class="text-xs-right">{{ new Date(props.item.created).toLocaleString() }}</td>
</tr>
</template>
<template slot="actions-prepend">
<v-btn flat v-text="$t('condition')" @click="showCondDialog = true"/>
</template>
</v-data-table>
</v-card>
</v-flex>
</v-layout>
<v-dialog v-model="showCondDialog" max-width="500px">
<v-card>
<v-card-title class="headline" v-text="$t('condition')"/>
<v-card-text>
<v-text-field v-model="search" :label="$t('search')"/>
<v-select v-model="type" :items="[$t('all'), $t('user'), $t('group')]" :label="$t('type')"/>
<v-text-field v-model="before" :label="$t('before')" mask="####/##/## ##:##" :return-masked-value="true"/>
<v-text-field v-model="after" :label="$t('after')" mask="####/##/## ##:##" :return-masked-value="true"/>
</v-card-text>
<v-card-actions>
<v-spacer/>
<v-btn color="primary" v-text="$t('apply')" @click="fetchData()"/>
</v-card-actions>
</v-card>
</v-dialog>
</v-container>
</template>

<script>
import { request } from '@/helpers/http'
import { getStorage, setStorage } from '@/helpers/storage'
import { showToast } from '@/swal'
import { EntryType } from '@/helpers/misc'
export default {
name: 'FileList',
data () {
return {
headers: [
{ text: this.$t('ID'), align: 'left', sortable: true, value: '_id' },
{ text: this.$t('email'), value: 'email', sortable: false, class: 'text-xs-right' },
{ text: this.$t('type'), value: 'type', sortable: false, class: 'text-xs-right' },
{ text: this.$t('created'), value: 'created', sortable: true, class: 'text-xs-right' }
],
entries: [],
pagination: getStorage(localStorage, 'entryPagination') || {
descending: true,
page: 1,
rowsPerPage: 15,
sortBy: 'created',
totalItems: 0
},
total: 0,
loading: true,
search: null,
type: null,
before: null,
after: null,
showCondDialog: false,
EntryType
}
},
watch: {
pagination: {
handler: function () {
setStorage(localStorage, 'entryPagination', this.pagination)
this.fetchData()
},
deep: true
}
},
methods: {
fetchData () {
this.loading = true
const { sortBy, descending, page, rowsPerPage } = this.pagination
const params = { sortBy, descending: descending || undefined }
const condition = this.getCondition()
Promise.all([
request({
url: '/api/entry/list',
params: Object.assign(
{ entry: this.$store.state.entry },
{ noexec: true },
params,
condition
)
}),
request({
url: '/api/entry/list',
params: Object.assign(
{ entry: this.$store.state.entry },
{ skip: (page - 1) * rowsPerPage, limit: rowsPerPage },
params,
condition
)
})
])
.then(([count, items]) => {
this.total = count
this.entries = items
})
.catch(e => {
showToast('error', 'error', e.message)
})
.finally(() => {
this.loading = false
})
},
getCondition () {
let condition = {}
if (this.search && this.search.trim()) {
condition.search = this.search
}
if (this.type && this.type.trim()) {
if (this.type === this.$t('user')) {
condition.type = 0
} else if (this.type === this.$t('group')) {
condition.type = 1
}
}
if (this.before && this.before.trim()) {
condition.before = +new Date(this.before)
}
if (this.after && this.after.trim()) {
condition.after = +new Date(this.after)
}
return condition
}
},
mounted () {
this.fetchData()
}
}
</script>

<style lang="stylus" scoped>
.fullwidth
width 100%
</style>
50 changes: 27 additions & 23 deletions src/views/file/list.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
<template>
<v-container fluid>
<v-layout align-center justify-center>
<v-data-table :rows-per-page-items="[5, 10, 15, 25, 50]" class="fullwidth" :headers="headers" :items="files" :pagination.sync="pagination" :total-items="total" :loading="loading">
<template slot="items" slot-scope="props">
<tr>
<td>
<router-link :to="'/file/show/' + props.item.id">
{{ props.item.id }}
</router-link>
</td>
<td class="text-xs-right">{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.type }}</td>
<td class="text-xs-right">
<v-chip v-for="(tag, i) in props.item.tags" :key="i">{{ tag }}</v-chip>
</td>
<td class="text-xs-right">{{ new Date(props.item.updated).toLocaleString() }}</td>
<td class="text-xs-right">{{ props.item.creator }}</td>
</tr>
</template>
<template slot="actions-prepend">
<v-btn flat to="/file/new" v-text="$t('new')" color="primary" />
<v-btn flat to="/file/upload" v-text="$t('upload')" />
<v-btn flat v-text="$t('condition')" @click="showCondDialog = true"/>
</template>
</v-data-table>
<v-flex sm12>
<v-card>
<v-data-table :rows-per-page-items="[5, 10, 15, 25, 50]" class="fullwidth" :headers="headers" :items="files" :pagination.sync="pagination" :total-items="total" :loading="loading">
<template slot="items" slot-scope="props">
<tr>
<td>
<router-link :to="'/file/show/' + props.item.id">
{{ props.item.id }}
</router-link>
</td>
<td class="text-xs-right">{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.type }}</td>
<td class="text-xs-right">
<v-chip v-for="(tag, i) in props.item.tags" :key="i">{{ tag }}</v-chip>
</td>
<td class="text-xs-right">{{ new Date(props.item.updated).toLocaleString() }}</td>
<td class="text-xs-right">{{ props.item.creator }}</td>
</tr>
</template>
<template slot="actions-prepend">
<v-btn flat to="/file/new" v-text="$t('new')" color="primary" />
<v-btn flat to="/file/upload" v-text="$t('upload')" />
<v-btn flat v-text="$t('condition')" @click="showCondDialog = true"/>
</template>
</v-data-table>
</v-card>
</v-flex>
</v-layout>
<v-dialog v-model="showCondDialog" max-width="500px">
<v-card>
Expand Down
Loading

0 comments on commit 7e4e912

Please sign in to comment.