Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Welcome To Open Falcon Portal
=========================

Hi! Nice to see you here!

If you'd like to ask a question
===============================

Please see [this web page ](http://book.open-falcon.com/) for community information, which includes falcon's wiki/FAQ and [IRC contacts](http://book.open-falcon.com/zh/authors.html).

The github issue tracker is not the best place for questions for various reasons, but IRC is very helpful places for those things.

If you'd like to contribute code
================================

The project takes contributions through [github pull requests](https://help.github.com/articles/using-pull-requests)

It is usually a good idea to [join the QQ group](http://jq.qq.com/?_wv=1027&k=g8tvOZ) to discuss any large features prior to submission, and this especially helps in avoiding duplicate work or efforts where we decide, upon seeing a pull request for the first time, that revisions are needed. (This is not usually needed for frentend development, but can be nice for large changes).

If you'd like to file a bug
===========================

I'd also read the community page above, but in particular, make sure you copy [this issue template](https://github.com/open-falcon/portal/blob/master/ISSUE_TEMPLATE.md) into your ticket description. This template helps us organize tickets faster and prevents asking some repeated questions, so it's very helpful to us and we appreciate your help with it.

Also please make sure you are testing on the latest released version of Falcon modules or the development branch.

Thanks!

If you'd like to contribute translations
========================================

Portal project is based on Flask framework, we use the Flask-Babel extension to enable muti-language display support.

If you would like to help with the translation(i18n) works, whether correcting a typo or improving a section, or maybe even add a new language support, follow instractions bellow and submit a github pull request, it would be nice of you to read [this guide](http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xiv-i18n-and-l10n) before action.

$ # activate python
$ source env/bin/activate

$ # run like this to add a new language translation file , otherwise skip this step
$ python scripts/tr_init.py en_GB

$ # update translation file
$ python scripts/tr_uptate.py

$ # translate all msgids, and ensure there is no fuzzy line left.
$ vi web/translations/es/LC_MESSAGES/messages.po

$ # update LANGUAGES in frame.config
$ vi frame/config.py

# # compile to use
$ python scripts/tr_compile.py

$ # have a test~
$ python wsgi.py

$ # create a pull request

39 changes: 39 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##### Issue Type:

Can you help us out in labelling this by telling us what kind of ticket this this? You can say:
- Bug Report
- Feature Idea
- Feature Pull Request
- New Module Pull Request
- Bugfix Pull Request
- Documentation Report
- Docs Pull Request

##### Module Version:

Let us know what version of Falcon module you are using. Please supply the verbatim output from running “./control version”. If you're filing a ticket on a version of module which is not the latest, we'd greatly appreciate it if you could retest on the latest version first. We don't expect you to test against the development branch most of the time, but we may ask for that if you have cycles. Thanks!

##### Module Configuration:

What have you changed about your Falcon module installation? What configuration settings have you changed/added/removed? Compare your cfg.json against a clean version from Github and let us know what's different.

##### Environment:

What OS are you running Falcon from and what OS are you monitoring? Examples include RHEL 5/6, Centos 5/6, Ubuntu 12.04/13.10, *BSD, Solaris. If this is a generic feature request or it doesn’t apply, just say “N/A”. Not all tickets may be about operating system related things and we understand that.

##### Summary:

Please summarize your request in this space. You will earn bonus points for being succinct, but please add enough detail so we can understand the request. Thanks!

##### Steps To Reproduce:

If this is a bug ticket, please enter the steps you use to reproduce the problem in the space below. If this is a feature request, please enter the steps you would use to use the feature. If it is necessary, add some screenshot to explain your issue would be great. Much appreciated!

##### Expected Results:

Please enter your expected results in this space. When running the steps supplied above in the previous section, what did you expect to happen? If showing example output, please indent your output by four spaces so it will render correctly in GitHub's viewer thingy.

##### Actual Results:

Please enter your actual results in this space. When running the steps supplied above, what actually happened? If you are showing example output, please indent your output by four spaces so it will render correctly in GitHub. Thanks again!

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ falcon portal
# use douban pypi
$ ./env/bin/pip install -r pip_requirements.txt -i http://pypi.douban.com/simple

# compile translation cache
$ ./env/bin/python scripts/tr_compile.py

## Init database and config

Expand Down
3 changes: 3 additions & 0 deletions babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_
6 changes: 6 additions & 0 deletions control
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function kill9() {
function restart() {
stop
sleep 2
check_pid
running=$?
if [ $running -gt 0 ];then
kill9 $(cat $pidfile)
sleep 2
fi
start
}

Expand Down
9 changes: 9 additions & 0 deletions frame/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
DB_PASS = ""
DB_NAME = "falcon_portal"

# -- i18n config --
BABEL_DEFAULT_LOCALE = 'zh_CN'
BABEL_DEFAULT_TIMEZONE = 'Asia/Shanghai'
# aviliable translations
LANGUAGES = {
'en': 'English',
'zh_CN': 'Chinese-Simplified'
}

# -- cookie config --
SECRET_KEY = "4e.5tyg8-u9ioj"
SESSION_COOKIE_NAME = "falcon-portal"
Expand Down
1 change: 1 addition & 0 deletions pip_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Flask==0.10.1
Flask-Babel==0.9
Jinja2==2.7.2
Werkzeug==0.9.4
gunicorn==19.3.0
Expand Down
8 changes: 8 additions & 0 deletions scripts/tr_compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!env/bin/python
import os
import sys
if sys.platform == 'win32':
pybabel = 'env\\Scripts\\pybabel'
else:
pybabel = 'env/bin/pybabel'
os.system(pybabel + ' compile -d web/translations')
15 changes: 15 additions & 0 deletions scripts/tr_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!env/bin/python
import os
import sys
if sys.platform == 'win32':
pybabel = 'env\\Scripts\\pybabel'
else:
pybabel = 'env/bin/pybabel'
if len(sys.argv) != 2:
print "usage: tr_init <language-code>"
sys.exit(1)
os.system(pybabel +
' extract -F babel.cfg -k lazy_gettext -o messages.pot web')
os.system(pybabel +
' init -i messages.pot -d web/translations -l ' + sys.argv[1])
os.unlink('messages.pot')
10 changes: 10 additions & 0 deletions scripts/tr_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!env/bin/python
import os
import sys
if sys.platform == 'win32':
pybabel = 'env\\Scripts\\pybabel'
else:
pybabel = 'env/bin/pybabel'
os.system(pybabel + ' extract -F babel.cfg -k lazy_gettext -o messages.pot web')
os.system(pybabel + ' update -i messages.pot -d web/translations')
os.unlink('messages.pot')
14 changes: 12 additions & 2 deletions web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
import datetime
import urllib
from flask import Flask, request, g, session, make_response, redirect
from flask.ext.babel import Babel
from frame.api import uic

app = Flask(__name__)
app.config.from_object("frame.config")
babel = Babel(app)

@babel.localeselector
def get_locale():
return request.accept_languages.best_match(app.config.get('LANGUAGES').keys())

@babel.timezoneselector
def get_timezone():
return app.config.get('BABEL_DEFAULT_TIMEZONE')

# config log
log_formatter = '%(asctime)s\t[%(filename)s:%(lineno)d] [%(levelname)s: %(message)s]'
Expand Down Expand Up @@ -37,7 +47,7 @@ def before_request():
for ignore_pre in IGNORE_PREFIX:
if p.startswith(ignore_pre):
return

g.locale = get_locale()
if 'user_name' in session and session['user_name']:
g.user_name = session['user_name']
else:
Expand All @@ -60,4 +70,4 @@ def redirect_to_sso():
return resp


from web.controller import home, group, plugin, host, expression, api, template, strategy, nodata, cluster
from web.controller import home, group, plugin, host, expression, api, template, strategy, nodata, cluster
2 changes: 1 addition & 1 deletion web/templates/cluster/creator.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@

</div>

{% endblock %}
{% endblock %}
18 changes: 9 additions & 9 deletions web/templates/cluster/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
<div class="pull-right">
<a class="btn btn-success btn-xs" href="/group/{{ group.id }}/cluster/creator">
<span class="glyphicon glyphicon-plus"></span>
新建
{{ _('Create') }}
</a>
</div>
</div>
<div class="panel-body" style="padding-left: 8px;">
当前HostGroup:<span class="green">{{ group.grp_name }}</span>
{{ _('current hostgroup:') }}:<span class="green">{{ group.grp_name }}</span>
</div>

<!-- Table -->
<table class="table table-hover table-bordered table-striped" style="margin-bottom: 0px; margin-top: 0px;">
<thead>
<tr>
<th>endpoint</th>
<th>metric</th>
<th>tags</th>
<th>creator</th>
<th>operation</th>
<th>{{ _('endpoint') }}</th>
<th>{{ _('metric') }}</th>
<th>{{ _('tags') }}</th>
<th>{{ _('creator') }}</th>
<th>{{ _('operation') }}</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -56,7 +56,7 @@
</tr>
{% else %}
<tr>
<td colspan="5">no records</td>
<td colspan="5">{{ _('no records') }}</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -65,4 +65,4 @@
</div>


{% endblock %}
{% endblock %}
10 changes: 5 additions & 5 deletions web/templates/expression/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<input type="hidden" id="expression_id" value="{{ data.expression.id }}">

<div class="panel panel-default">
<div class="panel-heading">{% if data.expression.id %}modify{% else %}add{% endif %} expression</div>
<div class="panel-heading">{% if data.expression.id %}{{ _('modify') }}{% else %}{{ _('add') }}{% endif %} {{ _('expression') }}</div>
<div class="panel-body">

<textarea class="form-control" rows="2" id="expression"
placeholder="e.g. each(metric=qps srv=falcon)">{{ data.expression.expression }}</textarea>
placeholder="{{ _('e.g.') }} each(metric=qps srv=falcon)">{{ data.expression.expression }}</textarea>

<div class="form-inline mt10" role="form">
<div class="form-group">
Expand Down Expand Up @@ -86,10 +86,10 @@
</div>

<div class="mb20">
<button class="btn btn-default" onclick="update_expression();">Submit</button>
<button class="btn btn-default" onclick="update_expression();">{{ _('Submit') }}</button>
<button class="btn btn-default" onclick="history.go(-1);">
<span class="glyphicon glyphicon-arrow-left"></span>
<span>Back</span>
<span>{{ _('Back') }}</span>
</button>
</div>

Expand All @@ -99,4 +99,4 @@
});
</script>

{% endblock %}
{% endblock %}
8 changes: 4 additions & 4 deletions web/templates/expression/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<div class="form-inline" role="form">
<div class="form-group">
<input type="text" value="{{ data.query }}" class="form-control" id="query"
placeholder="search..." onkeydown="if(event.keyCode==13)query_expression()">
placeholder="{{ _('search...') }}" onkeydown="if(event.keyCode==13)query_expression()">
</div>
<button type="button" onclick="query_expression();" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span>
</button>
<input type="checkbox" name="mine" id="mine" {% if data.mine == '1' %}checked="checked"{% endif %}>
<span>mine</span>
<span>{{ _('mine') }}</span>

<div class="pull-right">
<a href="{{ url_for('expression_add_get') }}" class="btn btn-default">
Expand Down Expand Up @@ -53,7 +53,7 @@

{% else %}
<hr>
no records
{{ _('no records') }}
{% endfor %}
</div>

Expand All @@ -70,4 +70,4 @@
$("#mine").click(query_expression);
});
</script>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions web/templates/expression/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<input type="hidden" id="expression_id" value="{{ data.expression.id }}">

