Project

General

Profile

« Previous | Next » 

Revision 55499

[maven-release-plugin] copy for tag dnet-objectStore-ui-2.0.0

View differences:

modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-objectStore-ui/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-objectStore-ui"}
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/ObjectStoreServiceEntryPointController.java
1
/**
2
 * Created by Sandro La Bruzzo on 11/18/15.
3
 */
4

  
5
package eu.dnetlib.functionality.modular.ui.objectStore;
6

  
7
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
8
import org.springframework.ui.ModelMap;
9

  
10
import javax.servlet.http.HttpServletRequest;
11
import javax.servlet.http.HttpServletResponse;
12

  
13
public class ObjectStoreServiceEntryPointController extends ModuleEntryPoint {
14
    @Override
15
    protected void initialize(ModelMap modelMap, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
16

  
17
    }
18
}
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/ObjectStoreServiceInternalController.java
1
package eu.dnetlib.functionality.modular.ui.objectStore;
2

  
3
import com.google.common.base.Function;
4
import com.google.common.collect.Lists;
5
import com.google.common.collect.Maps;
6
import com.google.gson.Gson;
7
import eu.dnetlib.data.objectstore.modular.ModularObjectStoreDeliver;
8
import eu.dnetlib.data.objectstore.modular.ModularObjectStoreService;
9
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
10
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
11
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
12
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
13
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
14
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
15
import eu.dnetlib.enabling.resultset.ResultSetListener;
16
import eu.dnetlib.functionality.modular.ui.objectStore.info.ObjectStoreInfo;
17
import org.apache.commons.lang.StringUtils;
18
import org.apache.commons.logging.Log;
19
import org.apache.commons.logging.LogFactory;
20
import org.springframework.beans.factory.annotation.Autowired;
21
import org.springframework.stereotype.Controller;
22
import org.springframework.ui.ModelMap;
23
import org.springframework.web.bind.annotation.RequestMapping;
24
import org.springframework.web.bind.annotation.RequestParam;
25
import org.springframework.web.bind.annotation.ResponseBody;
26

  
27
import java.util.List;
28
import java.util.Map;
29

  
30
/**
31
 * Created by Sandro La Bruzzo on 11/18/15.
32
 */
