mirror of
https://github.com/portainer/portainer.git
synced 2025-07-18 21:09:40 +02:00
* Initial extension build * Add auto login fix auto auth add some message Add extension version Double attempt to login Add auto login from jwt check Add autologin on logout revert sidebar Catch error 401 to relogin cleanup login Add password generator Hide User block and collapse sidebar by default hide user box and toggle sidebar remove defailt dd Integrate extension to portainer Move extension to build remove files from ignore Move extension folder fix alpine try to copy folder try add Change base image move folder extension ignore folder build Fix relative path Move ext to root fix image name versioned index Update extension on same image Update mod * fix kubeshell baseurl * Fix kube shell * move build and remove https * Tidy mod * Remove space * Fix hash test * Password manager * change to building locally * Restore version variable and add local install command * fix local dev image + hide users & auth * Password manageListen on locahost onlyr * FIxes base path * Hide only username * Move default to constants * Update app/portainer/components/PageHeader/HeaderContent.html Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com> * fix 2 failing FE tests [EE-2938] * remove password autogeneration from v1 * fix webhooks * fix docker container console and attach * fix default for portainer IP * update meta, dockerfile and makefile for new ver * fix basepath in kube and docker console * revert makefile changes * add icon back * Add remote short cut command * make local methods the default * default to 0.0.0 for version for local development * simplify make commands * small build fixes * resolve conflicts * Update api/filesystem/write.go Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com> * use a more secure default pass Co-authored-by: itsconquest <william.conquest@portainer.io> Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com>
162 lines
4.6 KiB
JavaScript
162 lines
4.6 KiB
JavaScript
import angular from 'angular';
|
|
|
|
import { buildOption } from '@/portainer/components/BoxSelector';
|
|
import { FeatureId } from '@/portainer/feature-flags/enums';
|
|
|
|
angular.module('portainer.app').controller('SettingsController', [
|
|
'$scope',
|
|
'$state',
|
|
'Notifications',
|
|
'SettingsService',
|
|
'StateManager',
|
|
'BackupService',
|
|
'FileSaver',
|
|
'Blob',
|
|
function ($scope, $state, Notifications, SettingsService, StateManager, BackupService, FileSaver) {
|
|
$scope.s3BackupFeatureId = FeatureId.S3_BACKUP_SETTING;
|
|
$scope.backupOptions = [
|
|
buildOption('backup_file', 'fa fa-download', 'Download backup file', '', 'file'),
|
|
buildOption('backup_s3', 'fa fa-upload', 'Store in S3', 'Define a cron schedule', 's3', FeatureId.S3_BACKUP_SETTING),
|
|
];
|
|
|
|
$scope.state = {
|
|
actionInProgress: false,
|
|
availableKubeconfigExpiryOptions: [
|
|
{
|
|
key: '1 day',
|
|
value: '24h',
|
|
},
|
|
{
|
|
key: '7 days',
|
|
value: `${24 * 7}h`,
|
|
},
|
|
{
|
|
key: '30 days',
|
|
value: `${24 * 30}h`,
|
|
},
|
|
{
|
|
key: '1 year',
|
|
value: `${24 * 30 * 12}h`,
|
|
},
|
|
{
|
|
key: 'No expiry',
|
|
value: '0',
|
|
},
|
|
],
|
|
backupInProgress: false,
|
|
featureLimited: false,
|
|
showHTTPS: !window.ddExtension,
|
|
};
|
|
|
|
$scope.BACKUP_FORM_TYPES = { S3: 's3', FILE: 'file' };
|
|
|
|
$scope.formValues = {
|
|
customLogo: false,
|
|
labelName: '',
|
|
labelValue: '',
|
|
enableTelemetry: false,
|
|
passwordProtect: false,
|
|
password: '',
|
|
backupFormType: $scope.BACKUP_FORM_TYPES.FILE,
|
|
};
|
|
|
|
$scope.onToggleAutoBackups = function onToggleAutoBackups(checked) {
|
|
$scope.$evalAsync(() => {
|
|
$scope.formValues.scheduleAutomaticBackups = checked;
|
|
});
|
|
};
|
|
|
|
$scope.onBackupOptionsChange = function (type, limited) {
|
|
$scope.formValues.backupFormType = type;
|
|
$scope.state.featureLimited = limited;
|
|
};
|
|
|
|
$scope.removeFilteredContainerLabel = function (index) {
|
|
var settings = $scope.settings;
|
|
settings.BlackListedLabels.splice(index, 1);
|
|
|
|
updateSettings(settings);
|
|
};
|
|
|
|
$scope.addFilteredContainerLabel = function () {
|
|
var settings = $scope.settings;
|
|
var label = {
|
|
name: $scope.formValues.labelName,
|
|
value: $scope.formValues.labelValue,
|
|
};
|
|
settings.BlackListedLabels.push(label);
|
|
|
|
updateSettings(settings);
|
|
};
|
|
|
|
$scope.downloadBackup = function () {
|
|
const payload = {};
|
|
if ($scope.formValues.passwordProtect) {
|
|
payload.password = $scope.formValues.password;
|
|
}
|
|
|
|
$scope.state.backupInProgress = true;
|
|
|
|
BackupService.downloadBackup(payload)
|
|
.then(function success(data) {
|
|
const downloadData = new Blob([data.file], { type: 'application/gzip' });
|
|
FileSaver.saveAs(downloadData, data.name);
|
|
Notifications.success('Backup successfully downloaded');
|
|
})
|
|
.catch(function error(err) {
|
|
Notifications.error('Failure', err, 'Unable to download backup');
|
|
})
|
|
.finally(function final() {
|
|
$scope.state.backupInProgress = false;
|
|
});
|
|
};
|
|
|
|
$scope.saveApplicationSettings = function () {
|
|
var settings = $scope.settings;
|
|
|
|
if (!$scope.formValues.customLogo) {
|
|
settings.LogoURL = '';
|
|
}
|
|
|
|
settings.EnableTelemetry = $scope.formValues.enableTelemetry;
|
|
|
|
$scope.state.actionInProgress = true;
|
|
updateSettings(settings);
|
|
};
|
|
|
|
function updateSettings(settings) {
|
|
SettingsService.update(settings)
|
|
.then(function success() {
|
|
Notifications.success('Settings updated');
|
|
StateManager.updateLogo(settings.LogoURL);
|
|
StateManager.updateSnapshotInterval(settings.SnapshotInterval);
|
|
StateManager.updateEnableTelemetry(settings.EnableTelemetry);
|
|
$state.reload();
|
|
})
|
|
.catch(function error(err) {
|
|
Notifications.error('Failure', err, 'Unable to update settings');
|
|
})
|
|
.finally(function final() {
|
|
$scope.state.actionInProgress = false;
|
|
});
|
|
}
|
|
|
|
function initView() {
|
|
SettingsService.settings()
|
|
.then(function success(data) {
|
|
var settings = data;
|
|
$scope.settings = settings;
|
|
|
|
if (settings.LogoURL !== '') {
|
|
$scope.formValues.customLogo = true;
|
|
}
|
|
$scope.formValues.enableTelemetry = settings.EnableTelemetry;
|
|
})
|
|
.catch(function error(err) {
|
|
Notifications.error('Failure', err, 'Unable to retrieve application settings');
|
|
});
|
|
}
|
|
|
|
initView();
|
|
},
|
|
]);
|