Merge branch 'develop'
commit
fb32b4413c
|
@ -20,6 +20,24 @@ server {
|
||||||
access_log off;
|
access_log off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /user_menu/json {
|
||||||
|
alias /api/api/static/templates/user_menu_header.json;
|
||||||
|
default_type application/json;
|
||||||
|
index user_menu_header.json;
|
||||||
|
expires max;
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /user_menu/html {
|
||||||
|
alias /api/api/static/templates/user_menu_header.html;
|
||||||
|
default_type text/html;
|
||||||
|
index user_menu_header.html;
|
||||||
|
expires max;
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
location /json {
|
location /json {
|
||||||
alias /api/api/static/templates/header.json;
|
alias /api/api/static/templates/header.json;
|
||||||
default_type application/json;
|
default_type application/json;
|
||||||
|
|
|
@ -29,14 +29,28 @@ def write_css():
|
||||||
|
|
||||||
class Menu():
|
class Menu():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
# self.user_menudict=self.gen_user_menu()
|
||||||
|
# pprint.pprint(self.user_menudict)
|
||||||
|
# self.write_user_menu()
|
||||||
|
|
||||||
self.menudict=self.gen_header()
|
self.menudict=self.gen_header()
|
||||||
pprint.pprint(self.menudict)
|
pprint.pprint(self.menudict)
|
||||||
self.write_headers()
|
self.write_headers()
|
||||||
write_css()
|
write_css()
|
||||||
|
|
||||||
|
''' HEADER & APP MENU '''
|
||||||
def gen_header(self):
|
def gen_header(self):
|
||||||
with open(r'menu/system.yaml') as yml:
|
with open(r'menu/system.yaml') as yml:
|
||||||
system=yaml.load(yml, Loader=yaml.FullLoader)
|
system=yaml.load(yml, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
user_menu = []
|
||||||
|
for item in system['user_menu']:
|
||||||
|
item['href']='https://'+item['subdomain']+'.'+application.config['DOMAIN']+item['href']
|
||||||
|
del item['subdomain']
|
||||||
|
user_menu.append(item)
|
||||||
|
user_menu_dict={'user_menu':user_menu,
|
||||||
|
'user_avatar':'https://sso.'+application.config['DOMAIN']+'/auth/realms/master/avatar-provider'}
|
||||||
|
|
||||||
apps_internal = []
|
apps_internal = []
|
||||||
for app in system['apps_internal']:
|
for app in system['apps_internal']:
|
||||||
app['href']='https://'+app['subdomain']+'.'+application.config['DOMAIN']+app['href']
|
app['href']='https://'+app['subdomain']+'.'+application.config['DOMAIN']+app['href']
|
||||||
|
@ -48,16 +62,26 @@ class Menu():
|
||||||
custom['background_login']='https://api.'+application.config['DOMAIN']+custom['background_login']
|
custom['background_login']='https://api.'+application.config['DOMAIN']+custom['background_login']
|
||||||
custom['logo']='https://api.'+application.config['DOMAIN']+custom['logo']
|
custom['logo']='https://api.'+application.config['DOMAIN']+custom['logo']
|
||||||
|
|
||||||
menudict={**custom,**{'apps_internal':apps_internal}}
|
menudict={**custom,**{'apps_internal':apps_internal,**user_menu_dict}}
|
||||||
menudict['user']={}
|
menudict['user']={}
|
||||||
menudict['user']['account']='https://sso.'+application.config['DOMAIN']+system['user']['account']
|
menudict['user']['account']='https://sso.'+application.config['DOMAIN']+system['user']['account']
|
||||||
menudict['user']['avatar']='https://sso.'+application.config['DOMAIN']+system['user']['avatar']
|
menudict['user']['avatar']='https://sso.'+application.config['DOMAIN']+system['user']['avatar']
|
||||||
menudict['user']['password']='https://sso.'+application.config['DOMAIN']+system['user']['password']
|
# menudict['user']['password']='https://sso.'+application.config['DOMAIN']+system['user']['password']
|
||||||
return menudict
|
return menudict
|
||||||
|
|
||||||
def write_headers(self):
|
def write_headers(self):
|
||||||
env = Environment(loader=FileSystemLoader('api/static/_templates'))
|
env = Environment(loader=FileSystemLoader('api/static/_templates'))
|
||||||
template = env.get_template('apps.html')
|
|
||||||
|
template = env.get_template('user_menu.html')
|
||||||
|
output_from_parsed_template = template.render(data=self.menudict)
|
||||||
|
print(output_from_parsed_template)
|
||||||
|
with open("api/static/templates/user_menu_header.html", "w") as fh:
|
||||||
|
fh.write(output_from_parsed_template)
|
||||||
|
|
||||||
|
# with open("api/static/templates/user_menu_header.json", "w") as fh:
|
||||||
|
# fh.write(json.dumps(self.menudict))
|
||||||
|
|
||||||
|
template = env.get_template('apps_menu.html')
|
||||||
output_from_parsed_template = template.render(data=self.menudict)
|
output_from_parsed_template = template.render(data=self.menudict)
|
||||||
print(output_from_parsed_template)
|
print(output_from_parsed_template)
|
||||||
with open("api/static/templates/header.html", "w") as fh:
|
with open("api/static/templates/header.html", "w") as fh:
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
|
||||||
|
<div id="navbar-menu-apps">
|
||||||
|
<div id="menu-apps-btn">
|
||||||
|
<button type="button" id="dropdownMenuAppsButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<img src="{{ data.user_avatar }}">
|
||||||
|
</button>
|
||||||
|
<div id="dropdownMenuApps" class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton" >
|
||||||
|
<ul id="app-aapps">
|
||||||
|
{% for item in data.user_menu %}
|
||||||
|
<li class="app {{ item.shorname }}">
|
||||||
|
<a href="{{ item.href }}" class="app-link" target="_blank">
|
||||||
|
<div class="icon {{ item.shorname }}">
|
||||||
|
<i class="{{ item.icon }}" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
|
<div class="text">{{ item.name }}</div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -25,4 +25,12 @@ def api_v2_header(format,application=False):
|
||||||
if application == 'nextcloud':
|
if application == 'nextcloud':
|
||||||
return render_template('header_nextcloud.html')
|
return render_template('header_nextcloud.html')
|
||||||
if application == 'wordpress':
|
if application == 'wordpress':
|
||||||
return render_template('header_wordpress.html')
|
return render_template('header_wordpress.html')
|
||||||
|
|
||||||
|
# @app.route('/user_menu/<format>', methods=['GET'])
|
||||||
|
# @app.route('/user_menu/<format>/<application>', methods=['GET'])
|
||||||
|
# def api_v2_user_menu(format,application=False):
|
||||||
|
# if application == False:
|
||||||
|
# if format == 'json':
|
||||||
|
# if application == False:
|
||||||
|
# return json.dumps(menu.get_user_nenu()), 200, {'Content-Type': 'application/json'}
|
Loading…
Reference in New Issue