This commit is contained in:
@@ -43,7 +43,7 @@ namespace rockfishCore.Controllers
|
|||||||
//do stuff with the notification
|
//do stuff with the notification
|
||||||
(string username, string password) = rockfishCore.Util.AutoOrderProcessingUtil.GetUsernameAndPasswordFromAuthorizeHeader(Authorization);
|
(string username, string password) = rockfishCore.Util.AutoOrderProcessingUtil.GetUsernameAndPasswordFromAuthorizeHeader(Authorization);
|
||||||
// Now use username and password with whatever authentication process you want
|
// Now use username and password with whatever authentication process you want
|
||||||
if (username == "Y24PYYDQSA1L12905N5MKU" && password == "GI2F7CP17C2JS872MHASAF")
|
if (username == "Y24PYYDQSA1L12905N5MKU" && password == "MA8GMQK2PC3FDNT1RTR68R")
|
||||||
{
|
{
|
||||||
//put the notification into the db as freeform notification information
|
//put the notification into the db as freeform notification information
|
||||||
//to be processed by other code later. i.e. just capture it as is cleanly and don't bother trying to do anything fancy here this should be tight and focused and side effect free
|
//to be processed by other code later. i.e. just capture it as is cleanly and don't bother trying to do anything fancy here this should be tight and focused and side effect free
|
||||||
|
|||||||
@@ -12,383 +12,445 @@
|
|||||||
/*global $, io, app */
|
/*global $, io, app */
|
||||||
|
|
||||||
app.api = (function () {
|
app.api = (function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
var initModule,
|
var initModule,
|
||||||
getAuthHeaderObject,
|
getAuthHeaderObject,
|
||||||
RockFishVersion,
|
RockFishVersion,
|
||||||
get,
|
get,
|
||||||
remove,
|
remove,
|
||||||
create,
|
create,
|
||||||
update,
|
update,
|
||||||
uploadFile,
|
uploadFile,
|
||||||
putAction,
|
putAction,
|
||||||
postAction,
|
postAction,
|
||||||
createLicense,
|
createLicense,
|
||||||
createRavLicense,
|
createRavLicense,
|
||||||
getLicenseRequests,
|
getLicenseRequests,
|
||||||
generateFromRequest,
|
generateFromRequest,
|
||||||
licenseEmailResponse;
|
licenseEmailResponse,
|
||||||
|
test;
|
||||||
|
|
||||||
RockFishVersion = "6.20";
|
RockFishVersion = "6.20";
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
// NOT AUTHORIZED ERROR HANDLER
|
// NOT AUTHORIZED ERROR HANDLER
|
||||||
|
|
||||||
$(document).ajaxError(function (event, jqxhr, settings, thrownError) {
|
$(document).ajaxError(function (event, jqxhr, settings, thrownError) {
|
||||||
//unauthorized? Trigger logout which will trigger login after clearing creds
|
//unauthorized? Trigger logout which will trigger login after clearing creds
|
||||||
if (jqxhr.status == 401) {
|
if (jqxhr.status == 401) {
|
||||||
window.location.replace("#!/logout");
|
window.location.replace("#!/logout");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
// UTILITY
|
// UTILITY
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Return the auth token header
|
// Return the auth token header
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
getAuthHeaderObject = function () {
|
getAuthHeaderObject = function () {
|
||||||
return {
|
return {
|
||||||
Authorization: "Bearer " + app.shell.stateMap.user.token
|
Authorization: "Bearer " + app.shell.stateMap.user.token
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
// ROCKFISH CORE ROUTES
|
// ROCKFISH CORE ROUTES
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//Create
|
//Create
|
||||||
//Route app.post('/api/:obj_type/create', function (req, res) {
|
//Route app.post('/api/:obj_type/create', function (req, res) {
|
||||||
//
|
//
|
||||||
create = function (apiRoute, objData, callback) {
|
create = function (apiRoute, objData, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
data: JSON.stringify(objData),
|
data: JSON.stringify(objData),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
msg:
|
||||||
error_detail: {}
|
textStatus +
|
||||||
|
"\n" +
|
||||||
|
jqXHR.responseText +
|
||||||
|
"\n" +
|
||||||
|
errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
//Get - get anything, the caller provides the route, this should replace most legacy get
|
//Get - get anything, the caller provides the route, this should replace most legacy get
|
||||||
//
|
//
|
||||||
get = function (apiRoute, callback) {
|
get = function (apiRoute, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
|
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
msg:
|
||||||
error_detail: {}
|
textStatus +
|
||||||
|
"\n" +
|
||||||
|
jqXHR.responseText +
|
||||||
|
"\n" +
|
||||||
|
errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
////////////////////
|
||||||
};
|
|
||||||
////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//Update
|
//Update
|
||||||
//route: app.post('/api/:obj_type/update/:id', function (req, res) {
|
//route: app.post('/api/:obj_type/update/:id', function (req, res) {
|
||||||
//
|
//
|
||||||
update = function (objType, objData, callback) {
|
update = function (objType, objData, callback) {
|
||||||
var theId;
|
var theId;
|
||||||
if (!objData.id) {
|
if (!objData.id) {
|
||||||
return callback({
|
return callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: "app.api.js::update->Error: missing id field in update document",
|
msg: "app.api.js::update->Error: missing id field in update document",
|
||||||
error_detail: objData
|
error_detail: objData
|
||||||
});
|
});
|
||||||
}
|
|
||||||
theId = objData.id;
|
|
||||||
$.ajax({
|
|
||||||
method: "put",
|
|
||||||
dataType: "json",
|
|
||||||
url: app.shell.stateMap.apiUrl + objType + "/" + theId,
|
|
||||||
headers: getAuthHeaderObject(),
|
|
||||||
contentType: "application/json; charset=utf-8",
|
|
||||||
data: JSON.stringify(objData),
|
|
||||||
success: function (data, textStatus) {
|
|
||||||
if (data == null) {
|
|
||||||
data = { ok: 1 };
|
|
||||||
}
|
}
|
||||||
|
theId = objData.id;
|
||||||
|
$.ajax({
|
||||||
|
method: "put",
|
||||||
|
dataType: "json",
|
||||||
|
url: app.shell.stateMap.apiUrl + objType + "/" + theId,
|
||||||
|
headers: getAuthHeaderObject(),
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
data: JSON.stringify(objData),
|
||||||
|
success: function (data, textStatus) {
|
||||||
|
if (data == null) {
|
||||||
|
data = { ok: 1 };
|
||||||
|
}
|
||||||
|
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
msg:
|
||||||
error_detail: {}
|
textStatus +
|
||||||
|
"\n" +
|
||||||
|
jqXHR.responseText +
|
||||||
|
"\n" +
|
||||||
|
errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//remove Item
|
//remove Item
|
||||||
remove = function (apiRoute, callback) {
|
remove = function (apiRoute, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
msg:
|
||||||
error_detail: {}
|
textStatus +
|
||||||
|
"\n" +
|
||||||
|
jqXHR.responseText +
|
||||||
|
"\n" +
|
||||||
|
errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// uploadFile
|
// uploadFile
|
||||||
// (ajax route to upload a file)
|
// (ajax route to upload a file)
|
||||||
//
|
//
|
||||||
uploadFile = function (apiRoute, objData, callback) {
|
uploadFile = function (apiRoute, objData, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
data: objData,
|
data: objData,
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + errorThrown,
|
msg: textStatus + "\n" + errorThrown,
|
||||||
error_detail: {}
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
//putAction - ad-hoc put method used to trigger actions etc
|
//putAction - ad-hoc put method used to trigger actions etc
|
||||||
//
|
//
|
||||||
putAction = function (apiRoute, callback) {
|
putAction = function (apiRoute, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "put",
|
method: "put",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
//data: JSON.stringify(objData),
|
//data: JSON.stringify(objData),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = { ok: 1 };
|
data = { ok: 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
msg:
|
||||||
error_detail: {}
|
textStatus +
|
||||||
|
"\n" +
|
||||||
|
jqXHR.responseText +
|
||||||
|
"\n" +
|
||||||
|
errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
//postAction - ad-hoc post method used to trigger actions etc
|
//postAction - ad-hoc post method used to trigger actions etc
|
||||||
// (becuase it shouldn't have been put in the first place above)
|
// (becuase it shouldn't have been put in the first place above)
|
||||||
postAction = function (apiRoute, callback) {
|
postAction = function (apiRoute, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + apiRoute,
|
url: app.shell.stateMap.apiUrl + apiRoute,
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = { ok: 1 };
|
data = { ok: 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
msg:
|
||||||
error_detail: {}
|
textStatus +
|
||||||
|
"\n" +
|
||||||
|
jqXHR.responseText +
|
||||||
|
"\n" +
|
||||||
|
errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
// LICENSE KEY RELATED API METHODS
|
// LICENSE KEY RELATED API METHODS
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//CreateLicense
|
//CreateLicense
|
||||||
//Route app.post('/api/license/create', function (req, res) {
|
//Route app.post('/api/license/create', function (req, res) {
|
||||||
//
|
//
|
||||||
createLicense = function (objData, callback) {
|
createLicense = function (objData, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
dataType: "text",
|
dataType: "text",
|
||||||
url: app.shell.stateMap.apiUrl + "license/generate",
|
url: app.shell.stateMap.apiUrl + "license/generate",
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
data: JSON.stringify(objData),
|
data: JSON.stringify(objData),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + errorThrown,
|
msg: textStatus + "\n" + errorThrown,
|
||||||
error_detail: {}
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//CreateRavLicense
|
//CreateRavLicense
|
||||||
//Route app.post('/api/license/create', function (req, res) {
|
//Route app.post('/api/license/create', function (req, res) {
|
||||||
//
|
//
|
||||||
createRavLicense = function (objData, callback) {
|
createRavLicense = function (objData, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
dataType: "text",
|
dataType: "text",
|
||||||
url: app.shell.stateMap.apiUrl + "rvl",
|
url: app.shell.stateMap.apiUrl + "rvl",
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
data: JSON.stringify(objData),
|
data: JSON.stringify(objData),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + errorThrown,
|
msg: textStatus + "\n" + errorThrown,
|
||||||
error_detail: {}
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//GetLicenseRequests
|
//GetLicenseRequests
|
||||||
//Fetch license requests
|
//Fetch license requests
|
||||||
//route: app.get('/api/license/requests', function (req, res) {
|
//route: app.get('/api/license/requests', function (req, res) {
|
||||||
//
|
//
|
||||||
getLicenseRequests = function (callback) {
|
getLicenseRequests = function (callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + "license/requests",
|
url: app.shell.stateMap.apiUrl + "license/requests",
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + errorThrown,
|
msg: textStatus + "\n" + errorThrown,
|
||||||
error_detail: {}
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//GenerateFromRequest
|
//GenerateFromRequest
|
||||||
//Fetch generated response to license request
|
//Fetch generated response to license request
|
||||||
//route: app.get('/api/license/generateFromRequest/:uid', function (req, res) {
|
//route: app.get('/api/license/generateFromRequest/:uid', function (req, res) {
|
||||||
//
|
//
|
||||||
generateFromRequest = function (uid, callback) {
|
generateFromRequest = function (uid, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: app.shell.stateMap.apiUrl + "license/generateFromRequest/" + uid,
|
url:
|
||||||
headers: getAuthHeaderObject(),
|
app.shell.stateMap.apiUrl +
|
||||||
success: function (data, textStatus) {
|
"license/generateFromRequest/" +
|
||||||
callback(data);
|
uid,
|
||||||
},
|
headers: getAuthHeaderObject(),
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
success: function (data, textStatus) {
|
||||||
callback({
|
callback(data);
|
||||||
error: 1,
|
},
|
||||||
msg: textStatus + "\n" + errorThrown,
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
error_detail: {}
|
callback({
|
||||||
|
error: 1,
|
||||||
|
msg: textStatus + "\n" + errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
//Email license request response
|
//Email license request response
|
||||||
//app.post('/api/license/email_response', function (req, res) {
|
//app.post('/api/license/email_response', function (req, res) {
|
||||||
//
|
//
|
||||||
licenseEmailResponse = function (objData, callback) {
|
licenseEmailResponse = function (objData, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
dataType: "text",
|
dataType: "text",
|
||||||
url: app.shell.stateMap.apiUrl + "license/email_response",
|
url: app.shell.stateMap.apiUrl + "license/email_response",
|
||||||
headers: getAuthHeaderObject(),
|
headers: getAuthHeaderObject(),
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
data: JSON.stringify(objData),
|
data: JSON.stringify(objData),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
callback({
|
callback({
|
||||||
error: 1,
|
error: 1,
|
||||||
msg: textStatus + "\n" + errorThrown,
|
msg: textStatus + "\n" + errorThrown,
|
||||||
error_detail: {}
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
initModule = function () {};
|
///////////////////////////////////////////////////////////
|
||||||
|
//test functin for rockfish endpoint testing
|
||||||
|
//
|
||||||
|
//
|
||||||
|
test = function (objData, callback) {
|
||||||
|
//Test fake shareit webhook
|
||||||
|
$.ajax({
|
||||||
|
method: "post",
|
||||||
|
dataType: "json",
|
||||||
|
url: app.shell.stateMap.apiUrl + "order/shareit",
|
||||||
|
username: 'Y24PYYDQSA1L12905N5MKU',
|
||||||
|
password: 'MA8GMQK2PC3FDNT1RTR68R',
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
data: JSON.stringify(objData),
|
||||||
|
success: function (data) {
|
||||||
|
callback(data);
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
callback({
|
||||||
|
error: 1,
|
||||||
|
msg: textStatus + "\n" + errorThrown,
|
||||||
|
error_detail: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
initModule = function () {};
|
||||||
initModule: initModule,
|
|
||||||
getAuthHeaderObject: getAuthHeaderObject,
|
return {
|
||||||
RockFishVersion: RockFishVersion,
|
initModule: initModule,
|
||||||
get: get,
|
getAuthHeaderObject: getAuthHeaderObject,
|
||||||
remove: remove,
|
RockFishVersion: RockFishVersion,
|
||||||
create: create,
|
get: get,
|
||||||
update: update,
|
remove: remove,
|
||||||
uploadFile: uploadFile,
|
create: create,
|
||||||
putAction: putAction,
|
update: update,
|
||||||
postAction: postAction,
|
uploadFile: uploadFile,
|
||||||
createLicense: createLicense,
|
putAction: putAction,
|
||||||
createRavLicense: createRavLicense,
|
postAction: postAction,
|
||||||
getLicenseRequests: getLicenseRequests,
|
createLicense: createLicense,
|
||||||
generateFromRequest: generateFromRequest,
|
createRavLicense: createRavLicense,
|
||||||
licenseEmailResponse: licenseEmailResponse
|
getLicenseRequests: getLicenseRequests,
|
||||||
};
|
generateFromRequest: generateFromRequest,
|
||||||
|
licenseEmailResponse: licenseEmailResponse,
|
||||||
|
test: test
|
||||||
|
};
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -7,108 +7,152 @@
|
|||||||
|
|
||||||
/*global $, app */
|
/*global $, app */
|
||||||
|
|
||||||
app.rfsettings = (function() {
|
app.rfsettings = (function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
||||||
var stateMap = {},
|
var stateMap = {},
|
||||||
configModule,
|
configModule,
|
||||||
onChangePassword,
|
onChangePassword,
|
||||||
initModule,
|
initModule,
|
||||||
onTest;
|
onTest;
|
||||||
//----------------- END MODULE SCOPE VARIABLES ---------------
|
//----------------- END MODULE SCOPE VARIABLES ---------------
|
||||||
|
|
||||||
//------------------- BEGIN UTILITY METHODS ------------------
|
//------------------- BEGIN UTILITY METHODS ------------------
|
||||||
//-------------------- END UTILITY METHODS -------------------
|
//-------------------- END UTILITY METHODS -------------------
|
||||||
|
|
||||||
//------------------- BEGIN EVENT HANDLERS -------------------
|
|
||||||
|
|
||||||
///////////////////////////////
|
|
||||||
//ONUPDATE
|
|
||||||
//
|
|
||||||
onChangePassword = function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
$.gevent.publish("app-clear-error");
|
|
||||||
//get form data
|
|
||||||
var formData = $("form").serializeArray({
|
|
||||||
checkboxesAsBools: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var submitData = app.utilB.objectifyFormDataArray(formData);
|
|
||||||
|
|
||||||
app.api.create(
|
|
||||||
"user/" + app.shell.stateMap.user.id + "/changepassword",
|
|
||||||
submitData,
|
|
||||||
function(res) {
|
|
||||||
if (res.error) {
|
|
||||||
$.gevent.publish("app-show-error", res.msg);
|
|
||||||
} else {
|
|
||||||
page("#!/logout");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return false; //prevent default?
|
|
||||||
};
|
|
||||||
|
|
||||||
|
//------------------- BEGIN EVENT HANDLERS -------------------
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
//ONTEST
|
//ONUPDATE
|
||||||
//
|
//
|
||||||
onTest = function(event) {
|
onChangePassword = function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
$.gevent.publish("app-clear-error");
|
||||||
|
//get form data
|
||||||
|
var formData = $("form").serializeArray({
|
||||||
|
checkboxesAsBools: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var submitData = app.utilB.objectifyFormDataArray(formData);
|
||||||
|
|
||||||
return false; //prevent default?
|
app.api.create(
|
||||||
};
|
"user/" + app.shell.stateMap.user.id + "/changepassword",
|
||||||
//-------------------- END EVENT HANDLERS --------------------
|
submitData,
|
||||||
|
function (res) {
|
||||||
//------------------- BEGIN PUBLIC METHODS -------------------
|
if (res.error) {
|
||||||
//CONFIGMODULE
|
$.gevent.publish("app-show-error", res.msg);
|
||||||
//
|
} else {
|
||||||
configModule = function(context) {
|
page("#!/logout");
|
||||||
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.rfsettings"]({}));
|
|
||||||
|
|
||||||
// bind actions
|
|
||||||
$("#btn-change-password").bind("click", onChangePassword);
|
|
||||||
$("#btn-test").bind("click", onTest);
|
|
||||||
|
|
||||||
//Context menu
|
|
||||||
app.nav.contextClear();
|
|
||||||
|
|
||||||
app.api.get("meta/server_version/", function(res) {
|
|
||||||
if (res.error) {
|
|
||||||
$.gevent.publish("app-show-error", res.msg);
|
|
||||||
} else {
|
|
||||||
$("#about").append(
|
|
||||||
"<p>Rockfish client version: " +
|
|
||||||
app.api.RockFishVersion +
|
|
||||||
"</p><p>Rockfish server version: " +
|
|
||||||
res.server_version +
|
|
||||||
"</p>"
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
////app.nav.setContextTitle("Search");
|
return false; //prevent default?
|
||||||
};
|
};
|
||||||
|
|
||||||
//PUBLIC METHODS
|
///////////////////////////////
|
||||||
//
|
//ONTEST
|
||||||
return {
|
//
|
||||||
configModule: configModule,
|
onTest = function (event) {
|
||||||
initModule: initModule
|
event.preventDefault();
|
||||||
};
|
var submitData = {
|
||||||
//------------------- END PUBLIC METHODS ---------------------
|
creation_date: "2018-06-19T11:08:09.0000000Z", // <-- NEW
|
||||||
|
id: 283832781, // <-- NEW
|
||||||
|
order_notification: {
|
||||||
|
// <-- NEW - Type of the message (same as in XML with out the "e5"-prefix)
|
||||||
|
purchase: {
|
||||||
|
customer_data: {
|
||||||
|
billing_contact: {},
|
||||||
|
customer_payment_data: {},
|
||||||
|
delivery_contact: {},
|
||||||
|
language: "English",
|
||||||
|
language_iso: "en", // <-- NEW
|
||||||
|
reg_name: "Test",
|
||||||
|
shopper_id: "5678", // <-- NEW, also known as Customer ID
|
||||||
|
subscribe_newsletter: false,
|
||||||
|
user_id: "abc@test.com-100"
|
||||||
|
},
|
||||||
|
payment_status: "complete",
|
||||||
|
payment_status_id: "PCA", // <-- NEW, our status ID
|
||||||
|
purchase_id: 1234567890,
|
||||||
|
purchase_date: "2018-03-29T10:25:12.0000000Z",
|
||||||
|
purchase_item: [
|
||||||
|
// <-- NEW, this is now an array
|
||||||
|
{
|
||||||
|
running_no: 1,
|
||||||
|
your_product_id:
|
||||||
|
"this is the same as product_code in the API"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
running_no: 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
purchase_origin: "online"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
app.api.test(submitData, function (res) {
|
||||||
|
if (res.error) {
|
||||||
|
$.gevent.publish("app-show-error", res.msg);
|
||||||
|
} else {
|
||||||
|
//do nothing, success!
|
||||||
|
|
||||||
|
//$('#key').val(res);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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.rfsettings"]({}));
|
||||||
|
|
||||||
|
// bind actions
|
||||||
|
$("#btn-change-password").bind("click", onChangePassword);
|
||||||
|
$("#btn-test").bind("click", onTest);
|
||||||
|
|
||||||
|
//Context menu
|
||||||
|
app.nav.contextClear();
|
||||||
|
|
||||||
|
app.api.get("meta/server_version/", function (res) {
|
||||||
|
if (res.error) {
|
||||||
|
$.gevent.publish("app-show-error", res.msg);
|
||||||
|
} else {
|
||||||
|
$("#about").append(
|
||||||
|
"<p>Rockfish client version: " +
|
||||||
|
app.api.RockFishVersion +
|
||||||
|
"</p><p>Rockfish server version: " +
|
||||||
|
res.server_version +
|
||||||
|
"</p>"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
////app.nav.setContextTitle("Search");
|
||||||
|
};
|
||||||
|
|
||||||
|
//PUBLIC METHODS
|
||||||
|
//
|
||||||
|
return {
|
||||||
|
configModule: configModule,
|
||||||
|
initModule: initModule
|
||||||
|
};
|
||||||
|
//------------------- END PUBLIC METHODS ---------------------
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user