diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-31 13:11:58 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-31 13:11:58 +0200 |
commit | 53bc0477f9b0217c87676103361b1633e9b12f19 (patch) | |
tree | c6461ab1c292b39e49e1a5924b75761b588b25ba | |
parent | separate addon and plugin configs (diff) | |
download | pyload-53bc0477f9b0217c87676103361b1633e9b12f19.tar.xz |
added account page
-rw-r--r-- | module/api/AccountApi.py | 11 | ||||
-rw-r--r-- | module/remote/apitypes.py | 2 | ||||
-rw-r--r-- | module/remote/pyload.thrift | 2 | ||||
-rw-r--r-- | module/web/pyload_app.py | 7 | ||||
-rw-r--r-- | module/web/static/css/default/accounts.less | 6 | ||||
-rw-r--r-- | module/web/static/css/default/settings.less | 4 | ||||
-rw-r--r-- | module/web/static/css/default/style.less | 4 | ||||
-rw-r--r-- | module/web/static/js/collections/AccountList.js | 23 | ||||
-rw-r--r-- | module/web/static/js/default.js | 7 | ||||
-rw-r--r-- | module/web/static/js/models/Account.js | 38 | ||||
-rw-r--r-- | module/web/static/js/views/accounts/accountListView.js | 44 | ||||
-rw-r--r-- | module/web/static/js/views/accounts/accountModal.js | 60 | ||||
-rw-r--r-- | module/web/static/js/views/accounts/accountView.js | 19 | ||||
-rw-r--r-- | module/web/templates/default/accounts.html | 45 | ||||
-rwxr-xr-x | module/web/templates/default/backbone/accountDialog.html | 40 | ||||
-rwxr-xr-x | module/web/templates/default/backbone/pluginChooserDialog.html | 2 | ||||
-rw-r--r-- | module/web/templates/default/base.html | 1 | ||||
-rw-r--r-- | module/web/templates/default/settings.html | 4 |
18 files changed, 306 insertions, 13 deletions
diff --git a/module/api/AccountApi.py b/module/api/AccountApi.py index 396824a55..d1586e7aa 100644 --- a/module/api/AccountApi.py +++ b/module/api/AccountApi.py @@ -5,6 +5,7 @@ from module.Api import Api, RequirePerm, Permission from ApiComponent import ApiComponent + class AccountApi(ApiComponent): """ All methods to control accounts """ @@ -35,13 +36,17 @@ class AccountApi(ApiComponent): """Changes pw/options for specific account.""" self.core.accountManager.updateAccount(plugin, account, password, options) + def updateAccountInfo(self, account): + """ Update account from :class:`AccountInfo` """ + #TODO + @RequirePerm(Permission.Accounts) - def removeAccount(self, plugin, account): + def removeAccount(self, account): """Remove account from pyload. - :param plugin: pluginname - :param account: accountname + :param account: :class:`ÀccountInfo` instance """ + # TODO self.core.accountManager.removeAccount(plugin, account) diff --git a/module/remote/apitypes.py b/module/remote/apitypes.py index 41f9be50e..f725aa386 100644 --- a/module/remote/apitypes.py +++ b/module/remote/apitypes.py @@ -487,7 +487,7 @@ class Iface(object): pass def recheckPackage(self, pid): pass - def removeAccount(self, plugin, account): + def removeAccount(self, account): pass def removeUser(self, uid): pass diff --git a/module/remote/pyload.thrift b/module/remote/pyload.thrift index adaede0ff..032be92fd 100644 --- a/module/remote/pyload.thrift +++ b/module/remote/pyload.thrift @@ -491,7 +491,7 @@ service Pyload { list<string> getAccountTypes(), void updateAccount(1: PluginName plugin, 2: string account, 3: string password), void updateAccountInfo(1: AccountInfo account), - void removeAccount(1: PluginName plugin, 2: string account), + void removeAccount(1: AccountInfo account), ///////////////////////// // Auth+User Information diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py index 45564ed08..483a47f07 100644 --- a/module/web/pyload_app.py +++ b/module/web/pyload_app.py @@ -154,10 +154,15 @@ def index(api): return render_to_response("dashboard.html", proc=[pre_processor]) @route("/settings") -@login_required() +@login_required('Plugins') def settings(api): return render_to_response("settings.html", proc=[pre_processor]) +@route("/accounts") +@login_required('Accounts') +def accounts(api): + return render_to_response("accounts.html", proc=[pre_processor]) + @route("/admin") @login_required() def admin(api): diff --git a/module/web/static/css/default/accounts.less b/module/web/static/css/default/accounts.less new file mode 100644 index 000000000..5d31df2db --- /dev/null +++ b/module/web/static/css/default/accounts.less @@ -0,0 +1,6 @@ +@import "common.less"; + +.logo-select { + width: 20px; + height: 20px; +}
\ No newline at end of file diff --git a/module/web/static/css/default/settings.less b/module/web/static/css/default/settings.less index 947cbaa22..435e1cf61 100644 --- a/module/web/static/css/default/settings.less +++ b/module/web/static/css/default/settings.less @@ -119,8 +119,4 @@ .logo-select {
width: 20px;
height: 20px;
-}
-
-.select2-container {
- min-width: 206px; // same as other input fields
}
\ No newline at end of file diff --git a/module/web/static/css/default/style.less b/module/web/static/css/default/style.less index 120864f39..4cafb1030 100644 --- a/module/web/static/css/default/style.less +++ b/module/web/static/css/default/style.less @@ -535,6 +535,10 @@ div.modal-header { }
+.select2-container {
+ min-width: 220px; // same as other input fields
+}
+
div.modal-body {
max-height: 100%;
}
diff --git a/module/web/static/js/collections/AccountList.js b/module/web/static/js/collections/AccountList.js new file mode 100644 index 000000000..1bcf87c1e --- /dev/null +++ b/module/web/static/js/collections/AccountList.js @@ -0,0 +1,23 @@ +define(['jquery', 'backbone', 'underscore', 'app', 'models/Account'], function($, Backbone, _, App, Account) { + + return Backbone.Collection.extend({ + + model: Account, + + comparator: function(account) { + return account.get('plugin'); + }, + + initialize: function() { + + }, + + fetch: function(options) { + // TODO: refresh options? + options = App.apiRequest('getAccounts/false', null, options); + return Backbone.Collection.prototype.fetch.call(this, options); + } + + }); + +});
\ No newline at end of file diff --git a/module/web/static/js/default.js b/module/web/static/js/default.js index 62b2ef9b6..d5a0cfb3e 100644 --- a/module/web/static/js/default.js +++ b/module/web/static/js/default.js @@ -20,5 +20,12 @@ define('default', ['require', 'jquery', 'app', 'views/headerView', 'views/dashbo }); }; + App.initAccountView = function() { + require(['views/accounts/accountListView'], function(AccountListView) { + App.accountView = new AccountListView(); + App.accountView.render(); + }); + }; + return App; });
\ No newline at end of file diff --git a/module/web/static/js/models/Account.js b/module/web/static/js/models/Account.js new file mode 100644 index 000000000..55e63ac08 --- /dev/null +++ b/module/web/static/js/models/Account.js @@ -0,0 +1,38 @@ +define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], function($, Backbone, _, Api) { + + return Backbone.Model.extend({ + + // TODO + // generated, not submitted + idAttribute: 'user', + + defaults: { + plugin: null, + loginname: null, + owner: -1, + valid: false, + validuntil: -1, + trafficleft: -1, + maxtraffic: -1, + premium: false, + activated: false, + shared: false, + options: null + }, + + // Model Constructor + initialize: function() { + + }, + + // Any time a model attribute is set, this method is called + validate: function(attrs) { + + }, + + save: function(options){ + // TODO + } + }); + +});
\ No newline at end of file diff --git a/module/web/static/js/views/accounts/accountListView.js b/module/web/static/js/views/accounts/accountListView.js new file mode 100644 index 000000000..ea01f679e --- /dev/null +++ b/module/web/static/js/views/accounts/accountListView.js @@ -0,0 +1,44 @@ +define(['jquery', 'underscore', 'backbone', 'app', 'collections/AccountList', './accountView'], + function($, _, Backbone, App, AccountList, accountView) { + + // Renders settings over view page + return Backbone.View.extend({ + + el: "body", + + events: { + 'click .btn-add': 'addAccount' + }, + + content: null, + accounts: null, + modal: null, + + initialize: function() { + this.content = this.$('#account-content'); + this.accounts = new AccountList(); + this.refresh(); + }, + + refresh: function() { + this.accounts.fetch({success: _.bind(this.render, this)}); + }, + + render: function() { + var self = this; + this.accounts.each(function(account) { + self.content.append(new accountView({model: account}).render().el); + }); + }, + + addAccount: function() { + var self = this; + _.requireOnce(['views/accounts/accountModal'], function(Modal) { + if (self.modal === null) + self.modal = new Modal(); + + self.modal.show(); + }); + } + }); + });
\ No newline at end of file diff --git a/module/web/static/js/views/accounts/accountModal.js b/module/web/static/js/views/accounts/accountModal.js new file mode 100644 index 000000000..898b10a89 --- /dev/null +++ b/module/web/static/js/views/accounts/accountModal.js @@ -0,0 +1,60 @@ +define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/default/accountDialog.html', 'select2'], + function($, _, App, modalView, template) { + return modalView.extend({ + + events: { + 'click .btn-add': 'add' + }, + template: _.compile(template), + plugins: null, + select: null, + + initialize: function() { + // Inherit parent events + this.events = _.extend({}, modalView.prototype.events, this.events); + var self = this; + $.ajax(App.apiRequest('getAccountTypes', null, {success: function(data) { + self.plugins = _.sortBy(data, function(item) { + return item; + }); + self.render(); + }})); + }, + + onRender: function() { + // TODO: could be a seperate input type if needed on multiple pages + if (this.plugins) + this.select = this.$('#pluginSelect').select2({ + escapeMarkup: function(m) { + return m; + }, + formatResult: this.format, + formatSelection: this.format, + data: {results: this.plugins, text: function(item) { + return item; + }}, + id: function(item) { + return item; + } + }); + }, + + onShow: function() { + }, + + onHide: function() { + }, + + format: function(data) { + return '<img class="logo-select" src="icons/' + data + '"> ' + data; + }, + + add: function(e) { + e.stopPropagation(); + if (this.select) { + var plugin = this.select.val(); + // TODO + } + } + }); + });
\ No newline at end of file diff --git a/module/web/static/js/views/accounts/accountView.js b/module/web/static/js/views/accounts/accountView.js new file mode 100644 index 000000000..f310e4cc2 --- /dev/null +++ b/module/web/static/js/views/accounts/accountView.js @@ -0,0 +1,19 @@ +define(['jquery', 'underscore', 'backbone', 'app'], + function($, _, Backbone, App) { + + // Renders settings over view page + return Backbone.View.extend({ + + el: "li", + + events: { + }, + + initialize: function() { + }, + + render: function() { + return this; + } + }); + });
\ No newline at end of file diff --git a/module/web/templates/default/accounts.html b/module/web/templates/default/accounts.html new file mode 100644 index 000000000..06b81c330 --- /dev/null +++ b/module/web/templates/default/accounts.html @@ -0,0 +1,45 @@ +{% extends 'default/base.html' %} + +{% block title %}{{ _("Accounts") }} - {{ super() }} {% endblock %} +{% block subtitle %}{{ _("Accounts") }} +{% endblock %} + +{% block css %} + <link href="static/css/default/accounts.less" rel="stylesheet/less" type="text/css" media="screen"/> +{% endblock %} + +{% block require %} + App.initAccountView(); +{% endblock %} + +{% block head %} + <script type="text/template" id="template-account"> + </script> +{% endblock %} + +{% block actionbar %} + <span class="span9"> + <button class="btn btn-small btn-blue btn-add">Add Account</button> + </span> +{% endblock %} + +{% block content %} + {# TODO: responsive layout instead of table #} + <div class="span10 offset2"> + <table class="table table-striped"> + <thead> + <tr> + <th>Name</th> + <th>Plugin</th> + <th>Valid</th> + <th>Premium</th> + <th>Traffic</th> + <th>Shared</th> + <th>Activated</th> + </tr> + </thead> + <tbody id="account-content"> + </tbody> + </table> + </div> +{% endblock %}
\ No newline at end of file diff --git a/module/web/templates/default/backbone/accountDialog.html b/module/web/templates/default/backbone/accountDialog.html new file mode 100755 index 000000000..dbc88e66d --- /dev/null +++ b/module/web/templates/default/backbone/accountDialog.html @@ -0,0 +1,40 @@ +{% extends 'default/backbone/modal.html' %} +{% block header %} + Add an account +{% endblock %} +{% block content %} + <form class="form-horizontal" action="#"> + <legend> + Please enter your account data + </legend> + <div class="control-group"> + <label class="control-label" for="pluginSelect"> + Plugin + </label> + <div class="controls"> + <input type="hidden" id="pluginSelect"> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="login"> + Loginname + </label> + <div class="controls"> + <input type="text" id="login"> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="password"> + Password + </label> + <div class="controls"> + <input type="password" id="password"> + </div> + </div> + + </form> +{% endblock %} +{% block buttons %} + <a href="#" class="btn btn-success btn-add">Add</a> + <a href="#" class="btn btn-close">Close</a> +{% endblock %}
\ No newline at end of file diff --git a/module/web/templates/default/backbone/pluginChooserDialog.html b/module/web/templates/default/backbone/pluginChooserDialog.html index 02284d0e6..a455b0cfd 100755 --- a/module/web/templates/default/backbone/pluginChooserDialog.html +++ b/module/web/templates/default/backbone/pluginChooserDialog.html @@ -3,7 +3,7 @@ Choose a plugin {% endblock %} {% block content %} - <form class="form-horizontal" action="#" xmlns="http://www.w3.org/1999/html"> + <form class="form-horizontal" action="#"> <legend> Please choose a plugin, which you want to configure </legend> diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html index 846b396a0..bf16f545a 100644 --- a/module/web/templates/default/base.html +++ b/module/web/templates/default/base.html @@ -136,6 +136,7 @@ <ul class="dropdown-menu" style="right: 0; left: -100%">
<li><a href="/"><i class="iconf-list-alt"></i> Dashboard</a></li>
<li><a href="/settings"><i class="iconf-wrench"></i> Settings</a></li>
+ <li><a href="/accounts"><i class="iconf-key"></i> Accounts</a></li>
<li><a href="/admin"><i class="iconf-cogs"></i> Admin</a></li>
<li class="divider"></li>
<li><a href="/logout"><i class="iconf-signout"></i> Logout</a></li>
diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html index 0b92730c2..20424606f 100644 --- a/module/web/templates/default/settings.html +++ b/module/web/templates/default/settings.html @@ -1,7 +1,7 @@ {% extends 'default/base.html' %}
-{% block title %}{{ _("Config") }} - {{ super() }} {% endblock %}
-{% block subtitle %}{{ _("Config") }}
+{% block title %}{{ _("Settings") }} - {{ super() }} {% endblock %}
+{% block subtitle %}{{ _("Settings") }}
{% endblock %}
{% block css %}
|