mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
Reimplement sysadmin with backbone
This commit is contained in:
@@ -70,7 +70,7 @@
|
||||
</a>
|
||||
{% if request.user.is_staff %}
|
||||
<div class="manage">
|
||||
{% block sys_admin %}<a href="{% url 'sys_useradmin' %}" title="{% trans "System Admin" %}" class="a"><img src="{{ MEDIA_URL }}img/admin_in.png" alt="" /></a>{% endblock %}
|
||||
{% block sys_admin %}<a href="{% url 'sysadmin' %}" title="{% trans "System Admin" %}" class="a"><img src="{{ MEDIA_URL }}img/admin_in.png" alt="" /></a>{% endblock %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if request.user.org and request.user.org.is_staff %}
|
||||
|
48
seahub/templates/js/sysadmin-templates.html
Normal file
48
seahub/templates/js/sysadmin-templates.html
Normal file
@@ -0,0 +1,48 @@
|
||||
{% load i18n %}
|
||||
|
||||
<script type="text/template" id="side-nav-tmpl">
|
||||
<h3 class="hd">{% trans "System Admin" %}</h3>
|
||||
<ul class="side-tabnav-tabs">
|
||||
<li class="tab <% if (cur_tab == 'shared') { %> tab-cur<% } %>">
|
||||
<a href="{{ SITE_ROOT }}sysadmin/#dashboard/"><span class="sf2-icon-wrench"></span>{% trans "Info" %}</a>
|
||||
</li>
|
||||
<li class="tab">
|
||||
<a href="{% url "sys_settings" %}"><span class="sf2-icon-cog2"></span>{% trans "Settings" %}</a>
|
||||
</li>
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/seafadmin/"><span class="sf2-icon-library"></span>{% trans "Libraries" %}</a>
|
||||
</li>
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/useradmin/"><span class="sf2-icon-user"></span>{% trans "Users" %}</a>
|
||||
</li>
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/groupadmin/"><span class="sf2-icon-group"></span>{% trans "Groups" %}</a>
|
||||
</li>
|
||||
{% if multi_tenancy %}
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/orgadmin/"><span class="sf2-icon-organization"></span>{% trans "Organizations" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/notificationadmin/"><span class="sf2-icon-msgs"></span>{% trans "Notifications" %}</a>
|
||||
</li>
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/publinkadmin/"><span class="sf2-icon-link"></span>{% trans "Links" %}</a>
|
||||
</li>
|
||||
{% if traffic_stats_enabled %}
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/trafficadmin/"><span class="sf2-icon-histogram"></span>{% trans "Traffic" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if sysadmin_extra_enabled %}
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/loginadmin/"><span class="sf2-icon-clock"></span>{% trans "Logs" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if events_enabled %}
|
||||
<li class="tab">
|
||||
<a href="{{ SITE_ROOT }}sys/virus_scan_records/"><span class="sf2-icon-security"></span>{% trans "Virus Scan" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</script>
|
130
seahub/templates/sysadmin/sysadmin_backbone.html
Normal file
130
seahub/templates/sysadmin/sysadmin_backbone.html
Normal file
@@ -0,0 +1,130 @@
|
||||
{% load staticfiles i18n %}
|
||||
{% load compress %}
|
||||
{% load seahub_tags avatar_tags group_avatar_tags %}
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{{ site_title }}</title>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="keywords" content="{% trans "File Collaboration Team Organization" %}" />
|
||||
<link rel="icon" type="image/x-icon" href="{{ MEDIA_URL }}img/favicon.png?t=1398068110" />
|
||||
<!--[if IE]>
|
||||
<link rel="shortcut icon" href="{{ MEDIA_URL }}img/favicon.png?t=1398068110"/>
|
||||
<![endif]-->
|
||||
|
||||
{% compress css %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/seahub.css?t=1398068110" />
|
||||
<link rel="stylesheet" type="text/css" href="{% static "css/select2-3.5.2.css" %}"/>
|
||||
<link rel="stylesheet" type="text/css" href="{% static "css/magnific-popup.css" %}" />
|
||||
{% endcompress %}
|
||||
|
||||
{% if branding_css != '' %}<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}{{ branding_css }}" />{% endif %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrapper" class="{{ LANGUAGE_CODE }}">
|
||||
<!--[if lt IE 10]>
|
||||
<p id="top-browser-tip">{% trans "We no longer support this version of IE. Please upgrade it to version 10 or above." %} <span class="close">{% trans "Close" %}</span></p>
|
||||
<![endif]-->
|
||||
{% block info_bar_message %}
|
||||
{% if request.user.is_authenticated and request.cur_note %}
|
||||
<div id="info-bar">
|
||||
<p id="info-bar-info">{{ request.cur_note.message|urlize|url_target_blank }}</p>
|
||||
<span class="close sf2-icon-x1 op-icon" title="{% trans "Close" %}"></span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock info_bar_message %}
|
||||
|
||||
<div id="header">
|
||||
<div id="header-inner">
|
||||
{% block notice_panel %}{% endblock %}
|
||||
<a href="{{ SITE_ROOT }}" id="logo" class="fleft">
|
||||
{% if seacloud_mode %}
|
||||
<img src="{{ MEDIA_URL }}img/seacloud_logo.png?t=1398068110" title="Seacloud" alt="logo" width="186" height="31" />
|
||||
{% else %}
|
||||
<img src="{{ MEDIA_URL }}{{ logo_path }}" title="Seafile" alt="logo" width="{{logo_width}}" height="{{logo_height}}" />
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
<div id="account" class="fright">
|
||||
<div id="my-info">
|
||||
{% avatar request.user 36 %} <span class="icon-caret-down vam"></span>
|
||||
</div>
|
||||
<div id="user-info-popup" class="top-info-popup hide">
|
||||
<div class="outer-caret up-outer-caret"><div class="inner-caret"></div></div>
|
||||
<div class="item ovhd">
|
||||
{% avatar request.user 36 %}
|
||||
<div class="txt">
|
||||
{{ request.user.username|email2nickname }} <br />
|
||||
{{ request.user.username}}
|
||||
</div>
|
||||
</div>
|
||||
<span class="loading-icon loading-tip"></span>
|
||||
<div id="space-traffic" class="hide" data-url="{% url 'space_and_traffic' %}"></div>
|
||||
<a class="item" href="{{ SITE_ROOT }}profile/">{% trans "Settings" %}</a>
|
||||
<a href="{{ SITE_ROOT }}accounts/logout/" class="item" id="logout">{% trans "Log out" %}</a>
|
||||
</div>
|
||||
<div class="manage">
|
||||
<a href="{{ SITE_ROOT }}" title="{% trans "Exit System Admin" %}"><img src="{{ MEDIA_URL }}img/admin_out.png" alt="" /></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main" class="clear">
|
||||
<div id="title-panel" class="w100 ovhd">
|
||||
</div>
|
||||
<div id="left-panel">
|
||||
<div class="side-tabnav hide" id="side-nav"></div>
|
||||
</div>
|
||||
<div id="right-panel">
|
||||
</div>
|
||||
<div id="main-panel" class="clear w100 ovhd">
|
||||
</div>
|
||||
|
||||
<div id="confirm-popup" class="hide">
|
||||
<div id="confirm-con"></div>
|
||||
<button id="confirm-yes" class="btn">{% trans "Yes"%}</button>
|
||||
<button class="simplemodal-close btn">{% trans "No"%}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
{% include 'js/sysadmin-templates.html' %}
|
||||
</div><!-- wrapper -->
|
||||
|
||||
<script type="text/javascript">
|
||||
var app = {
|
||||
config: {
|
||||
mediaUrl: '{{ MEDIA_URL }}',
|
||||
siteRoot: '{{ SITE_ROOT }}'
|
||||
}
|
||||
};
|
||||
app["pageOptions"] = {
|
||||
csrfToken: "{{ csrf_token }}",
|
||||
email: "{{request.user.username}}",
|
||||
name: "{{request.user.username|email2nickname|escapejs}}",
|
||||
events_enabled: {% if events_enabled %} true {% else %} false {% endif %},
|
||||
repo_password_min_length: {{ repo_password_min_length }},
|
||||
share_link_password_min_length: {{ share_link_password_min_length }},
|
||||
enable_upload_folder: {% if enable_upload_folder %} true {% else %} false {% endif %},
|
||||
enable_resumable_fileupload: {% if enable_resumable_fileupload %} true {% else %} false {% endif %},
|
||||
thumbnail_default_size: {{ thumbnail_default_size }},
|
||||
thumbnail_size_for_grid: {{ thumbnail_size_for_grid }},
|
||||
enable_encrypted_library: {% if enable_encrypted_library %} true {% else %} false {% endif %},
|
||||
max_upload_file_size: {% if max_upload_file_size %} {{ max_upload_file_size }} {% else %} '' {% endif %},
|
||||
folder_perm_enabled: {% if folder_perm_enabled %} true {% else %} false {% endif %},
|
||||
is_pro: {% if is_pro %} true {% else %} false {% endif %},
|
||||
file_audit_enabled: {% if file_audit_enabled %} true {% else %} false {% endif %},
|
||||
cur_note: {% if request.cur_note %} {'id': '{{ request.cur_note.id }}'} {% else %} null {% endif %}
|
||||
};
|
||||
</script>
|
||||
<script src="{{ STATIC_URL }}scripts/i18n/{{ LANGUAGE_CODE }}/djangojs.js"></script>
|
||||
{% if debug %}
|
||||
<script data-main="{% static "scripts/sysadmin-main.js" %}" src="{% static "scripts/lib/require.js" %}"></script>
|
||||
{% else %}
|
||||
<script data-main="{% static "scripts/dist/sysadmin-main.js" %}" src="{% static "scripts/lib/require.js" %}"></script>
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -204,6 +204,7 @@ urlpatterns = patterns(
|
||||
url(r'^inst/', include('seahub.institutions.urls', app_name='institutions', namespace='institutions')),
|
||||
|
||||
### system admin ###
|
||||
url(r'^sysadmin/$', sysadmin, name='sysadmin'),
|
||||
url(r'^sys/info/$', sys_info, name='sys_info'),
|
||||
url(r'^sys/settings/$', sys_settings, name='sys_settings'),
|
||||
url(r'^sys/seafadmin/$', sys_repo_admin, name='sys_repo_admin'),
|
||||
|
@@ -38,7 +38,8 @@ from seahub.institutions.models import Institution, InstitutionAdmin
|
||||
from seahub.utils import IS_EMAIL_CONFIGURED, string2list, is_valid_username, \
|
||||
is_pro_version, send_html_email, get_user_traffic_list, get_server_id, \
|
||||
clear_token, gen_file_get_url, is_org_context, handle_virus_record, \
|
||||
get_virus_record_by_id, get_virus_record
|
||||
get_virus_record_by_id, get_virus_record, FILE_AUDIT_ENABLED, \
|
||||
get_max_upload_file_size
|
||||
from seahub.utils.file_size import get_file_size_unit
|
||||
from seahub.utils.rpc import mute_seafile_api
|
||||
from seahub.utils.licenseparse import parse_license
|
||||
@@ -70,6 +71,31 @@ except ImportError:
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@login_required
|
||||
@sys_staff_required
|
||||
def sysadmin(request):
|
||||
"""
|
||||
"""
|
||||
username = request.user.username
|
||||
|
||||
max_upload_file_size = get_max_upload_file_size()
|
||||
|
||||
folder_perm_enabled = True if is_pro_version() and settings.ENABLE_FOLDER_PERM else False
|
||||
|
||||
return render_to_response('sysadmin/sysadmin_backbone.html', {
|
||||
'enable_upload_folder': settings.ENABLE_UPLOAD_FOLDER,
|
||||
'enable_resumable_fileupload': settings.ENABLE_RESUMABLE_FILEUPLOAD,
|
||||
'enable_thumbnail': settings.ENABLE_THUMBNAIL,
|
||||
'thumbnail_default_size': settings.THUMBNAIL_DEFAULT_SIZE,
|
||||
'thumbnail_size_for_grid': settings.THUMBNAIL_SIZE_FOR_GRID,
|
||||
'enable_encrypted_library': config.ENABLE_ENCRYPTED_LIBRARY,
|
||||
'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING,
|
||||
'max_upload_file_size': max_upload_file_size,
|
||||
'folder_perm_enabled': folder_perm_enabled,
|
||||
'is_pro': True if is_pro_version() else False,
|
||||
'file_audit_enabled': FILE_AUDIT_ENABLED
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
@sys_staff_required
|
||||
def sys_info(request):
|
||||
|
6
static/scripts/sysadmin-app/main.js
Normal file
6
static/scripts/sysadmin-app/main.js
Normal file
@@ -0,0 +1,6 @@
|
||||
define([
|
||||
'sysadmin-app/router'
|
||||
], function(Router){
|
||||
app.router = new Router();
|
||||
Backbone.history.start();
|
||||
});
|
49
static/scripts/sysadmin-app/router.js
Normal file
49
static/scripts/sysadmin-app/router.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/*global define*/
|
||||
define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/views/side-nav',
|
||||
'sysadmin-app/views/dashboard'
|
||||
], function($, Backbone, Common, SideNavView, DashboardView) {
|
||||
"use strict";
|
||||
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
'': 'showDashboard',
|
||||
'dashboard/': 'showDashboard',
|
||||
// Default
|
||||
'*actions': 'showDashboard'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
Common.prepareApiCsrf();
|
||||
Common.initAccountPopup();
|
||||
|
||||
this.sideNavView = new SideNavView();
|
||||
app.ui = {
|
||||
sideNavView: this.sideNavView
|
||||
};
|
||||
|
||||
this.dashboardView = new DashboardView();
|
||||
this.currentView = this.dashboardView;
|
||||
|
||||
$('#info-bar .close').click(Common.closeTopNoticeBar);
|
||||
},
|
||||
|
||||
switchCurrentView: function(newView) {
|
||||
if (this.currentView != newView) {
|
||||
this.currentView.hide();
|
||||
this.currentView = newView;
|
||||
}
|
||||
},
|
||||
|
||||
showDashboard: function() {
|
||||
this.switchCurrentView(this.dashboardView);
|
||||
this.sideNavView.setCurTab('dashboard');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return Router;
|
||||
});
|
35
static/scripts/sysadmin-app/views/dashboard.js
Normal file
35
static/scripts/sysadmin-app/views/dashboard.js
Normal file
@@ -0,0 +1,35 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var DashboardView = Backbone.View.extend({
|
||||
|
||||
tagName: 'div',
|
||||
|
||||
initialize: function() {
|
||||
|
||||
},
|
||||
|
||||
events: {
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
|
||||
},
|
||||
|
||||
show: function() {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return DashboardView;
|
||||
});
|
39
static/scripts/sysadmin-app/views/side-nav.js
Normal file
39
static/scripts/sysadmin-app/views/side-nav.js
Normal file
@@ -0,0 +1,39 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var sideNavView = Backbone.View.extend({
|
||||
el: '#side-nav',
|
||||
|
||||
template: _.template($("#side-nav-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.default_cur_tab = 'dashboard';
|
||||
this.data = {
|
||||
'cur_tab': this.default_cur_tab
|
||||
};
|
||||
this.render();
|
||||
this.$el.show();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.data));
|
||||
return this;
|
||||
},
|
||||
|
||||
setCurTab: function(cur_tab, options) {
|
||||
this.data.cur_tab = cur_tab || this.default_cur_tab;
|
||||
if (options) {
|
||||
$.extend(this.data, options);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return sideNavView;
|
||||
});
|
4
static/scripts/sysadmin-main.js
Normal file
4
static/scripts/sysadmin-main.js
Normal file
@@ -0,0 +1,4 @@
|
||||
//Load common code that includes config, then load the app logic for this page.
|
||||
require(['./common'], function (common) {
|
||||
require(['sysadmin-app/main']);
|
||||
});
|
Reference in New Issue
Block a user