More subscription license work

This commit is contained in:
2022-08-23 00:25:27 +00:00
parent e01bfd1625
commit fbca9f167d
2 changed files with 280 additions and 190 deletions

View File

@@ -13,18 +13,19 @@
/*global $, app */ /*global $, app */
app.ravLicense = (function () { app.ravLicense = (function () {
"use strict"; "use strict";
//---------------- BEGIN MODULE SCOPE VARIABLES -------------- //---------------- BEGIN MODULE SCOPE VARIABLES --------------
var stateMap = {}, var stateMap = {},
configModule, configModule,
initModule, initModule,
onGenerate, onGenerate,
onRevoke; onRevoke,
//----------------- END MODULE SCOPE VARIABLES --------------- onPerpetualChanged;
//----------------- END MODULE SCOPE VARIABLES ---------------
//------------------- BEGIN UTILITY METHODS ------------------ //------------------- BEGIN UTILITY METHODS ------------------
//-------------------- END UTILITY METHODS ------------------- //-------------------- END UTILITY METHODS -------------------
/* /*
public class dtoRavLicense public class dtoRavLicense
{ {
[Required] [Required]
@@ -55,165 +56,195 @@ app.ravLicense = (function () {
*/ */
//------------------- BEGIN EVENT HANDLERS ------------------- //------------------- BEGIN EVENT HANDLERS -------------------
onGenerate = function (event) { onGenerate = function (event) {
event.preventDefault(); event.preventDefault();
$.gevent.publish("app-clear-error"); $.gevent.publish("app-clear-error");
//get form data //get form data
var formData = $("form").serializeArray({ var formData = $("form").serializeArray({
checkboxesAsBools: true checkboxesAsBools: true
}); });
var submitData = app.utilB.objectifyFormDataArray(formData); var submitData = app.utilB.objectifyFormDataArray(formData);
//do features separately, above can't deal with multi select and we need to add schedtechs anyway //do features separately, above can't deal with multi select and we need to add schedtechs anyway
let features = []; let features = [];
features.push({
Feature: "ServiceTechs",
Count: Number($("#techcount").val())
});
let options = $("#options").val();
for (let i = 0; i < options.length; i++) { if ($("#perpetual").prop("checked")) {
features.push({ Feature: options[i], Count: 0 }); features.push({
} Feature: "ServiceTechs",
Count: Number($("#techcount").val())
});
} else {
features.push({
Feature: "ActiveInternalUsers",
Count: Number($("#subusercount").val())
});
submitData["features"] = features; features.push({
//submit Feature: "ActiveCustomerUsers",
// alert("STUB submit"); Count: Number($("#subcustcount").val())
app.api.createRavLicense(submitData, function (res) { });
if (res.error) { }
$.gevent.publish("app-show-error", res.msg);
} else { let options = $("#options").val();
page(
"#!/ravLicenses/" + for (let i = 0; i < options.length; i++) {
stateMap.id + features.push({ Feature: options[i], Count: 0 });
"/" + }
stateMap.context.params.cust_id
submitData["features"] = features;
//submit
// alert("STUB submit");
app.api.createRavLicense(submitData, function (res) {
if (res.error) {
$.gevent.publish("app-show-error", res.msg);
} else {
page(
"#!/ravLicenses/" +
stateMap.id +
"/" +
stateMap.context.params.cust_id
);
return false;
}
});
return false; //prevent default
};
onRevoke = function (event) {
event.preventDefault();
$("#registeredTo").val("REVOKED");
$("#licenseExpires").prop("checked", true);
var yesterday = moment().add(-1, "days").toISOString().substring(0, 10);
$('input[type="date"]').val(yesterday);
return false; //prevent default
};
onPerpetualChanged = function (event) {
event.preventDefault();
$("#perpettechcountblock").toggleClass("d-none");
$("#subusercountblock").toggleClass("d-none");
$("#subcustcountblock").toggleClass("d-none");
return false; //prevent default
};
// onSelectAllAddOns = function (event) {
// event.preventDefault();
// $('#wbi').prop('checked', true);
// $('#mbi').prop('checked', true);
// $('#ri').prop('checked', true);
// $('#qbi').prop('checked', true);
// $('#qboi').prop('checked', true);
// $('#pti').prop('checked', true);
// $('#quickNotification').prop('checked', true);
// $('#exportToXls').prop('checked', true);
// $('#outlookSchedule').prop('checked', true);
// $('#oli').prop('checked', true);
// $('#importExportCSVDuplicate').prop('checked', true);
// return false; //prevent default
// };
// onTemplates = function(event) {
// event.preventDefault();
// alert("STUB: templates");
// return false; //prevent default
// };
//-------------------- END EVENT HANDLERS --------------------
//------------------- BEGIN PUBLIC METHODS -------------------
//CONFIGMODULE
//
configModule = function (context) {
stateMap.context = context.context;
if (stateMap.context.params.id) {
stateMap.id = stateMap.context.params.id;
}
};
//INITMODULE
//
initModule = function ($container) {
if (typeof $container === "undefined") {
$container = $("#app-shell-main-content");
}
$container.html(Handlebars.templates["app.ravLicense"]({}));
///ravLicense/:id
//id is always site id and this form is only to make a new license, not to view one
//case 3233 customer list
//Fill customer list combo
// var customerList = {};
//get company name to pre-fill regto
//api/site/77/name
app.api.get("site/" + stateMap.id + "/newlicenseinfo", function (res) {
if (res.error) {
$.gevent.publish("app-show-error", res.msg);
} else {
$("#registeredTo").val(res.name);
$("#dbId").val(res.dbid);
}
});
//Context menu
app.nav.contextClear();
////app.nav.setContextTitle("License");
//make context menu
//Context menu
app.nav.contextClear();
app.nav.contextAddButton(
"btn-generate",
"Generate and Send",
"key",
onGenerate
); );
return false;
}
});
return false; //prevent default // app.nav.contextAddButton('btn-select-all-addons', 'All', 'check-all', onSelectAllAddOns);
}; // app.nav.contextAddLink("licenseRequests/", "Requests", "voice");
// app.nav.contextAddLink("licenseTemplates/", "", "layers");
//case 3233
onRevoke = function (event) { app.nav.contextAddLink(
event.preventDefault(); "ravLicenses/" +
$("#registeredTo").val("REVOKED"); stateMap.id +
$("#licenseExpires").prop("checked", true); "/" +
var yesterday = moment().add(-1, "days").toISOString().substring(0, 10); stateMap.context.params.cust_id,
$('input[type="date"]').val(yesterday); "Licenses",
"ticket"
); //from here to new license
return false; //prevent default app.nav.contextAddButton("btn-revoke", "Revoke", "nuke", onRevoke);
};
// onSelectAllAddOns = function (event) { //set all date inputs to today plus one year
// event.preventDefault(); var oneYearFromNow = moment()
// $('#wbi').prop('checked', true); .add(1, "years")
// $('#mbi').prop('checked', true); .toISOString()
// $('#ri').prop('checked', true); .substring(0, 10);
// $('#qbi').prop('checked', true); $('input[type="date"]').val(oneYearFromNow);
// $('#qboi').prop('checked', true); $("#siteId").val(stateMap.id);
// $('#pti').prop('checked', true);
// $('#quickNotification').prop('checked', true);
// $('#exportToXls').prop('checked', true);
// $('#outlookSchedule').prop('checked', true);
// $('#oli').prop('checked', true);
// $('#importExportCSVDuplicate').prop('checked', true);
// return false; //prevent default //var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10);
// }; //$('#lockoutDate').val(oneMonthFromNow);
// bind actions
$("#btn-revoke").bind("click", onRevoke);
$("#perpetual").bind("change", onPerpetualChanged);
};
// onTemplates = function(event) { // return public methods
// event.preventDefault(); return {
// alert("STUB: templates"); configModule: configModule,
initModule: initModule
// return false; //prevent default };
// }; //------------------- END PUBLIC METHODS ---------------------
//-------------------- END EVENT HANDLERS --------------------
//------------------- BEGIN PUBLIC METHODS -------------------
//CONFIGMODULE
//
configModule = function (context) {
stateMap.context = context.context;
if (stateMap.context.params.id) {
stateMap.id = stateMap.context.params.id;
}
};
//INITMODULE
//
initModule = function ($container) {
if (typeof $container === "undefined") {
$container = $("#app-shell-main-content");
}
$container.html(Handlebars.templates["app.ravLicense"]({}));
///ravLicense/:id
//id is always site id and this form is only to make a new license, not to view one
//case 3233 customer list
//Fill customer list combo
// var customerList = {};
//get company name to pre-fill regto
//api/site/77/name
app.api.get("site/" + stateMap.id + "/newlicenseinfo", function (res) {
if (res.error) {
$.gevent.publish("app-show-error", res.msg);
} else {
$("#registeredTo").val(res.name);
$("#dbId").val(res.dbid);
}
});
//Context menu
app.nav.contextClear();
////app.nav.setContextTitle("License");
//make context menu
//Context menu
app.nav.contextClear();
app.nav.contextAddButton(
"btn-generate",
"Generate and Send",
"key",
onGenerate
);
// app.nav.contextAddButton('btn-select-all-addons', 'All', 'check-all', onSelectAllAddOns);
// app.nav.contextAddLink("licenseRequests/", "Requests", "voice");
// app.nav.contextAddLink("licenseTemplates/", "", "layers");
//case 3233
app.nav.contextAddLink(
"ravLicenses/" + stateMap.id + "/" + stateMap.context.params.cust_id,
"Licenses",
"ticket"
); //from here to new license
//set all date inputs to today plus one year
var oneYearFromNow = moment()
.add(1, "years")
.toISOString()
.substring(0, 10);
$('input[type="date"]').val(oneYearFromNow);
$("#siteId").val(stateMap.id);
//var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10);
//$('#lockoutDate').val(oneMonthFromNow);
// bind actions
$("#btn-revoke").bind("click", onRevoke);
};
// return public methods
return {
configModule: configModule,
initModule: initModule
};
//------------------- END PUBLIC METHODS ---------------------
})(); })();

