This commit is contained in:
2020-06-18 18:07:09 +00:00
parent 59bfd20488
commit f2b6f237db
4 changed files with 501 additions and 534 deletions

View File

@@ -114,7 +114,7 @@ namespace rockfishCore.Controllers
{
return NotFound();
}
var custInfo = await ct.Customer.AsNoTracking().Where(z => z.Id == site.CustomerId).Select(z => new { z.Name, z.Id, dbid = site.DbId }).SingleAsync();
var custInfo = await ct.Customer.AsNoTracking().Where(z => z.Id == site.CustomerId).Select(z => new { z.Name, z.Id, site.CustomerId, dbid = site.DbId }).SingleAsync();
return Ok(custInfo);
}

View File

@@ -76,14 +76,16 @@ app.ravLicense = (function () {
features.push({ Feature: options[i], Count: 0 });
}
submitData["features"]=features;
submitData["features"] = features;
//submit
// alert("STUB submit");
app.api.createRavLicense(submitData, function (res) {
if (res.error) {
$.gevent.publish("app-show-error", res.msg);
} else {
$("#key").val(res);
page(
"#!/ravLicenses/" + stateMap.id + "/" + stateMap.context.params.cust_id
);
return false;
}
});
@@ -173,7 +175,12 @@ app.ravLicense = (function () {
// app.nav.contextAddLink("licenseRequests/", "Requests", "voice");
// app.nav.contextAddLink("licenseTemplates/", "", "layers");
//case 3233
app.nav.contextAddLink("licenses/", "List", "");
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()

View File

@@ -63,7 +63,11 @@ app.ravLicenses = (function () {
"<li class='my-5'>" +
"<div class='" +
itemClass +
"' role='alert'><pre>" +
"' role='alert'>"+
"<h4>"+
app.utilB.epochToLocalShortDateTime(obj.dtCreated)+
"</h4>"+
"<pre>" +
obj.key +
"</pre></div>" +
"</li>"
@@ -77,7 +81,7 @@ app.ravLicenses = (function () {
//=========/licenses==============
app.nav.contextClear(); ///ravLicense/122
app.nav.contextAddLink("ravLicense/" + stateMap.id, "New", "plus");
app.nav.contextAddLink("ravLicense/" + stateMap.id+ "/" + stateMap.context.params.cust_id, "New", "plus");
app.nav.contextAddLink(
"customerSiteEdit/" + stateMap.id + "/" + stateMap.context.params.cust_id,
"Site",

View File

@@ -12,37 +12,37 @@
/*global $, app */
app.shell = (function () {
'use strict';
"use strict";
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
var
stateMap = {
var stateMap = {
$container: undefined,
anchor_map: {},
user: {
authenticated: false,
token: '',
name: '',
token: "",
name: "",
id: 0
},
apiUrl: '',
apiUrl: "",
search_cache: {
has_cache: false
}
},
tokenExpired,
//onUPdate,
onLogin, onLogout, onShowError, onClearError,
onLogin,
onLogout,
onShowError,
onClearError,
initModule;
//----------------- END MODULE SCOPE VARIABLES ---------------
//------------------- BEGIN UTILITY METHODS ------------------
tokenExpired = function () {
//fetch stored creds if available
var creds = store.get('rockfish.usercreds');
var creds = store.get("rockfish.usercreds");
if (creds) {
//check if token has expired
//is the date greater than the expires date
@@ -56,30 +56,28 @@ app.shell = (function () {
} else {
return true;
}
}
};
//-------------------- END UTILITY METHODS -------------------
//------------------- BEGIN EVENT HANDLERS -------------------
onLogin = function (event, login_user) {
//store creds
store.set('rockfish.usercreds', stateMap.user);
store.set("rockfish.usercreds", stateMap.user);
//New token needs to reset lastNav
stateMap.lastNav = new Date();
//Go to the home page
page('#!/customers/');
page("#!/customers/");
return false;
};
onLogout = function (event) {
store.clear();
stateMap.user.authenticated = false;
stateMap.user.name = '';
stateMap.user.token = '';
stateMap.user.name = "";
stateMap.user.token = "";
stateMap.user.id = 0;
page('#!/authenticate/');
page("#!/authenticate/");
return false;
};
@@ -89,10 +87,9 @@ app.shell = (function () {
// return false;
// };
onShowError = function (event, msg) {
$("#app-error-div").removeClass("d-none");
$('#app-error-message').text(msg);
$("#app-error-message").text(msg);
return false;
};
@@ -101,62 +98,58 @@ app.shell = (function () {
return false;
};
//-------------------- END EVENT HANDLERS --------------------
//------------------- BEGIN PUBLIC METHODS -------------------
initModule = function ($container) {
document.title = 'Rockfish ' + app.api.RockFishVersion;
document.title = "Rockfish " + app.api.RockFishVersion;
//PRE FLIGHT CHECK
//================
//local storage required
if (!store.enabled) {
alert('Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.');
alert(
'Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.'
);
return;
}
//wait indicator for ajax functions
$(document).ajaxStart(function () {
$(document)
.ajaxStart(function () {
//disable all buttons
$('.app-frm-buttons button').prop('disabled', true).addClass('disabled');
$(".app-frm-buttons button")
.prop("disabled", true)
.addClass("disabled");
//$('.app-frm-buttons button').attr('disabled', 'disabled');
$("body").css("cursor", "progress");
//add app-ajax-busy style to buttons div where user clicked
$('.app-frm-buttons').addClass('app-ajax-busy');
}).ajaxStop(function () {
$(".app-frm-buttons").addClass("app-ajax-busy");
})
.ajaxStop(function () {
//with delay in case it's too fast to see
setTimeout(function () {
$('.app-frm-buttons button').prop('disabled', false).removeClass('disabled');
$(".app-frm-buttons button")
.prop("disabled", false)
.removeClass("disabled");
//$('.app-frm-buttons button').removeAttr('disabled');
$("body").css("cursor", "default");
$('.app-frm-buttons').removeClass('app-ajax-busy');
$(".app-frm-buttons").removeClass("app-ajax-busy");
}, 250);
});
//save on app so can call from anywhere
// app.mdInit = mdInit;
// load HTML and map jQuery collections
stateMap.$container = $container;
$container.html(Handlebars.templates['app.shell']({}));
$container.html(Handlebars.templates["app.shell"]({}));
//auto hide navbar on click
//rfac is a class only on the items that should trigger collapse
$('.rfac').on('click', function () {
$('.navbar-collapse').collapse('hide');
$(".rfac").on("click", function () {
$(".navbar-collapse").collapse("hide");
});
//SEARCH
@@ -165,20 +158,17 @@ app.shell = (function () {
//determine API url and save it
stateMap.apiUrl = app.utilB.getApiUrl();
//fetch stored creds if available
var creds = store.get('rockfish.usercreds');
var creds = store.get("rockfish.usercreds");
// if (creds) {
//check if token has expired
if (tokenExpired()) {
stateMap.user.authenticated = false;
stateMap.user.name = '';
stateMap.user.token = '';
stateMap.user.name = "";
stateMap.user.token = "";
stateMap.user.id = 0;
} else {
//Show the logout item in the menu
$(".app-mnu-logout").removeClass("app-hidden");
@@ -189,92 +179,77 @@ app.shell = (function () {
}
//}
//EVENT SUBSCRIPTIONS
$.gevent.subscribe($container, 'app-login', onLogin);
$.gevent.subscribe($container, 'app-logout', onLogout);
$.gevent.subscribe($container, "app-login", onLogin);
$.gevent.subscribe($container, "app-logout", onLogout);
//$.gevent.subscribe($container, 'rf-update', onUpdate);
$.gevent.subscribe($container, 'app-show-error', onShowError);
$.gevent.subscribe($container, 'app-clear-error', onClearError);
$.gevent.subscribe($container, "app-show-error", onShowError);
$.gevent.subscribe($container, "app-clear-error", onClearError);
//ROUTES
//
page.base('/default.htm');
page('*', beforeUrlChange);
page('/authenticate', authenticate);
page('/', inbox);
page('/reportData', reportData);
page('/reportDataProdEmails', reportDataProdEmail);
page('/reportDataExpires', reportDataExpires);
page('/search', search);
page('/logout', function () {
$.gevent.publish('app-logout');
page.base("/default.htm");
page("*", beforeUrlChange);
page("/authenticate", authenticate);
page("/", inbox);
page("/reportData", reportData);
page("/reportDataProdEmails", reportDataProdEmail);
page("/reportDataExpires", reportDataExpires);
page("/search", search);
page("/logout", function () {
$.gevent.publish("app-logout");
});
page('/customers', customers);
page('/customerEdit/:id', customerEdit);
page('/customerSites/:id', customerSites);
page('/customerSiteEdit/:id/:cust_id', customerSiteEdit);
page('/purchases/:id', purchases);
page('/purchaseEdit/:id/:site_id', purchaseEdit);
page('/license', license);
page('/licenseTemplates', licenseTemplates);
page('/licenseRequests', licenseRequests);
page('/licenseRequestEdit/:id', licenseRequestEdit);
page("/customers", customers);
page("/customerEdit/:id", customerEdit);
page("/customerSites/:id", customerSites);
page("/customerSiteEdit/:id/:cust_id", customerSiteEdit);
page("/purchases/:id", purchases);
page("/purchaseEdit/:id/:site_id", purchaseEdit);
page("/license", license);
page("/licenseTemplates", licenseTemplates);
page("/licenseRequests", licenseRequests);
page("/licenseRequestEdit/:id", licenseRequestEdit);
//case 3233
page('/licenses', licenses);
page('/licenseView/:id', licenseView);
page('/subscription', subscription);
page('/subnotify', subnotify);
page('/templates', templates);
page('/templateEdit/:id', templateEdit);
page('/inbox', inbox);
page.exit('/inbox', function(ctx,next) {
page("/licenses", licenses);
page("/licenseView/:id", licenseView);
page("/subscription", subscription);
page("/subnotify", subnotify);
page("/templates", templates);
page("/templateEdit/:id", templateEdit);
page("/inbox", inbox);
page.exit("/inbox", function (ctx, next) {
app.inbox.terminateModule();
next();
});
page('/mailEdit/:mail_account/:mail_folder/:mail_id', mailEdit);
page('/rfcases', rfcases);
page('/rfcaseEdit/:id', rfcaseEdit);
page('/rfsettings', rfsettings);
page('/ops', ops);
page('/trials', trials);
page('/trialEdit/:id', trialEdit);
page('/ravLicenses/:id/:cust_id', ravLicenses);
page('/ravLicense/:id', ravLicense);
page('*', notFound);
page("/mailEdit/:mail_account/:mail_folder/:mail_id", mailEdit);
page("/rfcases", rfcases);
page("/rfcaseEdit/:id", rfcaseEdit);
page("/rfsettings", rfsettings);
page("/ops", ops);
page("/trials", trials);
page("/trialEdit/:id", trialEdit);
page("/ravLicenses/:id/:cust_id", ravLicenses);
page("/ravLicense/:id/:cust_id", ravLicense);
page("*", notFound);
page({
hashbang: true
});
// /ROUTES
};
// End PUBLIC method /initModule/
var beforeUrlChange = function (ctx, next) {
$.gevent.publish('app-clear-error');
$.gevent.publish("app-clear-error");
app.shell.stateMap.mediaSize = app.utilB.getMediaSize();
//case 3513
document.title = 'Rockfish ' + app.api.RockFishVersion;
document.title = "Rockfish " + app.api.RockFishVersion;
//bypass stuff below if about to logout
if (ctx.path == '/logout') {
if (ctx.path == "/logout") {
return next();
}
//================================================================
//Check authentication token to see if expired, but only if it's been a few minutes since last navigation
if (stateMap.user.authenticated) {
@@ -282,21 +257,19 @@ app.shell = (function () {
//default to one hour ago in case it hasn't ever been set yet or isn't in statemap
if (!stateMap.lastNav) {
//Isn't this sketchy? Is this a date or a moment being set here
stateMap.lastNav = moment().subtract(3600, 's').toDate();//60 minutes ago
stateMap.lastNav = moment().subtract(3600, "s").toDate(); //60 minutes ago
}
var mNow = moment(new Date()); //todays date
var mLastNav = moment(stateMap.lastNav); // another date
var duration = moment.duration(mNow.diff(mLastNav));
var secondsSinceLastNav = duration.asSeconds();
if (secondsSinceLastNav > 300)//have we checked in the last 5 minutes?
{
if (secondsSinceLastNav > 300) {
//have we checked in the last 5 minutes?
if (tokenExpired()) {
stateMap.user.authenticated = false;
}
}
stateMap.lastNav = new Date();
}
@@ -309,11 +282,8 @@ app.shell = (function () {
duration: 200
});
//page nav to authenticate
if (ctx.path != '/authenticate/')
return page('#!/authenticate/');
if (ctx.path != "/authenticate/") return page("#!/authenticate/");
} else {
//logged in so make sure to show toolbar here
$("#rf-nav").show({
@@ -322,294 +292,280 @@ app.shell = (function () {
}
next();
}
};
//TODO: Clean up this coral reef steaming mess
//replace with a function that generates these functions since they are all (nearly) identical
var authenticate = function (ctx) {
app.authenticate.configModule({
context: ctx
});
app.authenticate.initModule();
}
};
var reportData = function (ctx) {
app.nav.setSelectedMenuItem('reportData');
app.nav.setSelectedMenuItem("reportData");
app.reportData.configModule({
context: ctx
});
app.reportData.initModule();
}
};
var reportDataProdEmail = function (ctx) {
app.nav.setSelectedMenuItem('reportData');
app.nav.setSelectedMenuItem("reportData");
app.reportDataProdEmail.configModule({
context: ctx
});
app.reportDataProdEmail.initModule();
}
};
var reportDataExpires = function (ctx) {
app.nav.setSelectedMenuItem('reportData');
app.nav.setSelectedMenuItem("reportData");
app.reportDataExpires.configModule({
context: ctx
});
app.reportDataExpires.initModule();
}
};
var search = function (ctx) {
app.nav.setSelectedMenuItem('search');
app.nav.setSelectedMenuItem("search");
app.search.configModule({
context: ctx
});
app.search.initModule();
}
};
var customers = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.customers.configModule({
context: ctx
});
app.customers.initModule();
}
};
var customerEdit = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.customerEdit.configModule({
context: ctx
});
app.customerEdit.initModule();
}
};
var customerSites = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.customerSites.configModule({
context: ctx
});
app.customerSites.initModule();
}
};
var customerSiteEdit = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.customerSiteEdit.configModule({
context: ctx
});
app.customerSiteEdit.initModule();
}
};
var purchases = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.purchases.configModule({
context: ctx
});
app.purchases.initModule();
}
};
var purchaseEdit = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.purchaseEdit.configModule({
context: ctx
});
app.purchaseEdit.initModule();
}
};
var license = function (ctx) {
app.nav.setSelectedMenuItem('license');
app.nav.setSelectedMenuItem("license");
app.license.configModule({
context: ctx
});
app.license.initModule();
}
};
var licenseTemplates = function (ctx) {
app.nav.setSelectedMenuItem('license');
app.nav.setSelectedMenuItem("license");
app.licenseTemplates.configModule({
context: ctx
});
app.licenseTemplates.initModule();
}
};
var licenseRequests = function (ctx) {
app.nav.setSelectedMenuItem('license');
app.nav.setSelectedMenuItem("license");
app.licenseRequests.configModule({
context: ctx
});
app.licenseRequests.initModule();
}
};
var licenseRequestEdit = function (ctx) {
app.nav.setSelectedMenuItem('license');
app.nav.setSelectedMenuItem("license");
app.licenseRequestEdit.configModule({
context: ctx
});
app.licenseRequestEdit.initModule();
}
};
//case 3233
var licenses = function (ctx) {
app.nav.setSelectedMenuItem('license');
app.nav.setSelectedMenuItem("license");
app.licenses.configModule({
context: ctx
});
app.licenses.initModule();
}
};
//case 3233
var licenseView = function (ctx) {
app.nav.setSelectedMenuItem('license');
app.nav.setSelectedMenuItem("license");
app.licenseView.configModule({
context: ctx
});
app.licenseView.initModule();
}
};
var subscription = function (ctx) {
app.nav.setSelectedMenuItem('subscription');
app.nav.setSelectedMenuItem("subscription");
app.subscription.configModule({
context: ctx
});
app.subscription.initModule();
}
};
var subnotify = function (ctx) {
app.nav.setSelectedMenuItem('subscription');
app.nav.setSelectedMenuItem("subscription");
app.subnotify.configModule({
context: ctx
});
app.subnotify.initModule();
}
};
var templates = function (ctx) {
app.nav.setSelectedMenuItem('templates');
app.nav.setSelectedMenuItem("templates");
app.templates.configModule({
context: ctx
});
app.templates.initModule();
}
};
var templateEdit = function (ctx) {
app.nav.setSelectedMenuItem('templates');
app.nav.setSelectedMenuItem("templates");
app.templateEdit.configModule({
context: ctx
});
app.templateEdit.initModule();
}
};
var inbox = function (ctx) {
app.nav.setSelectedMenuItem('inbox');
app.nav.setSelectedMenuItem("inbox");
app.inbox.configModule({
context: ctx
});
app.inbox.initModule();
}
};
var mailEdit = function (ctx) {
app.nav.setSelectedMenuItem('inbox');
app.nav.setSelectedMenuItem("inbox");
app.mailEdit.configModule({
context: ctx
});
app.mailEdit.initModule();
}
};
var rfcases = function (ctx) {
app.nav.setSelectedMenuItem('rfcases');
app.nav.setSelectedMenuItem("rfcases");
app.rfcases.configModule({
context: ctx
});
app.rfcases.initModule();
}
};
var rfcaseEdit = function (ctx) {
app.nav.setSelectedMenuItem('rfcases');
app.nav.setSelectedMenuItem("rfcases");
app.rfcaseEdit.configModule({
context: ctx
});
app.rfcaseEdit.initModule();
}
};
var rfsettings = function (ctx) {
app.nav.setSelectedMenuItem('rfsettings');
app.nav.setSelectedMenuItem("rfsettings");
app.rfsettings.configModule({
context: ctx
});
app.rfsettings.initModule();
}
};
var ops = function (ctx) {
app.nav.setSelectedMenuItem('ops');
app.nav.setSelectedMenuItem("ops");
app.ops.configModule({
context: ctx
});
app.ops.initModule();
}
};
//case 3233
var trials = function (ctx) {
app.nav.setSelectedMenuItem('trials');
app.nav.setSelectedMenuItem("trials");
app.trials.configModule({
context: ctx
});
app.trials.initModule();
}
};
//case 3233
var trialEdit = function (ctx) {
app.nav.setSelectedMenuItem('trials');
app.nav.setSelectedMenuItem("trials");
app.trialEdit.configModule({
context: ctx
});
app.trialEdit.initModule();
}
};
var trialEdit = function (ctx) {
app.nav.setSelectedMenuItem('trials');
app.nav.setSelectedMenuItem("trials");
app.trialEdit.configModule({
context: ctx
});
app.trialEdit.initModule();
}
};
var ravLicense = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.ravLicense.configModule({
context: ctx
});
app.ravLicense.initModule();
}
};
var ravLicenses = function (ctx) {
app.nav.setSelectedMenuItem('customers');
app.nav.setSelectedMenuItem("customers");
app.ravLicenses.configModule({
context: ctx
});
app.ravLicenses.initModule();
}
};
var notFound = function (ctx) {
app.fourohfour.configModule({
context: ctx
});
app.fourohfour.initModule();
}
};
return {
initModule: initModule,
stateMap: stateMap
};
//------------------- END PUBLIC METHODS ---------------------
}());
})();