Skip to content

Commit 4094fff

Browse files
committed
add settings/password_change state
1 parent a3ae5f0 commit 4094fff

8 files changed

Lines changed: 102 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"short code"
2626
],
2727
"author": "Dick Choi <fluke8259@gmail.com> (http://kazup.co)",
28-
"license": "ISC",
28+
"license": "No License",
2929
"bugs": {
3030
"url": "https://github.com/Rokt33r/codexen-app/issues"
3131
},

src/config/states.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ angular.module('codexen')
2727
controller: 'AuthSignInController as vm'
2828
})
2929

30+
.state('settings', {
31+
url: '/settings',
32+
views: {
33+
'main-view': {
34+
templateUrl: 'tpls/states/settings.tpl.html',
35+
controller: 'SettingsController as vm'
36+
}
37+
}
38+
})
39+
3040
/* Snippets */
3141
.state('snippets', {
3242
url: '/snippets',
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* global angular */
2+
angular.module('codexen')
3+
.controller('SettingsController', function (Settings) {
4+
var vm = this
5+
6+
vm.changePassword = changePassword
7+
vm.isSuccess = false
8+
vm.isError = false
9+
10+
function changePassword () {
11+
var params = {
12+
password: vm.password,
13+
newPassword: vm.newPassword
14+
}
15+
16+
Settings.changePassword(params)
17+
.success(function (data) {
18+
resetInput()
19+
vm.isSuccess = true
20+
vm.isError = false
21+
})
22+
.error(function () {
23+
resetInput()
24+
vm.isError = true
25+
vm.isSuccess = false
26+
})
27+
}
28+
29+
function resetInput () {
30+
vm.password = ''
31+
vm.newPassword = ''
32+
}
33+
})

src/services/Settings.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* global angular */
2+
angular.module('codexen')
3+
.factory('Settings', function ($http, apiUrl) {
4+
var changePassword = function (params) {
5+
var url = apiUrl + 'settings/change_password'
6+
7+
return $http.post(url, params)
8+
}
9+
10+
return {
11+
changePassword: changePassword
12+
}
13+
})

src/styles/_index.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ h1, h2, h3, h4, h5
2121
textarea
2222
resize: vertical
2323

24+
hr
25+
border-color $baseBorderColor
26+
2427
#side-view
2528
position:absolute
2629
top: 0

src/styles/states/settings.styl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.settings-state
2+
.panel
3+
margin-top 15px
4+
h1
5+
margin 30px 0
6+
.section
7+
h4
8+
margin-bottom 15px

src/tpls/directives/side-nav.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<img width="30" class="img-circle" ng-src="http://www.gravatar.com/avatar/{{ vm.currentUser.email | gravatar }}">
44
<a href ng-bind="vm.currentUser.name"></a>
55
<span class="nav-control-group pull-right">
6-
<a href class="btn btn-sm btn-default"><i class="fa fa-gears fa-fw"></i></a>
6+
<a ui-sref="settings" class="btn btn-sm btn-default" ui-sref-active="active"}"><i class="fa fa-gears fa-fw"></i></a>
77
<a href class="btn btn-sm btn-default" ng-click="vm.signOut()"><i class="fa fa-sign-out fa-fw"></i></a>
88
</span>
99

src/tpls/states/settings.tpl.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<div class="settings-state container-fluid">
2+
<div class="row">
3+
<div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-lg-6 col-lg-offset-3 panel panel-default">
4+
<h1><i class="fa fa-gears"></i> Settings</h1>
5+
<p>
6+
Some settings...
7+
</p>
8+
<hr>
9+
<div class="section">
10+
<h4>Change Password</h4>
11+
<form ng-submit="vm.changePassword()">
12+
<alert type="success" ng-show="vm.isSuccess" close="vm.isSuccess=false">
13+
Successfully changed!!
14+
</alert>
15+
<alert type="danger" ng-show="vm.isError" close="vm.isError=false">
16+
Request failed!!
17+
</alert>
18+
<div class="form-group">
19+
<label for="password">Current Password</label>
20+
<input ng-model="vm.password" class="form-control" type="password" name="password" placeholder="Current Password">
21+
</div>
22+
<div class="form-group">
23+
<label for="newPassword"> New Password</label>
24+
<input ng-model="vm.newPassword" class="form-control" type="password" name="newPassword" placeholder="New Password">
25+
</div>
26+
<div class="form-group">
27+
<button type="submit" class="btn btn-primary form-control">Change Password</button>
28+
</div>
29+
</form>
30+
</div>
31+
</div>
32+
</div>
33+
</div>

0 commit comments

Comments
 (0)