Add UI bits for setting backgroundImage

This commit is contained in:
Johannes Zellner
2022-05-14 19:41:47 +02:00
parent 41e2f7006f
commit ae0b5f010b
6 changed files with 109 additions and 1 deletions
+21
View File
@@ -1938,6 +1938,27 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
}
};
Client.prototype.getBackgroundImageUrl = function () {
return client.apiOrigin + '/api/v1/profile/backgroundImage?access_token=' + token + '&bustcache=' + Date.now();
};
Client.prototype.setBackgroundImage = function (backgroundImage, callback) {
// Blob type if object
var fd = new FormData();
fd.append('backgroundImage', backgroundImage);
var config = {
headers: { 'Content-Type': undefined },
transformRequest: angular.identity
};
post('/api/v1/profile/backgroundImage', fd, config, function (error, data, status) {
if (error) return callback(error);
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
});
};
Client.prototype.makeUserLocal = function (userId, callback) {
post('/api/v1/users/' + userId + '/make_local', {}, null, function (error, data, status) {
if (error) return callback(error);
+3
View File
@@ -12,6 +12,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.subscription = {};
$scope.notificationCount = 0;
$scope.hideNavBarActions = $location.path() === '/logs';
$scope.backgroundImageUrl = '';
$scope.reboot = {
busy: false,
@@ -131,6 +132,8 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.config = Client.getConfig();
document.getElementById('mainContentContainer').style.backgroundImage = 'url("' + Client.getBackgroundImageUrl() + '")';
$scope.initialized = true;
if (Client.getConfig().mandatory2FA && !Client.getUserInfo().twoFactorAuthenticationEnabled) {