33

  
34
@Controller
35
public class ObjectStoreServiceInternalController {
36

  
37

  
38
    private static final Log log = LogFactory.getLog(ObjectStoreServiceInternalController.class);
39

  
40
    @Autowired
41
    public UniqueServiceLocator serviceLocator;
42

  
43

  
44
    @Autowired
45
    public ModularObjectStoreService objectStoreservice;
46

  
47
    private final Gson gson = new Gson();
48

  
49

  
50
    private final Function<String, ObjectStoreFile> convertFunction = new Function<String, ObjectStoreFile>() {
51
        @Override
52
        public ObjectStoreFile apply(String input) {
53
            return gson.fromJson(input, ObjectStoreFile.class);
54
        }
55
    };
56

  
57

  
58
    @RequestMapping(value = "/ui/objectStore/listObjectStores.do")
59
    @ResponseBody
60
    public List<ObjectStoreInfo> listObjectStoreInfo(final ModelMap map) throws ObjectStoreServiceException {
61
        final Map<String, ObjectStoreInfo> inputObjectStore = Maps.newHashMap();
62
        retrieveObjectStoreFromProfiles(inputObjectStore);
63
        retrieveObjectStoreFromService(inputObjectStore);
64
        return Lists.newArrayList(inputObjectStore.values());
65
    }
66

  
67

  
68
    private void retrieveObjectStoreFromService(final Map<String, ObjectStoreInfo> inputMap) {
69

  
70
        final List<String> stores = objectStoreservice.getFeeder().getDao().listObjectStores();
71
        for (final String s : stores) {
72
            if (!inputMap.containsKey(s)) {
73
                try {
74
                    final ObjectStoreInfo info = new ObjectStoreInfo();
75
                    final ObjectStore store = objectStoreservice.getObjectStoreDeliver().getDao().getObjectStore(s);
76
                    info.setInterpretation(store.getInterpretation());
77
                    info.setSize(store.getSize());
78
                    info.setObjectStoreId(s);
79
                    info.setMissingObjectStore(false);
80
                    inputMap.put(s, info);
81
                } catch (ObjectStoreServiceException e) {
82
                    log.error(e);
83
                }
84
            } else {
85
                inputMap.get(s).setMissingObjectStore(false);
86
            }
87
        }
88
    }
89

  
90

  
91
    private void retrieveObjectStoreFromProfiles(final Map<String, ObjectStoreInfo> inputMap) {
92
        final String query = "for $x in  collection('/db/DRIVER/ObjectStoreDSResources/ObjectStoreDSResourceType') \n" +
93
                "let $interpretation :=$x//OBJECTSTORE_INTERPRETATION\n" +
94
                "let $uri := $x//RESOURCE_URI/@value/string()  \n" +
95
                "let $id := $x//RESOURCE_IDENTIFIER/@value/string() \n" +
96
                "let $lastDate := $x//LAST_STORAGE_DATE  \n" +
97
                "let $size :=$x//STORE_SIZE \n" +
98
                "return concat($uri,'@::@',$id,'@::@',$interpretation,'@::@',$lastDate,'@::@',$size) ";
99

  
100

  
101
        ISLookUpService lookUpService = serviceLocator.getService(ISLookUpService.class);
102
        try {
103
            List<String> results = lookUpService.quickSearchProfile(query);
104
            if (results == null) return;
105
            for (String result : results) {
106
                String dataInfo[] = result.split("@::@");
107
                if (dataInfo != null && dataInfo.length == 5) {
108
                    final String webUri = dataInfo[0];
109
                    final String id = dataInfo[1];
110
                    final String interpretation = dataInfo[2];
111
                    final String lastDate = dataInfo[3];
112
                    final int size = Integer.parseInt(dataInfo[4]);
113
                    final ObjectStoreInfo currentInfo = new ObjectStoreInfo();
114
                    currentInfo.setObjectStoreId(id);
115
                    currentInfo.setInterpretation(interpretation);
116
                    currentInfo.setLastStorageDate(lastDate);
117
                    currentInfo.setSize(size);
118
                    currentInfo.setServiceURI(webUri);
119
                    currentInfo.setMissingProfile(false);
120
                    inputMap.put(id, currentInfo);
121
                }
122
            }
123
        } catch (ISLookUpException e) {
124
            log.error(String.format("%s", "Error on making query on is " + query, e));
125
        }
126
    }
127

  
128

  
129
    @RequestMapping(value = "/ui/objectStore/getObjectStoreInfo.do")
130
    @ResponseBody
131
    public ObjectStoreInfo getObjectStoreInfo(
132
            final ModelMap map, @RequestParam(value = "objId", required = true) final String objId,
133
            @RequestParam(value = "from", required = true) final int from,
134
            @RequestParam(value ="id",required = false) final String recordId) {
135
        try {
136
            final ModularObjectStoreDeliver objectStoreDeliver = objectStoreservice.getObjectStoreDeliver();
137
            final ObjectStore store = objectStoreDeliver.getDao().getObjectStore(objId);
138

  
139
            ResultSetListener rs;
140
            if (recordId!=null && !StringUtils.isEmpty(recordId)){
141
                rs = store.deliverIds(Lists.newArrayList(recordId));
142
            }
143
            else {
144
             rs = store.deliver((long) 0, System.currentTimeMillis());
145
            }
146
            final List<String> page = rs.getResult((1 + from), (from + 25));
147

  
148

  
149
            final ObjectStoreInfo info = new ObjectStoreInfo();
150
            info.setInterpretation(store.getInterpretation());
151
            info.setObjectStoreId(store.getId());
152
            info.setSize(store.getSize());
153
            info.setMissingObjectStore(false);
154
            info.setMissingProfile(existId(objId));
155
            info.setResults(Lists.transform(page, convertFunction));
156
            return info;
157
        } catch (ObjectStoreServiceException e) {
158
            return null;
159
        }
160
    }
161

  
162

  
163
    private boolean existId(final String objectStoreId) {
164

  
165
        ISLookUpService lookUpService = serviceLocator.getService(ISLookUpService.class);
166
        try {
167
            final String resourceProfile = lookUpService.getResourceProfile(objectStoreId);
168
            return resourceProfile == null;
169
        } catch (ISLookUpException e) {
170
            log.debug(objectStoreId + " not found!");
171
        }
172
        return true;
173
    }
174

  
175
}
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/objectStore/info/ObjectStoreInfo.java
1
package eu.dnetlib.functionality.modular.ui.objectStore.info;
2

  
3
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
4

  
5
import java.util.List;
6

  
7
/**
8
 * Created by Sandro La Bruzzo on 11/19/15.
9
 */
