From db58c2311e146ddcca24b3b60b37c7d7f36b3112 Mon Sep 17 00:00:00 2001 From: Shu Muto Date: Wed, 13 Dec 2017 14:23:25 +0900 Subject: [PATCH] Use load-edit directive for Sign Certificate action Change-Id: I3d6ae0b513120cf50c89b40234b602b816adfd48 Depends-On: Ie38bff8fba90de99095b589d70da45dcb202fa56 --- .../sign-certificate-modal.controller.js | 24 +------------------ .../sign-certificate-modal.html | 16 +++++-------- .../sign-certificate-model.js | 4 +--- 3 files changed, 8 insertions(+), 36 deletions(-) diff --git a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.controller.js b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.controller.js index 7c273bee..b26daa56 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.controller.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.controller.js @@ -36,35 +36,13 @@ function signCertificateController(magnum, model) { var ctrl = this; - ctrl.changeFile = changeFile; ctrl.model = model; ctrl.form = null; + ctrl.title = gettext("CSR"); magnum.getCluster(model.newCertificateSpec.cluster_uuid).success(onGetCluster); function onGetCluster(response) { ctrl.model.cluster_name = response.name; } - - function changeFile(files) { - // NOTE: this uses on-file-changed directive in Swift-UI included Horizon. - if (files.length) { - // load csr file and set into model - var reader = new FileReader(); - reader.readAsText(files[0]); - reader.onload = function() { - model.newCertificateSpec.csr = reader.result; - ctrl.model.csrfile = files[0]; - ctrl.form.$setDirty(); - }; - // Note that a $scope.$digest() is now needed for the change to the ngModel to be - // reflected in the page (since this callback is fired from inside a DOM event) - // but the on-file-changed directive currently does a digest after this callback - // is invoked. - } else { - model.newCertificateSpec.csr = ""; - ctrl.model.csrfile = null; - ctrl.form.$setPristine(); - } - } } })(); diff --git a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.html b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.html index de7f3fd8..495d3fc8 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.html +++ b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-modal.html @@ -11,16 +11,12 @@ diff --git a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-model.js b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-model.js index 62c76c73..ef5a1ad4 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-model.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/sign-certificate/sign-certificate-model.js @@ -25,9 +25,8 @@ function CertificateModel(magnum) { var model = { - newClusterSpec: {}, + newCertificateSpec: {}, cluster_name: "", - csrfile: null, // API methods init: init, @@ -41,7 +40,6 @@ csr: "" }; model.cluster_name = ""; - model.csrfile = null; } function signCertificate() {