first version of the webui

This commit is contained in:
Gauthier Roebroeck 2019-10-04 16:45:33 +08:00
parent ee57007aa8
commit b059788d4f
40 changed files with 17656 additions and 0 deletions

View File

@ -0,0 +1,2 @@
> 1%
last 2 versions

View File

@ -0,0 +1,5 @@
[*.{js, jsx, ts, tsx, vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

View File

@ -0,0 +1,3 @@
VUE_APP_KOMGA_API_URL=http://127.0.0.1:8080
VUE_APP_LOGIN=admin
VUE_APP_PASSWORD=admin

28
komga-webui/.eslintrc.js Normal file
View File

@ -0,0 +1,28 @@
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'@vue/standard',
'@vue/typescript'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: '@typescript-eslint/parser'
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)'
],
env: {
jest: true
}
}
]
}

24
komga-webui/.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
.DS_Store
node_modules
/dist
/tests/e2e/videos/
/tests/e2e/screenshots/
# 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?

View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}

3
komga-webui/cypress.json Normal file
View File

@ -0,0 +1,3 @@
{
"pluginsFile": "tests/e2e/plugins/index.js"
}

View File

@ -0,0 +1,37 @@
module.exports = {
moduleFileExtensions: [
'js',
'jsx',
'json',
'vue',
'ts',
'tsx'
],
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.tsx?$': 'ts-jest'
},
transformIgnorePatterns: [
'/node_modules/'
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
snapshotSerializers: [
'jest-serializer-vue'
],
testMatch: [
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
],
testURL: 'http://localhost/',
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname'
],
globals: {
'ts-jest': {
babelConfig: true
}
}
}

16339
komga-webui/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

45
komga-webui/package.json Normal file
View File

@ -0,0 +1,45 @@
{
"name": "komga-webui",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --host 127.0.0.1 --port 8081",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test:e2e": "vue-cli-service test:e2e",
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"axios": "^0.19.0",
"core-js": "^2.6.5",
"vue": "^2.6.10",
"vue-router": "^3.0.3",
"vuelidate": "^0.7.4",
"vuetify": "^2.0.0",
"vuex": "^3.0.1"
},
"devDependencies": {
"@types/jest": "^23.1.4",
"@types/vuelidate": "^0.7.7",
"@vue/cli-plugin-babel": "^3.11.0",
"@vue/cli-plugin-e2e-cypress": "^3.11.0",
"@vue/cli-plugin-eslint": "^3.11.0",
"@vue/cli-plugin-typescript": "^3.11.0",
"@vue/cli-plugin-unit-jest": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/eslint-config-typescript": "^4.0.0",
"@vue/test-utils": "1.0.0-beta.29",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"sass": "^1.17.4",
"sass-loader": "^7.1.0",
"ts-jest": "^23.0.0",
"typescript": "^3.4.3",
"vue-cli-plugin-vuetify": "^0.6.3",
"vue-template-compiler": "^2.6.10",
"vuetify-loader": "^1.2.2"
}
}

View File

