From 653d637b4ee1aa6fd112c11bf082883c3252c928 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@gmail.com>
Date: Thu, 28 Aug 2014 04:51:53 +0200
Subject: [webui] Improve and fix

---
 module/webui/themes/default/js/admin.coffee | 58 +++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 module/webui/themes/default/js/admin.coffee

(limited to 'module/webui/themes/default/js/admin.coffee')

diff --git a/module/webui/themes/default/js/admin.coffee b/module/webui/themes/default/js/admin.coffee
new file mode 100644
index 000000000..5afbcbb66
--- /dev/null
+++ b/module/webui/themes/default/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()
-- 
cgit v1.2.3