Skip to content

Commit ad27b9b

Browse files
author
frostwind
committed
Added all tests page
Added underscore dependency
1 parent 25a9a8d commit ad27b9b

File tree

13 files changed

+1660
-21
lines changed

13 files changed

+1660
-21
lines changed

Diff for: assets/index.html

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ <h1>
3232
<li>
3333
<a href="/#/tests">All my tests</a>
3434
</li>
35-
<li>
36-
<a href="/#/settings">Settings</a>
37-
</li>
3835
</ul>
3936
</nav>
4037
</div>

Diff for: assets/javascripts/controllers/all_tests.coffee

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
_ = require 'underscore'
2+
3+
module.exports = class
4+
@$inject: ['$scope', '$http', '$routeParams', '$location', '$websocket']
5+
constructor: (@scope, @http, @params, @location, @socket) ->
6+
@scope.tests = []
7+
8+
@http.get '/api/tests'
9+
.success (res) =>
10+
@scope.tests = res
11+
12+
angular.extend @scope,
13+
delete: @delete
14+
15+
delete: (id) =>
16+
@http.delete '/api/tests/'+id
17+
.success (res) =>
18+
@scope.tests = _(@scope.tests).reject (test) ->
19+
id is test._id

Diff for: assets/javascripts/index.coffee

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ class Config
1414
controller: 'NewTestController'
1515

1616
.when '/tests',
17-
templateUrl: 'views/tests.html'
17+
templateUrl: 'views/all_tests.html'
18+
controller: 'AllTestsController'
1819

1920
.when '/tests/:id',
2021
templateUrl: 'views/start_test.html'
2122
controller: 'StartTestController'
2223

23-
.when '/settings',
24-
templateUrl: 'views/settings.html'
25-
2624
.otherwise
2725
redirectTo: '/'
2826

Diff for: assets/javascripts/modules/app.controllers.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
app = angular.module 'app.controllers', []
22

33
app.controller 'NewTestController', require '../controllers/new_test'
4+
app.controller 'AllTestsController', require '../controllers/all_tests'
45
app.controller 'StartTestController', require '../controllers/start_test'
56

67
module.exports = app

Diff for: assets/stylesheets/colors.styl

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
$blue = #00aaea
22
$green = #009999
3+
$red = #c33434
34
$very-light-grey = #c0c0c0
45
$light-grey = #fafafa
56
$grey = #959595

Diff for: assets/stylesheets/main.styl

+27
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,30 @@ main > footer
211211
background $light-grey
212212
td, th
213213
padding remify(6) 0 remify(6) remify(6)
214+
215+
#all-tests
216+
margin-top remify(38)
217+
218+
.test
219+
col(1/3, cycle:3)
220+
background $light-grey
221+
border 1px solid $very-light-grey
222+
border-radius 4px
223+
padding remify(12) remify(24)
224+
margin-bottom remify(24)
225+
226+
h3
227+
text-transform uppercase
228+
.buttons
229+
float right
230+
a
231+
font-weight bold
232+
color $blue
233+
text-decoration underline
234+
margin 0 remify(6)
235+
&:nth-child(1)
236+
color $green
237+
&:nth-child(2)
238+
color $blue
239+
&:nth-child(3)
240+
color $red

Diff for: assets/views/all_tests.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<section class="subheader">
2+
<div class="container">
3+
<h2>View all my tests</h2>
4+
</div>
5+
</section>
6+
7+
<section id="all-tests">
8+
<div class="container">
9+
<div class="test" ng-repeat="test in tests">
10+
<h3>{{test.name}}</h3>
11+
<div class="buttons">
12+
<a ng-href="/#/tests/{{test._id}}">Start</a>
13+
<a ng-href="/#/tests/{{test._id}}/edit">Edit</a>
14+
<a href="" ng-click="delete(test._id)">Delete</a>
15+
</div>
16+
</div>
17+
</div>
18+
</section>

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"gulp-connect": "^2.2.0",
3333
"gulp-stylus": "^2.0.0",
3434
"jeet": "^6.1.2",
35+
"underscore": "^1.7.0",
3536
"vinyl-source-stream": "^1.0.0",
3637
"ws": "^0.7.0"
3738
}

Diff for: static/index.html

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ <h1>
3232
<li>
3333
<a href="/#/tests">All my tests</a>
3434
</li>
35-
<li>
36-
<a href="/#/settings">Settings</a>
37-
</li>
3835
</ul>
3936
</nav>
4037
</div>

0 commit comments

Comments
 (0)