mirror of https://github.com/veops/cmdb.git
Modify code organization
This commit is contained in:
parent
ccf1d1c09a
commit
92183423df
|
@ -65,12 +65,12 @@ settings.py
|
|||
*.db
|
||||
|
||||
# UI
|
||||
ui/node_modules
|
||||
ui/dist
|
||||
cmdb-ui/node_modules
|
||||
cmdb-ui/dist
|
||||
|
||||
# Log files
|
||||
ui/npm-debug.log*
|
||||
ui/yarn-debug.log*
|
||||
ui/yarn-error.log*
|
||||
ui/yarn.lock
|
||||
ui/package-lock.json
|
||||
cmdb-ui/npm-debug.log*
|
||||
cmdb-ui/yarn-debug.log*
|
||||
cmdb-ui/yarn-error.log*
|
||||
cmdb-ui/yarn.lock
|
||||
cmdb-ui/package-lock.json
|
||||
|
|
14
Dockerfile
14
Dockerfile
|
@ -3,7 +3,7 @@ FROM node:alpine AS builder
|
|||
|
||||
LABEL description="cmdb-ui"
|
||||
|
||||
COPY ui /data/apps/cmdb-ui
|
||||
COPY cmdb-ui /data/apps/cmdb-ui
|
||||
|
||||
WORKDIR /data/apps/cmdb-ui
|
||||
|
||||
|
@ -22,7 +22,7 @@ FROM python:3.7-alpine AS cmdb-api
|
|||
|
||||
LABEL description="Python3.7,cmdb"
|
||||
|
||||
COPY . /data/apps/cmdb
|
||||
COPY cmdb-api /data/apps/cmdb
|
||||
|
||||
WORKDIR /data/apps/cmdb
|
||||
|
||||
|
@ -30,11 +30,11 @@ RUN apk add --no-cache tzdata gcc musl-dev libffi-dev
|
|||
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
RUN pip install --no-cache-dir -r docs/requirements.txt \
|
||||
&& cp ./api/settings.py.example ./api/settings.py \
|
||||
&& sed -i "s#{user}:{password}@127.0.0.1:3306/{db}#cmdb:123456@mysql:3306/cmdb#g" api/settings.py \
|
||||
&& sed -i "s#redis://127.0.0.1#redis://redis#g" api/settings.py \
|
||||
&& sed -i 's#CACHE_REDIS_HOST = "127.0.0.1"#CACHE_REDIS_HOST = "redis"#g' api/settings.py
|
||||
RUN pip install --no-cache-dir -r requirements.txt \
|
||||
&& cp ./settings.py.example settings.py \
|
||||
&& sed -i "s#{user}:{password}@127.0.0.1:3306/{db}#cmdb:123456@mysql:3306/cmdb#g" settings.py \
|
||||
&& sed -i "s#redis://127.0.0.1#redis://redis#g" settings.py \
|
||||
&& sed -i 's#CACHE_REDIS_HOST = "127.0.0.1"#CACHE_REDIS_HOST = "redis"#g' settings.py
|
||||
|
||||
CMD ["bash", "-c", "flask run"]
|
||||
|
||||
|
|
34
README.md
34
README.md
|
@ -28,19 +28,19 @@ Overview
|
|||
3. 关系视图 - 模型之间的关系, 用树形图方式展示, **管理员可配置**
|
||||
|
||||
##### 资源视图
|
||||

|
||||

|
||||
|
||||
##### 树形视图
|
||||

|
||||

|
||||
|
||||
##### 关系视图
|
||||

|
||||

|
||||
|
||||
##### 用户订阅
|
||||

|
||||

|
||||
|
||||
##### 关系视图配置
|
||||

|
||||

