pt. 3a - AngularJS basic code

This commit is contained in:
2015-11-24 20:18:51 +01:00
parent a0bb8c7001
commit b83f1b42df
7 changed files with 112 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
body {
padding-top: 20px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
.burp {
margin-bottom: 2em;
}
.burp .date {
text-decoration: underline overline;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+24
View File
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html ng-app="burpApp">
<head>
<meta charset="utf-8">
<title>BURP: Bayer Ubiquitous Rating Platform</title>
<link rel="stylesheet" href="css/app.css">
<script src="js/angular.min.js"></script>
<script src="js/angular-route.min.js"></script>
<script src="js/angular-resource.min.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
</head>
<body>
<div ng-view></div>
</body>
</html>
+13
View File
@@ -0,0 +1,13 @@
var burpApp = angular.module('burpApp', ['ngRoute', 'burpControllers' ]);
burpApp.config([ '$routeProvider', function($routeProvider) {
$routeProvider.when('/list', {
templateUrl : 'partials/list.html',
controller : 'BurpListCtrl'
}).when('/tag/:taggedBurps*', {
templateUrl : 'partials/tag.html',
controller : 'TagCtrl'
}).otherwise({
redirectTo : '/list'
});
} ]);
@@ -0,0 +1,29 @@
var burpControllers = angular.module('burpControllers', ['ngResource']);
burpControllers.controller('BurpListCtrl', [ '$scope', '$resource', function($scope, $resource) {
var burps = $resource('/burps/search/findFirst8ByOrderByTimestampDesc').get();
burps.$promise.then(function(data) {
$scope.burps = burps._embedded.burps;
for (var i = 0; i < $scope.burps.length; i++) {
$scope.burps[i].user = $resource($scope.burps[i]._links.user.href).get();
$scope.burps[i].tags = $resource($scope.burps[i]._links.tags.href).get();
}
});
} ]);
burpControllers.controller('TagCtrl', [ '$scope', '$routeParams', '$resource', function($scope, $routeParams, $resource) {
var burpsList = $resource($routeParams.taggedBurps).get();
burpsList.$promise.then(function(data) {
$scope.burps = burpsList._embedded.burps;
for (var i = 0; i < $scope.burps.length; i++) {
$scope.burps[i].user = $resource($scope.burps[i]._links.user.href).get();
$scope.burps[i].tags = $resource($scope.burps[i]._links.tags.href).get();
}
});
} ]);
@@ -0,0 +1,19 @@
<div>
<div>
<div>
<div class="burp" ng-repeat="burp in burps">
<div class="user">{{burp.user.name}}</div>
<div class="date">{{burp.timestamp | date:'HH:mm:ss dd.MM.yyyy'}}</div>
<div class="text">{{burp.text}}</div>
<span class="tag" ng-repeat="tag in burp.tags._embedded.tags">
<a href="#/tag/{{tag._links.burps.href}}">#{{tag.name}}</a>
</span>
</div>
<div>
<pre style="font-size: 75%">{{burps | json}}</pre>
</div>
</div>
</div>
</div>
@@ -0,0 +1,15 @@
<div>
<div>
<div>
<div class="burp" ng-repeat="burp in burps">
<div class="user">{{burp.user.name}}</div>
<div class="date">{{burp.timestamp | date:'HH:mm:ss dd.MM.yyyy'}}</div>
<div class="text">{{burp.text}}</div>
<span class="tag" ng-repeat="tag in burp.tags._embedded.tags">
<a href="#/tag/{{tag._links.burps.href}}">#{{tag.name}}</a>
</span>
</div>
</div>
</div>
</div>