10
public class ObjectStoreInfo {
11

  
12
    private String objectStoreId;
13

  
14
    private int size;
15

  
16
    private String interpretation;
17

  
18
    private List<ObjectStoreFile> results;
19

  
20
    private String lastStorageDate;
21

  
22
    private String serviceURI;
23

  
24
    private boolean missingProfile = true;
25

  
26
    private boolean missingObjectStore = true;
27

  
28
    public boolean isMissingProfile() {
29
        return missingProfile;
30
    }
31

  
32
    public void setMissingProfile(boolean missingProfile) {
33
        this.missingProfile = missingProfile;
34
    }
35

  
36
    public boolean isMissingObjectStore() {
37
        return missingObjectStore;
38
    }
39

  
40
    public void setMissingObjectStore(boolean missingObjectStore) {
41
        this.missingObjectStore = missingObjectStore;
42
    }
43

  
44
    public String getLastStorageDate() {
45
        return lastStorageDate;
46
    }
47

  
48
    public void setLastStorageDate(String lastStorageDate) {
49
        this.lastStorageDate = lastStorageDate;
50
    }
51

  
52
    public String getServiceURI() {
53
        return serviceURI;
54
    }
55

  
56
    public void setServiceURI(String serviceURI) {
57
        this.serviceURI = serviceURI;
58
    }
59

  
60
    public List<ObjectStoreFile> getResults() {
61
        return results;
62
    }
63

  
64
    public void setResults(List<ObjectStoreFile> results) {
65
        this.results = results;
66
    }
67

  
68
    public String getObjectStoreId() {
69
        return objectStoreId;
70
    }
71

  
72
    public void setObjectStoreId(String objectStoreId) {
73
        this.objectStoreId = objectStoreId;
74
    }
75

  
76
    public int getSize() {
77
        return size;
78
    }
79

  
80
    public void setSize(int size) {
81
        this.size = size;
82
    }
83

  
84

  
85
    public String getInterpretation() {
86
        return interpretation;
87
    }
88

  
89
    public void setInterpretation(String interpretation) {
90
        this.interpretation = interpretation;
91
    }
92
}
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/objectstoreInspector.st
1
$common/master( header={
2
	<script type="text/javascript" src="../resources/js/angular.min.js" ></script>
3
	<script type="text/javascript" src="../resources/js/angular-route.min.js"></script>
4
	<script type="text/javascript" src="../resources/js/angular-local-storage.min.js"></script>
5
	<script type="text/javascript" src="../resources/js/ng-grid-2.0.7.min.js"></script>
6
	<script type="text/javascript" src="../resources/js/objectstore_inspector_controllers.js"></script>
7
	<script type="text/javascript" src="../resources/js/objectstore_inspector.js"></script>
8
	<link rel="stylesheet" type="text/css" href="../resources/css/ng-grid.min.css" />
9
}, body={
10
	<div ng-app="objectStoreInspector" class="row">
11
		<div ng-view class="col-lg-12"></div>
12
	</div>
13
} )$
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/resources/eu/dnetlib/web/resources/html/objectStore/inspect.html
1

  
2
    <div class="row">
3
        <div class="col-md-6">