View File

@@ -2,82 +2,141 @@
<form id="frm" method="post" action="index.html"> <form id="frm" method="post" action="index.html">
<div class="row"> <div class="row">
<input id="siteId" name="siteId" type="hidden" value=""> <input id="siteId" name="siteId" type="hidden" value="" />
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group"> <div class="form-group">
<label for="registeredTo">Registered to</label> <label for="registeredTo">Registered to</label>
<input class="form-control" type="text" id="registeredTo" name="registeredTo" value=""> <input
class="form-control"
type="text"
id="registeredTo"
name="registeredTo"
value=""
/>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group"> <div class="form-group">
<label for="dbId">dbId</label> <label for="dbId">dbId</label>
<input class="form-control" type="text" id="dbId" name="dbId" value=""> <input
class="form-control"
type="text"
id="dbId"
name="dbId"
value=""
/>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group"> <div class="form-group">
<label for="maintenanceExpirationDate">Support expires</label> <label for="maintenanceExpirationDate">Support expires</label>
<input class="form-control" type="date" id="maintenanceExpirationDate" <input
name="maintenanceExpirationDate" value=""> class="form-control"
type="date"
id="maintenanceExpirationDate"
name="maintenanceExpirationDate"
value=""
/>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-check"> <div class="form-check">
<label class="form-check-label" for="licenseExpires"> <label class="form-check-label" for="licenseExpires">
<input class="form-check-input" type="checkbox" name="licenseExpires" id="licenseExpires"> <input
class="form-check-input"
type="checkbox"
name="licenseExpires"
id="licenseExpires"
/>
Temporary key / expires Temporary key / expires
</label> </label>
<input class="form-control" type="date" id="licenseExpirationDate" name="licenseExpirationDate" <input
value=""> class="form-control"
type="date"
id="licenseExpirationDate"
name="licenseExpirationDate"
value=""
/>
</div> </div>
</div> </div>
<div class="col-sm-6">
<div class="form-group">
<label for="techcount">Scheduleable users</label>
<input class="form-control" type="number" id="techcount" name="techcount" value="1">
</div>
</div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-check"> <div class="form-check">
<label class="form-check-label" for="perpetual"> <label class="form-check-label" for="perpetual">
<input class="form-check-input" type="checkbox" name="perpetual" id="perpetual"> <input
class="form-check-input"
type="checkbox"
name="perpetual"
id="perpetual"
/>
Perpetual license Perpetual license
</label> </label>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div id="perpettechcountblock" class="col-sm-6 d-none">
<div class="form-group"> <div class="form-group">
<label for="registeredTo">Subscription: 100 block Customer contacts</label> <label for="techcount">Scheduleable users</label>
<input class="form-control" type="number" id="subcustcount" name="subcustcount" value="1"> <input
class="form-control"
type="number"
id="techcount"
name="techcount"
value="1"
/>
</div>
</div>
<div id="subusercountblock" class="col-sm-6">
<div class="form-group">
<label for="subusercount">Internal users</label>
<input
class="form-control"
type="number"
id="subusercount"
name="subusercount"
value="1"
/>
</div>
</div>
<div id="subcustcountblock" class="col-sm-6">
<div class="form-group">
<label for="registeredTo">Customer users</label>
<input
class="form-control"
type="number"
id="subcustcount"
name="subcustcount"
value="100"
/>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group"> <div class="form-group">
<label for="options">Additional features</label> <label for="options">Additional features</label>
<select class="form-control" name="options" id="options" multiple> <select
class="form-control"
name="options"
id="options"
multiple
>
<option value="TrialMode">TrialMode</option> <option value="TrialMode">TrialMode</option>
<option value="XXXXX">XXXXX</option> <option value="future1">future1</option>
<option value="XXXXXX">XXXXXX</option> <option value="future2">future2</option>
</select> </select>
</div> </div>
</div> </div>
</div> </div>
<div class="app-frm-buttons"> {{!-- <div class="app-frm-buttons">
<button id="btn-revoke" class="btn btn-warning">Revoke</button> <button id="btn-revoke" class="btn btn-warning">Revoke</button>
</div> </div> --}}
</form> </form>
</div> </div>