(function () { "use strict"; var AlbumController = function ($scope, albumsService) { $scope.model = { newAlbum: false }; $scope.message = ["You can not undo deleting an album."]; $scope.getAlbums = function () { albumsService.getAlbums().then(function (data) { $scope.albums = data; }); }; $scope.remove = function (album) { albumsService.delete(album.albumId).then(function () { let index = $scope.albums.findIndex(x => x.albumId === album.albumId); if (index >= 0) { $scope.albums.splice(index, 1); } }); }; $scope.rename = function (album) { album.rename = !album.rename; album.tempName = album.Name; }; $scope.saveName = function (album) { if (album.tempName && album.tempName.length) { albumsService.update(album.albumId, album.tempName, album.archive).then(function () { album.Name = album.tempName; album.rename = false; }); } }; $scope.archive = function (album) { /*albumsService.update(album.albumId, album.Name, album.archive);*/ }; $scope.deleteDialog = function (album) { album.remove = true; }; $scope.getAlbums(); $scope.addNewAlbum = function () { $scope.model.newAlbum = true; }; $('.waiting').hide(); }; AlbumController.$inject = ['$scope', 'albumsService']; angular.module('streamApp').controller("albumsController", AlbumController); }());