Separates the Archive controller and service into their own modules.

Moves $scope.getMusicFolders to the Subsonic controller since its only used by it. It also made the tests crash :p

Adds variable declarations where they were missing. It causes an error with "use strict".
This commit is contained in:
Hyzual 2014-11-09 18:11:16 +01:00
parent f51391f4b9
commit b49830adbe
6 changed files with 63 additions and 50 deletions

View file

@ -1,7 +1,7 @@
/* Declare app level module */
angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize',
'jamstash.subsonic.ctrl'])
'jamstash.subsonic.ctrl', 'jamstash.archive.ctrl'])
.config(['$routeProvider',function($routeProvider) {
'use strict';

View file

@ -1,4 +1,11 @@
angular.module('JamStash').factory('archive', ['$rootScope, $http, $q, $sce, globals, model, utils, map, notifications',
/**
* jamstash.archive.service Module
*
* Access Archive.org
*/
angular.module('jamstash.archive.service', ['jamstash.settings', 'jamstash.model', 'jamstash.notifications'])
.factory('archive', ['$rootScope', '$http', '$q', '$sce', 'globals', 'model', 'utils', 'map', 'notifications',
function($rootScope, $http, $q, $sce, globals, model, utils, map, notifications) {
'use strict';
@ -17,7 +24,7 @@ angular.module('JamStash').factory('archive', ['$rootScope, $http, $q, $sce, glo
var mapAlbum = function (data) {
var song = data;
var coverartthumb, coverartfull, starred, title, album, publisher, avg_rating, downloads, identifier;
var coverartthumb, coverartfull, starred, title, album, publisher, avg_rating, downloads, identifier, source, date;
var url = globals.archiveUrl + 'details/' + song.identifier;
coverartthumb = 'images/albumdefault_50.jpg';
coverartfull = 'images/albumdefault_160.jpg';
@ -71,7 +78,7 @@ angular.module('JamStash').factory('archive', ['$rootScope, $http, $q, $sce, glo
timeout: globals.settings.Timeout,
success: function (data) {
if (data.response.docs.length > 0) {
items = data.response.docs;
var items = data.response.docs;
//alert(JSON.stringify(data["response"]));
content.artist = [];
angular.forEach(items, function (item, key) {

View file

@ -1,5 +1,11 @@
angular.module('JamStash')
.controller('ArchiveCtrl', ['$scope, $rootScope, $location, $routeParams, $http, $timeout, utils, globals, model, notifications, player, archive, json',
/**
* jamstash.archive.ctrl Module
*
* Access Archive.org
*/
angular.module('jamstash.archive.ctrl', ['jamstash.archive.service'])
.controller('ArchiveCtrl', ['$scope', '$rootScope', '$location', '$routeParams', '$http', '$timeout', 'utils', 'globals', 'model', 'notifications', 'player', 'archive', 'json',
function($scope, $rootScope, $location, $routeParams, $http, $timeout, utils, globals, model, notifications, player, archive, json){
'use strict';

View file

@ -92,8 +92,8 @@
} else {
var el = $(pl);
var off = el.offset();
width = el.width();
height = el.height();
var width = el.width();
var height = el.height();
switch (pos) {
case 'right':
//show the menu to the right of placeholder
@ -391,56 +391,18 @@
$rootScope.queue.push(data);
};
$rootScope.removeSong = function (item, songs) {
var index = songs.indexOf(item)
var index = songs.indexOf(item);
songs.splice(index, 1);
};
$scope.removeSongFromQueue = function (item) {
var index = $rootScope.queue.indexOf(item)
$rootScope.queue.splice(index, 1);
}
};
$scope.isActive = function (route) {
return route === $location.path();
};
$rootScope.getSplitPosition = function (scope, elm) {
alert(elm.getBoundingClientRect().left);
};
$scope.getMusicFolders = function () {
$.ajax({
url: globals.BaseURL() + '/getMusicFolders.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (data["subsonic-response"].musicFolders.musicFolder !== undefined) {
var folders = [];
if (data["subsonic-response"].musicFolders.musicFolder.length > 0) {
folders = data["subsonic-response"].musicFolders.musicFolder;
} else {
folders[0] = data["subsonic-response"].musicFolders.musicFolder;
}
folders.unshift({
"id": -1,
"name": "All Folders"
});
$rootScope.MusicFolders = folders;
if (utils.getValue('MusicFolders')) {
var folder = angular.fromJson(utils.getValue('MusicFolders'));
var i = 0, index = "";
angular.forEach($rootScope.MusicFolders, function (item, key) {
if (item.id == folder.id) {
index = i;
}
i++;
});
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[index];
} else {
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[0];
}
$scope.$apply();
}
}
});
window.alert(elm.getBoundingClientRect().left);
};
$scope.download = function (id) {
$.ajax({

BIN
app/images/pin_gl_12x12.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

View file

@ -300,7 +300,7 @@ angular.module('jamstash.subsonic.ctrl', ['jamstash.subsonic.service'])
notifications.updateMessage(errorNotif, true);
});
};
$scope.getRandomSongs = function (action, genre, folder) {
$rootScope.getRandomSongs = function (action, genre, folder) {
subsonic.getRandomSongs(action, genre, folder).then(function (data) {
$scope.album = data.album;
$scope.song = data.song;
@ -396,6 +396,44 @@ angular.module('jamstash.subsonic.ctrl', ['jamstash.subsonic.service'])
$scope.selectedPodcast = data.selectedPodcast;
});
};
$scope.getMusicFolders = function () {
$.ajax({
url: globals.BaseURL() + '/getMusicFolders.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (data["subsonic-response"].musicFolders.musicFolder !== undefined) {
var folders = [];
if (data["subsonic-response"].musicFolders.musicFolder.length > 0) {
folders = data["subsonic-response"].musicFolders.musicFolder;
} else {
folders[0] = data["subsonic-response"].musicFolders.musicFolder;
}
folders.unshift({
"id": -1,
"name": "All Folders"
});
$rootScope.MusicFolders = folders;
if (utils.getValue('MusicFolders')) {
var folder = angular.fromJson(utils.getValue('MusicFolders'));
var i = 0, index = "";
angular.forEach($rootScope.MusicFolders, function (item, key) {
if (item.id == folder.id) {
index = i;
}
i++;
});
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[index];
} else {
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[0];
}
$scope.$apply();
}
}
});
};
/* Launch on Startup */
$scope.getArtists();