Skip to content

Commit

Permalink
Merge pull request #1032 from jakejarrett/settings-api-key
Browse files Browse the repository at this point in the history
Introduce a setting for the API Key
  • Loading branch information
jakejarrett authored Jan 5, 2018
2 parents 8ca1d2c + 3f8471b commit c898968
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/public/js/common/openExternalLinkDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ app.directive('openExternal', function () {
if ( this.hasAttribute('data-link') ) {
el = attrs.href;
} else {
el = attrs.href + '?client_id=' + window.scClientId;
el = attrs.href + '?client_id=' + window.localStorage.scClientId;
}
gui.Shell.openExternal( el );
});
Expand Down
2 changes: 1 addition & 1 deletion app/public/js/common/playerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ app.factory('playerService', function (
trackObj.songThumbnail = 'public/img/song-placeholder.png';
}

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

// check rate limit
utilsService.isPlayable(trackUrl).then(function () {
Expand Down
5 changes: 5 additions & 0 deletions app/public/js/settings/settingsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

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

$scope.scClientId = function () {
window.localStorage.scClientId = $scope.client_id;
};

/**
* Clea storage which remove everything stored in window.localStorage
*/
Expand Down
2 changes: 1 addition & 1 deletion app/public/js/system/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ window.settings.visitor = ua('UA-67310953-1');
window.scAccessToken = userConfig.accessToken;

// set window clientId
window.scClientId = userConfig.clientId;
window.localStorage.setItem('scClientId', userConfig.clientId);
15 changes: 15 additions & 0 deletions app/public/stylesheets/sass/_components/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
justify-content: center;
margin: 10px 0 10px;
}

.flex-column {
flex-direction: column;
}

// Switch for Settings
.onoffswitch {
position: relative;
Expand Down Expand Up @@ -64,3 +69,13 @@
box-shadow: 3px 6px 18px 0px rgba(0, 0, 0, 0.2);
border: 1px solid rgba(0, 0, 0, .3);
}

.settings-secondary-container {
width: 590px;
}

input[type="text"].full-width {
margin-top: 5px;
margin-bottom: 10px;
width: 100%;
}
9 changes: 9 additions & 0 deletions app/views/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ <h2>Notifications</h2>
</div>
</div>
</li>
<li class="full-flex flex-column">
<div class="settings-secondary-container leftSide">
<h2>API Key</h2>
<label>Swap out API Key for your own.</label>
</div>
<div class="settings-secondary-container leftSide">
<input type="text" class="full-width" name="client_id" id="client_id" ng-model="client_id" ng-change="scClientId()" ng-value="client_id">
</div>
</li>
<li class="full-flex">
<div class="settings-container leftSide">
<h2>Clean local storage</h2>
Expand Down

0 comments on commit c898968

Please sign in to comment.