mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
AC-232 License viewer completed.
This commit is contained in:
@@ -77,6 +77,10 @@
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.break {
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
.login-alert {
|
.login-alert {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -419,6 +423,22 @@
|
|||||||
color: #5bb75b;
|
color: #5bb75b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.field-success {
|
||||||
|
color: #5bb75b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-success input {
|
||||||
|
border-color: #5bb75b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-failure {
|
||||||
|
color: #FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-failure input {
|
||||||
|
border-color: #FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
.job-changed,
|
.job-changed,
|
||||||
.license-warning,
|
.license-warning,
|
||||||
.license-demo {
|
.license-demo {
|
||||||
|
|||||||
@@ -32,34 +32,36 @@ angular.module('LicenseFormDefinition', [])
|
|||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
license_date: {
|
license_date: {
|
||||||
label: 'Activated On',
|
label: 'Expires On',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true,
|
readonly: true,
|
||||||
section: 'License'
|
section: 'License'
|
||||||
},
|
},
|
||||||
time_remaining: {
|
time_remaining: {
|
||||||
label: 'Days Left',
|
label: 'Time Left',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true,
|
readonly: true,
|
||||||
section: 'License'
|
section: 'License'
|
||||||
},
|
},
|
||||||
available_instances: {
|
available_instances: {
|
||||||
label: 'License Count',
|
label: 'Available',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true,
|
readonly: true,
|
||||||
section: 'Available Servers'
|
section: 'Managed Hosts'
|
||||||
},
|
},
|
||||||
current_instances: {
|
current_instances: {
|
||||||
label: 'Used',
|
label: 'Used',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true,
|
readonly: true,
|
||||||
section: 'Available Servers'
|
section: 'Managed Hosts'
|
||||||
},
|
},
|
||||||
free_instances: {
|
free_instances: {
|
||||||
label: 'Remaining',
|
label: 'Remaining',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true,
|
readonly: true,
|
||||||
section: 'Available Servers'
|
section: 'Managed Hosts',
|
||||||
|
controlNGClass: 'free_instances_class',
|
||||||
|
labelNGClass: 'free_instances_class'
|
||||||
},
|
},
|
||||||
company_name: {
|
company_name: {
|
||||||
label: 'Company',
|
label: 'Company',
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
|||||||
}
|
}
|
||||||
|
|
||||||
listScope['toggle_' + list.iterator] = function(id) {
|
listScope['toggle_' + list.iterator] = function(id) {
|
||||||
console.log('here!');
|
|
||||||
for (var i=0; i < scope[list.name].length; i++) {
|
for (var i=0; i < scope[list.name].length; i++) {
|
||||||
if (listScope[list.name][i]['id'] == id) {
|
if (listScope[list.name][i]['id'] == id) {
|
||||||
listScope[list.name][i]['checked'] = '1';
|
listScope[list.name][i]['checked'] = '1';
|
||||||
|
|||||||
@@ -233,13 +233,17 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += (field.ngShow) ? this.attr(field,'ngShow') : "";
|
html += (field.ngShow) ? this.attr(field,'ngShow') : "";
|
||||||
html += (field.ngHide) ? this.attr(field,'ngHide') : "";
|
html += (field.ngHide) ? this.attr(field,'ngHide') : "";
|
||||||
html += ">\n";
|
html += ">\n";
|
||||||
html += "<label class=\"control-label";
|
html += "<label ";
|
||||||
|
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
||||||
|
html += "class=\"control-label";
|
||||||
html += (field.labelClass) ? " " + field.labelClass : "";
|
html += (field.labelClass) ? " " + field.labelClass : "";
|
||||||
html += "\" for=\"" + fld + '">';
|
html += "\" for=\"" + fld + '">';
|
||||||
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
||||||
html += (field.icon) ? this.icon(field.icon) : "";
|
html += (field.icon) ? this.icon(field.icon) : "";
|
||||||
html += field.label + '</label>' + "\n";
|
html += field.label + '</label>' + "\n";
|
||||||
html += "<div class=\"controls\">\n";
|
html += "<div ";
|
||||||
|
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
||||||
|
html += "class=\"controls\">\n";
|
||||||
html += (field.clear || field.genMD5) ? "<div class=\"input-append\">\n" : "";
|
html += (field.clear || field.genMD5) ? "<div class=\"input-append\">\n" : "";
|
||||||
if (field.control === null || field.control === undefined || field.control) {
|
if (field.control === null || field.control === undefined || field.control) {
|
||||||
html += "<input ";
|
html += "<input ";
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities', 'FormGenerator'])
|
angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities', 'FormGenerator', 'PromptDialog'])
|
||||||
.factory('ViewLicense', ['$location', 'LicenseForm', 'GenerateForm', 'Rest', 'Alert', 'GetBasePath', 'ProcessErrors',
|
.factory('ViewLicense', ['$location', 'LicenseForm', 'GenerateForm', 'Rest', 'Alert', 'GetBasePath', 'ProcessErrors',
|
||||||
function($location, LicenseForm, GenerateForm, Rest, Alert, GetBasePath, ProcessErrors) {
|
'FormatDate', 'Prompt',
|
||||||
|
function($location, LicenseForm, GenerateForm, Rest, Alert, GetBasePath, ProcessErrors, FormatDate, Prompt) {
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
var defaultUrl=GetBasePath('config');
|
var defaultUrl=GetBasePath('config');
|
||||||
@@ -20,16 +21,30 @@ angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities',
|
|||||||
// load the form
|
// load the form
|
||||||
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
|
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
scope.formModalAction = function() {
|
scope.formModalAction = function() {
|
||||||
$('#form-modal').modal("hide");
|
$('#form-modal').modal("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.formModalActionLabel = 'OK';
|
scope.formModalActionLabel = 'OK';
|
||||||
scope.formModalCancelShow = false;
|
scope.formModalCancelShow = false;
|
||||||
scope.formModalInfo = false;
|
scope.formModalInfo = 'Purchase/Extend License';
|
||||||
$('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none');
|
$('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none');
|
||||||
$('#form-modal').addClass('skinny-modal');
|
$('#form-modal').addClass('skinny-modal');
|
||||||
scope.formModalHeader = 'AWX License';
|
scope.formModalHeader = 'AWX License';
|
||||||
|
|
||||||
|
// Respond to View JSON button
|
||||||
|
scope.formModalInfoAction = function() {
|
||||||
|
Prompt({
|
||||||
|
hdr: 'AWX Licensing',
|
||||||
|
body: "<p class=\"break\">AWX licenses can be purchased, renewed or extended by visiting <a id=\"license-link\" " +
|
||||||
|
"target=\"_blank\" href=\"http://www.ansibleworks.com/ansibleworks-awx/\">" +
|
||||||
|
"ansibleworks.com/ansibleworks-awx</a>.</p><p>Would you like to visit the AWX licensing site now?</p>",
|
||||||
|
'class': 'btn-primary',
|
||||||
|
action: function() { var href = $('#license-link').attr('href'); window.location = href; }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
@@ -39,7 +54,31 @@ angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities',
|
|||||||
scope[fld] = data['license_info'][fld];
|
scope[fld] = data['license_info'][fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var license = data['license_info'][fld];
|
var dt = new Date(parseInt(scope['license_date']));
|
||||||
|
if (dt.getFullYear() == '1970') {
|
||||||
|
// date was passed in seconds rather than milliseconds
|
||||||
|
dt = new Date(parseInt(scope['license_date']) * 1000);
|
||||||
|
scope['time_remaining'] = scope['time_remaining'] + '000';
|
||||||
|
}
|
||||||
|
scope['license_date'] = FormatDate(dt);
|
||||||
|
|
||||||
|
var days = parseInt(scope['time_remaining'] / 86400000);
|
||||||
|
var remainder = scope['time_remaining'] - (days * 86400000);
|
||||||
|
var hours = parseInt(remainder / 3600000);
|
||||||
|
remainder = remainder - (hours * 3600000);
|
||||||
|
var minutes = parseInt(remainder / 60000);
|
||||||
|
remainder = remainder - (minutes * 60000);
|
||||||
|
var seconds = parseInt(remainder / 1000);
|
||||||
|
scope['time_remaining'] = days + ' days ' + ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2);
|
||||||
|
|
||||||
|
if (parseInt(scope['free_instances']) <= 0) {
|
||||||
|
scope['free_instances_class'] = 'field-failure';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope['free_instances_class'] = 'field-success';
|
||||||
|
}
|
||||||
|
|
||||||
|
var license = data['license_info'];
|
||||||
if (license['valid_key'] !== undefined && license['valid_key'] == false) {
|
if (license['valid_key'] !== undefined && license['valid_key'] == false) {
|
||||||
scope['license_status'] = 'Invalid';
|
scope['license_status'] = 'Invalid';
|
||||||
scope['status_color'] = 'license-invalid';
|
scope['status_color'] = 'license-invalid';
|
||||||
@@ -53,13 +92,14 @@ angular.module('License', ['LicenseFormDefinition', 'RestServices', 'Utilities',
|
|||||||
scope['status_color'] = 'license-expired';
|
scope['status_color'] = 'license-expired';
|
||||||
}
|
}
|
||||||
else if (license['free_instances'] !== undefined && parseInt(license['free_instances']) <= 0) {
|
else if (license['free_instances'] !== undefined && parseInt(license['free_instances']) <= 0) {
|
||||||
scope['license_status'] = 'No available servers';
|
scope['license_status'] = 'No available managed hosts';
|
||||||
scope['status_color'] = 'license-warning';
|
scope['status_color'] = 'license-invalid';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope['license_status'] = 'Valid';
|
scope['license_status'] = 'Valid';
|
||||||
scope['status_color'] = 'license-valid';
|
scope['status_color'] = 'license-valid';
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
|
|||||||
@@ -139,21 +139,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Confirmation Dialog -->
|
|
||||||
<div id="prompt-modal" class="modal hide">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-target="#prompt-modal"
|
|
||||||
data-dismiss="modal" aria-hidden="true">×</button>
|
|
||||||
<h3 ng-bind="promptHeader" id="prompt-header"></h3>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body" ng-bind="promptBody" id="prompt-body">
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a href="#" data-target="#prompt-modal" data-dismiss="modal" class="btn">No</a>
|
|
||||||
<a href="" ng-click="promptAction()" id="prompt-action-btn" class="btn">Yes</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Password Dialog -->
|
<!-- Password Dialog -->
|
||||||
<div id="password-modal" class="modal hide">
|
<div id="password-modal" class="modal hide">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@@ -213,6 +198,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Confirmation Dialog -->
|
||||||
|
<div id="prompt-modal" class="modal hide">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-target="#prompt-modal"
|
||||||
|
data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h3 ng-bind="promptHeader" id="prompt-header"></h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" ng-bind-html-unsafe="promptBody" id="prompt-body">
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="#" data-target="#prompt-modal" data-dismiss="modal" class="btn">No</a>
|
||||||
|
<a href="" ng-click="promptAction()" id="prompt-action-btn" class="btn">Yes</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Alerts/error handling dialogs -->
|
<!-- Alerts/error handling dialogs -->
|
||||||
<div id="alert-modal" class="modal hide">
|
<div id="alert-modal" class="modal hide">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
|||||||
Reference in New Issue
Block a user