135 lines
7.6 KiB
JavaScript
135 lines
7.6 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('changeModule')
|
|
.directive('impactAnalysisBanner', ['$state', 'i18nService', 'systemAlertService', 'ticketModel', 'relationModel', '$filter', 'events',
|
|
function ($state, i18nService, systemAlertService, ticketModel, relationModel, $filter, events) {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
templateUrl: 'views/impact-analysis/impact-analysis-banner.html',
|
|
scope: {
|
|
context: '=',
|
|
impactAnalysisStatus: '='
|
|
},
|
|
link: function (scope) {
|
|
scope.toggle = function () {
|
|
scope.visible = !scope.visible;
|
|
};
|
|
scope.conductImpactAnalysis = function () {
|
|
$state.go('impactGraph', { id: scope.context.id, type: EntityVO.TYPE_CHANGE, displayId: scope.context.displayId });
|
|
};
|
|
scope.relateAllCIs = function () {
|
|
var modalOptions = {
|
|
type: 'info',
|
|
title: i18nService.getLocalizedString('impactAnalysis.relateAndComplete.title'),
|
|
text: i18nService.getLocalizedString('impactAnalysis.relateAndComplete.question.allCIs'),
|
|
details: i18nService.getLocalizedString('impactAnalysis.relateAndComplete.details'),
|
|
additionalInfo: i18nService.getLocalizedString('create.change.wizard.ci.confirmCIRelation.text'),
|
|
buttons: [
|
|
{
|
|
text: i18nService.getLocalizedString('impactAnalysis.relateAndComplete.confirmation.yes'),
|
|
data: true
|
|
},
|
|
{
|
|
text: i18nService.getLocalizedString('impactAnalysis.relateAndComplete.confirmation.no'),
|
|
data: false
|
|
}
|
|
]
|
|
};
|
|
return systemAlertService.modal(modalOptions).result.then(function (data) {
|
|
if (data) {
|
|
var relatedCIs = [];
|
|
scope.$emit(events.SHOW_PROGRESS_MODAL_FOR_EDIT, {
|
|
showModal: true,
|
|
title: $filter('i18n')('change.details.relatingCIs.title'),
|
|
text: $filter('i18n')('change.details.relatingCIs.text')
|
|
});
|
|
ticketModel.getImpactAnalysisVisualisationData(EntityVO.TYPE_CHANGE, scope.context.id)
|
|
.then(function (impactData) {
|
|
_.each(impactData.impactedCIs, function (ci) {
|
|
if (!ci.isRelated) {
|
|
relatedCIs.push({
|
|
id: ci.reconciliationId,
|
|
desc: ci.name,
|
|
tag: "linkeditem",
|
|
relationshipType: "impacts",
|
|
type: "asset"
|
|
});
|
|
}
|
|
});
|
|
relationModel.addRelation({ uuid: scope.context.id, type: EntityVO.TYPE_CHANGE }, relatedCIs)
|
|
.finally(function () {
|
|
ticketModel.impactAnalysisAction(scope.context.id, EntityVO.TYPE_CHANGE, { "command": "dismiss" }).then(function () {
|
|
scope.context.hasImpactAnalysis = false;
|
|
scope.$emit(events.SHOW_PROGRESS_MODAL_FOR_EDIT, { showModal: false });
|
|
systemAlertService.success({
|
|
text: $filter('i18n')('ticket.notification.link.message', relatedCIs.length),
|
|
hide: 10000
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
scope.ignoreandDismiss = function () {
|
|
return systemAlertService.modal({
|
|
title: i18nService.getLocalizedString('impact.analysis.dismiss.modal.title'),
|
|
text: i18nService.getLocalizedString('impact.analysis.dismiss.modal.text'),
|
|
buttons: [
|
|
{
|
|
text: i18nService.getLocalizedString('common.button.yes'),
|
|
data: true
|
|
},
|
|
{
|
|
text: i18nService.getLocalizedString('common.button.no'),
|
|
data: false
|
|
}
|
|
]
|
|
}).result.then(function (data) {
|
|
if (data) {
|
|
scope.dismiss();
|
|
}
|
|
});
|
|
};
|
|
scope.cancelImpactAnalysis = function () {
|
|
return systemAlertService.modal({
|
|
title: i18nService.getLocalizedString('impact.analysis.cancel.modal.title'),
|
|
text: i18nService.getLocalizedString('impact.analysis.cancel.modal.text'),
|
|
buttons: [
|
|
{
|
|
text: i18nService.getLocalizedString('common.button.yes'),
|
|
data: true
|
|
},
|
|
{
|
|
text: i18nService.getLocalizedString('common.button.no'),
|
|
data: false
|
|
}
|
|
]
|
|
}).result.then(function (data) {
|
|
if (data) {
|
|
scope.loading = true;
|
|
var command = { "command": "cancel" }; //start will start the impact analysis
|
|
ticketModel.impactAnalysisAction(scope.context.id, EntityVO.TYPE_CHANGE, command)
|
|
.then(function () {
|
|
scope.context.hasImpactAnalysis = false;
|
|
scope.loading = false;
|
|
});
|
|
}
|
|
});
|
|
};
|
|
scope.dismiss = function () {
|
|
scope.loading = true;
|
|
var command = { "command": "dismiss" }; //start will start the impact analysis
|
|
ticketModel.impactAnalysisAction(scope.context.id, EntityVO.TYPE_CHANGE, command)
|
|
.then(function () {
|
|
scope.context.hasImpactAnalysis = false;
|
|
scope.loading = false;
|
|
});
|
|
};
|
|
}
|
|
};
|
|
}]);
|
|
})();
|