|
||||
|
||||
Docker一键快速构建
|
||||
----
|
||||
|
@ -66,24 +66,24 @@ Install
|
|||
```bash
|
||||
git clone https://github.com/pycook/cmdb.git
|
||||
cd cmdb
|
||||
cp api/settings.py.example api/settings.py
|
||||
cp cmdb-api/settings.py.example cmdb-api/settings.py
|
||||
```
|
||||
**设置api/settings.py里的database**
|
||||
**设置cmdb-api/settings.py里的database**
|
||||
|
||||
- 安装库
|
||||
- 后端: ```pipenv run pipenv install```
|
||||
- 前端: ```cd ui && yarn install && cd ..```
|
||||
- 后端: ```cd cmdb-api && pipenv run pipenv install && cd ..```
|
||||
- 前端: ```cd cmdb-ui && yarn install && cd ..```
|
||||
|
||||
- 创建数据库表 ```pipenv run flask db-setup && pipenv run flask init-cache```
|
||||
- 可以将docs/cmdb.sql导入到数据库里,登录用户和密码都是:admin
|
||||
- 可以将docs/cmdb.sql导入到数据库里,登录用户和密码分别是:demo/123456
|
||||
|
||||
- 启动服务
|
||||
- 后端: ```pipenv run flask run -h 0.0.0.0```
|
||||
- 前端: ```cd ui && yarn run serve```
|
||||
- worker: ```celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1```
|
||||
- 后端: 进入**cmdb-api**目录执行 ```pipenv run flask run -h 0.0.0.0```
|
||||
- 前端: 进入**cmdb-ui**目录执行```yarn run serve```
|
||||
- worker: 进入**cmdb-api**目录执行 ```pipenv run celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1```
|
||||
|
||||
- 浏览器打开: [http://127.0.0.1:8000](http://127.0.0.1:8000)
|
||||
- 如果是非本机访问, 要修改**ui/.env**里**VUE_APP_API_BASE_URL**里的IP地址为后端服务的ip地址
|
||||
- 如果是非本机访问, 要修改**cmdb-ui/.env**里**VUE_APP_API_BASE_URL**里的IP地址为后端服务的ip地址
|
||||
|
||||
|
||||
Install by Makefile
|
||||
|
@ -95,9 +95,9 @@ Install by Makefile
|
|||
```bash
|
||||
git clone https://github.com/pycook/cmdb.git
|
||||
cd cmdb
|
||||
cp api/settings.py.example api/settings.py
|
||||
cp cmdb-api/settings.py.example cmdb-api/settings.py
|
||||
```
|
||||
**设置api/settings.py里的database**
|
||||
**cmdb-api/settings.py里的database**
|
||||
|
||||
- 顺序在cmdb目录下执行
|
||||
- 环境: ```make env```
|
||||
|
@ -109,4 +109,4 @@ cp api/settings.py.example api/settings.py
|
|||
----
|
||||
_**欢迎加入CMDB运维开发QQ群(336164978)**_
|
||||
|
||||

|
||||

|
|
@ -6,6 +6,7 @@ import sys
|
|||
from inspect import getmembers
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
from api.flask_cas import CAS
|
||||
from flask import Flask
|
||||
from flask import make_response, jsonify
|
||||
from flask.blueprints import Blueprint
|
||||
|
@ -23,8 +24,7 @@ from api.extensions import (
|
|||
rd,
|
||||
es
|
||||
)
|
||||
from api.flask_cas import CAS
|
||||
from api.models.acl import User
|
||||
from .models.acl import User
|
||||
|
||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||
PROJECT_ROOT = os.path.join(HERE, os.pardir)
|
||||
|
@ -72,7 +72,7 @@ class ReverseProxy(object):
|
|||
return self.app(environ, start_response)
|
||||
|
||||
|
||||
def create_app(config_object="{0}.settings".format(API_PACKAGE)):
|
||||
def create_app(config_object="settings"):
|
||||
"""Create application factory, as explained here: http://flask.pocoo.org/docs/patterns/appfactories/.
|
||||
|
||||
:param config_object: The configuration object to use.
|
|
@ -6,7 +6,7 @@ from flask import Blueprint
|
|||
from flask_restful import Api
|
||||
|
||||
from api.resource import register_resources
|
||||
from .account import LoginView, LogoutView
|
||||
from api.views.account import LoginView, LogoutView
|
||||
|
||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
[*]
|
||||
charset=utf-8
|
||||
end_of_line=lf
|
||||
insert_final_newline=false
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[{*.ng,*.sht,*.html,*.shtm,*.shtml,*.htm}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[{*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[*.svg]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[*.js.map]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[*.less]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[*.vue]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[{.analysis_options,*.yml,*.yaml}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
NODE_ENV=production
|
||||
VUE_APP_PREVIEW=false
|
||||
VUE_APP_API_BASE_URL=http://127.0.0.1:5000/api
|
|
@ -0,0 +1,3 @@
|
|||
NODE_ENV=production
|
||||
VUE_APP_PREVIEW=true
|
||||
VUE_APP_API_BASE_URL=http://127.0.0.1:5001/api
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"printWidth": 120,
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 10.15.0
|
||||
cache: yarn
|
||||
script:
|
||||
- yarn
|
||||
- yarn run lint --no-fix && yarn run build
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 Anan Yang
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,25 @@
|
|||
module.exports = {
|
||||
presets: [
|
||||
'@vue/app',
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
'useBuiltIns': 'usage', // "usage" | "entry" | false, defaults to false.
|
||||
'corejs': '3.1.2',
|
||||
'targets': {
|
||||
'esmodules': true,
|
||||
'ie': '11'
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
// if your use import on Demand, Use this code
|
||||
// ,
|
||||
// plugins: [
|
||||
// [ 'import', {
|
||||
// 'libraryName': 'ant-design-vue',
|
||||
// 'libraryDirectory': 'es',
|
||||
// 'style': true // `style: true` 会加载 less 文件
|
||||
// } ]
|
||||
// ]
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
moduleFileExtensions: [
|
||||
'js',
|
||||
'jsx',
|
||||
'json',
|
||||
'vue'
|
||||
],
|
||||
transform: {
|
||||
'^.+\\.vue$': 'vue-jest',
|
||||
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
|
||||
'^.+\\.jsx?$': 'babel-jest'
|
||||
},
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1'
|
||||
},
|
||||
snapshotSerializers: [
|
||||
'jest-serializer-vue'
|
||||
],
|
||||
testMatch: [
|
||||
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
|
||||
],
|
||||
testURL: 'http://localhost/'
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"include": ["src/**/*"]
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue