Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / fusion / scripts / controllers / jcs-admin-controller.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 app.controller('cacheAdminController', function ($scope,$interval,$http,$modal,modalService,AdminService){
21         
22     AdminService.getCacheRegions().then(function(data){
23                 
24                 var j = data;
25                 $scope.data = JSON.parse(j.data);
26                 $scope.regions =$scope.data;
27                 //$scope.resetMenu();
28         
29         },function(error){
30                 console.log("failed");
31                 reloadPageOnce();
32         });
33         $scope.clearAll = function() {
34                 modalService.popupConfirmWin("Confirm",'You are about to clear all of the items for all cache regions. Do you want to continue?',
35                         function(){
36                                 $http.get("jcs_admin/clearAll").success(function(response){$scope.regions=response;});
37                                         
38         })
39         };
40         
41         $scope.clearRegion = function(cacheName) {
42                 modalService.popupConfirmWin("Confirm",'You are about to clear all of the items in the cache region "' + cacheName + '". Do you want to continue?',
43                         function(){
44                                $http.get("jcs_admin/clearRegion?cacheName="+cacheName).success(function(response){$scope.regions=response;});
45                                         
46         })
47         };
48         
49         $scope.clearItem = function(cacheName,key) {
50                 modalService.popupConfirmWin("Confirm",'You are about to clear this item from the cache region "' + cacheName + '". Do you want to continue?',
51                         function(){
52                                $http.get("jcs_admin/clearItem?keyName="+key+"&cacheName="+cacheName).success(function(response){$scope.regions=response;});
53                                         
54         })
55         };
56         
57         $scope.showRegionDetails = function(cacheName) {
58                 $http.get("jcs_admin/showRegionDetails?cacheName="+cacheName).success(function(response){modalService.showSuccess('',response);});
59         };
60
61         $scope.showItemDetails = function(cacheName,key) {
62                         $http.get("jcs_admin/showItemDetails?keyName="+key+"&cacheName="+cacheName).success(function(response){ 
63                                 var message = "CacheName: "+ response.cacheName 
64                                         +"\nkey: "+response.key
65                                         +"\nIS_SPOOL: "+response.attr.IS_SPOOL
66                                         +"\nIS_LATERAL: "+response.attr.IS_LATERAL
67                                         +"\nIS_REMOTE: "+response.attr.IS_REMOTE
68                                         +"\nIS_ETERNAL: "+response.attr.IS_ETERNAL
69                                         +"\nversion: "+response.attr.version
70                                         +"\nmaxLifeSeconds: "+response.attr.maxLifeSeconds
71                                         +"\nmaxIdleTimeSeconds: "+response.attr.maxIdleTimeSeconds
72                                         +"\nsize: "+response.attr.size
73                                         +"\ncreateTime: "+response.attr.createTime
74                                         +"\nlastAccessTime: "+response.attr.lastAccessTime
75                                         +"\nidleTime: "+response.attr.idleTime
76                                         +"\ntimeToLiveSeconds: "+response.attr.timeToLiveSeconds
77                                         +"\nisSpool: "+response.attr.isSpool
78                                         +"\nisLateral: "+response.attr.isLateral
79                                         +"\nisRemote: "+response.attr.isRemote
80                                         +"\nisEternal: "+response.attr.isEternal;
81                                 modalService.showSuccess('',message);});
82         };
83 });