diff --git a/src/web_console/authority/admin_auth.js b/src/web_console/authority/admin_auth.js
index 6658fa3..c68a030 100644
--- a/src/web_console/authority/admin_auth.js
+++ b/src/web_console/authority/admin_auth.js
@@ -1,6 +1,6 @@
/**
* Created by strawmanbobi
- * 2015-01-24
+ * 2016-11-24
*/
require('../mini_poem/configuration/constants');
diff --git a/src/web_console/irext_console.js b/src/web_console/irext_console.js
index bf4f015..9919c2d 100644
--- a/src/web_console/irext_console.js
+++ b/src/web_console/irext_console.js
@@ -45,24 +45,32 @@ require('./routes');
var certificateLogic = require('./work_unit/certificate_logic.js');
// kick start the engine
-System.startup(app, serverListenPort, "irext Console V0.0.2");
+System.startup(app, serverListenPort, "irext Console V0.0.3");
-////////////////// middleware //////////////////
+////////////////// authentication middleware //////////////////
function tokenValidation (req, res, next) {
- var menu0 = req.url.indexOf("code/index.html");
- var menu1 = req.url.indexOf("doc/index.html");
- var menu2 = req.url.indexOf("version/index.html");
- var menu3 = req.url.indexOf("stat/index.html");
- var menu4 = req.url.indexOf("push/index.html");
+ var bodyParam;
+ var adminID = null;
+ var token = null;
+ bodyParam = req.body;
+ if (null != bodyParam) {
+ adminID = bodyParam.admin_id;
+ token = bodyParam.token;
+ }
+
+ if (req.url.indexOf("/irext/int/list_remote_indexes") != -1) {
+ // override for get method
+ adminID = req.query.id;
+ token = req.query.token;
+ }
if (req.url.indexOf("/irext/int") != -1) {
var contentType = req.get("content-type");
if (null != contentType && contentType.indexOf("multipart/form-data") != -1) {
+ // request of content type of multipart/form-data would be validated inside each service
next();
} else {
- var id = req.query.id;
- var token = req.query.token;
- certificateLogic.verifyTokenWorkUnit(id, token, function(validateTokenErr) {
+ certificateLogic.verifyTokenWorkUnit(adminID, token, function(validateTokenErr) {
if(errorCode.SUCCESS.code != validateTokenErr.code) {
var fakeResponse = {
status: validateTokenErr,
@@ -75,29 +83,24 @@ function tokenValidation (req, res, next) {
}
});
}
- } else if (menu0 != -1 || menu1 != -1 || menu2 != -1 || menu3 != -1 || menu4 != -1) {
- var id = req.query.id;
- var token = req.query.token;
+ } else if (req.url.indexOf("/irext/nav/nav_to_url") != -1) {
+ var page = bodyParam.page;
+ var pageCode = page.indexOf("code");
+ var pageDoc = page.indexOf("doc");
+ var pageStat = page.indexOf("stat");
+
var permissions = "";
- if (-1 != menu0) {
+ if (-1 != pageCode) {
permissions = ",0";
- } else if (-1 != menu1) {
+ } else if (-1 != pageDoc) {
permissions = ",1";
- } else if (-1 != menu2) {
+ } else if (-1 != pageStat) {
permissions = ",2";
- } else if (-1 != menu3) {
- permissions = ",3";
- } else if (-1 != menu4) {
- permissions = ",4";
}
- certificateLogic.verifyTokenWithPermissionWorkUnit(id, token, permissions, function(validateTokenErr) {
+ certificateLogic.verifyTokenWithPermissionWorkUnit(adminID, token, permissions, function(validateTokenErr) {
if(errorCode.SUCCESS.code != validateTokenErr.code) {
- var fakeResponse = {
- status: validateTokenErr,
- entity: null
- };
res.redirect("/error/auth_error.html");
} else {
next();
diff --git a/src/web_console/mini_poem/cache/redis.js b/src/web_console/mini_poem/cache/redis.js
index 7d2f6b8..62231e7 100644
--- a/src/web_console/mini_poem/cache/redis.js
+++ b/src/web_console/mini_poem/cache/redis.js
@@ -1,6 +1,6 @@
/**
* Created by strawmanbobi
- * 2015-06-24.
+ * 2016-11-24
*/
require('../configuration/constants');
diff --git a/src/web_console/mini_poem/external/python_caller.js b/src/web_console/mini_poem/external/python_caller.js
index b6f8b21..4f22c4d 100644
--- a/src/web_console/mini_poem/external/python_caller.js
+++ b/src/web_console/mini_poem/external/python_caller.js
@@ -1,6 +1,6 @@
/**
* Created by strawmanbobi
- * 2015-08-03.
+ * 2016-12-03
*/
var pythonShell = require('python-shell');
diff --git a/src/web_console/mini_poem/utils/system_utils.js b/src/web_console/mini_poem/utils/system_utils.js
index 49a891d..dd88694 100644
--- a/src/web_console/mini_poem/utils/system_utils.js
+++ b/src/web_console/mini_poem/utils/system_utils.js
@@ -1,6 +1,6 @@
-/*
+/**
* Created by Strawmanbobi
- * 2015-03-02
+ * 2016-12-02
*/
var dateUtils = require('./date_utils');
diff --git a/src/web_console/routes/index.js b/src/web_console/routes/index.js
index e047beb..d192243 100644
--- a/src/web_console/routes/index.js
+++ b/src/web_console/routes/index.js
@@ -5,6 +5,7 @@
var server = require('../irext_console.js');
+require('./navigation_routes.js');
require('./internal_routes.js');
require('./certificate_routes.js');
-require('./stat_routes.js');
\ No newline at end of file
+require('./stat_routes.js');
diff --git a/src/web_console/routes/internal_routes.js b/src/web_console/routes/internal_routes.js
index 957fbe0..3903510 100644
--- a/src/web_console/routes/internal_routes.js
+++ b/src/web_console/routes/internal_routes.js
@@ -6,18 +6,17 @@
var app = require('../irext_console.js');
var intService = require('../services/internal_service.js');
-app.get('/irext/int/list_provinces', intService.listProvinces);
-app.get('/irext/int/list_cities', intService.listCities);
-app.get('/irext/int/list_operators', intService.listOperators);
-app.get('/irext/int/list_categories', intService.listCategories);
-app.get('/irext/int/list_brands', intService.listBrands);
-app.get('/irext/int/list_ir_protocols', intService.listIRProtocols);
-app.get('/irext/int/list_remote_indexes', intService.listRemoteIndexes);
-app.get('/irext/int/search_remote_indexes', intService.searchRemoteIndexes);
-app.get('/irext/int/download_remote_index', intService.downloadRemoteIndex);
+app.post('/irext/int/list_provinces', intService.listProvinces);
+app.post('/irext/int/list_cities', intService.listCities);
+app.post('/irext/int/list_operators', intService.listOperators);
+app.post('/irext/int/list_categories', intService.listCategories);
+app.post('/irext/int/list_brands', intService.listBrands);
+app.post('/irext/int/list_ir_protocols', intService.listIRProtocols);
+app.post('/irext/int/search_remote_indexes', intService.searchRemoteIndexes);
+app.post('/irext/int/download_remote_index', intService.downloadRemoteIndex);
-app.get('/irext/int/list_unpublished_brands', intService.listUnpublishedBrands);
-app.get('/irext/int/list_unpublished_remote_indexes', intService.listUnpublishedRemoteIndexes);
+app.post('/irext/int/list_unpublished_brands', intService.listUnpublishedBrands);
+app.post('/irext/int/list_unpublished_remote_indexes', intService.listUnpublishedRemoteIndexes);
app.post('/irext/int/create_remote_index', intService.createRemoteIndex);
app.post('/irext/int/delete_remote_index', intService.deleteRemoteIndex);
@@ -30,3 +29,4 @@ app.post('/irext/int/publish_brands', intService.publishBrands);
app.post('/irext/int/create_protocol', intService.createProtocol);
+app.get('/irext/int/list_remote_indexes', intService.listRemoteIndexes);
\ No newline at end of file
diff --git a/src/web_console/routes/navigation_routes.js b/src/web_console/routes/navigation_routes.js
new file mode 100644
index 0000000..f7e691d
--- /dev/null
+++ b/src/web_console/routes/navigation_routes.js
@@ -0,0 +1,9 @@
+/**
+ * Created by Strawmanbobi
+ * 2016-12-05
+ */
+
+var app = require('../irext_console.js');
+var navigationService = require('../services/navigation_service.js');
+
+app.post('/irext/nav/nav_to_url', navigationService.navToURL);
\ No newline at end of file
diff --git a/src/web_console/services/internal_service.js b/src/web_console/services/internal_service.js
index 764a2ab..cb4f82a 100644
--- a/src/web_console/services/internal_service.js
+++ b/src/web_console/services/internal_service.js
@@ -34,8 +34,8 @@ var errorCode = new ErrorCode();
* return : CategoryResponse
*/
exports.listCategories = function (req, res) {
- var from = req.query.from;
- var count = req.query.count;
+ var from = req.body.from;
+ var count = req.body.count;
var categoryResponse = new CategoryResponse();
internalLogic.listCategoriesWorkUnit(from, count, function (listCategoriesErr, categories) {
@@ -54,9 +54,9 @@ exports.listCategories = function (req, res) {
* return : BrandResponse
*/
exports.listBrands = function (req, res) {
- var categoryID = req.query.category_id;
- var from = req.query.from;
- var count = req.query.count;
+ var categoryID = req.body.category_id;
+ var from = req.body.from;
+ var count = req.body.count;
var brandResponse = new BrandResponse();
internalLogic.listBrandsWorkUnit(categoryID, from, count, function (listBrandsErr, brands) {
@@ -91,8 +91,8 @@ exports.listUnpublishedBrands = function (req, res) {
* return : ProtocolResponse
*/
exports.listIRProtocols = function (req, res) {
- var from = req.query.from;
- var count = req.query.count;
+ var from = req.body.from;
+ var count = req.body.count;
var protocolResponse = new ProtocolResponse();
internalLogic.listIRProtocolsWorkUnit(from, count, function (listProtocolsErr, protocols) {
@@ -124,7 +124,7 @@ exports.listProvinces = function (req, res) {
* return : CityResponse
*/
exports.listCities = function (req, res) {
- var provincePrefix = req.query.province_prefix;
+ var provincePrefix = req.body.province_prefix;
var cityResponse = new CityResponse();
internalLogic.listCitiesWorkUnit(provincePrefix, function (listCitiesErr, cities) {
@@ -141,8 +141,8 @@ exports.listCities = function (req, res) {
* return : CityResponse
*/
exports.listCoveredCities = function (req, res) {
- var from = req.query.from;
- var count = req.query.count;
+ var from = req.body.from;
+ var count = req.body.count;
var cityResponse = new CityResponse();
internalLogic.listCoveredCitiesWorkUnit(from, count, function (listCitiesErr, cities) {
@@ -159,9 +159,9 @@ exports.listCoveredCities = function (req, res) {
* return : OperatorResponse
*/
exports.listOperators = function (req, res) {
- var cityCode = req.query.city_code;
- var from = req.query.from;
- var count = req.query.count;
+ var cityCode = req.body.city_code;
+ var from = req.body.from;
+ var count = req.body.count;
var operatorResponse = new OperatorResponse();
internalLogic.listOperatorsWorkUnit(cityCode, from, count, function (listOperatorsErr, operators) {
@@ -189,8 +189,6 @@ exports.listRemoteIndexes = function (req, res) {
internalLogic.listRemoteIndexesWorkUnit(categoryID, brandID, cityCode, from, count,
function (listRemoteIndexesErr, remoteIndexes) {
- // remoteIndexResponse.status = listRemoteIndexesErr;
- //remoteIndexResponse = remoteIndexes;
res.send(remoteIndexes);
res.end();
});
@@ -204,9 +202,9 @@ exports.listRemoteIndexes = function (req, res) {
* return : Remote Index List
*/
exports.searchRemoteIndexes = function (req, res) {
- var remoteMap = req.query.remote_map;
- var from = req.query.from;
- var count = req.query.count;
+ var remoteMap = req.body.remote_map;
+ var from = req.body.from;
+ var count = req.body.count;
internalLogic.searchRemoteIndexesWorkUnit(remoteMap, from, count,
function (listRemoteIndexesErr, remoteIndexes) {
@@ -223,7 +221,7 @@ exports.searchRemoteIndexes = function (req, res) {
* return : Redirect to binary download
*/
exports.downloadRemoteIndex = function (req, res) {
- var remoteIndexID = req.query.remote_index_id;
+ var remoteIndexID = req.body.remote_index_id;
internalLogic.downloadRemoteBinCachedWorkUnit(remoteIndexID, function (serveBinErr, filePath) {
if (errorCode.SUCCESS.code == serveBinErr.code) {
@@ -268,7 +266,7 @@ exports.createRemoteIndex = function (req, res) {
var filePath;
var contentType;
- var adminID = req.query.id;
+ var adminID = req.body.id;
form.on('file', function(field, file) {
// rename the incoming file to the file's name
@@ -329,7 +327,7 @@ exports.createRemoteIndex = function (req, res) {
*/
exports.deleteRemoteIndex = function (req, res) {
var remoteIndex = req.body;
- var adminID = req.query.id;
+ var adminID = req.body.id;
var serviceResponse = new ServiceResponse();
internalLogic.deleteRemoteIndexWorkUnit(remoteIndex, adminID, function (deleteRemoteErr) {
@@ -347,8 +345,8 @@ exports.deleteRemoteIndex = function (req, res) {
*/
exports.verifyRemoteIndex = function (req, res) {
var remoteIndex = req.body;
- var pass = req.query.pass;
- var adminID = req.query.id;
+ var pass = req.body.pass;
+ var adminID = req.body.id;
var serviceResponse = new ServiceResponse();
internalLogic.verifyRemoteIndexWorkUnit(remoteIndex, pass, adminID, function (verifyRemoteErr) {
@@ -365,7 +363,7 @@ exports.verifyRemoteIndex = function (req, res) {
*/
exports.fallbackRemoteIndex = function (req, res) {
var remoteIndex = req.body;
- var adminID = req.query.id;
+ var adminID = req.body.id;
var serviceResponse = new ServiceResponse();
internalLogic.fallbackRemoteIndexWorkUnit(remoteIndex, adminID, function (fallbackRemoteErr) {
@@ -396,7 +394,7 @@ exports.publishRemoteIndex = function (req, res) {
*/
exports.createBrand = function (req, res) {
var brand = req.body;
- var adminID = req.query.id;
+ var adminID = req.body.id;
var serviceResponse = new ServiceResponse();
internalLogic.createBrandWorkUnit(brand, adminID, function (createBrandErr) {
@@ -432,7 +430,7 @@ exports.createProtocol = function (req, res) {
var protocol;
var filePath;
var contentType;
- var adminID = req.query.id;
+ var adminID = req.body.id;
form.on('file', function(field, file) {
fs.rename(file.path, form.uploadDir + "/" + file.name);
diff --git a/src/web_console/services/navigation_service.js b/src/web_console/services/navigation_service.js
new file mode 100644
index 0000000..2b99ae6
--- /dev/null
+++ b/src/web_console/services/navigation_service.js
@@ -0,0 +1,22 @@
+/**
+ * Created by Strawmanbobi
+ * 2016-12-05
+ */
+
+// system inclusion
+var constants = require('../mini_poem/configuration/constants');
+var formidable = require('formidable');
+
+// local inclusion
+var logger = require('../mini_poem/logging/logger4js').helper;
+
+/*
+ * function : Navigation to certain URL
+ * parameter : Name of page to navigate
+ * return : Redirect to the certain URL
+ */
+exports.navToURL = function(req, res) {
+ var bodyParam = req.body;
+ var page = bodyParam.page;
+ res.redirect("/" + page);
+};
\ No newline at end of file
diff --git a/src/web_console/web/code/css/remote.css b/src/web_console/web/code/css/remote.css
index 3729a7f..bb9105c 100644
--- a/src/web_console/web/code/css/remote.css
+++ b/src/web_console/web/code/css/remote.css
@@ -1,6 +1,6 @@
-/*
+/**
* create by strawmanbobi
- * 2015-07-30
+ * 2016-11-30
*/
/* Space out content a bit */
diff --git a/src/web_console/web/code/index.html b/src/web_console/web/code/index.html
index 8c6dbde..ea30f34 100644
--- a/src/web_console/web/code/index.html
+++ b/src/web_console/web/code/index.html
@@ -532,5 +532,4 @@
-