add ui for insights enablement

This commit is contained in:
John Mitchell
2019-03-21 10:49:54 -04:00
committed by Christian Adams
parent 40dbe70854
commit 70af2dd66b
6 changed files with 75 additions and 18 deletions

View File

@@ -58,6 +58,8 @@ export default ['i18n', function(i18n) {
CUSTOM_VENV_PATHS: { CUSTOM_VENV_PATHS: {
type: 'textarea', type: 'textarea',
reset: 'CUSTOM_VENV_PATHS' reset: 'CUSTOM_VENV_PATHS'
INSIGHTS_DATA_ENABLED: {
type: 'toggleSwitch'
} }
}, },

View File

@@ -140,6 +140,11 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
.License-detailsGroup--withSeparator { .License-analyticsCheckbox {
border-top: 1px solid @default-icon-hov; padding-top: 5px;
}
.License-analyticsCheckboxGroup {
padding: 10px 0;
font-weight: bold;
} }

View File

@@ -9,9 +9,9 @@ import {N_} from "../i18n";
export default export default
['Wait', '$state', '$scope', '$rootScope', ['Wait', '$state', '$scope', '$rootScope',
'ProcessErrors', 'CheckLicense', 'moment','$window', 'ProcessErrors', 'CheckLicense', 'moment','$window',
'ConfigService', 'FeaturesService', 'pendoService', 'i18n', 'config', 'ConfigService', 'FeaturesService', 'pendoService', 'insightsEnablementService', 'i18n', 'config',
function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment, function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment,
$window, ConfigService, FeaturesService, pendoService, i18n, config) { $window, ConfigService, FeaturesService, pendoService, insightsEnablementService, i18n, config) {
const calcDaysRemaining = function(seconds) { const calcDaysRemaining = function(seconds) {
// calculate the number of days remaining on the license // calculate the number of days remaining on the license
@@ -54,7 +54,8 @@ export default
$scope.valid = CheckLicense.valid($scope.license.license_info); $scope.valid = CheckLicense.valid($scope.license.license_info);
$scope.compliant = $scope.license.license_info.compliant; $scope.compliant = $scope.license.license_info.compliant;
$scope.newLicense = { $scope.newLicense = {
pendo: true pendo: true,
insights: true
}; };
}; };
@@ -114,6 +115,13 @@ export default
} else { } else {
pendoService.updatePendoTrackingState('off'); pendoService.updatePendoTrackingState('off');
} }
if ($scope.newLicense.insights) {
insightsEnablementService.updateInsightsTrackingState(true);
} else {
insightsEnablementService.updateInsightsTrackingState(false);
}
$state.go('dashboard', { $state.go('dashboard', {
licenseMissing: false licenseMissing: false
}); });

View File

@@ -115,25 +115,38 @@
<div id="eula_notice" <div id="eula_notice"
class="License-eulaNotice">{{ license.eula }}</div> class="License-eulaNotice">{{ license.eula }}</div>
<div class="form-group License-detailsGroup"> <div class="form-group License-detailsGroup">
<div class="checkbox"> <div class="License-analyticsCheckbox checkbox">
<label class="License-details--label"> <label class="License-details--label">
<input type="checkbox" ng-model="newLicense.eula" ng-disabled="!user_is_superuser" required> <input type="checkbox" ng-model="newLicense.eula" ng-disabled="!user_is_superuser" required>
<translate>I agree to the End User License Agreement</translate> <translate>I agree to the End User License Agreement</translate>
</label> </label>
</div> </div>
</div> </div>
<div class="form-group License-detailsGroup License-detailsGroup--withSeparator" ng-if="licenseMissing"> <div class="License-subTitleText" ng-if="licenseMissing">
<div class="checkbox"> <translate>Tracking and Analytics</translate>
<label class="License-details--label"> </div>
<input type="checkbox" ng-model="newLicense.pendo" ng-disabled="!user_is_superuser" required> <div class="form-group License-detailsGroup" ng-if="licenseMissing">
<translate>By default, Tower collects and transmits analytics data on Tower usage to Red Hat. This data is used to enhance future releases of the Tower Software and help streamline customer experience and success. For more information, see <span class="License-helperText">
<a target="_blank" <translate>By default, Tower collects and transmits analytics data on Tower usage to Red Hat. You can uncheck these boxes to disable sending data to these services:</translate>
href="http://docs.ansible.com/ansible-tower/latest/html/installandreference/user-data.html#index-0"> </span>
this Tower documentation page <div class="License-analyticsCheckboxGroup">
</a>. Uncheck this box to disable this feature. <div class="License-analyticsCheckbox checkbox">
</translate> <input type="checkbox" ng-model="newLicense.pendo" ng-disabled="!user_is_superuser" required>
</label> <translate>Pendo</translate>
</div>
<div class="License-analyticsCheckbox checkbox">
<input type="checkbox" ng-model="newLicense.insights" ng-disabled="!user_is_superuser" required>
<translate>Insights</translate>
</div>
</div> </div>
<span class="License-helperText">
<translate>For more information about track and analytics, see
<a target="_blank"
href="http://docs.ansible.com/ansible-tower/latest/html/installandreference/user-data.html#index-0">
this Tower documentation page
</a>.
</translate>
</span>
</div> </div>
<div> <div>
<button ng-click="submit()" class="btn btn-success pull-right" ng-disabled="newLicense.file.license_key == null || newLicense.eula == null || !user_is_superuser" translate>Submit</button> <button ng-click="submit()" class="btn btn-success pull-right" ng-disabled="newLicense.file.license_key == null || newLicense.eula == null || !user_is_superuser" translate>Submit</button>

View File

@@ -0,0 +1,27 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors',
function ($rootScope, Rest, GetBasePath, ProcessErrors) {
return {
updateInsightsTrackingState: function(tracking_type) {
if (tracking_type === true || tracking_type === false) {
Rest.setUrl(`${GetBasePath('settings')}system`);
Rest.patch({ INSIGHTS_DATA_ENABLED: tracking_type })
.catch(function ({data, status}) {
ProcessErrors($rootScope, data, status, null, {
hdr: 'Error!',
msg: 'Failed to patch INSIGHTS_DATA_ENABLED in settings: ' +
status });
});
} else {
throw new Error(`Can't update insights data enabled in settings to
"${tracking_type}"`);
}
}
};
}];

View File

@@ -8,10 +8,12 @@ import authenticationService from './authentication.service';
import isAdmin from './isAdmin.factory'; import isAdmin from './isAdmin.factory';
import timer from './timer.factory'; import timer from './timer.factory';
import pendoService from './pendo.service'; import pendoService from './pendo.service';
import insightsEnablementService from './insightsEnablement.service';
export default export default
angular.module('authentication', []) angular.module('authentication', [])
.factory('Authorization', authenticationService) .factory('Authorization', authenticationService)
.factory('IsAdmin', isAdmin) .factory('IsAdmin', isAdmin)
.factory('Timer', timer) .factory('Timer', timer)
.service('pendoService', pendoService); .service('pendoService', pendoService)
.service('insightsEnablementService', insightsEnablementService);