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: {
type: 'textarea',
reset: 'CUSTOM_VENV_PATHS'
INSIGHTS_DATA_ENABLED: {
type: 'toggleSwitch'
}
},

View File

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

View File

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

View File

@@ -115,25 +115,38 @@
<div id="eula_notice"
class="License-eulaNotice">{{ license.eula }}</div>
<div class="form-group License-detailsGroup">
<div class="checkbox">
<div class="License-analyticsCheckbox checkbox">
<label class="License-details--label">
<input type="checkbox" ng-model="newLicense.eula" ng-disabled="!user_is_superuser" required>
<translate>I agree to the End User License Agreement</translate>
</label>
</div>
</div>
<div class="form-group License-detailsGroup License-detailsGroup--withSeparator" ng-if="licenseMissing">
<div class="checkbox">
<label class="License-details--label">
<input type="checkbox" ng-model="newLicense.pendo" ng-disabled="!user_is_superuser" required>
<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
<a target="_blank"
href="http://docs.ansible.com/ansible-tower/latest/html/installandreference/user-data.html#index-0">
this Tower documentation page
</a>. Uncheck this box to disable this feature.
</translate>
</label>
<div class="License-subTitleText" ng-if="licenseMissing">
<translate>Tracking and Analytics</translate>
</div>
<div class="form-group License-detailsGroup" ng-if="licenseMissing">
<span class="License-helperText">
<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>
</span>
<div class="License-analyticsCheckboxGroup">
<div class="License-analyticsCheckbox checkbox">
<input type="checkbox" ng-model="newLicense.pendo" ng-disabled="!user_is_superuser" required>
<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>
<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>
<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 timer from './timer.factory';
import pendoService from './pendo.service';
import insightsEnablementService from './insightsEnablement.service';
export default
angular.module('authentication', [])
.factory('Authorization', authenticationService)
.factory('IsAdmin', isAdmin)
.factory('Timer', timer)
.service('pendoService', pendoService);
.service('pendoService', pendoService)
.service('insightsEnablementService', insightsEnablementService);