mirror of https://github.com/jumpserver/jumpserver
perf: 优化 applet api
parent
c5ca20d957
commit
f316b241aa
Binary file not shown.
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 5.6 KiB |
|
@ -87,6 +87,7 @@ class DownloadUploadMixin:
|
||||||
class AppletViewSet(DownloadUploadMixin, JMSBulkModelViewSet):
|
class AppletViewSet(DownloadUploadMixin, JMSBulkModelViewSet):
|
||||||
queryset = Applet.objects.all()
|
queryset = Applet.objects.all()
|
||||||
serializer_class = serializers.AppletSerializer
|
serializer_class = serializers.AppletSerializer
|
||||||
|
filterset_fields = ['name', 'version', 'builtin', 'is_active']
|
||||||
search_fields = ['name', 'display_name', 'author']
|
search_fields = ['name', 'display_name', 'author']
|
||||||
rbac_perms = {
|
rbac_perms = {
|
||||||
'upload': 'terminal.add_applet',
|
'upload': 'terminal.add_applet',
|
||||||
|
|
|
@ -1,3 +1,55 @@
|
||||||
|
# Lina
|
||||||
|
|
||||||
|
Lina 是 JumpServer 的前端 UI 项目, 主要使用 [Vue](https://cn.vuejs.org/), [Element UI](https://element.eleme.cn/) 完成,
|
||||||
|
名字来源于 Dota 英雄 [Lina](https://baike.baidu.com/item/%E8%8E%89%E5%A8%9C/16693979)
|
||||||
|
|
||||||
|
## 开发运行
|
||||||
|
|
||||||
|
```
|
||||||
|
0. 前置条件: 部署运行好 JumpServer API 服务器
|
||||||
|
|
||||||
|
1. 安装依赖
|
||||||
|
$ yarn install
|
||||||
|
|
||||||
|
2. 修改 .env.development VUE_APP_CORE_HOST
|
||||||
|
# ...
|
||||||
|
VUE_APP_CORE_HOST = 'JUMPSERVER_APIHOST'
|
||||||
|
|
||||||
|
3. 运行
|
||||||
|
$ yarn serve
|
||||||
|
|
||||||
|
4. 构建
|
||||||
|
$ yarn build:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## 生产中部署
|
||||||
|
|
||||||
|
下载 RELEASE 文件,放到合适的目录,修改 nginx配置文件如下
|
||||||
|
|
||||||
|
```
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location /ui/ {
|
||||||
|
try_files $uri / /ui/index.html;
|
||||||
|
alias /opt/lina/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
rewrite ^/(.*)$ /ui/$1 last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 致谢
|
||||||
|
|
||||||
|
- [Vue](https://cn.vuejs.org) 前端框架
|
||||||
|
- [Element UI](https://element.eleme.cn/) 饿了么 UI组件库
|
||||||
|
- [Vue-element-admin](https://github.com/PanJiaChen/vue-element-admin) 项目脚手架
|
||||||
|
|
||||||
|
## License & Copyright
|
||||||
|
|
||||||
|
Be consistent with [jumpserver](https://github.com/jumpserver/jumpserver)
|
||||||
|
|
||||||
## Navicat Premium
|
## Navicat Premium
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework.serializers import ValidationError
|
from rest_framework.serializers import ValidationError
|
||||||
|
|
||||||
from common.db.models import JMSBaseModel
|
from common.db.models import JMSBaseModel
|
||||||
|
from common.utils import lazyproperty
|
||||||
|
|
||||||
__all__ = ['Applet', 'AppletPublication']
|
__all__ = ['Applet', 'AppletPublication']
|
||||||
|
|
||||||
|
@ -48,6 +49,14 @@ class Applet(JMSBaseModel):
|
||||||
else:
|
else:
|
||||||
return default_storage.path('applets/{}'.format(self.name))
|
return default_storage.path('applets/{}'.format(self.name))
|
||||||
|
|
||||||
|
@lazyproperty
|
||||||
|
def readme(self):
|
||||||
|
readme_file = os.path.join(self.path, 'README.md')
|
||||||
|
if os.path.isfile(readme_file):
|
||||||
|
with open(readme_file, 'r') as f:
|
||||||
|
return f.read()
|
||||||
|
return ''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def manifest(self):
|
def manifest(self):
|
||||||
path = os.path.join(self.path, 'manifest.yml')
|
path = os.path.join(self.path, 'manifest.yml')
|
||||||
|
|
|
@ -31,7 +31,7 @@ class AppletSerializer(serializers.ModelSerializer):
|
||||||
model = Applet
|
model = Applet
|
||||||
fields_mini = ['id', 'name', 'display_name', 'is_active']
|
fields_mini = ['id', 'name', 'display_name', 'is_active']
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'icon', 'date_created', 'date_updated',
|
'icon', 'readme', 'date_created', 'date_updated',
|
||||||
]
|
]
|
||||||
fields = fields_mini + [
|
fields = fields_mini + [
|
||||||
'version', 'author', 'type', 'protocols',
|
'version', 'author', 'type', 'protocols',
|
||||||
|
|
Loading…
Reference in New Issue