dashboard: remove checkbox in background image branding

This commit is contained in:
Johannes Zellner
2024-06-25 16:25:52 +02:00
parent 6f37bde55d
commit a4dd6cc928
5 changed files with 20 additions and 11 deletions
+3 -3
View File
@@ -55,12 +55,12 @@
<div class="form-group">
<div>
<input id="userBackgroundInput" type="checkbox" ng-model="background.enabled">
<label for="userBackgroundInput" class="control-label">{{ 'branding.backgroundImage' | tr }}</label>
<div class="branding-background" ng-show="background.enabled" ng-click="background.selectNew()">
<label class="control-label">{{ 'branding.backgroundImage' | tr }}</label>
<div class="branding-background" ng-click="background.selectNew()">
<img ng-src="{{ background.url() }}" onerror="this.src = '/img/background-image-placeholder.svg'"/>
<i class="picture-edit-indicator fa fa-pencil-alt"></i>
</div>
<a href="" ng-show="!background.cleared" ng-click="background.clear()">{{ 'branding.clearBackgroundImage' | tr }}</a>
<input type="file" id="backgroundFileInput" style="display: none" accept="image/*"/>
</div>
</div>
+13 -5
View File
@@ -138,11 +138,13 @@ angular.module('Application').controller('BrandingController', ['$scope', '$loca
enabled: false,
file: null,
src: null,
cleared: false,
newImageFile: null,
cacheBusting: Date.now(),
url() {
if ($scope.background.src) return $scope.background.src;
if ($scope.background.cleared) return '/img/background-image-placeholder.svg';
else if ($scope.background.src) return $scope.background.src;
else return `${Client.apiOrigin}/api/v1/cloudron/background?${$scope.background.cacheBusting}`;
},
@@ -151,12 +153,17 @@ angular.module('Application').controller('BrandingController', ['$scope', '$loca
},
submit(callback) {
if ($scope.background.enabled) {
if ($scope.background.newImageFile) Client.changeCloudronBackground($scope.background.newImageFile, callback);
else callback();
} else {
if ($scope.background.cleared) {
Client.changeCloudronBackground(null, callback);
} else if ($scope.background.newImageFile) {
Client.changeCloudronBackground($scope.background.newImageFile, callback);
} else {
callback();
}
},
clear() {
$scope.background.cleared = true;
}
};
@@ -183,6 +190,7 @@ angular.module('Application').controller('BrandingController', ['$scope', '$loca
$scope.$apply(function () {
const myImage = new File([blob], 'background.webp', { type: blob.type });
$scope.background.cleared = false;
$scope.background.newImageFile = myImage;
$scope.background.src = URL.createObjectURL(myImage);
});