4
            <h2>Inspect ObjectStore </h2>
5
        </div>
6
        <div class="col-md-6 text-right">
7
            <a href="#/list" class="btn btn-primary btn-sm"><span
8
                    class="glyphicon glyphicon-step-backward"></span>
9
                Back</a>
10
        </div>
11

  
12

  
13
    </div>
14
    <div class="panel panel-default">
15
        <div class="panel-heading">
16
            <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_format">
17
                <b>ObjectStore Info</b>
18
            </a>
19
        </div>
20
        <div objectStoreId="collapse_format" class="panel-collapse collapse in">
21
            <div class="panel-body">
22
                <table cellpadding="10">
23
                    <tr>
24
                        <td align="right">
25
                            <b>objectStoreId: </b>
26
                        </td>
27
                        <td>
28
                            <i style=" padding-left:10px">{{objectStoreInfo.objectStoreId}}</i>
29
                        </td>
30
                        <td style=" padding-left:10px">
31

  
32

  
33
                            <a ng-hide="objectStoreInfo.missingProfile" style=" padding-left:10px"
34
                               href="isManager.do#/profile/{{id}}"
35
                               class="btn btn-primary btn-sm">
36
                                <span class="glyphicon glyphicon-search"></span>
37
                                View Profile
38
                            </a>
39

  
40
                            <a ng-show="objectStoreInfo.missingProfile" style=" padding-left:10px"
41
                               class="btn btn-danger btn-sm">
42
                                <span class="glyphicon glyphicon-remove"></span>
43
                                Missing Profile
44
                            </a>
45

  
46
                        </td>
47
                        <td style=" padding-left:10px">
48
                            <a href="" class="btn btn-primary btn-sm" ng-click="loadInfo()"><span
49
                                    class="glyphicon glyphicon-refresh"></span> Refresh Info</a>
50
                        </td>
51
                    </tr>
52
                    <tr>
53
                        <td align="right">
54
                            <b>interpretation: </b>
55
                        </td>
56
                        <td>
57
                            <i style=" padding-left:10px">{{objectStoreInfo.interpretation}}</i>
58
                        </td>
59
                        <td></td>
60
                    </tr>
61
                    <tr>
62
                        <td align="right">
63
                            <b>last storage date: </b>
64
                        </td>
65
                        <td>
66
                            <i style=" padding-left:10px">{{objectStoreInfo.lastStorageDate}}</i>
67
                        </td>
68
                        <td></td>
69
                    </tr>
70
                    <tr>
71
                        <td align="right">
72
                            <b>Number of Elements: </b>
73
                        </td>
74
                        <td>
75
                            <i style=" padding-left:10px">{{objectStoreInfo.size}}</i>
76
                        </td>
77
                        <td></td>
78
                    </tr>
79
                    <tr>
80
                        <td align="right">
81
                            <b>Service URI: </b>
82
                        </td>
83
                        <td>
84
                            <i style=" padding-left:10px">
85
                                <a href="{{objectStoreInfo.serviceURI}}">{{objectStoreInfo.serviceURI}}</a>
86
                            </i>
87
                        </td>
88
                        <td></td>
89
                    </tr>
90

  
91
                </table>
92

  
93
            </div>
94
        </div>
95
    </div>
96

  
97

  
98
    <div class="row">
99
        <div class="col-md-12">
100

  
101
            <div class="panel panel-default">
102
                <div class="panel-heading">
103
                    <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_query">
104
                        <b>ObjectStore Query</b>
105
                    </a>
106
                </div>
107
                <div id="collapse_query" class="panel-collapse collapse in">
108
                    <div class="panel-body">
109
                        <table cellpadding="10">
110
                            <tr>
111
                                <td align="right" style="width:10%">
112
                                    <b>Id: </b>
113
                                </td>
114
                                <td style=" padding-left:10px; width:90%">
115
                                    <input type="text" class="form-control" ng-model="record_id"
116
                                           placeholder="Enter an identifier to search (fast)">
117
                                </td>
118
                                <td style=" padding-left:10px" style="width:10%" align="right">
