Skip to content

Commit c898968

Browse files
authored
Merge pull request #1032 from jakejarrett/settings-api-key
Introduce a setting for the API Key
2 parents 8ca1d2c + 3f8471b commit c898968

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

app/public/js/common/openExternalLinkDirective.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ app.directive('openExternal', function () {
1212
if ( this.hasAttribute('data-link') ) {
1313
el = attrs.href;
1414
} else {
15-
el = attrs.href + '?client_id=' + window.scClientId;
15+
el = attrs.href + '?client_id=' + window.localStorage.scClientId;
1616
}
1717
gui.Shell.openExternal( el );
1818
});

app/public/js/common/playerService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ app.factory('playerService', function (
151151
trackObj.songThumbnail = 'public/img/song-placeholder.png';
152152
}
153153

154-
trackUrl = trackObj.songUrl + '?client_id=' + $window.scClientId;
154+
trackUrl = trackObj.songUrl + '?client_id=' + window.localStorage.scClientId;
155155

156156
// check rate limit
157157
utilsService.isPlayable(trackUrl).then(function () {

app/public/js/settings/settingsCtrl.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
app.controller('SettingsCtrl', function ($scope, notificationFactory) {
44
$scope.title = "Settings";
5+
$scope.client_id = window.localStorage.scClientId;
56

67
/**
78
* Enable or disable song notification
@@ -16,6 +17,10 @@ app.controller('SettingsCtrl', function ($scope, notificationFactory) {
1617
window.localStorage.notificationToggle = $scope.notification;
1718
};
1819

20+
$scope.scClientId = function () {
21+
window.localStorage.scClientId = $scope.client_id;
22+
};
23+
1924
/**
2025
* Clea storage which remove everything stored in window.localStorage
2126
*/

app/public/js/system/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ window.settings.visitor = ua('UA-67310953-1');
1717
window.scAccessToken = userConfig.accessToken;
1818

1919
// set window clientId
20-
window.scClientId = userConfig.clientId;
20+
window.localStorage.setItem('scClientId', userConfig.clientId);

app/public/stylesheets/sass/_components/_settings.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
justify-content: center;
1313
margin: 10px 0 10px;
1414
}
15+
16+
.flex-column {
17+
flex-direction: column;
18+
}
19+
1520
// Switch for Settings
1621
.onoffswitch {
1722
position: relative;
@@ -64,3 +69,13 @@
6469
box-shadow: 3px 6px 18px 0px rgba(0, 0, 0, 0.2);
6570
border: 1px solid rgba(0, 0, 0, .3);
6671
}
72+
73+
.settings-secondary-container {
74+
width: 590px;
75+
}
76+
77+
input[type="text"].full-width {
78+
margin-top: 5px;
79+
margin-bottom: 10px;
80+
width: 100%;
81+
}

app/views/settings/settings.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ <h2>Notifications</h2>
1616
</div>
1717
</div>
1818
</li>
19+
<li class="full-flex flex-column">
20+
<div class="settings-secondary-container leftSide">
21+
<h2>API Key</h2>
22+
<label>Swap out API Key for your own.</label>
23+
</div>
24+
<div class="settings-secondary-container leftSide">
25+
<input type="text" class="full-width" name="client_id" id="client_id" ng-model="client_id" ng-change="scClientId()" ng-value="client_id">
26+
</div>
27+
</li>
1928
<li class="full-flex">
2029
<div class="settings-container leftSide">
2130
<h2>Clean local storage</h2>

0 commit comments

Comments
 (0)