Skip to content

Commit 549ce7f

Browse files
committed
add How-to & Signout modal
1 parent c72b544 commit 549ce7f

12 files changed

Lines changed: 113 additions & 10 deletions

File tree

src/browser/main/controllers/directives/SideNavController.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global angular */
22
angular.module('codexen')
3-
.controller('SideNavController', function ($auth, User, $rootScope, $scope) {
3+
.controller('SideNavController', function ($auth, User, $rootScope, $scope, Modal) {
44
var vm = this
55

66
vm.isAuthenticated = $auth.isAuthenticated()
@@ -16,11 +16,7 @@ angular.module('codexen')
1616
reloadUser()
1717

1818
vm.signOut = function () {
19-
$auth.logout()
20-
.then(function () {
21-
console.log('Sign Out')
22-
$rootScope.$broadcast('userSignOut')
23-
})
19+
Modal.signOut()
2420
}
2521

2622
$scope.$on('userSignIn', function () {
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+
.controller('SignOutModalController', function ($modalInstance) {
4+
var vm = this
5+
6+
vm.submit = function () {
7+
$modalInstance.close()
8+
}
9+
10+
vm.cancel = function () {
11+
$modalInstance.dismiss('cancel')
12+
}
13+
})

src/browser/main/controllers/states/AuthSignInController.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ angular.module('codexen')
33
.controller('AuthSignInController', function ($auth, $rootScope) {
44
var vm = this
55

6+
vm.authFailed = false
7+
68
vm.signIn = function () {
9+
vm.authFailed = false
710
$auth.login({
811
email: vm.email,
912
password: vm.password
1013
}).then(function (data) {
1114
console.log(data)
1215
$rootScope.$broadcast('userSignIn')
16+
}, function (err) {
17+
console.log(err)
18+
vm.authFailed = true
1319
})
1420
}
1521
})

src/browser/main/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<script src="../vendor/angular-md5.js"></script>
3535
<script src="../vendor/moment.js"></script>
3636
<script src="../vendor/marked.js"></script>
37+
<script src="../vendor/hotkeys.js" charset="utf-8"></script>
3738

3839
<!-- inject:js -->
3940
<script src="app.js"></script>
@@ -76,6 +77,7 @@
7677
<script src="controllers/modals/NewRecipeModalController.js"></script>
7778
<script src="controllers/modals/NewSnippetModalController.js"></script>
7879
<script src="controllers/modals/SelectSnippetModalController.js"></script>
80+
<script src="controllers/modals/SignOutModalController.js"></script>
7981
<script src="../shared/shared.js"></script>
8082
<script src="../shared/config/ace.js"></script>
8183
<script src="../shared/config/env.js"></script>

src/browser/main/index.inject.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<script src="../vendor/angular-md5.js"></script>
3333
<script src="../vendor/moment.js"></script>
3434
<script src="../vendor/marked.js"></script>
35+
<script src="../vendor/hotkeys.js" charset="utf-8"></script>
3536

3637
<!-- inject:js -->
3738
<!-- endinject -->

src/browser/main/services/Modal.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
/* global angular */
22
angular.module('codexen')
3-
.factory('Modal', function ($modal, $rootScope) {
3+
.factory('Modal', function ($modal, $rootScope, $auth) {
4+
var signOut = function () {
5+
return $modal.open({
6+
templateUrl: 'tpls/modals/sign-out-modal.html',
7+
controller: 'SignOutModalController as vm'
8+
}).result.then(function () {
9+
$auth.logout()
10+
.then(function () {
11+
console.log('Sign Out')
12+
$rootScope.$broadcast('userSignOut')
13+
})
14+
})
15+
}
16+
417
/* Recipe */
518
var newRecipe = function () {
619
return $modal.open({
@@ -98,6 +111,7 @@ angular.module('codexen')
98111
}
99112

100113
return {
114+
signOut: signOut,
101115
newRecipe: newRecipe,
102116
editRecipe: editRecipe,
103117
deleteRecipe: deleteRecipe,

src/browser/main/styles/app.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ body > .ui-select-bootstrap.open {
274274
.home-state {
275275
padding: 10px;
276276
}
277+
.home-state p {
278+
margin: 5px auto 15px;
279+
}
280+
.home-state ol {
281+
margin: 35px auto;
282+
}
283+
.home-state li {
284+
margin-bottom: 25px;
285+
}
277286
.settings-state .panel {
278287
margin-top: 15px;
279288
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
.home-state
22
padding 10px
3+
p
4+
margin 5px auto 15px
5+
ol
6+
margin 35px auto
7+
li
8+
margin-bottom 25px
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="new-snippet-modal">
2+
<div class="modal-header">
3+
<h4>Sign Out</h4>
4+
</div>
5+
6+
<div class="modal-body">
7+
<p>
8+
Are you sure to sign out?
9+
</p>
10+
</div>
11+
12+
<div class="modal-footer">
13+
<button ng-click="vm.submit()" type="button" name="button" class="btn btn-danger">Sign Out</button>
14+
<button ng-click="vm.cancel()" type="button" name="button" class="btn btn-default">Cancel</button>
15+
</div>
16+
</div>

src/browser/main/tpls/states/auth.signin.tpl.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<form ng-submit="vm.signIn()">
2+
<p ng-if="vm.authFailed" class="alert alert-danger">
3+
Incorrect email or password entered. Please try again.
4+
</p>
25
<div class="form-group">
36
<label for="email">E-mail</label>
47
<input ng-model="vm.email" type="text" id="email" name="name" class="form-control" placeholder="E-mail">

0 commit comments

Comments
 (0)