119
                                    <a style=" padding-left:10px" ng-click="getRecordById()" href="objectstoreInspector.do#inspect.do/{{id}}/0/{{record_id}}"
120
                                       class="btn btn-primary btn-sm">
121
                                        <span class="glyphicon glyphicon-search"></span>
122
                                        Search Id
123
                                    </a>
124
                                </td>
125
                            </tr>
126
                        </table>
127
                    </div>
128
                </div>
129
            </div>
130
        </div>
131
    </div>
132

  
133
    <div class="row">
134
        <div class="col-md-12 ">
135
            <h3>Number of results: {{searchResult.total}}</h3>
136
        </div>
137
    </div>
138
    <div class="row">
139
        <div class="col-md-2 text-left">
140
            results from {{start + 1 }} to {{nextPage }}
141
        </div>
142
        <div class="col-md-9 text-center">
143
            <ul class="pagination">
144
                <li>
145
                    <a href="#/inspect.do/{{id}}/{{previousPage}}" ng-click="prevPage()">&laquo;
146
                    </a>
147
                </li>
148
                <li>
149
                    <a href="#/inspect.do/{{id}}/{{nextPage}}">&raquo;
150
                    </a>
151
                </li>
152
            </ul>
153
        </div>
154
    </div>
155

  
156
    <div class="row" ng-repeat="item in objectStoreInfo.results">
157
        <div class="col-md-12">
158
            <div class="panel panel-default">
159
                <div class="panel-heading">
160
                    <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse_{{$index}}">
161
                        <b>{{$index+(1 + start)}}</b>
162
                    </a>
163
                </div>
164
                <div id="collapse_{{$index}}" class="panel-collapse collapse in">
165
                    <div class="panel-body">
166
                        <div class="col-lg-3 text-right"><b>Object Identifier:</b></div>
167
                        <div class="col-lg-8 text-left"> {{item.objectID}}</div>
168
                        <div class="col-lg-3 text-right"><b>Related Metadata Identifier:</b></div>
169
                        <div class="col-lg-8 text-left"> {{item.metadataRelatedID}}</div>
170
                        <div class="col-lg-3 text-right"><b>Mime Type:</b></div>
171
                        <div class="col-lg-8 text-left"> {{item.mimeType}}</div>
172
                        <div class="col-lg-3 text-right"><b>File Size:</b></div>
173
                        <div class="col-lg-8 text-left"> {{item.fileSizeKB}} Kb</div>
174
                        <div class="col-lg-3 text-right"><b>MD5:</b></div>
175
                        <div class="col-lg-8 text-left"> {{item.md5Sum}}</div>
176
                        <div class="col-lg-3 text-right"><b>Downloaded URL:</b></div>
177
                        <div class="col-lg-8 text-left"><a href="{{item.downloadedURL}}">{{item.downloadedURL}}</a>
178
                        </div>
179
                        <div class="col-lg-3 text-right"><b>Object Store URL:</b></div>
180
                        <div class="col-lg-8 text-left"><a href="../objectStore/retrieve.do?objectStore={{objectStoreInfo.objectStoreId}}&objectId={{item.objectID}}">{{item.uri}}</a></div>
181
                    </div>
182

  
183

  
184
                </div>
185
            </div>
186
        </div>
187
    </div>
188

  
189

  
190

  
191

  
192

  
193

  
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/resources/eu/dnetlib/web/resources/html/objectStore/list.html
1
<style>
2
    .gridStyle {
3
        width: 100%;
4
        height: 150px;
5
        margin-bottom: 20px;
6
        margin-top: 20px;
7
        font-size: 11px;
8
    }
9

  
10
    .gridStyle-big {
11
        width: 100%;
12
        height: 300px;
13
        margin-top: 20px;
14
        margin-bottom: 20px;
15
        font-size: 11px;
16
    }
17
</style>
18
<div class="row">
19
    <div class="col-md-12">
20
        <a href="" ng-click="refreshInfo()" class="btn btn-primary btn-sm"><span
