Removes duplicate "globals" service and adds it into its own globals-service.js file.
Adds unit tests for the two functions BaseURL and BaseParams Conflicts: js/service.js
This commit is contained in:
parent
d6104aa573
commit
f57b969e55
4 changed files with 88 additions and 99 deletions
38
js/app.js
38
js/app.js
|
@ -2,44 +2,6 @@
|
|||
var JamStash = angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize']);
|
||||
//var JamStash = angular.module('JamStash', ['ngCookies', 'ngRoute']);
|
||||
|
||||
JamStash.service('globals', function (utils) {
|
||||
this.settings = {
|
||||
// Subsonic
|
||||
/* Demo Server
|
||||
Username: "android-guest"),
|
||||
Password: "guest"),
|
||||
Server: "http://subsonic.org/demo"),
|
||||
*/
|
||||
Url: "http://beta.jamstash.com/#/archive/",
|
||||
Username: "",
|
||||
Password: "",
|
||||
Server: "",
|
||||
Timeout: 10000,
|
||||
Protocol: "jsonp",
|
||||
ApplicationName: "Jamstash",
|
||||
ApiVersion: "1.6.0",
|
||||
AutoPlaylists: "",
|
||||
AutoPlaylistSize: 25,
|
||||
AutoAlbumSize: 15,
|
||||
// General
|
||||
HideAZ: false,
|
||||
ScrollTitle: true,
|
||||
NotificationSong: true,
|
||||
NotificationNowPlaying: false,
|
||||
SaveTrackPosition: false,
|
||||
ForceFlash: false,
|
||||
Theme: "Default",
|
||||
DefaultLibraryLayout: "grid",
|
||||
AutoPlay: false,
|
||||
LoopQueue: false,
|
||||
Repeat: false,
|
||||
Debug: false
|
||||
};
|
||||
this.DefaultCollection = [];
|
||||
this.SavedGenres = [];
|
||||
this.BaseURL = function () { return this.settings.Server + '/rest'; };
|
||||
this.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };
|
||||
});
|
||||
/*
|
||||
JamStash.config(function ($sceDelegateProvider) {
|
||||
$sceDelegateProvider.resourceUrlWhitelist(['/^\s*(https?|file|ms-appx):/', 'self']);
|
||||
|
|
|
@ -75,67 +75,6 @@
|
|||
};
|
||||
});
|
||||
|
||||
JamStash.service('globals', function () {
|
||||
this.SearchTypes = [
|
||||
{ id: "song", name: "Song" },
|
||||
{ id: "album", name: "Album" },
|
||||
{ id: "artist", name: "Artist" }
|
||||
];
|
||||
this.Layouts = [
|
||||
{ id: "grid", name: "Grid" },
|
||||
{ id: "list", name: "List" }
|
||||
];
|
||||
this.AlbumSorts = [
|
||||
{ id: "default", name: "Default Sort" },
|
||||
{ id: "artist", name: "Artist" },
|
||||
{ id: "album", name: "Album" },
|
||||
{ id: "track", name: "Track" },
|
||||
{ id: "createdate desc", name: "Date Added" }
|
||||
];
|
||||
this.settings = {
|
||||
// Subsonic
|
||||
/* Demo Server
|
||||
Username: "android-guest"),
|
||||
Password: "guest"),
|
||||
Server: "http://subsonic.org/demo"),
|
||||
*/
|
||||
Url: "http://Jamstash.com/beta/#/archive/",
|
||||
Username: "",
|
||||
Password: "",
|
||||
Server: "",
|
||||
Timeout: 20000,
|
||||
Protocol: "jsonp",
|
||||
ApplicationName: "Jamstash",
|
||||
ApiVersion: "1.6.0",
|
||||
AutoPlaylists: "",
|
||||
AutoPlaylistSize: 25,
|
||||
AutoAlbumSize: 15,
|
||||
// General
|
||||
HideAZ: false,
|
||||
ScrollTitle: true,
|
||||
NotificationSong: true,
|
||||
NotificationNowPlaying: false,
|
||||
SaveTrackPosition: false,
|
||||
ForceFlash: false,
|
||||
Theme: "Default",
|
||||
DefaultLibraryLayout: this.Layouts[0],
|
||||
DefaultSearchType: this.SearchTypes[0],
|
||||
DefaultAlbumSort: this.AlbumSorts[0],
|
||||
DefaultArchiveAlbumSort: "date desc",
|
||||
Jukebox: false,
|
||||
AutoPlay: false,
|
||||
LoopQueue: false,
|
||||
Repeat: false,
|
||||
Debug: false
|
||||
};
|
||||
this.SavedCollections = [];
|
||||
this.SavedGenres = [];
|
||||
this.Player1 = '#playdeck_1';
|
||||
this.archiveUrl = 'https://archive.org/';
|
||||
|
||||
this.BaseURL = function () { return this.settings.Server + '/rest'; };
|
||||
this.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };
|
||||
});
|
||||
JamStash.service('notifications', function ($rootScope, globals) {
|
||||
var msgIndex = 1;
|
||||
this.updateMessage = function (msg, autohide) {
|
||||
|
|
65
js/services/globals-service.js
Normal file
65
js/services/globals-service.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
|
||||
var jamstash = angular.module('JamStash');
|
||||
|
||||
jamstash.service('globals', function () {
|
||||
this.SearchTypes = [
|
||||
{ id: "song", name: "Song" },
|
||||
{ id: "album", name: "Album" },
|
||||
{ id: "artist", name: "Artist" }
|
||||
];
|
||||
this.Layouts = [
|
||||
{ id: "grid", name: "Grid" },
|
||||
{ id: "list", name: "List" }
|
||||
];
|
||||
this.AlbumSorts = [
|
||||
{ id: "default", name: "Default Sort" },
|
||||
{ id: "artist", name: "Artist" },
|
||||
{ id: "album", name: "Album" },
|
||||
{ id: "track", name: "Track" },
|
||||
{ id: "createdate desc", name: "Date Added" }
|
||||
];
|
||||
this.settings = {
|
||||
// Subsonic
|
||||
/* Demo Server
|
||||
Username: "android-guest"),
|
||||
Password: "guest"),
|
||||
Server: "http://subsonic.org/demo"),
|
||||
*/
|
||||
Url: "http://Jamstash.com/beta/#/archive/",
|
||||
Username: "",
|
||||
Password: "",
|
||||
Server: "",
|
||||
Timeout: 20000,
|
||||
Protocol: "jsonp",
|
||||
ApplicationName: "Jamstash",
|
||||
ApiVersion: "1.6.0",
|
||||
AutoPlaylists: "",
|
||||
AutoPlaylistSize: 25,
|
||||
AutoAlbumSize: 15,
|
||||
// General
|
||||
HideAZ: false,
|
||||
ScrollTitle: true,
|
||||
NotificationSong: true,
|
||||
NotificationNowPlaying: false,
|
||||
SaveTrackPosition: false,
|
||||
ForceFlash: false,
|
||||
Theme: "Default",
|
||||
DefaultLibraryLayout: this.Layouts[0],
|
||||
DefaultSearchType: this.SearchTypes[0],
|
||||
DefaultAlbumSort: this.AlbumSorts[0],
|
||||
DefaultArchiveAlbumSort: "date desc",
|
||||
Jukebox: false,
|
||||
AutoPlay: false,
|
||||
LoopQueue: false,
|
||||
Repeat: false,
|
||||
Debug: false
|
||||
};
|
||||
this.SavedCollections = [];
|
||||
this.SavedGenres = [];
|
||||
this.Player1 = '#playdeck_1';
|
||||
this.archiveUrl = 'https://archive.org/';
|
||||
|
||||
this.BaseURL = function () { return this.settings.Server + '/rest'; };
|
||||
this.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };
|
||||
});
|
23
test/services/globals-service_test.js
Normal file
23
test/services/globals-service_test.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
describe("globals service", function() {
|
||||
'use strict';
|
||||
|
||||
var globals;
|
||||
beforeEach(module('JamStash'));
|
||||
beforeEach(inject(function(_globals_) {
|
||||
globals = _globals_;
|
||||
}));
|
||||
|
||||
it("given 'http://subsonic.org/demo', when calling BaseURL() then I get 'http://subsonic.org/demo/rest'", function() {
|
||||
globals.settings.Server = "http://subsonic.org/demo";
|
||||
expect(globals.BaseURL()).toBe("http://subsonic.org/demo/rest");
|
||||
});
|
||||
|
||||
it("given a username, password, protocol, api version and application name, when calling BaseParams() then I get a concatenated string of url params", function () {
|
||||
globals.settings.Username = "jdoe";
|
||||
globals.settings.Password = "testpassword";
|
||||
globals.settings.Protocol = "jsonp";
|
||||
globals.settings.ApiVersion = "1.10.2";
|
||||
globals.settings.ApplicationName = "MyApp";
|
||||
expect(globals.BaseParams()).toBe("u=jdoe&p=testpassword&f=jsonp&v=1.10.2&c=MyApp");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue