add license route to settings page

This commit is contained in:
John Mitchell
2018-04-03 17:36:46 -04:00
parent 652bdf7875
commit 4e6ce9af18
6 changed files with 97 additions and 22 deletions

View File

@@ -2328,6 +2328,10 @@ body {
margin-top: 20px; margin-top: 20px;
} }
.Panel--noBottomPadding {
padding-bottom: 0px;
}
.Panel-hidden { .Panel-hidden {
display: none; display: none;
} }

View File

@@ -3,6 +3,7 @@
* *
* All Rights Reserved * All Rights Reserved
*************************************************/ *************************************************/
import defaultStrings from '~assets/default.strings.json';
export default [ export default [
'$scope', '$rootScope', '$state', '$stateParams', '$timeout', '$q', 'Alert', '$scope', '$rootScope', '$state', '$stateParams', '$timeout', '$q', 'Alert',
@@ -55,6 +56,8 @@ export default [
) { ) {
var vm = this; var vm = this;
vm.product = defaultStrings.BRAND_NAME;
var formDefs = { var formDefs = {
'azure': configurationAzureForm, 'azure': configurationAzureForm,
'github': configurationGithubForm, 'github': configurationGithubForm,
@@ -219,7 +222,7 @@ export default [
}; };
function activeTabCheck(setForm) { function activeTabCheck(setForm) {
if(!$scope[formTracker.currentFormName()].$dirty) { if(!$scope[formTracker.currentFormName()] || !$scope[formTracker.currentFormName()].$dirty) {
active(setForm); active(setForm);
} else { } else {
var msg = i18n._('You have unsaved changes. Would you like to proceed <strong>without</strong> saving?'); var msg = i18n._('You have unsaved changes. Would you like to proceed <strong>without</strong> saving?');
@@ -268,18 +271,30 @@ export default [
formTracker.setCurrentSystem(formTracker.currentSystem); formTracker.setCurrentSystem(formTracker.currentSystem);
} }
} }
else {
formTracker.setCurrent(setForm);
}
vm.activeTab = setForm; vm.activeTab = setForm;
$state.go('configuration', {
currentTab: setForm if (setForm !== 'license') {
}, { formTracker.setCurrent(setForm);
location: true,
inherit: false, $state.go('configuration', {
notify: false, currentTab: setForm
reload: false }, {
}); location: true,
inherit: false,
notify: false,
reload: false
});
} else {
$state.go('configuration.license', {
currentTab: setForm
}, {
location: true,
inherit: false,
notify: false,
reload: false
});
}
} }
var formCancel = function() { var formCancel = function() {

View File

@@ -5,7 +5,7 @@
</div> </div>
<div class="tab-pane" id="configuration-panel"> <div class="tab-pane" id="configuration-panel">
<div ng-cloak id="htmlTemplate" class="Panel"> <div ng-cloak id="htmlTemplate" class="Panel" ng-class="{'Panel--noBottomPadding': vm.activeTab === 'license' }">
<div class="Form-header"> <div class="Form-header">
<div class="Form-title" translate>CONFIGURE {{BRAND_NAME}}</div> <div class="Form-title" translate>CONFIGURE {{BRAND_NAME}}</div>
</div> </div>
@@ -16,6 +16,7 @@
<div class="Form-tab" ng-click="vm.activeTabCheck('jobs')" ng-class="{'is-selected': vm.activeTab === 'jobs' }" translate>Jobs</div> <div class="Form-tab" ng-click="vm.activeTabCheck('jobs')" ng-class="{'is-selected': vm.activeTab === 'jobs' }" translate>Jobs</div>
<div class="Form-tab" ng-click="vm.activeTabCheck('system')" ng-class="{'is-selected': vm.activeTab === 'system' }" translate>System</div> <div class="Form-tab" ng-click="vm.activeTabCheck('system')" ng-class="{'is-selected': vm.activeTab === 'system' }" translate>System</div>
<div class="Form-tab" ng-click="vm.activeTabCheck('ui')" ng-class="{'is-selected': vm.activeTab === 'ui' }" translate>User Interface</div> <div class="Form-tab" ng-click="vm.activeTabCheck('ui')" ng-class="{'is-selected': vm.activeTab === 'ui' }" translate>User Interface</div>
<div class="Form-tab" ng-show="vm.product === 'Tower'" ng-click="vm.activeTabCheck('license')" ng-class="{'is-selected': vm.activeTab === 'license' }" translate>License</div>
</div> </div>
</div> </div>
</div> </div>
@@ -26,3 +27,5 @@
<div id="FormModal-dialog"></div> <div id="FormModal-dialog"></div>
</div> </div>
</div> </div>
<div ui-view="license" ng-show="vm.product === 'Tower' && vm.activeTab === 'license'"></div>

View File

@@ -3,16 +3,15 @@
* *
* All Rights Reserved * All Rights Reserved
*************************************************/ *************************************************/
import {templateUrl} from '../shared/template-url/template-url.factory';
import {templateUrl} from '../shared/template-url/template-url.factory'; import ConfigurationController from './configuration.controller';
import ConfigurationController from './configuration.controller'; import { N_ } from '../i18n';
import { N_ } from '../i18n';
// Import form controllers // Import form controllers
import ConfigurationAuthController from './auth-form/configuration-auth.controller'; import ConfigurationAuthController from './auth-form/configuration-auth.controller';
import ConfigurationJobsController from './jobs-form/configuration-jobs.controller'; import ConfigurationJobsController from './jobs-form/configuration-jobs.controller';
import ConfigurationSystemController from './system-form/configuration-system.controller'; import ConfigurationSystemController from './system-form/configuration-system.controller';
import ConfigurationUiController from './ui-form/configuration-ui.controller'; import ConfigurationUiController from './ui-form/configuration-ui.controller';
export default { export default {
name: 'configuration', name: 'configuration',
@@ -58,6 +57,6 @@
templateUrl: templateUrl('configuration/ui-form/configuration-ui'), templateUrl: templateUrl('configuration/ui-form/configuration-ui'),
controller: ConfigurationUiController, controller: ConfigurationUiController,
controllerAs: 'uiVm' controllerAs: 'uiVm'
} },
}, },
}; };

View File

@@ -0,0 +1,52 @@
/*************************************************
* Copyright (c) 2016 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
import {templateUrl} from '../shared/template-url/template-url.factory';
import { N_ } from '../i18n';
import _ from 'lodash';
export default {
name: 'configuration.license',
route: '/license',
// templateUrl: templateUrl('license/license'),
// controller: 'licenseController',
data: {},
ncyBreadcrumb: {
label: N_('LICENSE')
},
onEnter: ['$state', 'ConfigService', (state, configService) => {
return configService.getConfig()
.then(config => {
if (_.get(config, 'license_info.license_type') === 'open') {
return state.go('setup');
}
});
}],
views: {
'license@configuration': {
templateUrl: templateUrl('license/license'),
controller: 'licenseController'
},
},
resolve: {
features: ['CheckLicense', '$rootScope',
function(CheckLicense, $rootScope) {
if($rootScope.licenseMissing === undefined){
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;
});
}]
},
};

View File

@@ -7,6 +7,7 @@
import configurationService from './configuration.service'; import configurationService from './configuration.service';
import ConfigurationUtils from './configurationUtils.service'; import ConfigurationUtils from './configurationUtils.service';
import configurationRoute from './configuration.route'; import configurationRoute from './configuration.route';
import licenseRoute from './license.route';
import configurationController from './configuration.controller.js'; import configurationController from './configuration.controller.js';
// Import forms // Import forms
@@ -66,4 +67,5 @@ angular.module('configuration', [])
.service('ConfigurationService', configurationService) .service('ConfigurationService', configurationService)
.run(['$stateExtender', function($stateExtender) { .run(['$stateExtender', function($stateExtender) {
$stateExtender.addState(configurationRoute); $stateExtender.addState(configurationRoute);
$stateExtender.addState(licenseRoute);
}]); }]);