aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller
diff options
context:
space:
mode:
authorMichael Mokry <mm117s@att.com>2017-07-07 16:00:59 -0500
committerMichael Mokry <mm117s@att.com>2017-07-10 18:58:00 +0000
commiteb654437ee2815028602daa943d0a939a5bee3cd (patch)
tree77ad3b26bcf60a80cbbf87dbd1b06f60de976c39 /POLICY-SDK-APP/src/main/webapp/app/policyApp/controller
parentbb927b5325d7b82cdc65bf25aa217ad7c56a46b3 (diff)
[POLICY-67] Add new Rainy Day Decision Policy
Change-Id: I8fb730e4363c885ccbe3a05ae971c5de5608d70c Signed-off-by: Michael Mokry <mm117s@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/webapp/app/policyApp/controller')
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js100
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/DecisionRainyDayDictGridController.js153
3 files changed, 254 insertions, 1 deletions
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js
index 243591f22..cf0d0961c 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js
@@ -24,7 +24,7 @@ var subDictionarys = [["Action Dictionary"],
["BRMS Controller" , "BRMS Dependency", "BRMS Param Template"],
["Attribute Dictionary","EcompName Dictionary"],
["PEP Options","Site Dictionary","Service Dictionary","Varbind Dictionary", "VNF Type","VSCL Action"],
- ["Settings Dictionary"],
+ ["Settings Dictionary","Rainy Day Allowed Treatments"],
["Descriptive Scope"],
["Action List", "Address Group", "Parent Dictionary List", "Port List", "Prefix List", "Protocol List", "Security Zone", "Service Group", "Service List", "Tag List", "Tag Picker List", "Term List", "Zone"],
["DCAE UUID","MicroService ConfigName","MicroService Location", "MicroService Models", "MicroService Dictionary"],
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js
new file mode 100644
index 000000000..fc34fa7ca
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+app.controller('editRainyDayDictController' , function ($scope, $modalInstance, message, UserInfoServiceDS2, Notification){
+
+ if(message.rainyDayDictionaryData==null)
+ $scope.label='Add Allowed Treatments',
+ $scope.treatments = [];
+ else{
+ $scope.treatments = [];
+ $scope.label='Edit Treatment'
+ $scope.disableCd=true;
+ var headers = message.rainyDayDictionaryData.treatments;
+ var splitEqual = ',';
+ if(headers != null && headers != ""){
+ if (headers.indexOf(splitEqual) >= 0) {
+ var splitValue = headers.split(splitEqual);
+ for(i = 0; i < splitValue.length; i++){
+ var key = splitValue[i];
+ $scope.treatments.push({'treatment': key});
+ }
+ }else{
+ var key = headers;
+ $scope.treatments.push({'treatment': key});
+ }
+ }
+ }
+
+
+ /*getting user info from session*/
+ var userid = null;
+ UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
+ .then(function (response) {
+ userid = response.userid;
+ });
+
+ $scope.editRainyDayTreatment = message.rainyDayDictionaryData;
+ $scope.saveDecisionTreatments = function(rainyDayDictionaryData) {
+ var finalData = extend(rainyDayDictionaryData, $scope.treatmentDatas[0]);
+ var uuu = "saveDictionary/decision_dictionary/save_RainyDay";
+ var postData={rainyDayDictionaryData: rainyDayDictionaryData, userid: userid};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){
+ $scope.rainyDayDictionaryDatas=data.rainyDayDictionaryDatas;});
+ if($scope.rainyDayDictionaryDatas == "Duplicate"){
+ Notification.error("Allowed Treatments Dictionary exists with Same Building Block and Workstep.")
+ }else{
+ console.log($scope.rainyDayDictionaryDatas);
+ $modalInstance.close({rainyDayDictionaryDatas:$scope.rainyDayDictionaryDatas});
+ }
+ },
+ error : function(data){
+ alert("Error while saving.");
+ }
+ });
+ };
+
+ function extend(obj, src) {
+ for (var key in src) {
+ if (src.hasOwnProperty(key)) obj[key] = src[key];
+ }
+ return obj;
+ }
+
+ $scope.treatmentDatas = [{"userDataTypeValues" : $scope.treatments}];
+ $scope.addNewTreatment = function() {
+ $scope.treatments.push({});
+ };
+ $scope.removeTreatment = function() {
+ var lastItem = $scope.treatments.length-1;
+ $scope.treatments.splice(lastItem);
+ };
+
+
+ $scope.close = function() {
+ $modalInstance.close();
+ };
+}); \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/DecisionRainyDayDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/DecisionRainyDayDictGridController.js
new file mode 100644
index 000000000..e4fa18645
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/DecisionRainyDayDictGridController.js
@@ -0,0 +1,153 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+app.controller('decisionRainyDayDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+ $( "#dialog" ).hide();
+
+ PolicyAppService.getData('getDictionary/get_RainyDayDictionaryData').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.rainyDayDictionaryDatas = JSON.parse($scope.data.rainyDayDictionaryDatas);
+ console.log($scope.rainyDayDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('get_LockDownData').then(function(data){
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
+ if($scope.lockdowndata[0].lockdown == true){
+ $scope.decisionRainyDayDictionaryGrid.columnDefs[0].visible = false;
+ $scope.gridApi.grid.refresh();
+ }else{
+ $scope.decisionRainyDayDictionaryGrid.columnDefs[0].visible = true;
+ $scope.gridApi.grid.refresh();
+ }
+ },function(error){
+ console.log("failed");
+ });
+ $scope.decisionRainyDayDictionaryGrid = {
+ data : 'rainyDayDictionaryDatas',
+ enableFiltering: true,
+ exporterCsvFilename: 'AllowedTreatments.csv',
+ enableGridMenu: true,
+ enableSelectAll: true,
+ columnDefs: [{
+ field: 'id', enableFiltering: false, headerCellTemplate: '' +
+ '<button id=\'New\' ng-click="grid.appScope.createNewRainyDayDictWindow()" class="btn btn-success">' + 'Create</button>',
+ cellTemplate:
+ '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editRainyDayDictWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
+ '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteRainyDayDict(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
+ },
+ {field: 'bbid', displayName : 'Building Block ID', sort: { direction: 'asc', priority: 0 }},
+ {field: 'workstep', displayName : 'Work Step' },
+ {field: 'treatments', displayName : 'Allowed Treatments'}
+ ],
+ exporterMenuPdf: false,
+ exporterPdfDefaultStyle: {fontSize: 9},
+ exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
+ exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
+ exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
+ exporterPdfFooter: function ( currentPage, pageCount ) {
+ return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
+ },
+ exporterPdfCustomFormatter: function ( docDefinition ) {
+ docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
+ docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
+ return docDefinition;
+ },
+ exporterPdfOrientation: 'portrait',
+ exporterPdfPageSize: 'LETTER',
+ exporterPdfMaxGridWidth: 500,
+ exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
+ onRegisterApi: function(gridApi){
+ $scope.gridApi = gridApi;
+ }
+ };
+
+ $scope.editRainyDayTreatment = null;
+ $scope.createNewRainyDayDictWindow = function(){
+ $scope.editRainyDayTreatment = null;
+ var modalInstance = $modal.open({
+ backdrop: 'static', keyboard: false,
+ templateUrl : 'add_RainyDayDict_popup.html',
+ controller: 'editRainyDayDictController',
+ resolve: {
+ message: function () {
+ var message = {
+ rainyDayDictionaryDatas: $scope.editRainyDayTreatment
+ };
+ return message;
+ }
+ }
+ });
+ modalInstance.result.then(function(response){
+ console.log('response', response);
+ $scope.rainyDayDictionaryDatas=response.rainyDayDictionaryDatas;
+ });
+ };
+
+ $scope.editRainyDayDictWindow = function(rainyDayDictionaryData) {
+ $scope.editRainyDayTreatment = rainyDayDictionaryData;
+ var modalInstance = $modal.open({
+ backdrop: 'static', keyboard: false,
+ templateUrl : 'add_RainyDayDict_popup.html',
+ controller: 'editRainyDayDictController',
+ resolve: {
+ message: function () {
+ var message = {
+ rainyDayDictionaryData: $scope.editRainyDayTreatment
+ };
+ return message;
+ }
+ }
+ });
+ modalInstance.result.then(function(response){
+ console.log('response', response);
+ $scope.rainyDayDictionaryDatas = response.rainyDayDictionaryDatas;
+ });
+ };
+
+ $scope.deleteRainyDayDict = function(data) {
+ modalService.popupConfirmWin("Confirm","You are about to delete the Rainy Day Allowed Treatment Dictionary "+data.allowedTreatments+". Do you want to continue?",
+ function(){
+ var uuu = "deleteDictionary/decision_dictionary/remove_rainyDay";
+ var postData={data: data};
+ $.ajax({
+ type : 'POST',
+ url : uuu,
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(postData),
+ success : function(data){
+ $scope.$apply(function(){$scope.rainyDayDictionaryDatas=data.rainyDayDictionaryDatas;});
+ },
+ error : function(data){
+ console.log(data);
+ modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
+ }
+ });
+
+ })
+ };
+
+
+}); \ No newline at end of file