<div class="panel panel-default">
<div class="panel-heading">expression detail</div>
<div class="panel-heading">{{ _('expression detail') }}</div>
<div class="panel-body">

{% set left = '{' %}
Expand Down Expand Up @@ -37,4 +37,4 @@
</div>
</div>

{% endblock %}
{% endblock %}
12 changes: 6 additions & 6 deletions web/templates/group/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@

<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">批量重命名HostGroup</h3>
<h3 class="panel-title">{{ _('Batch rename hostgroup') }}</h3>
</div>
<div class="panel-body">
<div role="form">
<div class="form-group">
<label for="old_str">old</label>
<label for="old_str">{{ _('old') }}</label>
<input type="text" class="form-control" id="old_str">
</div>
<div class="form-group">
<label for="new_str">new</label>
<label for="new_str">{{ _('new') }}</label>
<input type="text" class="form-control" id="new_str">
</div>
<button type="button" class="btn btn-default" onclick="rename_group();">Submit</button>
<button class="btn btn-default" onclick="history.go(-1);">Cancel</button>
<button type="button" class="btn btn-default" onclick="rename_group();">{{ _('Submit') }}</button>
<button class="btn btn-default" onclick="history.go(-1);">{{ _('Cancel') }}</button>
</div>
</div>
<div class="panel-footer">使用Python字符串的replace(old, new)方法做替换;只操作您是creator的并且在监控系统中创建的HostGroup,从服务树同步过来的不受影响
</div>
</div>

{% endblock %}
{% endblock %}
Loading