From ab47678d768178de568d09b1a8c53470527af1a3 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Fri, 05 Dec 2014 12:12:32 +0000
Subject: [PATCH] #396 fix - Highlight of current section, changed Packs listing to include necessary codes for licenses
---
securis/src/main/resources/META-INF/persistence.xml | 3 +
securis/src/main/webapp/js/catalogs.js | 19 +++++----
securis/src/main/webapp/js/main.js | 5 +-
securis/src/main/webapp/licenses.html | 17 +++++---
securis/src/main/webapp/header.html | 7 ++-
securis/src/main/webapp/js/licenses.js | 33 ++++++++++++++++
securis/src/main/webapp/index.jsp | 2
7 files changed, 62 insertions(+), 24 deletions(-)
diff --git a/securis/src/main/resources/META-INF/persistence.xml b/securis/src/main/resources/META-INF/persistence.xml
index 92977c8..c355b77 100644
--- a/securis/src/main/resources/META-INF/persistence.xml
+++ b/securis/src/main/resources/META-INF/persistence.xml
@@ -5,7 +5,8 @@
<persistence-unit name="localdb" transaction-type="RESOURCE_LOCAL">
<description>SeCuris LocalDB</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
-
+ <shared-cache-mode>NONE</shared-cache-mode>
+
<!-- <jta-data-source>java:comp/env/jdbc/SeCurisDS</jta-data-source>
-->
<!-- <class>net.curisit.securis.db.UserSettingsUnits</class> -->
diff --git a/securis/src/main/webapp/header.html b/securis/src/main/webapp/header.html
index c5b0e23..906211a 100644
--- a/securis/src/main/webapp/header.html
+++ b/securis/src/main/webapp/header.html
@@ -2,10 +2,11 @@
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
+
<ul class="nav navbar-nav navbar-left">
- <li i18n style="color: white; padding-top: 15px;">SeCuris</li>
- <li><a i18n href="licenses">Licenses</a></li>
- <li><a i18n href="admin">Admin</a></li>
+ <li><h3 style="color: #eeeeee; margin-right: 20px;margin-top: 10px;">SeCuris</h2></li>
+ <li ng-class="{active: $location.path() === '/licenses'}" ><a i18n ng-class="" href="licenses">Licenses</a></li>
+ <li ng-class="{active: $location.path() === '/admin'}"><a i18n href="admin">Admin</a></li>
</ul>
</div>
<div class="navbar-collapse collapse">
diff --git a/securis/src/main/webapp/index.jsp b/securis/src/main/webapp/index.jsp
index 5fbd102..4383c24 100644
--- a/securis/src/main/webapp/index.jsp
+++ b/securis/src/main/webapp/index.jsp
@@ -58,7 +58,7 @@
<script type="text/javascript" src="js/licenses.js"></script>
<script type="text/javascript" src="js/admin.js"></script>
- <toaster-container toaster-options="{'time-out': 3000}"></toaster-container>
+ <toaster-container toaster-options="{'time-out': 5000}"></toaster-container>
</div>
</body>
</html>
\ No newline at end of file
diff --git a/securis/src/main/webapp/js/catalogs.js b/securis/src/main/webapp/js/catalogs.js
index f0dd291..e1d458f 100644
--- a/securis/src/main/webapp/js/catalogs.js
+++ b/securis/src/main/webapp/js/catalogs.js
@@ -87,11 +87,12 @@
* number it find it by position
*/
this.getMetadata = function(index) {
- if (!_metadata)
- throw new Error(
- 'There is no catalog metadata info');
- if (index === undefined)
+ if (!_metadata) {
+ throw new Error('There is no catalog metadata info');
+ }
+ if (index === undefined) {
return _current;
+ }
if (typeof index === 'string') {
for (var i = _metadata.length - 1; i >= 0
&& _metadata[i].resource !== index; i--)
@@ -217,13 +218,14 @@
}
this.loadRefs = function(callback, refsFields) {
if (!refsFields || refsFields.length === 0) {
- if (!_current)
+ if (!_current) {
throw new Error('There is no current catalog selected');
+ }
refsFields = [];
_current.fields.forEach(function(f) {
- if (f.resource)
- refsFields.push(f)
-
+ if (f.resource) {
+ refsFields.push(f);
+ }
});
}
@@ -248,6 +250,7 @@
refs[rf.name].forEach(function(row) {
comboData.push({
id : row[pk],
+ code : row.code,
label : row.label
|| row.name
|| row.code
diff --git a/securis/src/main/webapp/js/licenses.js b/securis/src/main/webapp/js/licenses.js
index 4d52d25..b27e52f 100644
--- a/securis/src/main/webapp/js/licenses.js
+++ b/securis/src/main/webapp/js/licenses.js
@@ -427,6 +427,10 @@
var refFields = [{resource: 'organization', name: 'organization_id'},{resource: 'licensetype', name: 'license_type_id'}];
Catalogs.loadRefs(function(refs) {
$scope.refs = refs;
+ angular.forEach($scope.packs, function(elem) {
+ elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
+ elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
+ });
}, refFields);
});
@@ -440,7 +444,12 @@
// the new pack
$scope.pack = null;
- $scope.packs = Packs.getPacksList();
+ $scope.packs = Packs.getPacksList(function(list) {
+ angular.forEach(list, function(elem) {
+ elem.organization_code = $scope.getOrganizationCode(elem.organization_id);
+ elem.license_type_code = $scope.getLicenseTypeCode(elem.license_type_id);
+ });
+ });
$scope.save = function() {
Packs.savePackData($scope.pack, $scope.isNew, function() {
@@ -609,6 +618,28 @@
return label;
}
+ $scope.getOrganizationCode = function(orgId) {
+ return $scope._getCodeFromId('organization_id', orgId);
+ }
+
+ $scope.getLicenseTypeCode = function(ltId) {
+ return $scope._getCodeFromId('license_type_id', ltId);
+ }
+
+ $scope._getCodeFromId = function(field, myid) {
+ if (!myid) {
+ return null;
+ }
+ var list = $scope.refs[field];
+ for(var i = 0; list && i < list.length; i++) {
+ var elem = list[i];
+ if (elem.id === myid) {
+ return elem.code;
+ }
+ }
+ return null;
+ }
+
$scope.createMetadataRow = function() {
if (!$scope.formu.metadata) {
$scope.formu.metadata = [];
diff --git a/securis/src/main/webapp/js/main.js b/securis/src/main/webapp/js/main.js
index aa73fd3..4528dc1 100644
--- a/securis/src/main/webapp/js/main.js
+++ b/securis/src/main/webapp/js/main.js
@@ -84,9 +84,8 @@
m.controller('MainCtrl', ['$scope', '$http', '$location', '$L', '$store',
function($scope, $http, $location, $L, $store) {
- $scope.currentRoute = null;
- console.log('Current location: ' + $location);
- console.log($location);
+ $scope.$location = $location;
+
$location.path('/login');
if ($store.get('token') != null) {
diff --git a/securis/src/main/webapp/licenses.html b/securis/src/main/webapp/licenses.html
index f641478..fe77fb0 100644
--- a/securis/src/main/webapp/licenses.html
+++ b/securis/src/main/webapp/licenses.html
@@ -275,9 +275,10 @@
<thead>
<tr>
<th i18n>Code</th>
- <th i18n>Organization</th>
<th i18n>Application</th>
- <th i18n>Licenses</th>
+ <th i18n>Lic. type</th>
+ <th i18n>Organization</th>
+ <th i18n>Lics.</th>
<th></th>
</tr>
</thead>
@@ -287,9 +288,10 @@
ng-class="{success: currentPack.id === p.id}"
ng-click="selectPack(p)">
<td style="white-space: nowrap;" ng-bind="p.code"></td>
- <td ng-bind="ellipsis(p.organization_name, 20)"
- title="{{pack.organization_name}}"></td>
<td ng-bind="p.application_name"></td>
+ <td ng-bind="p.license_type_code"></td>
+ <td ng-bind="ellipsis(p.organization_code + ' - ' + p.organization_name, 25)"
+ title="{{p.organization_code + ' - ' + pack.organization_name}}"></td>
<td
title="Total: {{p.num_licenses}}, available: {{p.num_available}}">{{p.num_licenses}}
({{p.num_available}})</td>
@@ -448,16 +450,17 @@
<div class="form-group" >
<label class="col-md-3 control-label" for="request_data" i18n>Request
data</label>
- <div class="col-md-7">
+ <div class="col-md-{{(isNew || Licenses.isActionAvailable('add_request', license)) ? 7 : 8}}">
<textarea id="request_data" name="request_data" placeholder=""
class="form-control" ng-model="license.request_data" rows="2"
ng-required="mandatory.request_data"
+ ng-readonly="!isNew && !Licenses.isActionAvailable('add_request', license)"
ng-maxlength="{{maxlength.request_data}}"></textarea>
<div class="alert inline-alert alert-warning"
ng-show="licenseForm.request_data.$invalid">
- <!-- Invalid ? {{licenseForm.request_data.$invalid}}
+ <!-- Invalid ? {{licenseForm.request_data.$invalid}}
Error ? {{licenseForm.request_data.$error | json}}
- Error ? {{licenseForm.request_data.$error.maxlength}} -->
+ Error ? {{licenseForm.request_data.$error.maxlength}} -->
<span class="glyphicon glyphicon-warning-sign">
<span
ng-show="licenseForm.request_data.$error.maxlength"
--
Gitblit v1.3.2