From c02e5ffa41018efe2db7df78189046a95e12eec1 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 23 Jan 2015 11:58:17 -0500 Subject: [PATCH] Adding EULA checkbox in license modal Added the EULA text and checkbox on the UI. We received the shortened text from Rob Nalen --- awx/ui/static/js/forms/LicenseUpdate.js | 19 +++++++++++++++++-- awx/ui/static/js/helpers/License.js | 20 ++++++++++++++++---- awx/ui/static/less/ansible-ui.less | 4 ++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/awx/ui/static/js/forms/LicenseUpdate.js b/awx/ui/static/js/forms/LicenseUpdate.js index 38b55dd46b..55e18791fa 100644 --- a/awx/ui/static/js/forms/LicenseUpdate.js +++ b/awx/ui/static/js/forms/LicenseUpdate.js @@ -25,15 +25,30 @@ angular.module('LicenseUpdateFormDefinition', []) editRequird: true, rows: 10, 'default': '---' + }, + eula: { + label: 'End User License Agreement', + type: 'textarea', + addRequired: true, + editRequird: true, + rows: 5, + readonly: true + }, + eula_agreement: { + label: 'I agree to the End User License Agreement', + type: 'checkbox', + addRequired: true, + editRequird: true, + trueValue: 'true', + falseValue: 'false' } }, - buttons: { form_submit: { label: "Submit", "class": "pull-right btn-primary", ngClick: "submitLicenseKey()", - ngDisabled: true + // ngDisabled: "true" } }, diff --git a/awx/ui/static/js/helpers/License.js b/awx/ui/static/js/helpers/License.js index 26c411bdf2..c148713c2f 100644 --- a/awx/ui/static/js/helpers/License.js +++ b/awx/ui/static/js/helpers/License.js @@ -1,4 +1,3 @@ - /****************************************************** * Copyright (c) 2014 AnsibleWorks, Inc. * @@ -157,6 +156,7 @@ function($rootScope, $compile, CreateDialog, Store, LicenseUpdateForm, GenerateF scope = (in_scope) ? in_scope : self.scope; json_data = ToJSON('json', license_key); + json_data.eula_accepted = (scope.eula_agreement === "true") ? true : false; if (typeof json_data === 'object' && Object.keys(json_data).length > 0) { Rest.setUrl(url); Rest.post(json_data) @@ -359,6 +359,8 @@ function ($location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, G scope.parseType = 'json'; scope.license_json = JSON.stringify(self.license, null, ' '); + scope.eula = self.eula; + scope.eula_agreement = false; h = CheckLicense.getHTML(self.getLicense(),true).body; $('#license-modal-dialog #license_tabs').append("
  • Update License
  • "); $('#license-modal-dialog .tab-content').append("
    "); @@ -367,6 +369,15 @@ function ($location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, G setTimeout(function() { $compile(e)(scope); $('#license-modal-dialog').dialog('open'); + $('#license_form_submit_btn').attr('disabled' , 'true' ); + $('#license_eula_agreement_chbox').on('click' , function(){ + if(scope.eula_agreement === "false"){ + $('#license_form_submit_btn').attr('disabled' , 'true' ); + } + if(scope.eula_agreement === "true"){ + $('#license_form_submit_btn').removeAttr('disabled'); + } + }); }, 300); }); @@ -387,7 +398,7 @@ function ($location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, G scope: scope, buttons: buttons, width: 675, - height: 600, + height: (IsAdmin()) ? 745 : 600, minWidth: 400, title: 'Ansible Tower License', id: 'license-modal-dialog', @@ -497,7 +508,7 @@ function ($location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, G } else { days = Math.floor(scope.time_remaining / 86400000); } - scope.time_remaining = (days!==1) ? $filter('number')(days, 0) + ' days' : $filter('number')(days, 0) + ' day'; + scope.time_remaining = (days!==1) ? $filter('number')(days, 0) + ' days' : $filter('number')(days, 0) + ' day'; // '1 day' and '0 days/2 days' or more } if (parseInt(scope.free_instances) <= 0) { @@ -554,6 +565,7 @@ function ($location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, G self.setLicense(data.license_info, version); html = self.getDefaultHTML(data.license_info); self.loadDefaultScope(data.license_info, version); + self.eula = (data.eula) ? data.eula : "" ; self.createDialog(html); }); CheckLicense.GetLicense('LicenseDataReady', scope); @@ -572,7 +584,6 @@ function ($location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, G purchase_msg = '

    To purchase a license or extend an existing license ' + 'visit the Ansible online store, ' + 'or visit support.ansible.com for assistance.

    '; - if (license && !Authorization.licenseTested()) { // This is our first time evaluating the license license.tested = true; @@ -619,3 +630,4 @@ function ($location, $rootScope, $compile, $filter, GenerateForm, Rest, Alert, G } ]); */ + diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index e8e005a691..bc741ca16a 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -360,6 +360,10 @@ textarea.allowresize { color: @grey-txt; } +#license_eula{ + white-space: nowrap; +} + .modal-dialog .ui-accordion .ui-accordion-content { overflow: hidden; }