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:
parent
f51391f4b9
commit
b49830adbe
6 changed files with 63 additions and 50 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* Declare app level module */
|
/* Declare app level module */
|
||||||
angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize',
|
angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize',
|
||||||
'jamstash.subsonic.ctrl'])
|
'jamstash.subsonic.ctrl', 'jamstash.archive.ctrl'])
|
||||||
|
|
||||||
.config(['$routeProvider',function($routeProvider) {
|
.config(['$routeProvider',function($routeProvider) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -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) {
|
function($rootScope, $http, $q, $sce, globals, model, utils, map, notifications) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -17,7 +24,7 @@ angular.module('JamStash').factory('archive', ['$rootScope, $http, $q, $sce, glo
|
||||||
|
|
||||||
var mapAlbum = function (data) {
|
var mapAlbum = function (data) {
|
||||||
var song = 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;
|
var url = globals.archiveUrl + 'details/' + song.identifier;
|
||||||
coverartthumb = 'images/albumdefault_50.jpg';
|
coverartthumb = 'images/albumdefault_50.jpg';
|
||||||
coverartfull = 'images/albumdefault_160.jpg';
|
coverartfull = 'images/albumdefault_160.jpg';
|
||||||
|
@ -71,7 +78,7 @@ angular.module('JamStash').factory('archive', ['$rootScope, $http, $q, $sce, glo
|
||||||
timeout: globals.settings.Timeout,
|
timeout: globals.settings.Timeout,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.response.docs.length > 0) {
|
if (data.response.docs.length > 0) {
|
||||||
items = data.response.docs;
|
var items = data.response.docs;
|
||||||
//alert(JSON.stringify(data["response"]));
|
//alert(JSON.stringify(data["response"]));
|
||||||
content.artist = [];
|
content.artist = [];
|
||||||
angular.forEach(items, function (item, key) {
|
angular.forEach(items, function (item, key) {
|
||||||
|
|
|
@ -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){
|
function($scope, $rootScope, $location, $routeParams, $http, $timeout, utils, globals, model, notifications, player, archive, json){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,8 @@
|
||||||
} else {
|
} else {
|
||||||
var el = $(pl);
|
var el = $(pl);
|
||||||
var off = el.offset();
|
var off = el.offset();
|
||||||
width = el.width();
|
var width = el.width();
|
||||||
height = el.height();
|
var height = el.height();
|
||||||
switch (pos) {
|
switch (pos) {
|
||||||
case 'right':
|
case 'right':
|
||||||
//show the menu to the right of placeholder
|
//show the menu to the right of placeholder
|
||||||
|
@ -391,56 +391,18 @@
|
||||||
$rootScope.queue.push(data);
|
$rootScope.queue.push(data);
|
||||||
};
|
};
|
||||||
$rootScope.removeSong = function (item, songs) {
|
$rootScope.removeSong = function (item, songs) {
|
||||||
var index = songs.indexOf(item)
|
var index = songs.indexOf(item);
|
||||||
songs.splice(index, 1);
|
songs.splice(index, 1);
|
||||||
};
|
};
|
||||||
$scope.removeSongFromQueue = function (item) {
|
$scope.removeSongFromQueue = function (item) {
|
||||||
var index = $rootScope.queue.indexOf(item)
|
var index = $rootScope.queue.indexOf(item)
|
||||||
$rootScope.queue.splice(index, 1);
|
$rootScope.queue.splice(index, 1);
|
||||||
}
|
};
|
||||||
$scope.isActive = function (route) {
|
$scope.isActive = function (route) {
|
||||||
return route === $location.path();
|
return route === $location.path();
|
||||||
};
|
};
|
||||||
$rootScope.getSplitPosition = function (scope, elm) {
|
$rootScope.getSplitPosition = function (scope, elm) {
|
||||||
alert(elm.getBoundingClientRect().left);
|
window.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
$scope.download = function (id) {
|
$scope.download = function (id) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
BIN
app/images/pin_gl_12x12.png
Normal file
BIN
app/images/pin_gl_12x12.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 291 B |
|
@ -300,7 +300,7 @@ angular.module('jamstash.subsonic.ctrl', ['jamstash.subsonic.service'])
|
||||||
notifications.updateMessage(errorNotif, true);
|
notifications.updateMessage(errorNotif, true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
$scope.getRandomSongs = function (action, genre, folder) {
|
$rootScope.getRandomSongs = function (action, genre, folder) {
|
||||||
subsonic.getRandomSongs(action, genre, folder).then(function (data) {
|
subsonic.getRandomSongs(action, genre, folder).then(function (data) {
|
||||||
$scope.album = data.album;
|
$scope.album = data.album;
|
||||||
$scope.song = data.song;
|
$scope.song = data.song;
|
||||||
|
@ -396,6 +396,44 @@ angular.module('jamstash.subsonic.ctrl', ['jamstash.subsonic.service'])
|
||||||
$scope.selectedPodcast = data.selectedPodcast;
|
$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 */
|
/* Launch on Startup */
|
||||||
$scope.getArtists();
|
$scope.getArtists();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue