more angular fun
This commit is contained in:
parent
cca99e23b7
commit
93868e0d18
3 changed files with 38 additions and 7 deletions
|
|
@ -215,6 +215,14 @@ public class AlbumServlet
|
|||
return;
|
||||
}
|
||||
|
||||
if ("/_roots.json".equals(pathInfo)) {
|
||||
res.setContentType("application/json");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = res.getWriter();
|
||||
out.append("[\"").append(base.getName()).append("\"]");
|
||||
return;
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > nextCacheRefresh) {
|
||||
cachedRootNode = null;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,29 @@
|
|||
|
||||
var album = angular.module("album", [ ]);
|
||||
|
||||
album.controller("AlbumController", ["$http", "$log", function($http, $log) {
|
||||
album.controller("AlbumController", ["$http", "$log", "$scope", function($http, $log, $scope) {
|
||||
var alb = this;
|
||||
this.roots = [ ];
|
||||
this.items = [ ];
|
||||
this.update = function() {
|
||||
$log.info("updating...");
|
||||
$http.get("/photo/album/Downloads.json").success(function(data) {
|
||||
alb.items = data.contents;
|
||||
});
|
||||
if (alb.roots.length == 0) {
|
||||
$http.get("/photo/album/_roots.json").success(function(data) {
|
||||
alb.roots = data;
|
||||
alb.update();
|
||||
});
|
||||
} else {
|
||||
$http.get("/photo/album/" + alb.roots[0] + ".json").success(function(data) {
|
||||
alb.items = data.contents;
|
||||
for (var i = 0; i < alb.items.length; i++) {
|
||||
if (alb.items[i].type == "movie") {
|
||||
alb.items[i].path += ".frame";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
$scope.$watch('$viewContentLoaded', function(){
|
||||
alb.update();
|
||||
});
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,18 @@
|
|||
<head>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script>
|
||||
<script src="album.js"></script>
|
||||
<style type="text/css">
|
||||
.grid {
|
||||
float: left;
|
||||
max-width: 275px;
|
||||
height: 310px;
|
||||
max-height: 310px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body ng-controller="AlbumController as album">
|
||||
<h1>Album</h1>
|
||||
<form><input type="button" ng-click="album.update()" value="Update" /></form>
|
||||
<div ng-repeat="item in album.items">
|
||||
<h1>{{ album.roots[0] }}</h1>
|
||||
<div ng-repeat="item in album.items" class="grid">
|
||||
<img ng-src="/photo/album{{ item.path }}?size=250"/>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue