diff --git a/app/portainer/react/components/settings.ts b/app/portainer/react/components/settings.ts index ce83d0aa9..2f9f3a4ee 100644 --- a/app/portainer/react/components/settings.ts +++ b/app/portainer/react/components/settings.ts @@ -10,6 +10,7 @@ import { ApplicationSettingsPanel } from '@/react/portainer/settings/SettingsVie import { KubeSettingsPanel } from '@/react/portainer/settings/SettingsView/KubeSettingsPanel'; import { HelmCertPanel } from '@/react/portainer/settings/SettingsView/HelmCertPanel'; import { HiddenContainersPanel } from '@/react/portainer/settings/SettingsView/HiddenContainersPanel/HiddenContainersPanel'; +import { SSLSettingsPanelWrapper } from '@/react/portainer/settings/SettingsView/SSLSettingsPanel/SSLSettingsPanel'; export const settingsModule = angular .module('portainer.app.react.components.settings', []) @@ -26,6 +27,10 @@ export const settingsModule = angular 'applicationSettingsPanel', r2a(withReactQuery(ApplicationSettingsPanel), ['onSuccess']) ) + .component( + 'sslSettingsPanel', + r2a(withReactQuery(SSLSettingsPanelWrapper), []) + ) .component('helmCertPanel', r2a(withReactQuery(HelmCertPanel), [])) .component( 'hiddenContainersPanel', diff --git a/app/portainer/settings/general/index.js b/app/portainer/settings/general/index.js index ab9158702..82d992c80 100644 --- a/app/portainer/settings/general/index.js +++ b/app/portainer/settings/general/index.js @@ -1,5 +1,3 @@ import angular from 'angular'; -import { sslCertificate } from './ssl-certificate'; - -export default angular.module('portainer.settings.general', []).component('sslCertificateSettings', sslCertificate).name; +export default angular.module('portainer.settings.general', []).name; diff --git a/app/portainer/settings/general/ssl-certificate/index.js b/app/portainer/settings/general/ssl-certificate/index.js deleted file mode 100644 index 0d5d62af7..000000000 --- a/app/portainer/settings/general/ssl-certificate/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import controller from './ssl-certificate.controller.js'; - -export const sslCertificate = { - templateUrl: './ssl-certificate.html', - controller, -}; diff --git a/app/portainer/settings/general/ssl-certificate/ssl-certificate.controller.js b/app/portainer/settings/general/ssl-certificate/ssl-certificate.controller.js deleted file mode 100644 index c5dfd4dda..000000000 --- a/app/portainer/settings/general/ssl-certificate/ssl-certificate.controller.js +++ /dev/null @@ -1,78 +0,0 @@ -class SslCertificateController { - /* @ngInject */ - constructor($async, $scope, $state, SSLService, Notifications) { - Object.assign(this, { $async, $scope, $state, SSLService, Notifications }); - - this.cert = null; - this.originalValues = { - forceHTTPS: false, - certFile: null, - keyFile: null, - }; - - this.formValues = { - certFile: null, - keyFile: null, - forceHTTPS: false, - }; - - this.state = { - actionInProgress: false, - reloadingPage: false, - }; - - this.certFilePattern = `.pem,.crt,.cer,.cert`; - this.keyFilePattern = `.pem,.key`; - - this.save = this.save.bind(this); - this.onChangeForceHTTPS = this.onChangeForceHTTPS.bind(this); - } - - isFormChanged() { - return Object.entries(this.originalValues).some(([key, value]) => value != this.formValues[key]); - } - - onChangeForceHTTPS(checked) { - return this.$scope.$evalAsync(() => { - this.formValues.forceHTTPS = checked; - }); - } - - async save() { - return this.$async(async () => { - this.state.actionInProgress = true; - try { - const cert = this.formValues.certFile ? await this.formValues.certFile.text() : null; - const key = this.formValues.keyFile ? await this.formValues.keyFile.text() : null; - const httpEnabled = !this.formValues.forceHTTPS; - await this.SSLService.upload({ httpEnabled, cert, key }); - - await new Promise((resolve) => setTimeout(resolve, 2000)); - location.reload(); - this.state.reloadingPage = true; - } catch (err) { - this.Notifications.error('Failure', err, 'Failed applying changes'); - } - this.state.actionInProgress = false; - }); - } - - wasHTTPsChanged() { - return this.originalValues.forceHTTPS !== this.formValues.forceHTTPS; - } - - async $onInit() { - return this.$async(async () => { - try { - const certInfo = await this.SSLService.get(); - - this.formValues.forceHTTPS = !certInfo.httpEnabled; - this.originalValues.forceHTTPS = this.formValues.forceHTTPS; - } catch (err) { - this.Notifications.error('Failure', err, 'Failed loading certificate info'); - } - }); - } -} - -export default SslCertificateController; diff --git a/app/portainer/settings/general/ssl-certificate/ssl-certificate.html b/app/portainer/settings/general/ssl-certificate/ssl-certificate.html deleted file mode 100644 index 921068e14..000000000 --- a/app/portainer/settings/general/ssl-certificate/ssl-certificate.html +++ /dev/null @@ -1,121 +0,0 @@ -