in gateway-admin-ui/admin-ui/app/provider-config-wizard/provider-config-wizard.component.ts [122:194]
onFinishAdd() {
console.debug('ProviderConfigWizard --> Selected provider category: ' + this.selectedCategory);
let catWizard = this.getCategoryWizard(this.selectedCategory);
let type = catWizard ? catWizard.getSelectedType() : 'undefined';
console.debug('ProviderConfigWizard --> Selected provider type: ' + type);
if (catWizard) {
let pc: ProviderConfig;
let isContributed = false;
let isContributingWizard = false;
if (ProviderConfigWizardComponent.isProviderContributorWizard(catWizard)) {
isContributingWizard = true;
let contribWiz = catWizard as ProviderContributorWizard;
let role = contribWiz.getProviderRole();
console.debug('Wizard is ProviderContributorWizard for role ' + role);
for (let provider of this.providers) {
if (role === provider.role) {
console.debug('Found existing provider config for ' + role);
pc = provider;
break;
}
}
if (!pc) {
console.debug('No existing provider config found for ' + role + ', so creating one...');
pc = contribWiz.createNewProviderConfig();
this.providers.push(pc);
}
// If there is an existing provider config of the current type
if (pc) {
if (ProviderConfigWizardComponent.isProviderConfigValid(catWizard.getProviderConfig())) {
contribWiz.contribute(pc);
isContributed = true;
} else {
console.debug('CategoryWizard ProviderConfig is not valid.');
}
}
}
if (!pc && !isContributingWizard) { // If not a contributing wizard, just use the category wizard's provider config
pc = catWizard.getProviderConfig();
}
if (pc && (isContributed || (!isContributingWizard && ProviderConfigWizardComponent.isProviderConfigValid(pc)))) {
if (!isContributed) {
this.providers.push(pc);
}
console.debug('ProviderConfigWizard --> Provider: name=' + pc.name + ', role=' + pc.role + ', enabled=' + pc.enabled);
if (pc.params) {
// If the provider is managing its own param order, allow it to re-order the params now
if (ProviderConfigWizardComponent.isOrderedParamContainer(pc)) {
pc.params = (pc as OrderedParamContainer).orderParams(pc.params);
}
for (let name of Object.getOwnPropertyNames(pc.params)) {
console.debug('\tParam: ' + name + ' = ' + pc.params[name]);
}
}
this.step = 0; // Return to the beginning
// Clear the wizard state
this.getCategoryWizard(this.selectedCategory).reset();
} else {
console.debug('ProviderConfig is missing or invalid.');
}
}
}