From 72a503f266a762838af2050780eda6d115991fa7 Mon Sep 17 00:00:00 2001 From: Thomas Lebeau Date: Thu, 20 Feb 2014 12:36:16 +0100 Subject: [PATCH] Add tools section, with adminpw tool. --- js/app.js | 44 ++++++++++++++++++++++++++++++++++++++++++ views/tools_adminpw.ms | 38 ++++++++++++++++++++++++++++++++++++ views/tools_list.ms | 18 +++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 views/tools_adminpw.ms create mode 100644 views/tools_list.ms diff --git a/js/app.js b/js/app.js index 18d87096..70d3a2ba 100644 --- a/js/app.js +++ b/js/app.js @@ -266,6 +266,7 @@ app = Sammy('#main', function (sam) { {name: "Applications", path: '#/apps'}, {name: "Services", path: '#/services'}, {name: "Monitoring", path: '#/monitor'}, + {name: "Tools", path: '#/tools'}, ]}; c.view('home', data); @@ -634,6 +635,49 @@ app = Sammy('#main', function (sam) { }); + /** + * Tools + * + */ + + sam.get('#/tools', function (c) { + // Available tools + data = {links: [ + {name: "Change administration password", path: '#/tools/adminpw'}, + ]}; + c.view('tools_list', data); + }); + + // Update administration password + sam.get('#/tools/adminpw', function (c) { + c.view('tools_adminpw'); + }); + sam.put('#/tools/adminpw', function (c) { + params = {} + $.each(c.params.toHash(), function(key, value) { + if (value !== '') { params[key] = value; } + }); + if ($.isEmptyObject(params)) { + c.flash('fail', 'You should modify something'); + store.clear('slide'); + c.redirect('#/tools/adminpw'); + } else if (params['new_password'] !== params['confirm_new_password']) { + c.flash('fail', 'Your password didn\'t match'); + store.clear('slide'); + c.redirect('#/tools/adminpw'); + } else { + // Remove useless variable + delete params['confirm_new_password']; + // Update password and redirect to the home + c.api('/adminpw', function(data) { // http://api.yunohost.org/#!/tools/tools_adminpw_put_3 + c.redirect('#/'); + }, 'PUT', params); + } + }); + + + + }); diff --git a/views/tools_adminpw.ms b/views/tools_adminpw.ms new file mode 100644 index 00000000..f2813dc0 --- /dev/null +++ b/views/tools_adminpw.ms @@ -0,0 +1,38 @@ +
+ Tools +
+
+
Change administration password
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
diff --git a/views/tools_list.ms b/views/tools_list.ms new file mode 100644 index 00000000..545ce8a0 --- /dev/null +++ b/views/tools_list.ms @@ -0,0 +1,18 @@ +
+ Menu +
+
+
Tools
+
+ + +
+{{#links}} + +

{{name}}

+ +
+
+{{/links}} +
+