21
                class="glyphicon glyphicon-refresh"></span>
22
            Refresh</a>
23
    </div>
24

  
25

  
26
    <div class="col-md-12" style="height: 100%">
27
        <div class="gridStyle" id="gridObjectstores" ng-grid="gridOptions"></div>
28
    </div>
29
</div>
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/resources/eu/dnetlib/web/resources/js/objectstore_inspector.js
1
var module = angular.module('objectStoreInspector', ['ngGrid', 'ngRoute', 'objectStoresControllers']);
2

  
3
module.config([
4
    '$routeProvider',
5
    function ($routeProvider) {
6
        $routeProvider
7
            .when('/list', {
8
                templateUrl: '../resources/html/objectStore/list.html',
9
                controller: 'objectStoresController'
10
            })
11
            .when('/inspect.do/:id', {
12
                templateUrl: '../resources/html/objectStore/inspect.html',
13
                controller: 'inspectObjectStoreController'
14
            }).when('/inspect.do/:id/:start/:query', {
15
                    templateUrl: '../resources/html/objectStore/inspect.html',
16
                    controller: 'inspectObjectStoreController'
17
                }).when('/inspect.do/:id/:start', {
18
                templateUrl: '../resources/html/objectStore/inspect.html',
19
                controller: 'inspectObjectStoreController'
20
            })
21
            .otherwise({redirectTo: '/list'});
22
    }
23
]);
24

  
25

  
26
module.controller('moduleMenuCtrl', ['$scope', '$location',
27
    function ($scope, $location) {
28
        $scope.isActive = function (regex) {
29
            var re = new RegExp(regex);
30
            return re.test($location.path());
31
        }
32
    }
33
]);
34

  
35
module.filter('encodeURIComponent', function () {
36
    return window.encodeURIComponent;
37
});
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/src/main/resources/eu/dnetlib/web/resources/js/objectstore_inspector_controllers.js
1
var objectStoreInspectorControllers = angular.module('objectStoresControllers', ['LocalStorageModule']);
2

  
3
function common_init($scope, $http, $sce, $location) {
4
    initSpinner();
5
    $scope.showError = function (error) {
6
        show_notification("error", error);
7
    }
8
    $scope.showNotification = function (message) {
9
        show_notification("info", message);
10
    }
11
    $scope.showSpinner = function () {
12
        showSpinner();
13
    }
14
    $scope.hideSpinner = function () {
15
        hideSpinner();
16
    }
17
    $scope.to_trusted = function (html) {
18
        return $sce.trustAsHtml(html);
19
    }
20
    $scope.go = function (path) {
21
        $location.path(path);
22
    }
23
    $scope.encodeValue = function (val) {
24
        return val;
25
    }
26
}
27

  
28
function ngGridFlexibleHeightPlugin(opts) {
29
    var self = this;
30
    self.grid = null;
31
    self.scope = null;
32
    self.init = function (scope, grid, services) {
33
        self.domUtilityService = services.DomUtilityService;
34
        self.grid = grid;
35
        self.scope = scope;
36
        var recalcHeightForData = function () {
37
            setTimeout(innerRecalcForData, 1);
38
        };
39
        var innerRecalcForData = function () {
40
            var gridId = self.grid.gridId;
41
            var footerPanelSel = '.' + gridId + ' .ngFooterPanel';
42
            var extraHeight = self.grid.$topPanel.height() + $(footerPanelSel).height();
43
            var naturalHeight = self.grid.$canvas.height() + 1;
44
            if (opts != null) {
45
                if (opts.minHeight != null && (naturalHeight + extraHeight) < opts.minHeight) {
46
                    naturalHeight = opts.minHeight - extraHeight - 2;
47
                }
48
                if (opts.maxHeight != null && (naturalHeight + extraHeight) > opts.maxHeight) {
49
                    naturalHeight = opts.maxHeight;
50
                }
51
            }
52

  
53
            var newViewportHeight = naturalHeight + 3;
54
            if (!self.scope.baseViewportHeight || self.scope.baseViewportHeight !== newViewportHeight) {
55
                self.grid.$viewport.css('height', newViewportHeight + 'px');
56
                self.grid.$root.css('height', (newViewportHeight + extraHeight) + 'px');
57
                self.scope.baseViewportHeight = newViewportHeight;
58
                self.domUtilityService.RebuildGrid(self.scope, self.grid);
59
            }
60
        };
61
        self.scope.catHashKeys = function () {
62
            var hash = '',
63
                idx;
64
            for (idx in self.scope.renderedRows) {
65
                hash += self.scope.renderedRows[idx].$$hashKey;
66
            }
67
            return hash;
68
        };
69
        self.scope.$watch('catHashKeys()', innerRecalcForData);
70
        self.scope.$watch(self.grid.config.data, recalcHeightForData);
71
    };
72
}
73

  
74
window.onresize = function () {
75

  
76

  
77
    var elem = document.getElementById('gridObjectstores');
78
    var height = 0;
79
    var body = window.document.body;
80
    if (window.innerHeight) {
81
        height = window.innerHeight;
82
    } else if (body.parentElement.clientHeight) {
83
        height = body.parentElement.clientHeight;
84
    } else if (body && body.clientHeight) {
85
        height = body.clientHeight;
86
    }
87
    elem.style.height = ((height - elem.offsetTop - 280) + "px");
88

  
89
};
90

  
91
function hasOwnProperty(obj, prop) {
92
    var proto = obj.__proto__ || obj.constructor.prototype;
93
    return (prop in obj) &&
94
        (!(prop in proto) || proto[prop] !== obj[prop]);
95
}
96

  
97
objectStoreInspectorControllers.directive('compileTemplate', function ($compile, $parse) {
98
    return {
99
        link: function (scope, element, attr) {
100
            var parsed = $parse(attr.ngBindHtml);
101

  
102
            function getStringValue() {
103
                return (parsed(scope) || '').toString();
104
            }
105

  
106
            //Recompile if the template changes
107
            scope.$watch(getStringValue, function () {
108
                $compile(element, null, -9999)(scope);  //The -9999 makes it skip directives so that we do not recompile ourselves
109
            });
110
        }
111
    }
112
});
113

  
114
objectStoreInspectorControllers.controller('inspectObjectStoreController', [
115
    '$scope', '$http', '$sce', '$location', '$routeParams',
116
    function ($scope, $http, $sce, $location, $routeParams) {
117
        common_init($scope, $http, $sce, $location);
118

  
119
        $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
120
        $scope.id = $routeParams.id;
121

  
122

  
123
        $scope.getRecordById = function () {
124
            console.log("Funcion getRecordById called");
125
        }
126

  
127

  
128

  
129
        $scope.start = $routeParams['start'];
130
        if ($scope.start == null)
131
            $scope.start = 0;
132
        else
133
            $scope.start = parseInt($scope.start);
134

  
135

  
136
        $scope.record_id = $routeParams['query'];
137

  
138

  
139

  
140

  
141
        $scope.previousPage = 0
142

  
143
        $scope.nextPage = 0
144

  
145
        $scope.loadInfo = function () {
146

  
147
            $http.post('objectStore/getObjectStoreInfo.do', $.param({
148
                'objId': $routeParams.id,
149
                'from': $scope.start,
150
                'id': $scope.record_id
151
            })).success(function (data) {
152

  
153
                $scope.objectStoreInfo = data;
154
                if (hasOwnProperty($scope, 'results') == false) {
155
                    $scope.searchResult = {}
156
                }
157

  
158
                $scope.searchResult.total = data.size;
159

  
160
                $scope.previousPage = Math.max($scope.start - 25, 0);
161
                $scope.nextPage = Math.min($scope.searchResult.total, $scope.start + 25);
162
            }).error(function () {
163
                $scope.showError('Error getting info from objectStore');
164

  
165
            });
166

  
167
        };
168

  
169
        $scope.loadInfo();
170

  
171

  
172
    }]);
