mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-11 20:01:10 +00:00
show/delete public lib
This commit is contained in:
6
media/scripts/app/main/organization.js
Normal file
6
media/scripts/app/main/organization.js
Normal file
@@ -0,0 +1,6 @@
|
||||
define([
|
||||
'app/routers/organization'
|
||||
], function(Router){
|
||||
new Router();
|
||||
Backbone.history.start();
|
||||
});
|
30
media/scripts/app/routers/organization.js
Normal file
30
media/scripts/app/routers/organization.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/*global define*/
|
||||
define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'app/views/organization'
|
||||
], function($, Backbone, OrganizationView) {
|
||||
"use strict";
|
||||
|
||||
var OrganizationRouter = Backbone.Router.extend({
|
||||
routes: {
|
||||
'libs/:id(/*path)': 'showDir',
|
||||
// Default
|
||||
'*actions': 'defaultAction'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
this.organizationView = new OrganizationView();
|
||||
},
|
||||
|
||||
showDir: function() {
|
||||
alert('todo');
|
||||
},
|
||||
|
||||
defaultAction: function(){
|
||||
this.organizationView.showPublicRepos();
|
||||
}
|
||||
});
|
||||
|
||||
return OrganizationRouter;
|
||||
});
|
@@ -54,12 +54,14 @@ define([
|
||||
this.sharedReposView.hide();
|
||||
this.reposView.show();
|
||||
this.dirView.hide();
|
||||
$('#repo-create').show();
|
||||
},
|
||||
|
||||
showSharedRepos: function() {
|
||||
this.dirView.hide();
|
||||
this.reposView.hide();
|
||||
this.sharedReposView.show();
|
||||
$('#repo-create').hide();
|
||||
},
|
||||
|
||||
showDir: function(category, repo_id, path) {
|
||||
|
70
media/scripts/app/views/organization-repo.js
Normal file
70
media/scripts/app/views/organization-repo.js
Normal file
@@ -0,0 +1,70 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'text!' + app.config._tmplRoot + 'organization-repos.html'
|
||||
], function($, _, Backbone, Common, reposTemplate) {
|
||||
'use strict';
|
||||
|
||||
var OrganizationRepoView = Backbone.View.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template(reposTemplate),
|
||||
|
||||
events: {
|
||||
'mouseenter': 'showAction',
|
||||
'mouseleave': 'hideAction',
|
||||
'click .cancel-share': 'removeShare'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
},
|
||||
|
||||
removeShare: function(e) {
|
||||
var _this = this,
|
||||
success_callback = function(data) {
|
||||
Common.feedback(gettext('Success'), 'success', Common.SUCCESS_TIMOUT);
|
||||
_this.$el.remove();
|
||||
_this.collection.remove(_this.model, {silent: true});
|
||||
if (_this.collection.length == 0) {
|
||||
$('#organization-repos table').hide();
|
||||
$('#organization-repos .empty-tips').show();
|
||||
};
|
||||
};
|
||||
|
||||
Common.ajaxGet({
|
||||
'get_url': Common.getUrl({name: 'ajax_repo_remove_share'}),
|
||||
'data': {
|
||||
'repo_id': this.model.get('id'),
|
||||
'share_type': this.model.get('share_type')
|
||||
},
|
||||
'after_op_success': success_callback
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var data, show_unshare_btn;
|
||||
if (this.model.get('share_from') == app.pageOptions.current_user || app.pageOptions.is_staff == true) {
|
||||
show_unshare_btn = true;
|
||||
} else {
|
||||
show_unshare_btn = false;
|
||||
};
|
||||
data = $.extend(this.model.toJSON(), {'show_unshare_btn': show_unshare_btn});
|
||||
this.$el.html(this.template(data));
|
||||
return this;
|
||||
},
|
||||
|
||||
showAction: function() {
|
||||
this.$el.addClass('hl');
|
||||
this.$el.find('.op-icon').removeClass('vh');
|
||||
},
|
||||
|
||||
hideAction: function() {
|
||||
this.$el.removeClass('hl');
|
||||
this.$el.find('.op-icon').addClass('vh');
|
||||
}
|
||||
});
|
||||
|
||||
return OrganizationRepoView;
|
||||
});
|
63
media/scripts/app/views/organization.js
Normal file
63
media/scripts/app/views/organization.js
Normal file
@@ -0,0 +1,63 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'app/collections/repos',
|
||||
'app/views/organization-repo'
|
||||
], function($, _, Backbone, Common, RepoCollection, OrganizationRepoView) {
|
||||
'use strict';
|
||||
|
||||
var OrganizationView = Backbone.View.extend({
|
||||
el: '#main',
|
||||
|
||||
initialize: function() {
|
||||
|
||||
this.$table = $('#organization-repos table');
|
||||
this.$tableBody = $('tbody', this.$table);
|
||||
this.$loadingTip = $('#organization-repos .loading-tip');
|
||||
this.$emptyTip = $('#organization-repos .empty-tips');
|
||||
|
||||
this.repos = new RepoCollection({type: 'org'});
|
||||
this.listenTo(this.repos, 'add', this.addOne);
|
||||
this.listenTo(this.repos, 'reset', this.reset);
|
||||
},
|
||||
|
||||
events: {
|
||||
'click #repo-create': 'createRepo'
|
||||
},
|
||||
|
||||
createRepo: function() {
|
||||
alert('todo');
|
||||
},
|
||||
|
||||
addOne: function(repo, collection, options) {
|
||||
var view = new OrganizationRepoView({model: repo, collection: this.repos});
|
||||
if (options.prepend) {
|
||||
this.$tableBody.prepend(view.render().el);
|
||||
} else {
|
||||
this.$tableBody.append(view.render().el);
|
||||
}
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.$tableBody.empty();
|
||||
this.repos.each(this.addOne, this);
|
||||
if (this.repos.length) {
|
||||
this.$emptyTip.hide();
|
||||
this.$table.show();
|
||||
} else {
|
||||
this.$emptyTip.show();
|
||||
this.$table.hide();
|
||||
}
|
||||
this.$loadingTip.hide();
|
||||
},
|
||||
|
||||
showPublicRepos: function() {
|
||||
this.repos.fetch({reset: true});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return OrganizationView;
|
||||
});
|
@@ -23,7 +23,7 @@ define([
|
||||
|
||||
removeShare: function(e) {
|
||||
var _this = this,
|
||||
after_leave_success = function(data) {
|
||||
success_callback = function(data) {
|
||||
Common.feedback(gettext('Success'), 'success', Common.SUCCESS_TIMOUT);
|
||||
_this.$el.remove();
|
||||
_this.collection.remove(_this.model, {silent: true});
|
||||
@@ -40,7 +40,7 @@ define([
|
||||
'from': this.model.get('owner'),
|
||||
'share_type': this.model.get('share_type')
|
||||
},
|
||||
'after_op_success': after_leave_success
|
||||
'after_op_success': success_callback
|
||||
});
|
||||
},
|
||||
|
||||
|
4
media/scripts/organization.js
Normal file
4
media/scripts/organization.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(['app/main/organization']);
|
||||
});
|
@@ -622,10 +622,13 @@ class Repos(APIView):
|
||||
"desc": r.repo_desc,
|
||||
"owner": "Organization",
|
||||
"mtime": r.last_modified,
|
||||
"mtime_relative": translate_seahub_time(r.last_modified),
|
||||
"root": r.root,
|
||||
"size": r.size,
|
||||
"encrypted": r.encrypted,
|
||||
"permission": r.permission,
|
||||
"share_from": r.user,
|
||||
"share_type": r.share_type,
|
||||
}
|
||||
if r.encrypted:
|
||||
repo["enc_version"] = commit.enc_version
|
||||
|
23
seahub/templates/js/organization-repos.html
Normal file
23
seahub/templates/js/organization-repos.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{% load i18n %}
|
||||
<td>
|
||||
<% if (encrypted) { %>
|
||||
<img src="<%= app.config.mediaUrl %>img/sync-folder-encrypt-20.png" title="{% trans "Read-Write" %}" alt="" />
|
||||
<% } else { %>
|
||||
<% if (permission == 'rw') { %>
|
||||
<img src="<%= app.config.mediaUrl %>img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="" />
|
||||
<% } else { %>
|
||||
<img src="<%= app.config.mediaUrl %>img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="" />
|
||||
<% } %>
|
||||
<% } %>
|
||||
</td>
|
||||
{# TODO #}
|
||||
<td><a href="#/libs/<%= id %>"><%- name %></a></td>
|
||||
<td><%- desc %></td>
|
||||
<td><%- mtime_relative %></td>
|
||||
<td><%- share_from %></td>
|
||||
<td>
|
||||
<% if (show_unshare_btn == true) { %>
|
||||
<img src="<%= app.config.mediaUrl%>img/rm.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
|
||||
<% } %>
|
||||
</td>
|
||||
|
@@ -1,71 +1,59 @@
|
||||
{% extends "pub_base.html" %}
|
||||
{% load seahub_tags avatar_tags group_avatar_tags i18n %}
|
||||
{% extends 'base_for_backbone.html' %}
|
||||
{% load seahub_tags avatar_tags i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block cur_lib %}tab-cur{% endblock %}
|
||||
{% block sub_title %}{% trans "Organization" %} - {% endblock %}
|
||||
|
||||
{% block left_panel %}
|
||||
<div class="side-tabnav">
|
||||
<h3 class="hd">{% trans "Organization" %}</h3>
|
||||
<ul class="side-tabnav-tabs">
|
||||
<li class="tab tab-cur"><a href="{% url 'pubrepo' %}" class="lib">{% trans "Libraries" %}</a></li>
|
||||
<li class="tab {% block cur_grp %}{% endblock %}"><a href="{% url 'pubgrp' %}" class="group">{% trans "Groups" %}</a></li>
|
||||
<li class="tab {% block cur_user %}{% endblock %}"><a href="{% url 'pubuser' %}" class="members">{% trans "Members" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block right_panel %}
|
||||
<div class="hd ovhd">
|
||||
<h3 class="fleft">{% trans "Libraries" %}</h3>
|
||||
<button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library"%}</span></button>
|
||||
</div>
|
||||
{% if public_repos %}
|
||||
<table>
|
||||
|
||||
<div id="organization-repos">
|
||||
<table class="repo-list hide">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="4%"></th>
|
||||
<th width="20%">{% trans "Name"%} <span id="pub-repo-list-name-down" class="icon-caret-up cspt"></span> <span id="pub-repo-list-name-up" class="icon-caret-down cspt hide"></span></th>
|
||||
<th width="30%">{% trans "Description"%}</th>
|
||||
<th width="18%">{% trans "Last Update"%} <span id="pub-repo-list-time-up" class="icon-caret-up cspt hide"></span> <span id="pub-repo-list-time-down" class="icon-caret-down cspt"></span></th>
|
||||
<th width="15%">{% trans "Share From"%}</th>
|
||||
<th width="13%">{% trans "Operations"%}</th>
|
||||
<th width="20%">{% trans "Description"%}</th>
|
||||
<th width="20%">{% trans "Last Update"%} <span id="pub-repo-list-time-up" class="icon-caret-up cspt hide"></span> <span id="pub-repo-list-time-down" class="icon-caret-down cspt"></span></th>
|
||||
<th width="20%">{% trans "Share From"%}</th>
|
||||
<th width="16%">{% trans "Operations"%}</th>
|
||||
</tr>
|
||||
{% for repo in public_repos %}
|
||||
<tr data-repo_name="{{repo.props.repo_name}}" data-time="{% if repo.props.last_modified %}{{ repo.props.last_modified }}{% else %}0{% endif %}">
|
||||
<td>
|
||||
{% if repo.encrypted %}
|
||||
<img src="{{MEDIA_URL}}img/sync-folder-encrypt-20.png" title="{% trans "Read-Write"%}" alt="{% trans "Directory icon"%}" />
|
||||
{% else %}
|
||||
{% if repo.user_perm == 'rw' %}
|
||||
<img src="{{MEDIA_URL}}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write"%}" alt="{% trans "Directory icon"%}" />
|
||||
{% else %}
|
||||
<img src="{{MEDIA_URL}}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only"%}" alt="{% trans "Directory icon"%}" />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td><a href="{% url 'repo' repo.props.repo_id %}">{{ repo.props.repo_name }}</a></td>
|
||||
<td>{{ repo.props.repo_desc }}</td>
|
||||
<td>{% if repo.props.last_modified %}{{ repo.props.last_modified|translate_seahub_time }}{% else %}--{% endif %}</td>
|
||||
<td>{{ repo.props.user|email2nickname }}</td>
|
||||
<td>
|
||||
{% if request.user.is_staff or repo.share_from_me %}
|
||||
<img src="{{MEDIA_URL}}img/rm.png" alt="" data-href="{% url 'unsetinnerpub' repo.repo_id %}?permission={{repo.permission}}" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="empty-tips">
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" class="loading-tip" />
|
||||
<div class="empty-tips hide">
|
||||
<h2 class="alc">{% trans "No public library" %}</h2>
|
||||
<p>{% blocktrans %}You can create a public library by clicking "New Library" button, others can view and download this library.{% endblocktrans %}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "snippets/repo_create_form.html" %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
$(".cancel-share").click(function() {
|
||||
location.href = $(this).data('href');
|
||||
});
|
||||
|
||||
function repoCreateSuccessCallback() {
|
||||
location.reload();
|
||||
}
|
||||
{% url 'public_repo_create' as repo_create_url %}
|
||||
{% with post_url=repo_create_url %}
|
||||
{% include "snippets/repo_create_js.html" %}
|
||||
{% endwith %}
|
||||
{% include "snippets/sort_lib_js.html" %}
|
||||
<script>
|
||||
app["pageOptions"] = {
|
||||
base_url: "{{ SITE_ROOT }}" + "home/my/",
|
||||
reposUrl: "{% url 'api2-repos' %}",
|
||||
current_user: "{{ request.user.username }}",
|
||||
is_staff: {% if request.user.is_staff %} true {% else %} false {% endif %}
|
||||
};
|
||||
</script>
|
||||
<script data-main="{{ MEDIA_URL }}scripts/organization" src="{{ MEDIA_URL }}scripts/lib/require.js"></script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user