summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-11 22:01:55 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-11 22:01:55 +0200
commitbca8ceaa7de08fa4395ca243eb96a65888d74ef8 (patch)
tree3842d89a2d222cf9301ce8086242abced5b8ff29 /module/web
parentclosed #402 (diff)
downloadpyload-bca8ceaa7de08fa4395ca243eb96a65888d74ef8.tar.xz
restart / quit buttons in webif
Diffstat (limited to 'module/web')
-rw-r--r--module/web/media/img/dialog-question.pngbin0 -> 2073 bytes
-rw-r--r--module/web/media/js/admin.coffee58
-rw-r--r--module/web/media/js/admin.js1
-rw-r--r--module/web/templates/default/admin.html61
4 files changed, 67 insertions, 53 deletions
diff --git a/module/web/media/img/dialog-question.png b/module/web/media/img/dialog-question.png
new file mode 100644
index 000000000..b0af3db5b
--- /dev/null
+++ b/module/web/media/img/dialog-question.png
Binary files differ
diff --git a/module/web/media/js/admin.coffee b/module/web/media/js/admin.coffee
new file mode 100644
index 000000000..82b0dd3ec
--- /dev/null
+++ b/module/web/media/js/admin.coffee
@@ -0,0 +1,58 @@
+root = this
+
+window.addEvent "domready", ->
+
+ root.passwordDialog = new MooDialog {destroyOnHide: false}
+ root.passwordDialog.setContent $ 'password_box'
+
+ $("login_password_reset").addEvent "click", (e) -> root.passwordDialog.close()
+ $("login_password_button").addEvent "click", (e) ->
+
+ newpw = $("login_new_password").get("value")
+ newpw2 = $("login_new_password2").get("value")
+
+ if newpw is newpw2
+ form = $("password_form")
+ form.set "send", {
+ onSuccess: (data) ->
+ root.notify.alert "Success", {
+ 'className': 'success'
+ }
+ onFailure: (data) ->
+ root.notify.alert "Error", {
+ 'className': 'error'
+ }
+ }
+
+ form.send()
+
+ root.passwordDialog.close()
+ else
+ alert '{{_("Passwords did not match.")}}'
+
+ e.stop()
+
+ for item in $$(".change_password")
+ id = item.get("id")
+ user = id.split("|")[1]
+ $("user_login").set("value", user)
+ item.addEvent "click", (e) -> root.passwordDialog.open()
+
+ $('quit-pyload').addEvent "click", (e) ->
+ new MooDialog.Confirm "{{_('You are really sure you want to quit pyLoad?')}}", ->
+ new Request.JSON({
+ url: '/api/kill'
+ method: 'get'
+ }).send()
+ , ->
+ e.stop()
+
+ $('restart-pyload').addEvent "click", (e) ->
+ new MooDialog.Confirm "{{_('Are you sure you want to restart pyLoad?')}}", ->
+ new Request.JSON({
+ url: '/api/restart'
+ method: 'get'
+ onSuccess: (data) -> alert "{{_('pyLoad restarted')}}"
+ }).send()
+ , ->
+ e.stop() \ No newline at end of file
diff --git a/module/web/media/js/admin.js b/module/web/media/js/admin.js
new file mode 100644
index 000000000..6ecea6514
--- /dev/null
+++ b/module/web/media/js/admin.js
@@ -0,0 +1 @@
+var root;root=this;window.addEvent("domready",function(){var f,c,b,e,a,d;root.passwordDialog=new MooDialog({destroyOnHide:false});root.passwordDialog.setContent($("password_box"));$("login_password_reset").addEvent("click",function(g){return root.passwordDialog.close()});$("login_password_button").addEvent("click",function(j){var h,i,g;i=$("login_new_password").get("value");g=$("login_new_password2").get("value");if(i===g){h=$("password_form");h.set("send",{onSuccess:function(k){return root.notify.alert("Success",{className:"success"})},onFailure:function(k){return root.notify.alert("Error",{className:"error"})}});h.send();root.passwordDialog.close()}else{alert('{{_("Passwords did not match.")}}')}return j.stop()});d=$$(".change_password");for(e=0,a=d.length;e<a;e++){c=d[e];f=c.get("id");b=f.split("|")[1];$("user_login").set("value",b);c.addEvent("click",function(g){return root.passwordDialog.open()})}$("quit-pyload").addEvent("click",function(g){new MooDialog.Confirm("{{_('You are really sure you want to quit pyLoad?')}}",function(){return new Request.JSON({url:"/api/kill",method:"get"}).send()},function(){});return g.stop()});return $("restart-pyload").addEvent("click",function(g){new MooDialog.Confirm("{{_('Are you sure you want to restart pyLoad?')}}",function(){return new Request.JSON({url:"/api/restart",method:"get",onSuccess:function(h){return alert("{{_('pyLoad restarted')}}")}}).send()},function(){});return g.stop()})}); \ No newline at end of file
diff --git a/module/web/templates/default/admin.html b/module/web/templates/default/admin.html
index df1843997..b049411fd 100644
--- a/module/web/templates/default/admin.html
+++ b/module/web/templates/default/admin.html
@@ -1,64 +1,19 @@
{% extends 'default/base.html' %}
{% block head %}
- <script type="text/javascript">
-
- root = this;
-
- window.addEvent("domready", function() {
-
- root.passwordDialog = new MooDialog({destroyOnHide: false});
- root.passwordDialog.setContent($('password_box'));
-
- $("login_password_reset").addEvent("click", function(e) {root.passwordDialog.close();});
- $("login_password_button").addEvent("click", function(e) {
-
- var current = $("login_current_password").get("value");
- var newpw = $("login_new_password").get("value");
- var newpw2 = $("login_new_password2").get("value");
-
- if (newpw == newpw2) {
- var form = $("password_form");
-
- form.set("send", {
- onSuccess: function(data) {
- root.notify.alert("Success", {
- 'className': 'success'
- });
- },
- onFailure: function(data) {
- root.notify.alert("Error", {
- 'className': 'error'
- });
- }});
-
- form.send();
-
- root.passwordDialog.close();
- } else {
- alert("{{_("Passwords did not match.")}}");
- }
- e.stop();
- });
-
- $$(".change_password").each(function(item) {
- var id = item.get("id");
- var user = id.split("|")[1];
- $("user_login").set("value", user);
-
- item.addEvent("click", function(e) {
- root.passwordDialog.open();
- });
- });
- });
- </script>
+ <script type="text/javascript" src="media/js/admin.js"></script>
{% endblock %}
-{% block title %}{{ _("Administrate User") }} - {{ super() }} {% endblock %}
-{% block subtitle %}{{ _("Administrate User") }}{% endblock %}
+{% block title %}{{ _("Administrate") }} - {{ super() }} {% endblock %}
+{% block subtitle %}{{ _("Administrate") }}{% endblock %}
{% block content %}
+
+ <a href="#" id="quit-pyload" style="font-size: large; font-weight: bold;">{{_("Quit pyLoad")}}</a> |
+ <a href="#" id="restart-pyload" style="font-size: large; font-weight: bold;">{{_("Restart pyLoad")}}</a>
+ <br>
+ <br>
{{ _("To add user or change passwords use:") }} <b>python pyLoadCore.py -u</b><br>
{{ _("Important: Admin user have always all permissions!") }}