change the admin page to settings page

move editable setting to settings page
change the settings request from master to user
add 2 editable settings:OPEN_REGISTRY and APPROVAL_RBT
remove some setting from docklet.conf.template
This commit is contained in:
zhongyh16 2017-06-16 16:01:46 +08:00
parent 652f8fa504
commit 28f5a05cd7
14 changed files with 677 additions and 653 deletions

View File

@ -173,10 +173,6 @@
# same value on each machine. Please don't use the default value. # same value on each machine. Please don't use the default value.
# AUTH_KEY=docklet # AUTH_KEY=docklet
# OPEN_REGISTRY: whether allow user to register new account or not.
# default:False
# OPEN_REGISTRY=False
# APPROVAL_RBT: whether to start the approval robot that will approve # APPROVAL_RBT: whether to start the approval robot that will approve
# beans applications from users automatically. # beans applications from users automatically.
# ON or OFF, default: ON. # ON or OFF, default: ON.

View File

@ -24,7 +24,6 @@ import http.server, cgi, json, sys, shutil
import xmlrpc.client import xmlrpc.client
from socketserver import ThreadingMixIn from socketserver import ThreadingMixIn
import nodemgr, vclustermgr, etcdlib, network, imagemgr, notificationmgr import nodemgr, vclustermgr, etcdlib, network, imagemgr, notificationmgr
from settings import settings
from logs import logs from logs import logs
import userManager,beansapplicationmgr import userManager,beansapplicationmgr
import monitor,traceback import monitor,traceback
@ -98,20 +97,6 @@ def isalive(user, beans, form):
return json.dumps({'success':'true'}) return json.dumps({'success':'true'})
@app.route("/settings/list/", methods=['POST'])
@login_required
def settings_list(user, beans, form):
user_group = post_to_user('/user/selfQuery/', {'token': request.form.get("token", None)}).get('data', None).get('group', None)
return json.dumps(settings.list(user_group = user_group))
@app.route("/settings/update/", methods=['POST'])
@login_required
def settings_update(user, beans, form):
user_group = post_to_user('/user/selfQuery/', {'token': request.form.get("token", None)}).get('data', None).get('group', None)
newSetting = {}
newSetting['ADMIN_EMAIL_ADDRESS'] = form.get('ADMIN_EMAIL_ADDRESS', '')
newSetting['EMAIL_FROM_ADDRESS'] = form.get('EMAIL_FROM_ADDRESS', '')
return json.dumps(settings.update(user_group = user_group, newSetting = newSetting))
@app.route("/logs/list/", methods=['POST']) @app.route("/logs/list/", methods=['POST'])
@login_required @login_required

View File

@ -1,7 +1,7 @@
import re, string, os import re, string, os
editableParms = ["LOG_LEVEL"] editableParms = ["LOG_LEVEL","ADMIN_EMAIL_ADDRESS","EMAIL_FROM_ADDRESS","OPEN_REGISTRY","APPROVAL_RBT"]
configPath = {"docklet": os.environ.get("DOCKLET_CONF")+"/docklet.conf", configPath = {"docklet": os.environ.get("DOCKLET_CONF")+"/docklet.conf",
"container": os.environ.get("DOCKLET_CONF")+"/container.conf"} "container": os.environ.get("DOCKLET_CONF")+"/container.conf"}
#configPath = {"docklet": "../conf/docklet.conf", #configPath = {"docklet": "../conf/docklet.conf",

View File

@ -33,6 +33,7 @@ import threading,traceback
from model import User,db from model import User,db
from httplib2 import Http from httplib2 import Http
from urllib.parse import urlencode from urllib.parse import urlencode
from settings import settings
external_login = env.getenv('EXTERNAL_LOGIN') external_login = env.getenv('EXTERNAL_LOGIN')
if(external_login == 'TRUE'): if(external_login == 'TRUE'):
@ -391,6 +392,21 @@ def chlxcsetting_user(cur_user, user, form):
result = G_usermgr.chlxcsetting(cur_user = cur_user, form = form) result = G_usermgr.chlxcsetting(cur_user = cur_user, form = form)
return json.dumps(result) return json.dumps(result)
@app.route("/settings/list/", methods=['POST'])
@login_required
def settings_list(cur_user, user, form):
return json.dumps(settings.list(user_group = 'admin'))
@app.route("/settings/update/", methods=['POST'])
@login_required
def settings_update(user, beans, form):
newSetting = {}
newSetting['OPEN_REGISTRY'] = form.get('OPEN_REGISTRY','')
newSetting['APPROVAL_RBT'] = form.get('APPROVAL_RBT','')
newSetting['ADMIN_EMAIL_ADDRESS'] = form.get('ADMIN_EMAIL_ADDRESS', '')
newSetting['EMAIL_FROM_ADDRESS'] = form.get('EMAIL_FROM_ADDRESS', '')
return json.dumps(settings.update(user_group = 'admin', newSetting = newSetting))
@app.route("/notification/list/", methods=['POST']) @app.route("/notification/list/", methods=['POST'])
@login_required @login_required
def list_notifications(cur_user, user, form): def list_notifications(cur_user, user, form):

View File