@ -0,0 +1,5 @@
module.exports = {
plugins: {
autoprefixer: {}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,20 @@
<!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>Komga</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
</head>
<body>
<noscript>
<strong>We're sorry but Komga 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>
</html>

5
komga-webui/src/App.vue Normal file
View File

@ -0,0 +1,5 @@
<template>
<v-app>
<router-view/>
</v-app>
</template>

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="512pt"
viewBox="0 0 512 512"
width="512pt"
version="1.1"
id="svg4586"
sodipodi:docname="komga.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata4592">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs4590">
<linearGradient
id="linearGradient6082"
osb:paint="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop6080"/>
</linearGradient>
<linearGradient
id="linearGradient6076"
osb:paint="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop6074"/>
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient6082"
id="linearGradient6084"
x1="77.866812"
y1="386.00679"
x2="217.20259"
y2="386.00679"
gradientUnits="userSpaceOnUse"/>
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1656"
inkscape:window-height="1368"
id="namedview4588"
showgrid="false"
inkscape:zoom="1.2512475"
inkscape:cx="221.50686"
inkscape:cy="305.20589"
inkscape:window-x="-7"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg4586"/>
<path
d="m512 256c0 141.386719-114.613281 256-256 256s-256-114.613281-256-256 114.613281-256 256-256 256 114.613281 256 256zm0 0"
fill="#005ed3"
id="path4556"/>
<path
d="m 512,256 c 0,-11.71094 -0.80469,-23.23047 -2.32422,-34.52344 L 382.48047,94.28125 320.52344,121.85938 256,56.933594 212.69531,131.30469 129.51953,94.28125 141.86719,178.42187 49.949219,193.81641 114.32031,256 l -64.371091,62.18359 82.121091,82.16016 -2.55078,17.375 91.95703,91.95703 C 232.76953,511.19531 244.28906,512 256,512 397.38672,512 512,397.38672 512,256 Z"
id="path4558"
inkscape:connector-curvature="0"
style="fill:#00459f"
sodipodi:nodetypes="scccccccccccccss"/>
<path
d="m256 86.742188 37.109375 63.738281 70.574219-31.414063-10.527344 71.71875 77.078125 12.910156-54.144531 52.304688 54.144531 52.304688-77.078125 12.910156 10.527344 71.71875-70.574219-31.414063-37.109375 63.738281-37.109375-63.738281-70.574219 31.414063 10.527344-71.71875-77.078125-12.910156 54.144531-52.304688-54.144531-52.304688 77.078125-12.910156-10.527344-71.71875 70.574219 31.414063zm0 0"
fill="#ff0335"
id="path4560"/>
<path
d="m430.230469 308.300781-77.070313 12.910157 10.519532 71.71875-70.570313-31.410157-37.109375 63.742188v-338.523438l37.109375 63.742188 70.570313-31.410157-6.757813 46.101563-3.761719 25.617187 58.800782 9.851563 18.269531 3.058594-13.390625 12.929687-40.75 39.371094 11.378906 10.988281zm0 0"
fill="#c2001b"
id="path4562"/>
<path
d="m256 455.066406-43.304688-74.371094-83.175781 37.023438 12.347657-84.140625-91.917969-15.394531 64.371093-62.183594-64.371093-62.183594 91.917969-15.394531-12.347657-84.140625 83.179688 37.023438 43.300781-74.371094 43.304688 74.371094 83.175781-37.023438-12.347657 84.140625 91.917969 15.394531-64.371093 62.183594 64.371093 62.183594-91.917969 15.398437 12.347657 84.136719-83.175781-37.023438zm-30.917969-112.722656 30.917969 53.101562 30.917969-53.101562 57.964843 25.800781-8.703124-59.292969 62.238281-10.425781-43.917969-42.425781 43.917969-42.425781-62.238281-10.425781 8.703124-59.292969-57.964843 25.800781-30.917969-53.101562-30.917969 53.101562-57.964843-25.800781 8.703124 59.292969-62.238281 10.425781 43.917969 42.425781-43.917969 42.425781 62.238281 10.425781-8.703124 59.292969zm0 0"
fill="#ffdf47"
id="path4564"/>
<path
d="m403.308594 261.441406-5.628906-5.441406 25.160156-24.300781 39.210937-37.878907-55.75-9.339843-36.171875-6.058594 2.800782-19.09375 9.550781-65.046875-83.179688 37.019531-43.300781-74.371093v59.621093l30.921875 53.109375 57.957031-25.808594-3.910156 26.667969-2.546875 17.378907-2.242187 15.25 2.480468.421874 59.761719 10.007813-43.921875 42.421875 16.96875 16.390625 26.953125 26.03125-62.242187 10.429687 8.699218 59.296876-57.957031-25.808594-30.921875 53.109375v59.621093l43.300781-74.371093 83.179688 37.019531-12.351563-84.140625 91.921875-15.398437zm0 0"
fill="#fec000"
id="path4566"/>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:296.55969238px;line-height:125%;font-family:Impact;-inkscape-font-specification:Impact;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.54528999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
x="63.51244"
y="501.34204"
id="text4596"
transform="matrix(1.1590846,-0.34467221,0.22789693,0.794981,0,0)"><tspan
sodipodi:role="line"
id="tspan4594"
x="63.51244"
y="501.34204"
style="font-size:296.55969238px;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.54528999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1">K</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,172 @@
<template>
<div>
<v-dialog v-model="modalAddLibrary"
:fullscreen="this.$vuetify.breakpoint.xsOnly"
:hide-overlay="this.$vuetify.breakpoint.xsOnly"
max-width="450"
>
<v-card>
<v-toolbar class="hidden-sm-and-up">
<v-btn icon @click="dialogCancel">
<v-icon>mdi-close</v-icon>
</v-btn>
<v-toolbar-title>{{ dialogTitle }}</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn text color="primary" @click="dialogConfirm">{{ confirmText }}</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-card-title class="hidden-xs-only">{{ dialogTitle }}</v-card-title>
<v-card-text>
<form novalidate>
<v-container fluid>
<v-row>
<v-col>
<v-text-field v-model="form.name"
label="Name"
:error-messages="getErrors('name')"
@input="$v.form.name.$touch()"
@blur="$v.form.name.$touch()"
></v-text-field>
</v-col>
</v-row>
<v-row>
<v-col cols="8">
<file-browser-dialog
v-model="modalFileBrowser"
:path.sync="form.path"
confirm-text="Choose"
dialog-title="Library's root folder"
></file-browser-dialog>
<v-text-field v-model="form.path"
label="Root folder"
disabled
:error-messages="getErrors('path')"
@input="$v.form.path.$touch()"
@blur="$v.form.path.$touch()"
></v-text-field>
</v-col>
<v-col cols="4">
<v-btn @click="modalFileBrowser = true">Browse</v-btn>
</v-col>
</v-row>
</v-container>
</form>
</v-card-text>
<v-card-actions class="hidden-xs-only">
<v-spacer></v-spacer>
<v-btn text @click="dialogCancel">Cancel</v-btn>
<v-btn text class="primary--text" @click="dialogConfirm">{{ confirmText }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar
v-model="snackbar"
bottom
color="error"
>
{{ snackText }}
<v-btn
text
@click="snackbar = false"
>
Close
</v-btn>
</v-snackbar>
</div>
</template>
<script lang="js">
import Vue from 'vue'
import FileBrowserDialog from '@/components/FileBrowserDialog.vue'
import { required } from 'vuelidate/lib/validators'
export default Vue.extend({
name: 'AddLibraryDialog',
components: { FileBrowserDialog },
data: () => {
return {
modalAddLibrary: true,
modalFileBrowser: false,
snackbar: false,
snackText: '',
dialogTitle: 'Add Library',
confirmText: 'Add',
form: {
name: '',
path: ''
},
validationFieldNames: new Map([])
}
},
watch: {
modalAddLibrary (val) {
!val && this.dialogCancel()
}
},
validations: {
form: {
name: { required },
path: { required }
}
},
methods: {
getErrors (fieldName) {
const errors = []
const field = this.$v.form[fieldName]
if (field && field.$invalid && field.$dirty) {
const properName = this.validationFieldNames.has(fieldName)
? this.validationFieldNames.get(fieldName) : fieldName.charAt(0).toUpperCase() + fieldName.substring(1)
errors.push(`${properName} is required.`)
}
return errors
},
showSnack (message) {
this.snackText = message
this.snackbar = true
},
dialogCancel () {
this.$router.push({ name: 'home' })
},
dialogConfirm () {
// this.$router.push({ name: 'home' })
this.addLibrary()
},
validateLibrary () {
this.$v.$touch()
if (!this.$v.$invalid) {
return {
name: this.form.name,
root: this.form.path
}
}
return null
},
async addLibrary () {
const library = this.validateLibrary()
if (library) {
try {
await this.$store.dispatch('postLibrary', library)
this.$router.push({ name: 'home' })
} catch (e) {
this.showSnack(e.message)
}
}
}
}
})
</script>
<style scoped>
</style>

View File

@ -0,0 +1,112 @@
<template>
<div>
<v-dialog v-model="modal"
max-width="450"
>
<v-card>
<v-card-title>Delete Library</v-card-title>
<v-card-text>
<v-container fluid>
<v-row>
<v-col>The library <b>{{ library.name }}</b> will be removed from this server. Your media files will not
be
affected. This <b>cannot</b> be undone. Continue ?
</v-col>
</v-row>
<v-row>
<v-col>
<v-checkbox v-model="confirmDelete" color="red">
<template v-slot:label>
Yes, delete the library "{{ library.name }}"
</template>
</v-checkbox>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="dialogCancel">Cancel</v-btn>
<v-btn text class="red--text"
@click="dialogConfirm"
:disabled="!confirmDelete"
>Delete
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar
v-model="snackbar"
bottom
color="error"
>
{{ snackText }}
<v-btn
text
@click="snackbar = false"
>
Close
</v-btn>
</v-snackbar>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'DeleteLibraryDialog',
data: () => {
return {
confirmDelete: false,
snackbar: false,
snackText: '',
modal: false
}
},
props: {
value: Boolean,
library: {
type: Object,
required: true
}
},
watch: {
value (val) {
this.modal = val
},
modal (val) {
!val && this.dialogCancel()
}
},
methods: {
dialogCancel () {
this.$emit('input', false)
this.confirmDelete = false
},
dialogConfirm () {
this.deleteLibrary()
this.$emit('input', false)
},
showSnack (message: string) {
this.snackText = message
this.snackbar = true
},
async deleteLibrary () {
try {
await this.$store.dispatch('deleteLibrary', this.library)
} catch (e) {
this.showSnack(e.message)
}
}
}
})
</script>
<style scoped>
</style>

View File

@ -0,0 +1,127 @@
<template>
<v-dialog v-model="modalFileBrowser"
max-width="450"
scrollable
>
<v-card>
<v-card-title>{{ dialogTitle }}</v-card-title>
<v-card-text style="height: 450px">
<v-text-field
v-model="selectedPath"
readonly
></v-text-field>
<v-list elevation="3" dense>
<template v-if="directoryListing.hasOwnProperty('parent')">
<v-list-item
@click.prevent="select(directoryListing.parent)"
>
<v-list-item-icon>
<v-icon>mdi-arrow-left</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>
Parent
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
</template>
<div v-for="(d, index) in directoryListing.directories" :key="index">
<v-list-item
@click.prevent="select(d.path)"
>
<v-list-item-icon>
<v-icon>{{ d.type === 'directory' ? 'mdi-folder' : 'mdi-file' }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>
{{ d.name }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider v-if="index !== directoryListing.directories.length-1"></v-divider>
</div>
</v-list>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="dialogCancel">Cancel</v-btn>
<v-btn text class="primary--text"
@click="dialogConfirm"
:disabled="!selectedPath"
>{{ confirmText }}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'FileBrowserDialog',
data: () => {
return {
directoryListing: {} as DirectoryListingDto,
selectedPath: '',
modalFileBrowser: false
}
},
watch: {
value (val) {
this.modalFileBrowser = val
},
modalFileBrowser (val) {
!val && this.dialogCancel()
}
},
props: {
value: Boolean,
path: {
type: String,
required: false
},
dialogTitle: {
type: String,
default: 'File Browser'
},
confirmText: {
type: String,
default: 'Choose'
}
},
async mounted () {
this.getDirs()
},
methods: {
dialogCancel () {
this.$emit('input', false)
},
dialogConfirm () {
this.$emit('input', false)
this.$emit('update:path', this.selectedPath)
},
async getDirs (path?: string) {
this.directoryListing = await this.$komgaFileSystem.getDirectoryListing(path)
},
select (path: string) {
this.selectedPath = path
this.getDirs(path)
}
}
})
</script>
<style scoped>
</style>

View File

@ -0,0 +1,26 @@
<template>
<v-layout justify-center>
<div class="text-center">
<div>
<v-img src="../assets/logo.svg"
max-width="400"
></v-img>
<h1 class="headline mt-4">Welcome to Komga</h1>
<p class="body-1">The user interface is quite new an still a little scarce.</p>
<v-btn color="primary" :to="{name: 'addlibrary'}">Add library</v-btn>
</div>
</div>
</v-layout>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'Welcome'
})
</script>
<style scoped>
</style>

24
komga-webui/src/main.ts Normal file
View File

@ -0,0 +1,24 @@
import Vue from 'vue'
import Vuelidate from 'vuelidate'
import App from './App.vue'
import httpPlugin from './plugins/http.plugin'
import komgaFileSystem from './plugins/komga-filesystem.plugin'
import komgaLibraries from './plugins/komga-libraries.plugin'
import vuetify from './plugins/vuetify'
import router from './router'
import store from './store'
Vue.use(Vuelidate)
Vue.use(httpPlugin)
Vue.use(komgaFileSystem, { http: Vue.prototype.$http })
Vue.use(komgaLibraries, { store: store, http: Vue.prototype.$http })
Vue.config.productionTip = false
new Vue({
router,
store,
vuetify,
render: h => h(App)
}).$mount('#app')

View File

@ -0,0 +1,25 @@
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'
import _Vue from 'vue'
export default {
install (Vue: typeof _Vue) {
const config = {
baseURL: process.env.VUE_APP_KOMGA_API_URL ? process.env.VUE_APP_KOMGA_API_URL : window.location.origin
} as AxiosRequestConfig
if (process.env.VUE_APP_LOGIN && process.env.VUE_APP_PASSWORD) {
config.auth = {
username: process.env.VUE_APP_LOGIN,
password: process.env.VUE_APP_PASSWORD
}
}
Vue.prototype.$http = axios.create(config)
}
}
declare module 'vue/types/vue' {
interface Vue {
$http: AxiosInstance;
}
}

