mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
Merge pull request #6696 from mabashian/5554-license
Fixed license delete navigation bug
This commit is contained in:
@@ -9,10 +9,10 @@ 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',
|
'ConfigService', 'FeaturesService', 'pendoService', 'i18n', 'config',
|
||||||
function( Wait, $state, $scope, $rootScope,
|
function( Wait, $state, $scope, $rootScope,
|
||||||
ProcessErrors, CheckLicense, moment, $window, ConfigService,
|
ProcessErrors, CheckLicense, moment, $window, ConfigService,
|
||||||
FeaturesService, pendoService, i18n){
|
FeaturesService, pendoService, i18n, config){
|
||||||
|
|
||||||
var calcDaysRemaining = function(seconds){
|
var calcDaysRemaining = function(seconds){
|
||||||
// calculate the number of days remaining on the license
|
// calculate the number of days remaining on the license
|
||||||
@@ -38,18 +38,13 @@ export default
|
|||||||
// license/license.partial.html compares fileName
|
// license/license.partial.html compares fileName
|
||||||
$scope.fileName = N_("No file selected.");
|
$scope.fileName = N_("No file selected.");
|
||||||
$scope.title = $rootScope.licenseMissing ? ("Tower " + i18n._("License")) : i18n._("License Management");
|
$scope.title = $rootScope.licenseMissing ? ("Tower " + i18n._("License")) : i18n._("License Management");
|
||||||
Wait('start');
|
$scope.license = config;
|
||||||
ConfigService.delete();
|
$scope.license.version = config.version.split('-')[0];
|
||||||
ConfigService.getConfig().then(function(config){
|
$scope.time = {};
|
||||||
$scope.license = config;
|
$scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining);
|
||||||
$scope.license.version = config.version.split('-')[0];
|
$scope.time.expiresOn = calcExpiresOn($scope.license.license_info.license_date);
|
||||||
$scope.time = {};
|
$scope.valid = CheckLicense.valid($scope.license.license_info);
|
||||||
$scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining);
|
$scope.compliant = $scope.license.license_info.compliant;
|
||||||
$scope.time.expiresOn = calcExpiresOn($scope.license.license_info.license_date);
|
|
||||||
$scope.valid = CheckLicense.valid($scope.license.license_info);
|
|
||||||
$scope.compliant = $scope.license.license_info.compliant;
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="License-form" name="license">
|
<form id="License-form" name="uploadlicense">
|
||||||
<div class="License-subTitleText prepend-asterisk"> <translate>License File</translate></div>
|
<div class="License-subTitleText prepend-asterisk"> <translate>License File</translate></div>
|
||||||
<div class="input-group License-file--container">
|
<div class="input-group License-file--container">
|
||||||
<span class="btn btn-primary" ng-click="fakeClick()" translate>Browse</span>
|
<span class="btn btn-primary" ng-click="fakeClick()" translate>Browse</span>
|
||||||
|
|||||||
@@ -24,6 +24,15 @@ export default {
|
|||||||
return CheckLicense.notify();
|
return CheckLicense.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
}]
|
}],
|
||||||
|
config: ['ConfigService', 'CheckLicense', '$rootScope',
|
||||||
|
function(ConfigService, CheckLicense, $rootScope) {
|
||||||
|
ConfigService.delete();
|
||||||
|
return ConfigService.getConfig()
|
||||||
|
.then(function(config){
|
||||||
|
$rootScope.licenseMissing = (CheckLicense.valid(config.license_info) === false) ? true : false;
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ describe('Controller: LicenseController', () => {
|
|||||||
let scope,
|
let scope,
|
||||||
LicenseController,
|
LicenseController,
|
||||||
ConfigService,
|
ConfigService,
|
||||||
ProcessErrors;
|
ProcessErrors,
|
||||||
|
config;
|
||||||
|
|
||||||
beforeEach(angular.mock.module('Tower'));
|
beforeEach(angular.mock.module('Tower'));
|
||||||
beforeEach(angular.mock.module('license', ($provide) => {
|
beforeEach(angular.mock.module('license', ($provide) => {
|
||||||
@@ -14,40 +15,33 @@ describe('Controller: LicenseController', () => {
|
|||||||
'delete'
|
'delete'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ConfigService.getConfig.and.returnValue({
|
config = {
|
||||||
then: function(callback){
|
license_info: {
|
||||||
return callback({
|
time_remaining: 1234567 // seconds
|
||||||
license_info: {
|
},
|
||||||
time_remaining: 1234567 // seconds
|
version: '3.1.0-devel'
|
||||||
},
|
};
|
||||||
version: '3.1.0-devel'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ProcessErrors = jasmine.createSpy('ProcessErrors');
|
ProcessErrors = jasmine.createSpy('ProcessErrors');
|
||||||
|
|
||||||
$provide.value('ConfigService', ConfigService);
|
$provide.value('ConfigService', ConfigService);
|
||||||
$provide.value('ProcessErrors', ProcessErrors);
|
$provide.value('ProcessErrors', ProcessErrors);
|
||||||
|
$provide.value('config', config);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_) => {
|
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_, _config_) => {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
ConfigService = _ConfigService_;
|
ConfigService = _ConfigService_;
|
||||||
ProcessErrors = _ProcessErrors_;
|
ProcessErrors = _ProcessErrors_;
|
||||||
|
config = _config_;
|
||||||
LicenseController = $controller('licenseController', {
|
LicenseController = $controller('licenseController', {
|
||||||
$scope: scope,
|
$scope: scope,
|
||||||
ConfigService: ConfigService,
|
ConfigService: ConfigService,
|
||||||
ProcessErrors: ProcessErrors
|
ProcessErrors: ProcessErrors,
|
||||||
|
config: config
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Suites
|
|
||||||
it('should GET a config object on initialization', ()=>{
|
|
||||||
expect(ConfigService.delete).toHaveBeenCalled();
|
|
||||||
expect(ConfigService.getConfig).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
xit('should show correct expiration date', ()=>{
|
xit('should show correct expiration date', ()=>{
|
||||||
let date = new Date(),
|
let date = new Date(),
|
||||||
options = {
|
options = {
|
||||||
|
|||||||
Reference in New Issue
Block a user