(function () { "use strict"; angular.module('streamApp').controller("albumController", AlbumController); AlbumController.$inject = ['$scope', 'streamService', 'albumsService', '$routeParams', '$location']; function AlbumController($scope, streamService, albumsService, $routeParams, $location) { $scope.id = $routeParams.id || 0; $scope.albumSelected = $scope.id; if ($scope.id) { albumsService.get($scope.id).then((album) => { album.Id = album.albumId; $scope.album = album; }); } albumsService.getAlbums().then((albums) => { if (!$scope.id) { $scope.album = $scope.albums[0] || {}; $scope.Id = $scope.album.albumId; } let id = parseInt($scope.id); $scope.albums = albums.map(x => { return { Id: x.albumId, Name: x.Name, Selected: x.albumId === id }; }); }); $scope.selectAlbum = function () { $scope.showSelectAlbum = !$scope.showSelectAlbum; } $scope.updateAlbum = function (item) { $scope.selectAlbum(); $location.url('/album/' + item.Id); } $scope.export = function () { albumsService.export($scope.id).then(data => data); } $scope.callback = streamService.getAlbum; } })();