View File

@ -0,0 +1,17 @@
import KomgaFilesystemService from '@/services/komga-filesystem.service'
import { AxiosInstance } from 'axios'
import _Vue from 'vue'
export default {
install (
Vue: typeof _Vue,
{ http }: { http: AxiosInstance }) {
Vue.prototype.$komgaFileSystem = new KomgaFilesystemService(http)
}
}
declare module 'vue/types/vue' {
interface Vue {
$komgaFileSystem: KomgaFilesystemService;
}
}

View File

@ -0,0 +1,47 @@
import KomgaLibrariesService from '@/services/komga-libraries.service'
import { AxiosInstance } from 'axios'
import _Vue from 'vue'
import { Module } from 'vuex/types'
let service: KomgaLibrariesService
const vuexModule: Module<any, any> = {
state: {
libraries: {} as LibraryDto
},
mutations: {
setLibraries (state, libraries) {
state.libraries = libraries
}
},
actions: {
async getLibraries ({ commit }) {
commit('setLibraries', await service.getLibraries())
},
async postLibrary ({ dispatch }, library) {
await service.postLibrary(library)
dispatch('getLibraries')
},
async deleteLibrary ({ dispatch }, library) {
await service.deleteLibrary(library)
dispatch('getLibraries')
}
}
}
export default {
install (
Vue: typeof _Vue,
{ store, http }: { store: any, http: AxiosInstance }) {
service = new KomgaLibrariesService(http)
Vue.prototype.$komgaLibraries = service
store.registerModule('komgaLibraries', vuexModule)
}
}
declare module 'vue/types/vue' {
interface Vue {
$komgaLibraries: KomgaLibrariesService;
}
}

