Skip to content

Commit

Permalink
Adding where support for models API and added Sources page
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyfox committed Aug 4, 2017
1 parent b131189 commit 12eddc7
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 170 deletions.
307 changes: 140 additions & 167 deletions .idea/workspace.xml

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions routes/v1/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ router.get('/:model', function(req, res, next) {
res.status(400).send(`Model [${req.params.model}] does not exist`);
return;
}

model.findAll().then(function (data) {
console.log(req.query);
model.findAll({ where: req.query }).then(function (data) {
"use strict";
res.send(data);
}).catch(function (error) {
res.status(400).send(`[${error.name}] ${error.original.code}`);
});

});
Expand Down
3 changes: 2 additions & 1 deletion www/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ angular.module('naranawm', [
'ngRoute',
'ngResource',
'naranawm.languages',
'naranawm.sources',
'naranawm.view1',
'naranawm.view2',
'naranawm.version',
'ui.bootstrap'
]).
config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$routeProvider.otherwise({redirectTo: '/view2'});
$routeProvider.otherwise({redirectTo: '/languages'});
}]);
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="languages/languages.js"></script>
<script src="sources/sources.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
Expand Down
21 changes: 21 additions & 0 deletions www/sources/sources.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="page-header">
<h1>Sources</h1>
</div>
<div class="col-md-12">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Language</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in sources">
<td>{{ row.name }}</td>
<td>{{ row.description }}</td>
<td>{{ row.LanguageIsoCode }}</td>
</tr>
</tbody>
</table>
</div>
16 changes: 16 additions & 0 deletions www/sources/sources.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

angular.module('naranawm.sources', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/sources', {
templateUrl: 'sources/sources.html',
controller: 'SourcesCtrl'
});
}])

.controller('SourcesCtrl', ["$scope", "Models", function($scope, Models) {
$scope.sources = Models.query({model: "Source"}, function() {

}); //query() returns all the entries
}]);

0 comments on commit 12eddc7

Please sign in to comment.