rsanchez
2014-12-05 ab47678d768178de568d09b1a8c53470527af1a3
#396 fix - Highlight of current section, changed Packs listing to
include necessary codes for licenses
7 files modified
changed files
securis/src/main/resources/META-INF/persistence.xml patch | view | blame | history
securis/src/main/webapp/header.html patch | view | blame | history
securis/src/main/webapp/index.jsp patch | view | blame | history
securis/src/main/webapp/js/catalogs.js patch | view | blame | history
securis/src/main/webapp/js/licenses.js patch | view | blame | history
securis/src/main/webapp/js/main.js patch | view | blame | history
securis/src/main/webapp/licenses.html patch | view | blame | history
securis/src/main/resources/META-INF/persistence.xml
....@@ -5,7 +5,8 @@
55 <persistence-unit name="localdb" transaction-type="RESOURCE_LOCAL">
66 <description>SeCuris LocalDB</description>
77 <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
8
-
8
+ <shared-cache-mode>NONE</shared-cache-mode>
9
+
910 <!-- <jta-data-source>java:comp/env/jdbc/SeCurisDS</jta-data-source>
1011 -->
1112 <!-- <class>net.curisit.securis.db.UserSettingsUnits</class> -->
securis/src/main/webapp/header.html
....@@ -2,10 +2,11 @@
22 <div class="navbar navbar-inverse navbar-fixed-top">
33 <div class="container">
44 <div class="navbar-header">
5
+
56 <ul class="nav navbar-nav navbar-left">
6
- <li i18n style="color: white; padding-top: 15px;">SeCuris</li>
7
- <li><a i18n href="licenses">Licenses</a></li>
8
- <li><a i18n href="admin">Admin</a></li>
7
+ <li><h3 style="color: #eeeeee; margin-right: 20px;margin-top: 10px;">SeCuris</h2></li>
8
+ <li ng-class="{active: $location.path() === '/licenses'}" ><a i18n ng-class="" href="licenses">Licenses</a></li>
9
+ <li ng-class="{active: $location.path() === '/admin'}"><a i18n href="admin">Admin</a></li>
910 </ul>
1011 </div>
1112 <div class="navbar-collapse collapse">
securis/src/main/webapp/index.jsp
....@@ -58,7 +58,7 @@
5858 <script type="text/javascript" src="js/licenses.js"></script>
5959 <script type="text/javascript" src="js/admin.js"></script>
6060
61
- <toaster-container toaster-options="{'time-out': 3000}"></toaster-container>
61
+ <toaster-container toaster-options="{'time-out': 5000}"></toaster-container>
6262 </div>
6363 </body>
6464 </html>
securis/src/main/webapp/js/catalogs.js
....@@ -87,11 +87,12 @@
8787 * number it find it by position
8888 */
8989 this.getMetadata = function(index) {
90
- if (!_metadata)
91
- throw new Error(
92
- 'There is no catalog metadata info');
93
- if (index === undefined)
90
+ if (!_metadata) {
91
+ throw new Error('There is no catalog metadata info');
92
+ }
93
+ if (index === undefined) {
9494 return _current;
95
+ }
9596 if (typeof index === 'string') {
9697 for (var i = _metadata.length - 1; i >= 0
9798 && _metadata[i].resource !== index; i--)
....@@ -217,13 +218,14 @@
217218 }
218219 this.loadRefs = function(callback, refsFields) {
219220 if (!refsFields || refsFields.length === 0) {
220
- if (!_current)
221
+ if (!_current) {
221222 throw new Error('There is no current catalog selected');
223
+ }
222224 refsFields = [];
223225 _current.fields.forEach(function(f) {
224
- if (f.resource)
225
- refsFields.push(f)
226
-
226
+ if (f.resource) {
227
+ refsFields.push(f);
228
+ }
227229 });
228230 }
229231
....@@ -248,6 +250,7 @@
248250 refs[rf.name].forEach(function(row) {
249251 comboData.push({
250252 id : row[pk],
253
+ code : row.code,
251254 label : row.label
252255 || row.name
253256 || row.code
securis/src/main/webapp/js/licenses.js
....@@ -427,6 +427,10 @@
427427 var refFields = [{resource: 'organization', name: 'organization_id'},{resource: 'licensetype', name: 'license_type_id'}];
428428 Catalogs.loadRefs(function(refs) {
429429 $scope.refs = refs;
430
+ angular.forEach($scope.packs, function(elem) {
431
+ elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
432
+ elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
433
+ });
430434 }, refFields);
431435 });
432436
....@@ -440,7 +444,12 @@
440444 // the new pack
441445 $scope.pack = null;
442446
443
- $scope.packs = Packs.getPacksList();
447
+ $scope.packs = Packs.getPacksList(function(list) {
448
+ angular.forEach(list, function(elem) {
449
+ elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
450
+ elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
451
+ });
452
+ });
444453
445454 $scope.save = function() {
446455 Packs.savePackData($scope.pack, $scope.isNew, function() {
....@@ -609,6 +618,28 @@
609618 return label;
610619 }
611620
621
+ $scope.getOrganizationCode = function(orgId) {
622
+ return $scope._getCodeFromId('organization_id', orgId);
623
+ }
624
+
625
+ $scope.getLicenseTypeCode = function(ltId) {
626
+ return $scope._getCodeFromId('license_type_id', ltId);
627
+ }
628
+
629
+ $scope._getCodeFromId = function(field, myid) {
630
+ if (!myid) {
631
+ return null;
632
+ }
633
+ var list = $scope.refs[field];
634
+ for(var i = 0; list && i < list.length; i++) {
635
+ var elem = list[i];
636
+ if (elem.id === myid) {
637
+ return elem.code;
638
+ }
639
+ }
640
+ return null;
641
+ }
642
+
612643 $scope.createMetadataRow = function() {
613644 if (!$scope.formu.metadata) {
614645 $scope.formu.metadata = [];
securis/src/main/webapp/js/main.js
....@@ -84,9 +84,8 @@
8484 m.controller('MainCtrl', ['$scope', '$http', '$location', '$L', '$store',
8585 function($scope, $http, $location, $L, $store) {
8686
87
- $scope.currentRoute = null;
88
- console.log('Current location: ' + $location);
89
- console.log($location);
87
+ $scope.$location = $location;
88
+
9089 $location.path('/login');
9190 if ($store.get('token') != null) {
9291
securis/src/main/webapp/licenses.html
....@@ -275,9 +275,10 @@
275275 <thead>
276276 <tr>
277277 <th i18n>Code</th>
278
- <th i18n>Organization</th>
279278 <th i18n>Application</th>
280
- <th i18n>Licenses</th>
279
+ <th i18n>Lic. type</th>
280
+ <th i18n>Organization</th>
281
+ <th i18n>Lics.</th>
281282 <th></th>
282283 </tr>
283284 </thead>
....@@ -287,9 +288,10 @@
287288 ng-class="{success: currentPack.id === p.id}"
288289 ng-click="selectPack(p)">
289290 <td style="white-space: nowrap;" ng-bind="p.code"></td>
290
- <td ng-bind="ellipsis(p.organization_name, 20)"
291
- title="{{pack.organization_name}}"></td>
292291 <td ng-bind="p.application_name"></td>
292
+ <td ng-bind="p.license_type_code"></td>
293
+ <td ng-bind="ellipsis(p.organization_code + ' - ' + p.organization_name, 25)"
294
+ title="{{p.organization_code + ' - ' + pack.organization_name}}"></td>
293295 <td
294296 title="Total: {{p.num_licenses}}, available: {{p.num_available}}">{{p.num_licenses}}
295297 ({{p.num_available}})</td>
....@@ -448,16 +450,17 @@
448450 <div class="form-group" >
449451 <label class="col-md-3 control-label" for="request_data" i18n>Request
450452 data</label>
451
- <div class="col-md-7">
453
+ <div class="col-md-{{(isNew || Licenses.isActionAvailable('add_request', license)) ? 7 : 8}}">
452454 <textarea id="request_data" name="request_data" placeholder=""
453455 class="form-control" ng-model="license.request_data" rows="2"
454456 ng-required="mandatory.request_data"
457
+ ng-readonly="!isNew && !Licenses.isActionAvailable('add_request', license)"
455458 ng-maxlength="{{maxlength.request_data}}"></textarea>
456459 <div class="alert inline-alert alert-warning"
457460 ng-show="licenseForm.request_data.$invalid">
458
- <!-- Invalid ? {{licenseForm.request_data.$invalid}}
461
+ <!-- Invalid ? {{licenseForm.request_data.$invalid}}
459462 Error ? {{licenseForm.request_data.$error | json}}
460
- Error ? {{licenseForm.request_data.$error.maxlength}} -->
463
+ Error ? {{licenseForm.request_data.$error.maxlength}} -->
461464 <span class="glyphicon glyphicon-warning-sign">
462465 <span
463466 ng-show="licenseForm.request_data.$error.maxlength"