View File

@ -0,0 +1,10 @@
import Vue from 'vue'
import Vuetify from 'vuetify/lib'
Vue.use(Vuetify)
export default new Vuetify({
icons: {
iconfont: 'mdi'
}
})

34
komga-webui/src/router.ts Normal file
View File

@ -0,0 +1,34 @@
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
redirect: { name: 'welcome' },
name: 'home',
component: () => import(/* webpackChunkName: "home" */ './views/Home.vue'),
children: [
{
path: '/libraries/add',
name: 'addlibrary',
component: () => import(/* webpackChunkName: "addlibrary" */ './components/AddLibraryDialog.vue')
},
{
path: '/welcome',
name: 'welcome',
component: () => import(/* webpackChunkName: "welcome" */ './components/Welcome.vue')
}
]
},
{
path: '*',
name: 'notfound',
component: () => import(/* webpackChunkName: "notfound" */ './views/PageNotFound.vue')
}
]
})

View File

@ -0,0 +1,19 @@
import { AxiosInstance } from 'axios'
const API_FILESYSTEM = '/api/v1/filesystem'
export default class KomgaFilesystemService {
private http: AxiosInstance;
constructor (http: AxiosInstance) {
this.http = http
}
async getDirectoryListing (path: String = ''): Promise<DirectoryListingDto> {
return (await this.http.get(API_FILESYSTEM, {
params: {
path: path
}
})).data
}
}