173

  
174
objectStoreInspectorControllers.controller('objectStoresController', [
175
    '$scope', '$http', '$sce', '$location',
176

  
177
    function ($scope, $http, $sce, $location) {
178
        common_init($scope, $http, $sce, $location);
179
        $scope.showSpinner();
180
        $http.get('objectStore/listObjectStores.do').success(function (data) {
181
            $scope.hideSpinner();
182
            $scope.objTable = data;
183
        }).error(function () {
184
            $scope.showError('Error listing xmldb collections');
185
            $scope.hideSpinner();
186
        });
187

  
188
        $scope.refreshInfo = function () {
189
            console.log("Should reload Info")
190
        }
191

  
192
        $scope.gridOptions = {
193
            data: 'objTable',
194
            enableRowSelection: false,
195
            enableCellEditOnFocus: false,
196
            enableHighlighting: true,
197
            plugins: [new ngGridFlexibleHeightPlugin()],
198

  
199
            columnDefs: [
200
                {
201
                    field: 'objectStoreId',
202
                    displayName: 'ID',
203
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b>{{row.getProperty(col.field)}}</b></div>',
204
                    headerClass: 'text-center',
205
                    width: '500px'
206
                },
207
                {field: 'interpretation', displayName: 'Interpretation'},
208
                {field: 'size', displayName: 'Size'},
209
                {
210
                    field: 'serviceURI',
211
                    displayName: 'Service URI',
212
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b ng-show="row.getProperty(col.field)"> {{row.getProperty(col.field)}} </b><b ng-hide="row.getProperty(col.field)" style="color: red"> Profile Missing! </b> </div>',
213
                    headerClass: 'text-center'
214
                },
215
                {
216
                    field: 'objectStoreId',
217
                    displayName: 'View',
218
                    cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b style="color:red" ng-show=\'row.getProperty("missingObjectStore")\'>Missing ObjectStore</b> <a ng-hide=\'row.getProperty("missingObjectStore")\'  href="objectstoreInspector.do#/inspect.do/{{row.getProperty(col.field)}}" class="btn btn-primary btn-xs" data-placement="top" title="{{row.getProperty(col.field)}}"><span class="glyphicon glyphicon-zoom-in"></span> inspect</a></div>',
219
                    width: '130px',
220
                    headerClass: 'text-center'
221
                }
222
            ]
223
        };
224

  
225

  
226
    }]);
modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
	<modelVersion>4.0.0</modelVersion>
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet45-parent</artifactId>
6
		<version>1.0.0</version>
7
	</parent>
8
	<scm>
9
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-objectStore-ui/tags/dnet-objectStore-ui-2.0.0</developerConnection>
10
	</scm>
11
	<groupId>eu.dnetlib</groupId>
12
	<artifactId>dnet-objectStore-ui</artifactId>
13
	<version>2.0.0</version>
14
	<dependencies>
15
		<dependency>
16
			<groupId>eu.dnetlib</groupId>
17
			<artifactId>cnr-resultset-client</artifactId>
18
			<version>[2.0.0,3.0.0)</version>
19
		</dependency>
20

  
21
		<dependency>
22
			<groupId>eu.dnetlib</groupId>
23
			<artifactId>dnet-modular-ui</artifactId>
24
			<version>[3.0.0,4.0.0)</version>
25
		</dependency>
26
		<dependency>
27
			<groupId>javax.servlet</groupId>
28
			<artifactId>javax.servlet-api</artifactId>
29
			<version>${javax.servlet.version}</version>
30
			<scope>provided</scope>
31
		</dependency>
32
		<dependency>
33
			<groupId>junit</groupId>
34
			<artifactId>junit</artifactId>
35
			<version>${junit.version}</version>
36
			<scope>test</scope>
37
		</dependency>
38

  
39
		<dependency>
40
			<groupId>eu.dnetlib</groupId>
41
			<artifactId>dnet-modular-objectstore-service</artifactId>
42
			<version>[4.2.0,5.0.0)</version>
43
		</dependency>
44

  
45
	</dependencies>
46
</project>

Also available in: Unified diff