Skip to content

Commit

Permalink
WIP: Add admin UI for managing data
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed May 2, 2021
1 parent f6625f5 commit 29da6c9
Show file tree
Hide file tree
Showing 29 changed files with 10,331 additions and 26 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ deps:
build:
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}'" cmd/${BIN}/*.go

.PHONY: run
run: build
./${BIN}

.PHONY: run-admin-frontend
run-admin-frontend:
cd admin && yarn serve

.PHONY: build-tokenizers
build-tokenizers:
go build -ldflags="-s -w" -buildmode=plugin -o kannada.tk tokenizers/kannada/kannada.go
Expand All @@ -40,5 +48,4 @@ release-dry:
release:
goreleaser --parallelism 1 --rm-dist --skip-validate


.DEFAULT_GOAL := build
.DEFAULT_GOAL := dist
17 changes: 17 additions & 0 deletions admin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/essential',
'@vue/airbnb',
],
parserOptions: {
parser: 'babel-eslint',
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
};
23 changes: 23 additions & 0 deletions admin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist


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

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

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

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn serve
```

### Compiles and minifies for production
```
yarn build
```

### Lints and fixes files
```
yarn lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions admin/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'
]
}
33 changes: 33 additions & 0 deletions admin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"buefy": "^0.9.7",
"core-js": "^3.6.5",
"node-sass": "^5.0.0",
"sass-loader": "^10.1.1",
"vue": "^2.6.11",
"vue-router": "^3.5.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-airbnb": "^5.3.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
Binary file added admin/public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions admin/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<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.png">
<title><%= htmlWebpackPlugin.options.title %></title>
</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>
</html>
26 changes: 26 additions & 0 deletions admin/src/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
async function hFetch(url, method, data) {
return new Promise((resolve, reject) => {
fetch(url, {
method: method || 'GET',
body: JSON.stringify(data),
mode: 'cors',
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
}).then((response) => {
if (response.ok) {
resolve(response.json());
} else {
reject(response);
}
}).catch((error) => {
reject(error);
});
});
}

export const getConfig = async () => hFetch('/admin/api/config');

export const updateEntry = async (data) => hFetch('/admin/api/entries', 'put', data);

export const search = async (q, fromLang, toLang) => hFetch(`/api/dictionary/${fromLang}/${toLang}/${encodeURIComponent(q)}`, 'get');
46 changes: 46 additions & 0 deletions admin/src/assets/buefy.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@import "~bulma/sass/base/_all";
@import "~bulma/sass/elements/_all";
@import "~bulma/sass/components/card";
@import "~bulma/sass/components/dropdown";
@import "~bulma/sass/components/level";
@import "~bulma/sass/components/menu";
@import "~bulma/sass/components/message";
@import "~bulma/sass/components/modal";
@import "~bulma/sass/components/navbar";
@import "~bulma/sass/components/pagination";
@import "~bulma/sass/components/tabs";
@import "~bulma/sass/form/_all";
@import "~bulma/sass/grid/columns";
@import "~bulma/sass/grid/tiles";
@import "~bulma/sass/layout/section";
@import "~bulma/sass/layout/footer";
@import "~bulma/sass/helpers/typography";
@import "~bulma/sass/helpers/color";

@import "~buefy/src/scss/utils/_all";
@import "~buefy/src/scss/components/_autocomplete";
@import "~buefy/src/scss/components/_carousel";
@import "~buefy/src/scss/components/_checkbox";
@import "~buefy/src/scss/components/_datepicker";
@import "~buefy/src/scss/components/_dialog";
@import "~buefy/src/scss/components/_dropdown";
@import "~buefy/src/scss/components/_form";
@import "~buefy/src/scss/components/_icon";
@import "~buefy/src/scss/components/_loading";
@import "~buefy/src/scss/components/_menu";
@import "~buefy/src/scss/components/_message";
@import "~buefy/src/scss/components/_modal";
@import "~buefy/src/scss/components/_pagination";
@import "~buefy/src/scss/components/_notices";
@import "~buefy/src/scss/components/_progress";
@import "~buefy/src/scss/components/_radio";
@import "~buefy/src/scss/components/_select";
@import "~buefy/src/scss/components/_sidebar";
@import "~buefy/src/scss/components/_switch";
@import "~buefy/src/scss/components/_table";
@import "~buefy/src/scss/components/_tabs";
@import "~buefy/src/scss/components/_tag";
@import "~buefy/src/scss/components/_taginput";
@import "~buefy/src/scss/components/_timepicker";
@import "~buefy/src/scss/components/_tooltip";
@import "~buefy/src/scss/components/_upload";
Binary file added admin/src/assets/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/src/assets/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions admin/src/assets/logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 29da6c9

Please sign in to comment.