View File

@ -0,0 +1,47 @@
import { AxiosInstance } from 'axios'
const API_LIBRARIES = '/api/v1/libraries'
export default class KomgaLibrariesService {
private http: AxiosInstance;
constructor (http: AxiosInstance) {
this.http = http
}
async getLibraries (): Promise<LibraryDto[]> {
try {
return (await this.http.get(API_LIBRARIES)).data
} catch (e) {
let msg = 'An error occurred while trying to retrieve libraries'
if (e.response.data.message) {
msg += `: ${e.response.data.message}`
}
throw new Error(msg)
}
}
async postLibrary (library: LibraryCreationDto): Promise<LibraryDto> {
try {
return (await this.http.post(API_LIBRARIES, library)).data
} catch (e) {
let msg = `An error occurred while trying to add library '${library.name}'`
if (e.response.data.message) {
msg += `: ${e.response.data.message}`
}
throw new Error(msg)
}
}
async deleteLibrary (library: LibraryDto) {
try {
await this.http.delete(`${API_LIBRARIES}/${library.id}`)
} catch (e) {
let msg = `An error occurred while trying to delete library '${library.name}'`
if (e.response.data.message) {
msg += `: ${e.response.data.message}`
}
throw new Error(msg)
}
}
}

17
komga-webui/src/shims-tsx.d.ts vendored Normal file
View File

@ -0,0 +1,17 @@
import Vue, { VNode } from 'vue'
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {
}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {
}
interface IntrinsicElements {
[elem: string]: any
}
}
}

4
komga-webui/src/shims-vue.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}

10
komga-webui/src/store.ts Normal file
View File

@ -0,0 +1,10 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {},
mutations: {},
actions: {}
})

View File

@ -0,0 +1,10 @@
interface DirectoryListingDto {
parent?: string,
directories: PathDto[]
}
interface PathDto {
type: string,
name: string,
path: string
}

View File

@ -0,0 +1,10 @@
interface LibraryCreationDto {
name: string,
root: string
}
interface LibraryDto {
id: number,
name: string,
root: string
}

View File

