diff --git a/flask-consul/units/cloud/huaweicloud.py b/flask-consul/units/cloud/huaweicloud.py index 8867b0c..1c6c136 100644 --- a/flask-consul/units/cloud/huaweicloud.py +++ b/flask-consul/units/cloud/huaweicloud.py @@ -173,7 +173,7 @@ def ecs(account,region,isextip=False): 'ostype':i['metadata']['os_type'].lower(), 'cpu':i['flavor']['vcpus'] + '核', 'mem':f"{str(round(int(i['flavor']['ram'])/1024,1)).rstrip('.0')}GB", - 'exp': exp_dict[i['id']] + 'exp': exp_dict.get(i['id'], '-') } for i in info} if isextip: diff --git a/flask-consul/views/login.py b/flask-consul/views/login.py index 0a93002..103d151 100644 --- a/flask-consul/views/login.py +++ b/flask-consul/views/login.py @@ -1,7 +1,8 @@ from flask import Blueprint from flask_restful import reqparse, Resource, Api from itsdangerous import TimedJSONWebSignatureSerializer -import sys +from werkzeug.datastructures import FileStorage +import sys,base64,traceback sys.path.append("..") from config import admin_passwd from units import token_auth, consul_kv @@ -17,7 +18,40 @@ parser = reqparse.RequestParser() parser.add_argument('username',type=str) parser.add_argument('password',type=str) parser.add_argument('ldap',type=str) +parser.add_argument('file',type=FileStorage, location="files", help="File is wrong.") +class Logo(Resource): + @token_auth.auth.login_required + def post(self, logo_opt): + if logo_opt == 'biglogo': + consul_kv_path = 'ConsulManager/img/biglogo' + isbig = True + elif logo_opt == 'smallogo': + consul_kv_path = 'ConsulManager/img/smallogo' + isbig = False + img = parser.parse_args().get("file") + try: + b64img = base64.b64encode(img.read()).decode('utf-8') + consul_kv.put_kv(consul_kv_path,b64img) + consul_kv.put_kv(f'ConsulManager/img/isbig',isbig) + return {"code": 20000, "data": f"导入成功!"} + except Exception as e: + logger.error(f"【logo】导入失败,{e}\n{traceback.format_exc()}") + return {"code": 50000, "data": f"导入失败!"} + def get(self, logo_opt): + if logo_opt == 'logo': + isbig = consul_kv.get_value(f'ConsulManager/img/isbig') + if isbig == {}: + isbig = True + if isbig: + consul_kv_path = 'ConsulManager/img/biglogo' + else: + consul_kv_path = 'ConsulManager/img/smallogo' + b64logo = consul_kv.get_value(consul_kv_path) + if b64logo: + return {"code": 20000, "isbig": isbig, "data": 'data:image/png;base64,' + b64logo} + else: + return {"code": 20000, "isbig": isbig, "data": 'default'} class User(Resource): @token_auth.auth.login_required def get(self, user_opt): @@ -58,3 +92,5 @@ class User(Resource): return {"code": 20000,"data": "success"} api.add_resource(User, '/api/user/') +api.add_resource(Logo,'/api/login/') + diff --git a/install/docker-compose/all_install.sh b/install/docker-compose/all_install.sh index 25a56be..cee918e 100755 --- a/install/docker-compose/all_install.sh +++ b/install/docker-compose/all_install.sh @@ -35,7 +35,7 @@ acl = { } } EOF - +chmod 777 -R $tsspath/consul/config cat < $tsspath/docker-compose.yaml version: '3.6' services: diff --git a/install/docker-compose/consul_install_only.sh b/install/docker-compose/consul_install_only.sh index e6ae719..b8b7ca9 100755 --- a/install/docker-compose/consul_install_only.sh +++ b/install/docker-compose/consul_install_only.sh @@ -33,7 +33,7 @@ acl = { } } EOF - +chmod 777 -R /opt/consul/config cat < /opt/consul/docker-compose.yaml version: '3.6' services: diff --git a/vue-consul/src/api/login.js b/vue-consul/src/api/login.js new file mode 100644 index 0000000..15218fe --- /dev/null +++ b/vue-consul/src/api/login.js @@ -0,0 +1,9 @@ +import request from '@/utils/request-ops' + +export function logo() { + return request({ + url: '/api/login/logo', + method: 'get' + }) +} + diff --git a/vue-consul/src/router/index.js b/vue-consul/src/router/index.js index c137942..e4816d7 100644 --- a/vue-consul/src/router/index.js +++ b/vue-consul/src/router/index.js @@ -279,6 +279,12 @@ export const constantRoutes = [ name: '系统设置', meta: { title: '系统设置', icon: 'el-icon-setting' }, children: [ + { + path: 'logo', + name: '修改Logo', + component: () => import('@/views/ldap/logo'), + meta: { title: '修改Logo', icon: 'el-icon-lock' } + }, { path: 'ldap', name: '统一认证', diff --git a/vue-consul/src/views/ldap/logo.vue b/vue-consul/src/views/ldap/logo.vue new file mode 100644 index 0000000..6f9a67a --- /dev/null +++ b/vue-consul/src/views/ldap/logo.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/vue-consul/src/views/login/index.vue b/vue-consul/src/views/login/index.vue index a6b5d61..1611afc 100644 --- a/vue-consul/src/views/login/index.vue +++ b/vue-consul/src/views/login/index.vue @@ -1,12 +1,15 @@ + + + +