@ -1,560 +0,0 @@
{% extends "base_AdminLTE.html"%}
{% block title %}Docklet | Admin{% endblock %}
{% block panel_title %}Admin{% endblock %}
{% block panel_list %}
<ol class="breadcrumb">
<li>
<a href="/dashboard/"><i class="fa fa-dashboard"></i>Home</a>
</li>
<li class="active">
<strong>Admin</strong>
</li>
</ol>
{% endblock %}
{% block css_src %}
<link href="//cdn.bootcss.com/datatables/1.10.11/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/datatables/1.10.11/css/jquery.dataTables_themeroller.css" rel="stylesheet">
<link href="/static/dist/css/modalconfig.css" rel="stylesheet">
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Quota</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#AddGroupModal"><i class="fa fa-plus"></i> Add Quota Group</button>
<div class="modal inmodal" id="AddGroupModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Add Group</h4>
<small class="font-bold">Add a group to Docklet</small>
</div>
<div class="modal-body">
<form action="/group/add/" method="POST" id="addGroupForm">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Name" class="form-control" name="groupname"/>
</div>
{% for quota in quotas %}
<div class="form-group">
<label>{{ quota['name'] }}</label>
<input type="text" class="form-control" name={{ quota['name'] }} placeholder="{{quota['hint']}}" />
</div>
{% endfor %}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onClick="javascript:sendAddGroup();">Submit</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#AddQuotaModal"><i class="fa fa-plus"></i> Add Quota</button>
<div class="modal inmodal" id="AddQuotaModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Add Quota</h4>
<small class="font-bold">Add a quota to Docklet</small>
</div>
<div class="modal-body">
<form action="/quota/add/" method="POST" id="addQuotaForm">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Name" class="form-control" name="quotaname"/>
</div>
<div class="form-group">
<label>Default Value</label>
<input type="text" placeholder="Enter Default Value" class="form-control" name="default_value"/>
</div>
<div class="form-group">
<label>Hint</label>
<input type="text" placeholder="Enter Hint" class="form-control" name="hint"/>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onClick="javascript:sendAddQuota();">Submit</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#ChangeDefaultModal"><i class="fa fa-plus"></i> Change Default</button>
<div class="modal inmodal" id="ChangeDefaultModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Change Default</h4>
<small class="font-bold">Change Default Quota Group</small>
</div>
<div class="modal-body">
<form action="/quota/chdefault/" method="POST" id="chDefaultForm">
<div class="form-group">
<label>Default Group</label>
<select class="form-control" name="defaultgroup" value={{ defaultgroup }} />
{% for group in groups %}
<option>{{ group['name'] }}</option>
{% endfor %}
</select>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onClick="javascript:sendChDefault();">Submit</button>
</div>
</div>
</div>
</div>
<div class="table table-responsive">
<table id="myGroupTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
{% for quota in quotas %}
<th> {{ quota['name'] }} </th>
{% endfor %}
<th>Command</th>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<th>{{ group['name'] }}</th>
{% for quota in quotas %}
<th> {{ group['quotas'][quota['name']] }} </th>
{% endfor %}
<th><a class="btn btn-xs btn-info" data-toggle="modal" data-target="#ModifyGroupModal_{{ group['name'] }}">Edit</a>&nbsp;
{% if group['name'] in [ "root", "primary", "admin", "foundation" ] %}
<a class="btn btn-xs btn-default" href="javascript:void(0)">Delete</a>&nbsp;
{% else %}
<a class="btn btn-xs btn-danger" href="/group/delete/{{group['name']}}">Delete</a>&nbsp;
{% endif %}
{% if group['name'] == defaultgroup %}
<span class="glyphicon glyphicon-ok"></span>
{% endif %}
</th>
<div class="modal inmodal" id="ModifyGroupModal_{{ group['name'] }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Modify Group</h4>
<small class="font-bold">Modify a group in Docklet</small>
</div>
<form action="/group/modify/{{group['name']}}/" method="POST" >
<div class="modal-body">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Name" class="form-control" name="groupname" readonly="true" value={{ group['name'] }} />
</div>
{% for quota in quotas %}
<div class="form-group">
<label> {{ quota['name'] }}</label>
<input type="text" placeholder="{{ quota['hint'] }}" class="form-control" name={{ quota['name'] }} value={{ group['quotas'][quota['name']] }} />
</div>
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Update Base Image</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body">
<div class="table table-responsive">
<table id="imageTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>ImageName</th>
<th>CreateTime</th>
<th>Description</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
{% for image in root_image %}
<tr>
<td>{{image['name']}}</td>
<td>{{image['time']}}</td>
<td><a href="/image/description/{{image['name']}}_root_private/" target="_blank">{{image['description']}}</a></td>
<td><button type="button" class="btn btn-xs btn-success" data-toggle="modal" data-target="#Update_{{image['name']}}">Update</button>
<div class="modal inmodal" id="Update_{{image['name']}}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-save modal-icon"></i>
<h4 class="modal-title">Update Base Image</h4>
<small class="font-bold">Update Base Image From Chosen Image</small>
</div>
<div class="modal-body">
<strong>Warning: This operation will update the base image. Maybe it will cause some error and then the base image will be destroyed. Please make sure you have the backup of base image.</strong>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<a href="/image/updatebase/{{image['name']}}/"><button type="button" class="btn btn-success">Update</button></a>
</div>
</div>
</div>
</div>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Container Default Setting</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<form id="chlxcsetting" class="form-horizontal" action="/quota/chlxcsetting/" method="POST">
<div class="form-group">
<label class="control-label col-sm-2">CPU</label>
<div class="col-sm-8"><input type="number" class="form-control" name="lxcCpu" id="lxcCpu" value={{lxcsetting['cpu']}} />CORE</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">MEMORY</label>
<div class="col-sm-8"><input type="number" class="form-control" name="lxcMemory" id="lxcMemory" value={{lxcsetting['memory']}} />MB</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">DISK</label>
<div class="col-sm-8"><input type="number" class="form-control" name="lxcDisk" id="lxcDisk" value={{lxcsetting['disk']}} />MB</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2"><button class="btn btn-primary" type="submit">Modify</button></div>
</div>
</form>
</div>
</div>
</div>
</div>
{% for field in ["docklet"] %}
<div class="row">
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
{% if field == "docklet" %}
<h3 class="box-title">Docklet Config</h3>
{% else %}
<h3 class="box-title">Container Config</h3>
{% endif %}
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<div class="table table-responsive">
<table id="myGroupTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
<th>History (Click to Reuse)</th>
<th>Default</th>
<th>Command</th>
</tr>
</thead>
<tbody>
{% for editable in [1,0] %}
{% for parm in parms[field] %}
{% if parm["editable"] == editable %}
<tr>
{% if parm["parm"]|length > 20%}
<th title={{parm["parm"]}}>{{ parm["parm"]|truncate(20) }}</th>
{% else %}
<th>{{ parm["parm"] }}</th>
{% endif %}
{% if parm["val"] == "novalidvaluea" %}
<th class="text-muted">No Valid Value</th>
{% elif parm["val"]|length > 20 %}
<th title="{{parm["val"]}}">{{ parm["val"]|truncate(20) }}</th>
{% else %}
<th>{{ parm["val"] }}</th>
{% endif %}
<th>
{% for history in parm["history"] %}
{% if history|length > 20 %}
<a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseHistoryModal_{{field}}_{{ parm["parm"]|replace(".","") }}_{{ loop.indexo }}" title="{{history}}">{{ history|truncate(20) }}</a>
{% else %}
<a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseHistoryModal_{{field}}_{{ parm["parm"]|replace(".","") }}_{{ loop.indexo }}">{{ history }}</a>
{% endif %}
<div class="modal inmodal" id="UseHistoryModal_{{field}}_{{ parm["parm"]|replace(".","") }}_{{ loop.indexo }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
{% if parm["editable"] == 0 %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>The parameter <strong> {{ parm["parm"] }} </strong> is non-editable!</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Well</button>
</div>
{% else %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>Sure to set <strong> {{ parm["parm"] }} </strong>to <strong>{{ history }} </strong>?</h4>
</div>
<form action="/system/modify/" method="POST">
<div style="display:none">
<input type="text" placeholder="" class="" name="field" value={{field}} />
</div>
<div class="modal-body" style="display:none">
<div class="form-group">
<label>Parameter</label>
<input type="text" placeholder="Enter Parameter" class="form-control" name="parm" value="{{ parm['parm'] }}" readonly="true" />
</div>
<div class="form-group">
<label>Value</label>
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="{{ history }}" />
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Yes</button>
<button type="button" class="btn btn-white" data-dismiss="modal">No</button>
</div>
</form>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</th>
{% if parm["default"]|length > 20 %}
<th><a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseDefaultModal_{{field}}_{{ parm["parm"]|replace(".","") }}" title={{ parm["default"] }}> {{ parm["default"]|truncate(20) }}</a></th>
{% else %}
<th><a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseDefaultModal_{{field}}_{{ parm["parm"]|replace(".","") }}"> {{ parm["default"] }}</a></th>
{% endif %}
<th>
<a class="btn btn-xs btn-success" data-toggle="modal" data-target="#ViewParmModal_{{field}}_{{ parm["parm"]|replace(".","") }}">Details</a>&nbsp;
{% if parm["editable"] == 1 %}
<a class="btn btn-xs btn-info" data-toggle="modal" data-target="#ModifyParmModal_{{field}}_{{ parm["parm"]|replace(".","") }}">Edit</a>&nbsp;
{% endif %}
</th>
<div class="modal inmodal" id="ViewParmModal_{{field}}_{{ parm["parm"]|replace(".","") }}" tabindex="-1" role="dialog" aria-hidden="true" class="container">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4>Details of {{parm['parm']}}</h4>
</div>
<div class="modal-body">
<pre>{{ parm['details'] }}</pre>
</div>
<div class="modal-footer"> <button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal inmodal" id="ModifyParmModal_{{field}}_{{ parm["parm"]|replace(".","") }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Modify Parameter</h4>
<small class="font-bold">Modify a parameter in Docklet</small>
</div>
<form action="/system/modify/" method="POST" >
<div style="display:none">
<input type="text" placeholder="" class="" name="field" value={{field}} />
</div>
<div class="modal-body">
<div class="form-group">
<label>Parameter</label>
<input type="text" placeholder="Enter Parameter" class="form-control" name="parm" value="{{ parm['parm'] }}" readonly="true" />
</div>
<div class="form-group">
<label>Value</label>
{% if parm['val'] == "novalidvaluea" %}
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="" />
{% else %}
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="{{ parm['val'] }}" />
{% endif %}
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal inmodal" id="UseDefaultModal_{{field}}_{{ parm["parm"]|replace(".","") }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
{% if parm["editable"] == 0 %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>The parameter <strong> {{ parm["parm"] }} </strong> is non-editable!</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Well</button>
</div>
{% else %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>Sure to set <strong> {{ parm["parm"] }} </strong> to <strong> {{ parm["default"] }} </strong> ?</h4>
</div>
<form action="/system/modify/" method="POST">
<div style="display:none">
<input type="text" placeholder="" class="" name="field" value={{field}} />
</div>
<div class="modal-body" style="display:none">
<div class="form-group">
<label>Parameter</label>
<input type="text" placeholder="Enter Parameter" class="form-control" name="parm" value="{{ parm['parm'] }}" readonly="true" />
</div>
<div class="form-group">
<label>Value</label>
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="{{ parm["default"] }}" />
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Yes</button>
<button type="button" class="btn btn-white" data-dismiss="modal">No</button>
</div>
</form>
{% endif %}
</div>
</div>
</div>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
<div class="row">
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Container Config</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<pre> {{ parms["container"] }} </pre>
</div>
</div>
</div>
</div>
{% endblock %}
{% block script_src %}
<script src="//cdn.bootcss.com/datatables/1.10.11/js/jquery.dataTables.min.js"></script>
<script src="//cdn.bootcss.com/datatables/1.10.11/js/dataTables.bootstrap.min.js"></script>
<script src="http://cdn.bootcss.com/datatables-tabletools/2.1.5/js/TableTools.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myGroupTable').DataTable();
})
function sendAddGroup(){
document.getElementById("addGroupForm").submit();
}
function sendAddQuota(){
document.getElementById("addQuotaForm").submit();
}
function sendChDefault(){
document.getElementById("chDefaultForm").submit();
}
function setFormGroup(arg){
$.post("/group/query/",
{
name: arg
},
function(data,status){
var result = eval("("+data+")").data;
$("#mGroupname").val(result.name);
$("#mCpu").val(result.cpu);
$("#mMemory").val(result.memory);
$("#mImage").val(result.imageQuantity);
$("#mLifecycle").val(result.lifeCycle);
});
}
</script>
{% endblock %}

View File

@ -169,15 +169,15 @@
<li id="nav_Notification"> <li id="nav_Notification">
<a href='/notification/'><i class="fa fa-envelope"></i> <span class="nav-label">Notifications</span></a> <a href='/notification/'><i class="fa fa-envelope"></i> <span class="nav-label">Notifications</span></a>
</li> </li>
<li id="admin"> <li id="settings">
<a href='/admin/'><i class="fa fa-user"></i> <span class="nav-label">Admin</span></a> <a href='/settings/'><i class="fa fa-user"></i> <span class="nav-label">Settings</span></a>
</li> </li>
<li id="nav_Cloud"> <li id="nav_Cloud">
<a href='/cloud/'><i class="fa fa-cloud"></i> <span class="nav-label">Cloud</span></a> <a href='/cloud/'><i class="fa fa-cloud"></i> <span class="nav-label">Cloud</span></a>
<li> <li>
<li id="settings"> <li id="logs">
<a href='/settings/'><i class="fa fa-user"></i> <span class="nav-label">Settings</span></a> <a href='/logs/'><i class="fa fa-user"></i> <span class="nav-label">Logs</span></a>
</li> </li>
{% endif %} {% endif %}

53
web/templates/logs.html Normal file
View File

@ -0,0 +1,53 @@
{% extends "base_AdminLTE.html"%}
{% block title %}Docklet | Logs{% endblock %}
{% block panel_title %}Logs{% endblock %}
{% block panel_list %}
<ol class="breadcrumb">
<li>
<a href="/dashboard/"><i class="fa fa-dashboard"></i>Home</a>
</li>
<li class="active">
<strong>Logs</strong>
</li>
</ol>
{% endblock %}
{% block css_src %}
<link href="/static/dist/css/filebox.css" rel="stylesheet">
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Logs</h3>
</div>
<div class="box-body">
{% for filename in logs %}
<div class="file-box">
<div class="file">
<a href="/logs/{{ filename }}/">
<span class="corner"></span>
<div class="icon">
<i class="fa fa-file"></i>
</div>
<div class="file-name">
{{ filename }}
</div>
</a>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,7 +1,7 @@
{% extends "base_AdminLTE.html"%} {% extends "base_AdminLTE.html"%}
{% block title %}Docklet | Settings{% endblock %} {% block title %}Docklet | Admin{% endblock %}
{% block panel_title %}Settings{% endblock %} {% block panel_title %}Admin{% endblock %}
{% block panel_list %} {% block panel_list %}
<ol class="breadcrumb"> <ol class="breadcrumb">
@ -9,26 +9,295 @@
<a href="/dashboard/"><i class="fa fa-dashboard"></i>Home</a> <a href="/dashboard/"><i class="fa fa-dashboard"></i>Home</a>
</li> </li>
<li class="active"> <li class="active">
<strong>Settings</strong> <strong>Admin</strong>
</li> </li>
</ol> </ol>
{% endblock %} {% endblock %}
{% block css_src %} {% block css_src %}
<link href="/static/dist/css/filebox.css" rel="stylesheet"> <link href="//cdn.bootcss.com/datatables/1.10.11/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/datatables/1.10.11/css/jquery.dataTables_themeroller.css" rel="stylesheet">
<link href="/static/dist/css/modalconfig.css" rel="stylesheet">
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Quota</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#AddGroupModal"><i class="fa fa-plus"></i> Add Quota Group</button>
<div class="modal inmodal" id="AddGroupModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Add Group</h4>
<small class="font-bold">Add a group to Docklet</small>
</div>
<div class="modal-body">
<form action="/group/add/" method="POST" id="addGroupForm">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Name" class="form-control" name="groupname"/>
</div>
{% for quota in quotas %}
<div class="form-group">
<label>{{ quota['name'] }}</label>
<input type="text" class="form-control" name={{ quota['name'] }} placeholder="{{quota['hint']}}" />
</div>
{% endfor %}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onClick="javascript:sendAddGroup();">Submit</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#AddQuotaModal"><i class="fa fa-plus"></i> Add Quota</button>
<div class="modal inmodal" id="AddQuotaModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Add Quota</h4>
<small class="font-bold">Add a quota to Docklet</small>
</div>
<div class="modal-body">
<form action="/quota/add/" method="POST" id="addQuotaForm">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Name" class="form-control" name="quotaname"/>
</div>
<div class="form-group">
<label>Default Value</label>
<input type="text" placeholder="Enter Default Value" class="form-control" name="default_value"/>
</div>
<div class="form-group">
<label>Hint</label>
<input type="text" placeholder="Enter Hint" class="form-control" name="hint"/>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onClick="javascript:sendAddQuota();">Submit</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#ChangeDefaultModal"><i class="fa fa-plus"></i> Change Default</button>
<div class="modal inmodal" id="ChangeDefaultModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Change Default</h4>
<small class="font-bold">Change Default Quota Group</small>
</div>
<div class="modal-body">
<form action="/quota/chdefault/" method="POST" id="chDefaultForm">
<div class="form-group">
<label>Default Group</label>
<select class="form-control" name="defaultgroup" value={{ defaultgroup }} />
{% for group in groups %}
<option>{{ group['name'] }}</option>
{% endfor %}
</select>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onClick="javascript:sendChDefault();">Submit</button>
</div>
</div>
</div>
</div>
<div class="table table-responsive">
<table id="myGroupTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
{% for quota in quotas %}
<th> {{ quota['name'] }} </th>
{% endfor %}
<th>Command</th>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<th>{{ group['name'] }}</th>
{% for quota in quotas %}
<th> {{ group['quotas'][quota['name']] }} </th>
{% endfor %}
<th><a class="btn btn-xs btn-info" data-toggle="modal" data-target="#ModifyGroupModal_{{ group['name'] }}">Edit</a>&nbsp;
{% if group['name'] in [ "root", "primary", "admin", "foundation" ] %}
<a class="btn btn-xs btn-default" href="javascript:void(0)">Delete</a>&nbsp;
{% else %}
<a class="btn btn-xs btn-danger" href="/group/delete/{{group['name']}}">Delete</a>&nbsp;
{% endif %}
{% if group['name'] == defaultgroup %}
<span class="glyphicon glyphicon-ok"></span>
{% endif %}
</th>
<div class="modal inmodal" id="ModifyGroupModal_{{ group['name'] }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Modify Group</h4>
<small class="font-bold">Modify a group in Docklet</small>
</div>
<form action="/group/modify/{{group['name']}}/" method="POST" >
<div class="modal-body">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Name" class="form-control" name="groupname" readonly="true" value={{ group['name'] }} />
</div>
{% for quota in quotas %}
<div class="form-group">
<label> {{ quota['name'] }}</label>
<input type="text" placeholder="{{ quota['hint'] }}" class="form-control" name={{ quota['name'] }} value={{ group['quotas'][quota['name']] }} />
</div>
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Update Base Image</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body">
<div class="table table-responsive">
<table id="imageTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>ImageName</th>
<th>CreateTime</th>
<th>Description</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
{% for image in root_image %}
<tr>
<td>{{image['name']}}</td>
<td>{{image['time']}}</td>
<td><a href="/image/description/{{image['name']}}_root_private/" target="_blank">{{image['description']}}</a></td>
<td><button type="button" class="btn btn-xs btn-success" data-toggle="modal" data-target="#Update_{{image['name']}}">Update</button>
<div class="modal inmodal" id="Update_{{image['name']}}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-save modal-icon"></i>
<h4 class="modal-title">Update Base Image</h4>
<small class="font-bold">Update Base Image From Chosen Image</small>
</div>
<div class="modal-body">
<strong>Warning: This operation will update the base image. Maybe it will cause some error and then the base image will be destroyed. Please make sure you have the backup of base image.</strong>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<a href="/image/updatebase/{{image['name']}}/"><button type="button" class="btn btn-success">Update</button></a>
</div>
</div>
</div>
</div>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Container Default Setting</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<form id="chlxcsetting" class="form-horizontal" action="/quota/chlxcsetting/" method="POST">
<div class="form-group">
<label class="control-label col-sm-2">CPU</label>
<div class="col-sm-8"><input type="number" class="form-control" name="lxcCpu" id="lxcCpu" value={{lxcsetting['cpu']}} />CORE</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">MEMORY</label>
<div class="col-sm-8"><input type="number" class="form-control" name="lxcMemory" id="lxcMemory" value={{lxcsetting['memory']}} />MB</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">DISK</label>
<div class="col-sm-8"><input type="number" class="form-control" name="lxcDisk" id="lxcDisk" value={{lxcsetting['disk']}} />MB</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2"><button class="btn btn-primary" type="submit">Modify</button></div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="box box-primary"> <div class="box box-primary">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Modify Settings</h3> <h3 class="box-title">Modify Settings</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<form role="form" action="/settings/" method="POST" > <form role="form" action="/settings/update/" method="POST" >
<div class="box-body"> <div class="box-body">
<div class="form-group"> <div class="form-group">
<label for="ADMIN_EMAIL_ADDRESS">Admin Email Address</label> <label for="ADMIN_EMAIL_ADDRESS">Admin Email Address</label>
@ -42,6 +311,18 @@
<p class="help-block">if this address is "", no email will be sent out.</p> <p class="help-block">if this address is "", no email will be sent out.</p>
<input type="input" class="form-control" id="EMAIL_FROM_ADDRESS" name="EMAIL_FROM_ADDRESS" value="{{ settings['EMAIL_FROM_ADDRESS'] }}"> <input type="input" class="form-control" id="EMAIL_FROM_ADDRESS" name="EMAIL_FROM_ADDRESS" value="{{ settings['EMAIL_FROM_ADDRESS'] }}">
</div> </div>
<div class="form-group">
<label for="OPEN_REGISTRY">OPEN_REGISTRY</label>
<p class="help-block">whether allow user to register a new account</p>
<p class="help-block">if the value is True, it will allow.</p>
<input type="input" class="form-control" id="OPEN_REGISTRY" name="OPEN_REGISTRY" value="{{ settings['OPEN_REGISTRY'] }}">
</div>
<div class="form-group">
<label for="APPROVAL_RBT">APPROVAL_RBT</label>
<p class="help-block">whether to start the approval robot that will approve beans applications from users automatically</p>
<p class="help-block">if the value is True, it will allow.</p>
<input type="input" class="form-control" id="APPROVAL_RBT" name="APPROVAL_RBT" value="{{ settings['APPROVAL_RBT'] }}">
</div>
</div> </div>
<div class="box-footer"> <div class="box-footer">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
@ -52,32 +333,268 @@
</div> </div>
</div> </div>
{% for field in ["docklet"] %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="box box-primary"> <div class="box box-info collapsed-box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Logs</h3> {% if field == "docklet" %}
<h3 class="box-title">Docklet Config</h3>
{% else %}
<h3 class="box-title">Container Config</h3>
{% endif %}
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div> </div>
<div class="box-body"> <div class="box-body" style="display:none">
{% for filename in logs %}
<div class="file-box">
<div class="file">
<a href="/logs/{{ filename }}/">
<span class="corner"></span>
<div class="icon"> <div class="table table-responsive">
<i class="fa fa-file"></i> <table id="myGroupTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
<th>History (Click to Reuse)</th>
<th>Default</th>
<th>Command</th>
</tr>
</thead>
<tbody>
{% for editable in [1,0] %}
{% for parm in parms[field] %}
{% if parm["editable"] == editable %}
<tr>
{% if parm["parm"]|length > 20%}
<th title={{parm["parm"]}}>{{ parm["parm"]|truncate(20) }}</th>
{% else %}
<th>{{ parm["parm"] }}</th>
{% endif %}
{% if parm["val"] == "novalidvaluea" %}
<th class="text-muted">No Valid Value</th>
{% elif parm["val"]|length > 20 %}
<th title="{{parm["val"]}}">{{ parm["val"]|truncate(20) }}</th>
{% else %}
<th>{{ parm["val"] }}</th>
{% endif %}
<th>
{% for history in parm["history"] %}
{% if history|length > 20 %}
<a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseHistoryModal_{{field}}_{{ parm["parm"]|replace(".","") }}_{{ loop.indexo }}" title="{{history}}">{{ history|truncate(20) }}</a>
{% else %}
<a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseHistoryModal_{{field}}_{{ parm["parm"]|replace(".","") }}_{{ loop.indexo }}">{{ history }}</a>
{% endif %}
<div class="modal inmodal" id="UseHistoryModal_{{field}}_{{ parm["parm"]|replace(".","") }}_{{ loop.indexo }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
{% if parm["editable"] == 0 %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>The parameter <strong> {{ parm["parm"] }} </strong> is non-editable!</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Well</button>
</div>
{% else %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>Sure to set <strong> {{ parm["parm"] }} </strong>to <strong>{{ history }} </strong>?</h4>
</div>
<form action="/system/modify/" method="POST">
<div style="display:none">
<input type="text" placeholder="" class="" name="field" value={{field}} />
</div>
<div class="modal-body" style="display:none">
<div class="form-group">
<label>Parameter</label>
<input type="text" placeholder="Enter Parameter" class="form-control" name="parm" value="{{ parm['parm'] }}" readonly="true" />
</div>
<div class="form-group">
<label>Value</label>
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="{{ history }}" />
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Yes</button>
<button type="button" class="btn btn-white" data-dismiss="modal">No</button>
</div>
</form>
{% endif %}
</div> </div>
<div class="file-name">
{{ filename }}
</div> </div>
</a> </div>
</div> {% endfor %}
</div> </th>
{% endfor %}
{% if parm["default"]|length > 20 %}
<th><a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseDefaultModal_{{field}}_{{ parm["parm"]|replace(".","") }}" title={{ parm["default"] }}> {{ parm["default"]|truncate(20) }}</a></th>
{% else %}
<th><a class="btn btn-xs btn-default" data-toggle="modal" data-target="#UseDefaultModal_{{field}}_{{ parm["parm"]|replace(".","") }}"> {{ parm["default"] }}</a></th>
{% endif %}
<th>
<a class="btn btn-xs btn-success" data-toggle="modal" data-target="#ViewParmModal_{{field}}_{{ parm["parm"]|replace(".","") }}">Details</a>&nbsp;
</th>
<div class="modal inmodal" id="ViewParmModal_{{field}}_{{ parm["parm"]|replace(".","") }}" tabindex="-1" role="dialog" aria-hidden="true" class="container">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4>Details of {{parm['parm']}}</h4>
</div>
<div class="modal-body">
<pre>{{ parm['details'] }}</pre>
</div>
<div class="modal-footer"> <button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal inmodal" id="ModifyParmModal_{{field}}_{{ parm["parm"]|replace(".","") }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<i class="fa fa-laptop modal-icon"></i>
<h4 class="modal-title">Modify Parameter</h4>
<small class="font-bold">Modify a parameter in Docklet</small>
</div>
<form action="/system/modify/" method="POST" >
<div style="display:none">
<input type="text" placeholder="" class="" name="field" value={{field}} />
</div>
<div class="modal-body">
<div class="form-group">
<label>Parameter</label>
<input type="text" placeholder="Enter Parameter" class="form-control" name="parm" value="{{ parm['parm'] }}" readonly="true" />
</div>
<div class="form-group">
<label>Value</label>
{% if parm['val'] == "novalidvaluea" %}
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="" />
{% else %}
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="{{ parm['val'] }}" />
{% endif %}
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal inmodal" id="UseDefaultModal_{{field}}_{{ parm["parm"]|replace(".","") }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated fadeIn">
{% if parm["editable"] == 0 %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>The parameter <strong> {{ parm["parm"] }} </strong> is non-editable!</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Well</button>
</div>
{% else %}
<div class="modal-header">
<i class="fa fa-laptop modal-icon"></i>
<h4>Sure to set <strong> {{ parm["parm"] }} </strong> to <strong> {{ parm["default"] }} </strong> ?</h4>
</div>
<form action="/system/modify/" method="POST">
<div style="display:none">
<input type="text" placeholder="" class="" name="field" value={{field}} />
</div>
<div class="modal-body" style="display:none">
<div class="form-group">
<label>Parameter</label>
<input type="text" placeholder="Enter Parameter" class="form-control" name="parm" value="{{ parm['parm'] }}" readonly="true" />
</div>
<div class="form-group">
<label>Value</label>
<input type="text" placeholder="Enter Value" class="form-control" name="val" value="{{ parm["default"] }}" />
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Yes</button>
<button type="button" class="btn btn-white" data-dismiss="modal">No</button>
</div>
</form>
{% endif %}
</div>
</div>
</div>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% endfor %}
<div class="row">
<div class="col-md-12">
<div class="box box-info collapsed-box">
<div class="box-header with-border">
<h3 class="box-title">Container Config</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body" style="display:none">
<pre> {{ parms["container"] }} </pre>
</div>
</div>
</div>
</div>
{% endblock %}
{% block script_src %}
<script src="//cdn.bootcss.com/datatables/1.10.11/js/jquery.dataTables.min.js"></script>
<script src="//cdn.bootcss.com/datatables/1.10.11/js/dataTables.bootstrap.min.js"></script>
<script src="http://cdn.bootcss.com/datatables-tabletools/2.1.5/js/TableTools.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myGroupTable').DataTable();
})
function sendAddGroup(){
document.getElementById("addGroupForm").submit();
}
function sendAddQuota(){
document.getElementById("addQuotaForm").submit();
}
function sendChDefault(){
document.getElementById("chDefaultForm").submit();
}
function setFormGroup(arg){
$.post("/group/query/",
{
name: arg
},
function(data,status){
var result = eval("("+data+")").data;
$("#mGroupname").val(result.name);
$("#mCpu").val(result.cpu);
$("#mMemory").val(result.memory);
$("#mImage").val(result.imageQuantity);
$("#mLifecycle").val(result.lifeCycle);
});
}
</script>
{% endblock %} {% endblock %}

View File

@ -27,7 +27,7 @@ from webViews.notification.notification import CreateNotificationView, Notificat
QueryNotificationView, ModifyNotificationView, DeleteNotificationView QueryNotificationView, ModifyNotificationView, DeleteNotificationView
from webViews.user.userinfo import userinfoView from webViews.user.userinfo import userinfoView
from webViews.user.userActivate import userActivateView from webViews.user.userActivate import userActivateView
from webViews.settings import settingsView from webViews.syslogs import logsView
from webViews.user.grouplist import grouplistView, groupqueryView, groupdetailView, groupmodifyView from webViews.user.grouplist import grouplistView, groupqueryView, groupdetailView, groupmodifyView
from functools import wraps from functools import wraps
from webViews.dockletrequest import dockletRequest from webViews.dockletrequest import dockletRequest
@ -69,7 +69,7 @@ def home():
@app.route("/login/", methods=['GET', 'POST']) @app.route("/login/", methods=['GET', 'POST'])
def login(): def login():
loginView.open_registry = env.getenv("OPEN_REGISTRY") loginView.open_registry = os.environ["OPEN_REGISTRY"]
return loginView.as_view() return loginView.as_view()
@app.route(external_login_url, methods=['GET']) @app.route(external_login_url, methods=['GET'])
@ -371,10 +371,10 @@ def monitorUserAll():
return monitorUserAllView.as_view() return monitorUserAllView.as_view()
''' '''
@app.route("/settings/", methods=['GET', 'POST']) @app.route("/logs/", methods=['GET', 'POST'])
@administration_required @administration_required
def settings(): def logs():
return settingsView.as_view() return logsView.as_view()
@app.route("/logs/<filename>/", methods=['GET']) @app.route("/logs/<filename>/", methods=['GET'])
@administration_required @administration_required
@ -552,11 +552,16 @@ def systemdelete():
def systemresetall(): def systemresetall():
return systemresetallView.as_view() return systemresetallView.as_view()
@app.route("/admin/", methods=['GET', 'POST']) @app.route("/settings/", methods=['GET', 'POST'])
@administration_required @administration_required
def adminpage(): def adminpage():
return adminView.as_view() return adminView.as_view()
@app.route("/settings/update/", methods=['POST'])
@administration_required
def updatesettings():
return updatesettingsView.as_view()
@app.route('/index/', methods=['GET']) @app.route('/index/', methods=['GET'])
def jupyter_control(): def jupyter_control():
return redirect('/dashboard/') return redirect('/dashboard/')
@ -653,6 +658,14 @@ if __name__ == '__main__':
secret_key_file.write(secret_key) secret_key_file.write(secret_key)
secret_key_file.close() secret_key_file.close()
try:
open_registryfile = open(env.getenv('FS_PREFIX') + '/local/settings.conf')
settings = jsobn.loads(open_registryfile.read())
open_registryfile.close()
os.environ['OPEN_REGISTRY'] = settings.get('OPEN_REGISTRY',"False")
except:
os.environ['OPEN_REGISTRY'] = "False"
os.environ['APP_KEY'] = app.secret_key os.environ['APP_KEY'] = app.secret_key
runcmd = sys.argv[0] runcmd = sys.argv[0]
app.runpath = runcmd.rsplit('/', 1)[0] app.runpath = runcmd.rsplit('/', 1)[0]

View File

@ -2,10 +2,10 @@ from flask import session, render_template, redirect, request
from webViews.view import normalView from webViews.view import normalView
from webViews.dockletrequest import dockletRequest from webViews.dockletrequest import dockletRequest
from webViews.dashboard import * from webViews.dashboard import *
import time, re, json import time, re, json, os
class adminView(normalView): class adminView(normalView):
template_path = "admin.html" template_path = "settings.html"
@classmethod @classmethod
def get(self): def get(self):
@ -16,61 +16,70 @@ class adminView(normalView):
parms = dockletRequest.post('/system/parmList/') parms = dockletRequest.post('/system/parmList/')
rootimage = dockletRequest.post('/image/list/').get('images') rootimage = dockletRequest.post('/image/list/').get('images')
lxcsetting = dockletRequest.post('/user/lxcsettingList/')['data'] lxcsetting = dockletRequest.post('/user/lxcsettingList/')['data']
return self.render(self.template_path, groups = groups, quotas = quotas, defaultgroup = defaultgroup, parms = parms, lxcsetting = lxcsetting, root_image = rootimage['private']) settings = dockletRequest.post('/settings/list/')['result']
return self.render(self.template_path, groups = groups, quotas = quotas, defaultgroup = defaultgroup, parms = parms, lxcsetting = lxcsetting, root_image = rootimage['private'], settings=settings)
class updatesettingsView(normalView):
@classmethod
def post(self):
result = dockletRequest.post("/settings/update/", request.form)
os.environ['OPEN_REGISTRY'] = request.form.get('OPEN_REGISTRY')
return redirect('/settings/')
class groupaddView(normalView): class groupaddView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/user/groupadd/', request.form) dockletRequest.post('/user/groupadd/', request.form)
return redirect('/admin/') return redirect('/settings/')
class systemmodifyView(normalView): class systemmodifyView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/system/modify/', request.form) dockletRequest.post('/system/modify/', request.form)
return redirect('/admin/') return redirect('/settings/')
class systemclearView(normalView): class systemclearView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/system/clear_history/', request.form) dockletRequest.post('/system/clear_history/', request.form)
return redirect('/admin/') return redirect('/settings/')
class systemaddView(normalView): class systemaddView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/system/add/', request.form) dockletRequest.post('/system/add/', request.form)
return redirect('/admin/') return redirect('/settings/')
class systemdeleteView(normalView): class systemdeleteView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/system/delete/', request.form) dockletRequest.post('/system/delete/', request.form)
return redirect('/admin/') return redirect('/settings/')
class systemresetallView(normalView): class systemresetallView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/system/reset_all/', request.form) dockletRequest.post('/system/reset_all/', request.form)
return redirect('/admin/') return redirect('/settings/')
class quotaaddView(normalView): class quotaaddView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/user/quotaadd/', request.form) dockletRequest.post('/user/quotaadd/', request.form)
return redirect('/admin/') return redirect('/settings/')
class chdefaultView(normalView): class chdefaultView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/user/chdefault/', request.form) dockletRequest.post('/user/chdefault/', request.form)
return redirect('/admin/') return redirect('/settings/')
class chlxcsettingView(normalView): class chlxcsettingView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/user/chlxcsetting/', request.form) dockletRequest.post('/user/chlxcsetting/', request.form)
return redirect('/admin/') return redirect('/settings/')
class groupdelView(normalView): class groupdelView(normalView):
@classmethod @classmethod
@ -79,7 +88,7 @@ class groupdelView(normalView):
"name" : self.groupname, "name" : self.groupname,
} }
dockletRequest.post('/user/groupdel/', data) dockletRequest.post('/user/groupdel/', data)
return redirect('/admin/') return redirect('/settings/')
@classmethod @classmethod
def get(self): def get(self):
@ -94,7 +103,7 @@ class historydelView(normalView):
@classmethod @classmethod
def post(self): def post(self):
dockletRequest.post('/system/historydel/', request.form) dockletRequest.post('/system/historydel/', request.form)
return redirect('/admin/') return redirect('/settings/')
class updatebaseImageView(normalView): class updatebaseImageView(normalView):
@classmethod @classmethod
@ -103,4 +112,4 @@ class updatebaseImageView(normalView):
"image": self.image "image": self.image
} }
dockletRequest.post('/image/updatebase/', data) dockletRequest.post('/image/updatebase/', data)
return redirect("/admin/") return redirect("/settings/")

View File

@ -38,7 +38,8 @@ class dockletRequest():
'user', 'user',
'beans', 'beans',
'notification', 'notification',
'cloud' 'cloud',
'settings'
} }
if ":" not in endpoint: if ":" not in endpoint:
endpoint = "http://"+endpoint+":"+master_port endpoint = "http://"+endpoint+":"+master_port

View File

@ -1,19 +0,0 @@
from flask import session,render_template,redirect, request
from webViews.view import normalView
from webViews.dockletrequest import dockletRequest
class settingsView(normalView):
template_path = "settings.html"
@classmethod
def get(self):
settings = dockletRequest.post('/settings/list/')['result']
logs = dockletRequest.post('/logs/list/')['result']
logs.sort()
logs.sort(key = len)
return self.render(self.template_path, settings = settings, logs = logs)
@classmethod
def post(self):
result = dockletRequest.post('/settings/update/', request.form)
return redirect('/settings/')

13
web/webViews/syslogs.py Normal file
View File

@ -0,0 +1,13 @@
from flask import session,render_template,redirect, request
from webViews.view import normalView
from webViews.dockletrequest import dockletRequest
class logsView(normalView):
template_path = "logs.html"
@classmethod
def get(self):
logs = dockletRequest.post('/logs/list/')['result']
logs.sort()
logs.sort(key = len)
return self.render(self.template_path, logs = logs)

View File

@ -20,4 +20,4 @@ class groupmodifyView(normalView):
@classmethod @classmethod
def post(self): def post(self):
result = json.dumps(dockletRequest.post('/user/groupModify/', request.form)) result = json.dumps(dockletRequest.post('/user/groupModify/', request.form))
return redirect('/admin/') return redirect('/settings/')