@ -0,0 +1,157 @@
<template>
<div>
<v-app-bar
app
hide-on-scroll
>
<v-app-bar-nav-icon @click.stop="toggleDrawer"></v-app-bar-nav-icon>
</v-app-bar>
<v-navigation-drawer app v-model="drawerVisible">
<v-list-item>
<v-list-item-avatar>
<v-img src="../assets/logo.svg"></v-img>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title class="title">
Komga
</v-list-item-title>
<v-list-item-subtitle>
Plex for comics!
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list>
<v-list-item :to="{name: 'home'}" exact>
<v-list-item-icon>
<v-icon>mdi-home</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>Home</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-icon>
<v-icon>mdi-book-multiple</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>Libraries</v-list-item-title>
</v-list-item-content>
<v-btn icon :to="{name: 'addlibrary'}" exact>
<v-icon>mdi-plus</v-icon>
</v-btn>
</v-list-item>
<v-list-item v-for="(l, index) in libraries" :key="index" dense>
<v-list-item-icon>
</v-list-item-icon>
<v-list-item-content>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-list-item-title v-on="on">{{ l.name }}</v-list-item-title>
</template>
<span>{{ l.root }}</span>
</v-tooltip>
</v-list-item-content>
<v-list-item-action>
<v-btn icon @click="promptDeleteLibrary(l)">
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
<!-- <v-list-item :to="{name: 'settings'}">-->
<!-- <v-list-item-action>-->
<!-- <v-icon>mdi-settings</v-icon>-->
<!-- </v-list-item-action>-->
<!-- <v-list-item-content>-->
<!-- <v-list-item-title>Settings</v-list-item-title>-->
<!-- </v-list-item-content>-->
<!-- </v-list-item>-->
<!-- <v-list-item @click="logout">-->
<!-- <v-list-item-icon>-->
<!-- <v-icon>mdi-power</v-icon>-->
<!-- </v-list-item-icon>-->
<!-- <v-list-item-content>-->
<!-- <v-list-item-title>Log out</v-list-item-title>-->
<!-- </v-list-item-content>-->
<!-- </v-list-item>-->
</v-list>
</v-navigation-drawer>
<v-content>
<v-container fluid>
<router-view/>
</v-container>
</v-content>
<delete-library-dialog v-model="modalDeleteLibrary"
:library="libraryToDelete">
</delete-library-dialog>
<v-snackbar
v-model="snackbar"
bottom
color="error"
>
{{ snackText }}
<v-btn
text
@click="snackbar = false"
>
Close
</v-btn>
</v-snackbar>
</div>
</template>
<script lang="ts">
import DeleteLibraryDialog from '@/components/DeleteLibraryDialog.vue'
import Vue from 'vue'
export default Vue.extend({
name: 'home',
components: { DeleteLibraryDialog },
data: () => ({
drawerVisible: true,
modalAddLibrary: false,
modalDeleteLibrary: false,
libraryToDelete: {} as LibraryDto,
snackbar: false,
snackText: ''
}),
computed: {
libraries (): LibraryDto[] {
return this.$store.state.komgaLibraries.libraries
}
},
async mounted () {
try {
await this.$store.dispatch('getLibraries')
} catch (e) {
this.showSnack(e.message)
}
},
methods: {
toggleDrawer () {
this.drawerVisible = !this.drawerVisible
},
showSnack (message: string) {
this.snackText = message
this.snackbar = true
},
promptDeleteLibrary (library: LibraryDto) {
this.libraryToDelete = library
this.modalDeleteLibrary = true
},
logout () {
}
}
})
</script>

View File

@ -0,0 +1,26 @@
<template>
<v-layout justify-center>
<div class="text-center">
<v-avatar color="grey lighten-3" size="400">
<div>
<v-icon class="secondary--text" size="140">mdi-help-circle</v-icon>
<h1 class="headline">Page not found</h1>
<p class="body-1">The page you are looking for doesn't exist.</p>
<v-btn color="primary" :to="{name: 'home'}">Go back to home page</v-btn>
</div>
</v-avatar>
</div>
</v-layout>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'PageNotFound'
})
</script>
<style scoped>
</style>

View File

@ -0,0 +1,12 @@
module.exports = {
plugins: [
'cypress'
],
env: {
mocha: true,
'cypress/globals': true
},
rules: {
strict: 'off'
}
}

View File

@ -0,0 +1,24 @@
// https://docs.cypress.io/guides/guides/plugins-guide.html
// if you need a custom webpack configuration you can uncomment the following import
// and then use the `file:preprocessor` event
// as explained in the cypress docs
// https://docs.cypress.io/api/plugins/preprocessors-api.html#Examples
/* eslint-disable import/no-extraneous-dependencies, global-require, arrow-body-style */
// const webpack = require('@cypress/webpack-preprocessor')
module.exports = (on, config) => {
// on('file:preprocessor', webpack({
// webpackOptions: require('@vue/cli-service/webpack.config'),
// watchOptions: {}
// }))
return Object.assign({}, config, {
fixturesFolder: 'tests/e2e/fixtures',
integrationFolder: 'tests/e2e/specs',
screenshotsFolder: 'tests/e2e/screenshots',
videosFolder: 'tests/e2e/videos',
supportFile: 'tests/e2e/support/index.js'
})
}

View File

@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

View File

@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

View File

@ -0,0 +1,5 @@
module.exports = {
env: {
jest: true
}
}

40
komga-webui/tsconfig.json Normal file
View File

@ -0,0 +1,40 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest",
"vuetify"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}