changed get request to post
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Created by strawmanbobi
|
||||
* 2015-01-24
|
||||
* 2016-11-24
|
||||
*/
|
||||
|
||||
require('../mini_poem/configuration/constants');
|
||||
|
||||
@@ -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();
|
||||
|
||||
2
src/web_console/mini_poem/cache/redis.js
vendored
2
src/web_console/mini_poem/cache/redis.js
vendored
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Created by strawmanbobi
|
||||
* 2015-06-24.
|
||||
* 2016-11-24
|
||||
*/
|
||||
|
||||
require('../configuration/constants');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Created by strawmanbobi
|
||||
* 2015-08-03.
|
||||
* 2016-12-03
|
||||
*/
|
||||
|
||||
var pythonShell = require('python-shell');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2015-03-02
|
||||
* 2016-12-02
|
||||
*/
|
||||
|
||||
var dateUtils = require('./date_utils');
|
||||
|
||||
@@ -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');
|
||||
require('./stat_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);
|
||||
9
src/web_console/routes/navigation_routes.js
Normal file
9
src/web_console/routes/navigation_routes.js
Normal file
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
22
src/web_console/services/navigation_service.js
Normal file
22
src/web_console/services/navigation_service.js
Normal file
@@ -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);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
/**
|
||||
* create by strawmanbobi
|
||||
* 2015-07-30
|
||||
* 2016-11-30
|
||||
*/
|
||||
|
||||
/* Space out content a bit */
|
||||
|
||||
@@ -532,5 +532,4 @@
|
||||
<script src="../public_js/chinese/await.js"></script>
|
||||
<script src="../public_js/chinese/chinese.js"></script>
|
||||
<script type="text/javascript" src="js/code_index.js"></script>
|
||||
<script type="text/javascript" src="../js/ui.js"></script>
|
||||
</html>
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Created by strawmanbobi
|
||||
* 2015-07-30.
|
||||
* 2016-11-30
|
||||
*/
|
||||
|
||||
var LS_KEY_ID = "user_name";
|
||||
var LS_KEY_TOKEN = "token";
|
||||
var LS_KEY_ID = 'user_name';
|
||||
var LS_KEY_TOKEN = 'token';
|
||||
var id = "";
|
||||
var token = "";
|
||||
var client = null;
|
||||
@@ -73,12 +73,12 @@ var remoteIndexesToPublish = [];
|
||||
|
||||
///////////////////////////// Initialization /////////////////////////////
|
||||
|
||||
$("#menu_toggle").click(function(e) {
|
||||
$('#menu_toggle').click(function(e) {
|
||||
if (null != client && client == 'console') {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
$("#wrapper").toggleClass("toggled");
|
||||
$('#wrapper').toggleClass('toggled');
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
@@ -90,19 +90,19 @@ $(document).ready(function() {
|
||||
hideSidebar();
|
||||
}
|
||||
|
||||
showMenu(id, token, "remote");
|
||||
// showMenu(id, token, 'remote');
|
||||
initializeSelectors();
|
||||
|
||||
$("#remote_file").change(function() {
|
||||
$('#remote_file').change(function() {
|
||||
var filePath = $(this).val();
|
||||
var fileName = filePath.substring(filePath.lastIndexOf('\\') + 1, filePath.lastIndexOf('.'));
|
||||
$("#remote_name").val(fileName);
|
||||
$('#remote_name').val(fileName);
|
||||
});
|
||||
|
||||
$("#protocol_file").change(function() {
|
||||
$('#protocol_file').change(function() {
|
||||
var filePath = $(this).val();
|
||||
var fileName = filePath.substring(filePath.lastIndexOf('\\') + 1, filePath.lastIndexOf('.'));
|
||||
$("#protocol_name_b").val(fileName);
|
||||
$('#protocol_name_b').val(fileName);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -122,17 +122,19 @@ function loadRemoteList(isSearch, remoteMap) {
|
||||
var url;
|
||||
|
||||
if (isSearch && remoteMap) {
|
||||
url = "/irext/int/search_remote_indexes?remote_map="+remoteMap+"&from=0&count=2000&id="+id+"&token="+token;
|
||||
url = '/irext/int/search_remote_indexes?remote_map='+remoteMap+'&from=0&count=2000&id='+id+'&token='+token;
|
||||
} else {
|
||||
if(currentFilterCategory.id == 3) {
|
||||
url = "/irext/int/list_remote_indexes?category_id="+currentFilterCategory.id+"&city_code="+currentFilterCity.code+
|
||||
"&from=0&count=100&id="+id+"&token="+token;
|
||||
url = '/irext/int/list_remote_indexes?category_id='+currentFilterCategory.id+'&city_code='+currentFilterCity.code+
|
||||
'&from=0&count=100&id='+id+'&token='+token;
|
||||
} else {
|
||||
url = "/irext/int/list_remote_indexes?category_id="+currentFilterCategory.id+"&brand_id="+currentFilterBrand.id+
|
||||
"&from=0&count=100&id="+id+"&token="+token;
|
||||
url = '/irext/int/list_remote_indexes?category_id='+currentFilterCategory.id+'&brand_id='+currentFilterBrand.id+
|
||||
'&from=0&count=100&id='+id+'&token='+token;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(url);
|
||||
|
||||
$('#remote_table_container').empty();
|
||||
$('#remote_table_container').append('<table id="remote_table" data-row-style="rowStyle"></table>');
|
||||
|
||||
@@ -287,25 +289,25 @@ function createRemote() {
|
||||
var versionPatten = new RegExp('[0-9]\\.[0-9]\\.[0-9]');
|
||||
|
||||
if (!remoteName || "" == remoteName) {
|
||||
popUpHintDialog("请输入编码名称");
|
||||
popUpHintDialog('请输入编码名称');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!remoteFile || "" == remoteFile) {
|
||||
popUpHintDialog("请输入控制码源文件");
|
||||
popUpHintDialog('请输入控制码源文件');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("categoryID = " + currentCategory.id + ", categoryName = " + currentCategory.name + ", " + currentCategory.name_en +
|
||||
", " + currentCategory.name_tw + ", brandID = " + currentBrand.id +
|
||||
", brandName = " + currentBrand.name + ", " + currentBrand.name_en + ", " + currentBrand.name_tw +
|
||||
", cityCode = " + currentCity.code + ", cityName = " + currentCity.name + ", " + currentCity.name_tw +
|
||||
", opID = " + currentOperator.operator_id + ", opName = " + currentOperator.operator_name + ", " + currentOperator.operator_name_tw + ", subCate = " + subCate +
|
||||
", protocolID = " + currentProtocol.id + ", protocolName = " + currentProtocol.name +
|
||||
", remoteName = " +remoteName + ", remoteFile = " + remoteFile + ", remoteNumber = " + remoteNumber);
|
||||
console.log('categoryID = ' + currentCategory.id + ', categoryName = ' + currentCategory.name + ', ' + currentCategory.name_en +
|
||||
', ' + currentCategory.name_tw + ', brandID = ' + currentBrand.id +
|
||||
', brandName = ' + currentBrand.name + ', ' + currentBrand.name_en + ', ' + currentBrand.name_tw +
|
||||
', cityCode = ' + currentCity.code + ', cityName = ' + currentCity.name + ', ' + currentCity.name_tw +
|
||||
', opID = ' + currentOperator.operator_id + ', opName = ' + currentOperator.operator_name + ', ' + currentOperator.operator_name_tw + ', subCate = ' + subCate +
|
||||
', protocolID = ' + currentProtocol.id + ', protocolName = ' + currentProtocol.name +
|
||||
', remoteName = ' +remoteName + ', remoteFile = ' + remoteFile + ', remoteNumber = ' + remoteNumber);
|
||||
|
||||
var form = $('#remote_upload_form');
|
||||
form.attr('action', '/irext/int/create_remote_index?id='+id+"&token="+token);
|
||||
form.attr('action', '/irext/int/create_remote_index?id='+id+'&token='+token);
|
||||
//form.attr('method', 'post');
|
||||
//form.attr('encoding', 'multipart/form-data');
|
||||
//form.attr('enctype', 'multipart/form-data');
|
||||
@@ -323,8 +325,8 @@ function createRemote() {
|
||||
$('#operator_name_tw').val(currentOperator.name_tw);
|
||||
|
||||
form.submit();
|
||||
$("#create_remote_dialog").modal('hide');
|
||||
$("#uploading_dialog").modal();
|
||||
$('#create_remote_dialog').modal('hide');
|
||||
$('#uploading_dialog').modal();
|
||||
}
|
||||
|
||||
function deleteRemote() {
|
||||
@@ -354,28 +356,31 @@ function deleteRemote() {
|
||||
break;
|
||||
}
|
||||
|
||||
remoteToDelete.admin_id = id;
|
||||
remoteToDelete.token = token;
|
||||
|
||||
$.ajax({
|
||||
url: "/irext/int/delete_remote_index?id="+id+"&token="+token,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: '/irext/int/delete_remote_index',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: remoteToDelete,
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
$("#delete_confirm_dialog").modal('hide');
|
||||
popUpHintDialog("已成功删除索引");
|
||||
$('#delete_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('已成功删除索引');
|
||||
loadRemoteList();
|
||||
$("#delete_confirm_dialog").modal("hide");
|
||||
$('#delete_confirm_dialog').modal('hide');
|
||||
} else {
|
||||
$("#delete_confirm_dialog").modal('hide');
|
||||
popUpHintDialog("删除索引操作失败");
|
||||
$("#delete_confirm_dialog").modal("hide");
|
||||
$('#delete_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('删除索引操作失败');
|
||||
$('#delete_confirm_dialog').modal('hide');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#delete_confirm_dialog").modal('hide');
|
||||
popUpHintDialog("删除索引操作失败");
|
||||
$("#delete_confirm_dialog").modal("hide");
|
||||
$('#delete_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('删除索引操作失败');
|
||||
$('#delete_confirm_dialog').modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -406,37 +411,41 @@ function fallbackRemote() {
|
||||
remoteToFallback.status = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
remoteToFallback.admin_id = id;
|
||||
remoteToFallback.token = token;
|
||||
|
||||
$.ajax({
|
||||
url: "/irext/int/fallback_remote_index?id="+id+"&token="+token,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: '/irext/int/fallback_remote_index',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: remoteToFallback,
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
$("#fallback_confirm_dialog").modal("hide");
|
||||
popUpHintDialog("已成功回退索引");
|
||||
$('#fallback_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('已成功回退索引');
|
||||
loadRemoteList();
|
||||
} else {
|
||||
$("#fallback_confirm_dialog").modal("hide");
|
||||
popUpHintDialog("回退索引操作失败");
|
||||
$('#fallback_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('回退索引操作失败');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#fallback_confirm_dialog").modal("hide");
|
||||
popUpHintDialog("回退索引操作失败");
|
||||
$('#fallback_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('回退索引操作失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function searchRemote() {
|
||||
var remoteMap = $("#remote_map").val();
|
||||
var remoteMap = $('#remote_map').val();
|
||||
|
||||
if (null != remoteMap && "" != remoteMap && remoteMap.length > 5) {
|
||||
loadRemoteList(true, remoteMap);
|
||||
$("#search_dialog").modal('hide');
|
||||
$('#search_dialog').modal('hide');
|
||||
} else {
|
||||
popUpHintDialog("编码映射格式不正确");
|
||||
popUpHintDialog('编码映射格式不正确');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,127 +475,144 @@ function verifyRemote() {
|
||||
remoteToVerify.status = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
remoteToVerify.admin_id = id;
|
||||
remoteToVerify.token = token;
|
||||
|
||||
$.ajax({
|
||||
url: "/irext/int/verify_remote_index?pass="+pass+"&id="+id+"&token="+token,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: '/irext/int/verify_remote_index',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: remoteToVerify,
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
$("#verify_confirm_dialog").modal("hide");
|
||||
popUpHintDialog("已成功更新索引");
|
||||
$('#verify_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('已成功更新索引');
|
||||
loadRemoteList();
|
||||
} else {
|
||||
$("#verify_confirm_dialog").modal("hide");
|
||||
popUpHintDialog("更新索引操作失败");
|
||||
$('#verify_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('更新索引操作失败');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#verify_confirm_dialog").modal("hide");
|
||||
popUpHintDialog("更新索引操作失败");
|
||||
$('#verify_confirm_dialog').modal('hide');
|
||||
popUpHintDialog('更新索引操作失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function publishUnpublished() {
|
||||
var date = formatDate(new Date(), "yyyy-MM-dd");
|
||||
JSONToCSVConvertor(brandsToPublish, "Unpublihshed Brand " + date, true);
|
||||
JSONToCSVConvertor(remoteIndexesToPublish, "Unpublihshed Remote " + date, true);
|
||||
var date = formatDate(new Date(), 'yyyy-MM-dd');
|
||||
// JSONToCSVConvertor(brandsToPublish, 'Unpublihshed Brand ' + date, true);
|
||||
// JSONToCSVConvertor(remoteIndexesToPublish, 'Unpublihshed Remote ' + date, true);
|
||||
}
|
||||
|
||||
function publishBrands() {
|
||||
$("#publish_hint").empty();
|
||||
$("#publish_hint").append('正在发布新增品牌,请稍候...');
|
||||
$('#publish_hint').empty();
|
||||
$('#publish_hint').append('正在发布新增品牌,请稍候...');
|
||||
|
||||
$.ajax({
|
||||
url: "/irext/int/publish_brands?id="+id+"&token="+token,
|
||||
type: "POST",
|
||||
url: '/irext/int/publish_brands',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 200000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
$("#publish_hint").empty();
|
||||
$("#publish_hint").append('正在发布新增编码,请稍候...');
|
||||
$('#publish_hint').empty();
|
||||
$('#publish_hint').append('正在发布新增编码,请稍候...');
|
||||
publishRemoteIndexes();
|
||||
// loadRemoteList();
|
||||
// $("#publish_dialog").modal("hide");
|
||||
// $('#publish_dialog').modal('hide');
|
||||
} else {
|
||||
popUpHintDialog("发布编码表操作失败");
|
||||
$("#publish_dialog").modal("hide");
|
||||
popUpHintDialog('发布编码表操作失败');
|
||||
$('#publish_dialog').modal('hide');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
popUpHintDialog("发布编码表操作失败");
|
||||
$("#publish_dialog").modal("hide");
|
||||
popUpHintDialog('发布编码表操作失败');
|
||||
$('#publish_dialog').modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function publishRemoteIndexes() {
|
||||
$.ajax({
|
||||
url: "/irext/int/publish_remote_index?id="+id+"&token="+token,
|
||||
type: "POST",
|
||||
url: '/irext/int/publish_remote_index',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 200000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
$("#publish_dialog").modal('hide');
|
||||
popUpHintDialog("已成功发布编码表");
|
||||
$('#publish_dialog').modal('hide');
|
||||
popUpHintDialog('已成功发布编码表');
|
||||
loadRemoteList();
|
||||
} else {
|
||||
$("#publish_dialog").modal('hide');
|
||||
popUpHintDialog("发布编码表操作失败");
|
||||
$('#publish_dialog').modal('hide');
|
||||
popUpHintDialog('发布编码表操作失败');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#publish_dialog").modal('hide');
|
||||
popUpHintDialog("发布编码表操作失败");
|
||||
$('#publish_dialog').modal('hide');
|
||||
popUpHintDialog('发布编码表操作失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createBrand() {
|
||||
var newName = $("#brand_name_b").val();
|
||||
var newNameEn = $("#brand_name_en_b").val();
|
||||
var newNameTw = $("#brand_name_tw_b").val();
|
||||
var brandPriority = $("#brand_priority").val();
|
||||
var newName = $('#brand_name_b').val();
|
||||
var newNameEn = $('#brand_name_en_b').val();
|
||||
var newNameTw = $('#brand_name_tw_b').val();
|
||||
var brandPriority = $('#brand_priority').val();
|
||||
|
||||
if (null == newName || "" == newName ||
|
||||
null == newNameEn || "" == newNameEn ||
|
||||
null == newNameTw) {
|
||||
popUpHintDialog("请填写名称");
|
||||
popUpHintDialog('请填写名称');
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBrandExists(newName)) {
|
||||
popUpHintDialog("这个品牌已经存在");
|
||||
popUpHintDialog('这个品牌已经存在');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "/irext/int/create_brand?id="+id+"&token="+token,
|
||||
type: "POST",
|
||||
url: '/irext/int/create_brand',
|
||||
type: 'POST',
|
||||
data: {
|
||||
category_id : currentCategory.id,
|
||||
category_name : currentCategory.name,
|
||||
name : newName,
|
||||
name_en : newNameEn,
|
||||
name_tw : newNameTw,
|
||||
priority: brandPriority
|
||||
priority : brandPriority,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
$("#create_brand_dialog").modal("hide");
|
||||
popUpHintDialog("已成功添加品牌");
|
||||
$('#create_brand_dialog').modal('hide');
|
||||
popUpHintDialog('已成功添加品牌');
|
||||
initializeBrands();
|
||||
} else {
|
||||
$("#create_brand_dialog").modal("hide");
|
||||
popUpHintDialog("品牌添加的操作失败");
|
||||
$('#create_brand_dialog').modal('hide');
|
||||
popUpHintDialog('品牌添加的操作失败');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#create_brand_dialog").modal("hide");
|
||||
popUpHintDialog("品牌添加的操作失败");
|
||||
$('#create_brand_dialog').modal('hide');
|
||||
popUpHintDialog('品牌添加的操作失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -597,34 +623,34 @@ function createProtocol() {
|
||||
var protocolType = $('#protocol_type').val();
|
||||
|
||||
if(!protocolName || "" == protocolName) {
|
||||
popUpHintDialog("请输入协议名称");
|
||||
popUpHintDialog('请输入协议名称');
|
||||
return;
|
||||
}
|
||||
|
||||
if(!protocolFile || "" == protocolFile) {
|
||||
popUpHintDialog("请输入协议XML文件");
|
||||
popUpHintDialog('请输入协议XML文件');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("protocolName = " + protocolName + ", protocolFile = " + protocolFile +
|
||||
", protocolType = " + protocolType);
|
||||
console.log('protocolName = ' + protocolName + ', protocolFile = ' + protocolFile +
|
||||
', protocolType = ' + protocolType);
|
||||
|
||||
var form = $('#protocol_upload_form');
|
||||
form.attr('action', '/irext/int/create_protocol?id='+id+"&token="+token);
|
||||
form.attr('action', '/irext/int/create_protocol');
|
||||
//form.attr('method', 'post');
|
||||
//form.attr('encoding', 'multipart/form-data');
|
||||
//form.attr('enctype', 'multipart/form-data');
|
||||
|
||||
form.submit();
|
||||
$("#create_protocol_dialog").modal("hide");
|
||||
$("#creating_protocol_dialog").modal();
|
||||
$('#create_protocol_dialog').modal('hide');
|
||||
$('#creating_protocol_dialog').modal();
|
||||
initializeProtocols();
|
||||
}
|
||||
|
||||
function createBleTestInfo() {
|
||||
var bleRemoteIndexInfo = $("#ble_test_info").val();
|
||||
$("#ble_remote_index").val(bleRemoteIndexInfo);
|
||||
$("#create_ble_test_dialog").modal("hide");
|
||||
var bleRemoteIndexInfo = $('#ble_test_info').val();
|
||||
$('#ble_remote_index').val(bleRemoteIndexInfo);
|
||||
$('#create_ble_test_dialog').modal('hide');
|
||||
}
|
||||
|
||||
///////////////////////////// Data process /////////////////////////////
|
||||
@@ -636,9 +662,15 @@ function initializeSubCates() {
|
||||
|
||||
function initializeProtocols() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_ir_protocols?from=0&count=200&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_ir_protocols',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
type: 'POST',
|
||||
data: {
|
||||
from : 0,
|
||||
count : 200,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -663,9 +695,15 @@ function initializeProtocols() {
|
||||
|
||||
function initializeCategories() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_categories?from=0&count=200&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_categories',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
type: 'POST',
|
||||
data: {
|
||||
from : 0,
|
||||
count : 200,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -696,9 +734,13 @@ function initializeCategories() {
|
||||
|
||||
function initializeProvince() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_provinces?id="+id+"&token="+token,
|
||||
url: '/irext/int/list_provinces',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
type: 'POST',
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -726,9 +768,14 @@ function initializeProvince() {
|
||||
function initializeCity() {
|
||||
var provincePrefix = currentProvince.code.substring(0, 2);
|
||||
$.ajax({
|
||||
url: "/irext/int/list_cities?province_prefix="+provincePrefix+"&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_cities',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
province_prefix : provincePrefix,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -769,9 +816,16 @@ function initializeCity() {
|
||||
|
||||
function initializeOperator() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_operators?city_code="+currentCity.code+"&from=0&count=50&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_operators',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
city_code : currentCity.code,
|
||||
from : 0,
|
||||
count : 200,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -811,9 +865,16 @@ function initializeOperator() {
|
||||
|
||||
function initializeBrands() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_brands?category_id="+currentCategory.id+"&from=0&count=300&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_brands',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
category_id : currentCategory.id,
|
||||
from : 0,
|
||||
count : 300,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -842,9 +903,15 @@ function initializeBrands() {
|
||||
|
||||
function initializeFilterCategories() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_categories?from=0&count=200&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_categories',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
from : 0,
|
||||
count : 200,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -871,9 +938,13 @@ function initializeFilterCategories() {
|
||||
|
||||
function initializeFilterProvince() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_provinces?id="+id+"&token="+token,
|
||||
url: '/irext/int/list_provinces',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -901,9 +972,14 @@ function initializeFilterProvince() {
|
||||
function initializeFilterCity() {
|
||||
var provincePrefix = currentFilterProvince.code.substring(0, 2);
|
||||
$.ajax({
|
||||
url: "/irext/int/list_cities?province_prefix="+provincePrefix+"&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_cities',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
province_prefix : provincePrefix,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -931,9 +1007,16 @@ function initializeFilterCity() {
|
||||
|
||||
function initializeFilterBrands() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_brands?category_id="+currentFilterCategory.id+"&from=0&count=300&id="+id+"&token="+token,
|
||||
url: '/irext/int/list_brands',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
category_id : currentFilterCategory.id,
|
||||
from : 0,
|
||||
count : 300,
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -947,7 +1030,7 @@ function initializeFilterBrands() {
|
||||
}
|
||||
}
|
||||
if(currentFilterCategory.id != 3) {
|
||||
console.log("reload remote table after brand is refreshed");
|
||||
console.log('reload remote table after brand is refreshed');
|
||||
loadRemoteList();
|
||||
}
|
||||
} else {
|
||||
@@ -963,7 +1046,7 @@ function initializeFilterBrands() {
|
||||
///////////////////////////// Event handler /////////////////////////////
|
||||
|
||||
function onCreateRemote() {
|
||||
$("#create_remote_dialog").modal();
|
||||
$('#create_remote_dialog').modal();
|
||||
}
|
||||
|
||||
function onProtocolChange() {
|
||||
@@ -975,7 +1058,7 @@ function onProtocolChange() {
|
||||
|
||||
function onRadioTypeChange() {
|
||||
currentRadioType = $('#radio_type').val();
|
||||
console.log("update current radio type to " + currentRadioType);
|
||||
console.log('update current radio type to ' + currentRadioType);
|
||||
|
||||
switch (parseInt(currentRadioType)) {
|
||||
case RADIO_TYPE_IRDA:
|
||||
@@ -993,12 +1076,12 @@ function onRadioTypeChange() {
|
||||
|
||||
function onSubCateChange() {
|
||||
currentSubCate = $('#sub_cate').val();
|
||||
console.log("update current sub category type to " + currentSubCate);
|
||||
console.log('update current sub category type to ' + currentSubCate);
|
||||
}
|
||||
|
||||
function onProtocolTypeChange() {
|
||||
currentProtocolType = $('#protocol_type').val();
|
||||
console.log("update current protocol type to " + currentProtocolType);
|
||||
console.log('update current protocol type to ' + currentProtocolType);
|
||||
}
|
||||
|
||||
function onCategoryChange() {
|
||||
@@ -1077,7 +1160,7 @@ function switchCategory() {
|
||||
showProtocolSelector(true);
|
||||
break;
|
||||
default:
|
||||
console.log("Wrong category : " + currentCategory.id);
|
||||
console.log('Wrong category : ' + currentCategory.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1145,7 +1228,7 @@ function onOperatorChange() {
|
||||
var currentOperatorID = $('#operator_id').val();
|
||||
|
||||
currentOperator = getStbOperatorByID(currentOperatorID);
|
||||
console.log("currentOperator = " + JSON.stringify(currentOperator));
|
||||
console.log('currentOperator = ' + JSON.stringify(currentOperator));
|
||||
}
|
||||
|
||||
function discoverCityCode() {
|
||||
@@ -1158,7 +1241,7 @@ function onFilterCategoryChange() {
|
||||
name: $('#filter_category_id option:selected').text()
|
||||
};
|
||||
|
||||
console.log("onFilterCategoryChange, id = " + currentFilterCategory.id);
|
||||
console.log('onFilterCategoryChange, id = ' + currentFilterCategory.id);
|
||||
|
||||
switch(parseInt(currentFilterCategory.id)) {
|
||||
case CATEGORY_AC:
|
||||
@@ -1231,7 +1314,7 @@ function onFilterCityChange() {
|
||||
}
|
||||
|
||||
function onCreateBrand() {
|
||||
$("#category_name_b").val(currentCategory.name);
|
||||
$('#category_name_b').val(currentCategory.name);
|
||||
$('#create_brand_dialog').modal({backdrop: 'static', keyboard: false});
|
||||
}
|
||||
|
||||
@@ -1262,9 +1345,9 @@ function onFallbackRemote() {
|
||||
selectedRemote.protocol + ' ' + selectedRemote.remote + ' 吗?';
|
||||
}
|
||||
|
||||
$("#fallback_hint").empty();
|
||||
$("#fallback_hint").append(hintText);
|
||||
$("#fallback_confirm_dialog").modal();
|
||||
$('#fallback_hint').empty();
|
||||
$('#fallback_hint').append(hintText);
|
||||
$('#fallback_confirm_dialog').modal();
|
||||
}
|
||||
|
||||
function onDeleteRemote() {
|
||||
@@ -1281,9 +1364,9 @@ function onDeleteRemote() {
|
||||
selectedRemote.protocol + ' ' + selectedRemote.remote + ' 吗?';
|
||||
}
|
||||
|
||||
$("#delete_hint").empty();
|
||||
$("#delete_hint").append(hintText);
|
||||
$("#delete_confirm_dialog").modal();
|
||||
$('#delete_hint').empty();
|
||||
$('#delete_hint').append(hintText);
|
||||
$('#delete_confirm_dialog').modal();
|
||||
}
|
||||
|
||||
function onSearchRemote() {
|
||||
@@ -1306,9 +1389,9 @@ function onVerifyRemote(isPass) {
|
||||
selectedRemote.protocol + ' ' + selectedRemote.remote + ' 吗?';
|
||||
}
|
||||
|
||||
$("#verify_hint").empty();
|
||||
$("#verify_hint").append(hintText);
|
||||
$("#verify_confirm_dialog").modal();
|
||||
$('#verify_hint').empty();
|
||||
$('#verify_hint').append(hintText);
|
||||
$('#verify_confirm_dialog').modal();
|
||||
}
|
||||
|
||||
function onPublishRemote() {
|
||||
@@ -1317,9 +1400,13 @@ function onPublishRemote() {
|
||||
|
||||
function getUnpublishedBrands() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_unpublished_brands?id="+id+"&token="+token,
|
||||
url: '/irext/int/list_unpublished_brands',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -1337,9 +1424,13 @@ function getUnpublishedBrands() {
|
||||
|
||||
function getUnpublishedRemoteIndexes() {
|
||||
$.ajax({
|
||||
url: "/irext/int/list_unpublished_remote_indexes?id="+id+"&token="+token,
|
||||
url: '/irext/int/list_unpublished_remote_indexes',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
type: 'GET',
|
||||
data: {
|
||||
admin_id : id,
|
||||
token : token
|
||||
},
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
@@ -1361,9 +1452,9 @@ function downloadBin() {
|
||||
popUpHintDialog('请先选中一个索引');
|
||||
return;
|
||||
}
|
||||
downloadURL = "/irext/int/download_remote_index?remote_index_id="+selectedRemote.id+"&id="+id+"&token="+token;
|
||||
downloadURL = '/irext/int/download_remote_index?remote_index_id='+selectedRemote.id+'&id='+id+'&token='+token;
|
||||
|
||||
if (null != client && client == "console") {
|
||||
if (null != client && client == 'console') {
|
||||
// directly download binary to remote via serial port
|
||||
} else {
|
||||
window.open(
|
||||
@@ -1375,9 +1466,9 @@ function downloadBin() {
|
||||
|
||||
function showPublishDialog() {
|
||||
var hintText = '共有 <font color="#FF0000">' + brandsToPublish.length + '</font> 个新增品牌,以及 <font color="#FF0000">' + remoteIndexesToPublish.length + '</font> 个新增编码待发布,请确认';
|
||||
$("#publish_hint").empty();
|
||||
$("#publish_hint").append(hintText);
|
||||
$("#publish_dialog").modal();
|
||||
$('#publish_hint').empty();
|
||||
$('#publish_hint').append(hintText);
|
||||
$('#publish_dialog').modal();
|
||||
}
|
||||
|
||||
///////////////////////////// UI functions /////////////////////////////
|
||||
@@ -1598,9 +1689,9 @@ function showBleRemoteInfo(show) {
|
||||
}
|
||||
|
||||
function popUpHintDialog(hint) {
|
||||
$("#text_hint").empty();
|
||||
$("#text_hint").append(hint);
|
||||
$("#hint_dialog").modal();
|
||||
$('#text_hint').empty();
|
||||
$('#text_hint').append(hint);
|
||||
$('#hint_dialog').modal();
|
||||
}
|
||||
|
||||
///////////////////////////// Utilities /////////////////////////////
|
||||
@@ -1656,7 +1747,7 @@ function getStbOperatorByID(operatorID) {
|
||||
}
|
||||
|
||||
function translateToTC(textID, targetTextID) {
|
||||
var val = $("#" + textID).val();
|
||||
var val = $('#' + textID).val();
|
||||
var tcVal = "";
|
||||
Chinese.prototype.loaded.onkeep(function() {
|
||||
var chinese = new Chinese();
|
||||
@@ -1664,10 +1755,10 @@ function translateToTC(textID, targetTextID) {
|
||||
if (null == tcVal) {
|
||||
tcVal = val;
|
||||
}
|
||||
$("#" + targetTextID).val(tcVal);
|
||||
$('#' + targetTextID).val(tcVal);
|
||||
});
|
||||
}
|
||||
|
||||
function gotoIndex() {
|
||||
window.location = "../index.html?id="+id+"&token="+token;
|
||||
window.location = '../index.html?id='+id+'&token='+token;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
/**
|
||||
* create by strawmanbobi
|
||||
* 2015-07-30
|
||||
* 2016-11-30
|
||||
*/
|
||||
|
||||
/* Space out content a bit */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* Created by Strawmanbobi on 2015-12-21.
|
||||
* Created by Strawmanbobi
|
||||
* 2016-12-01
|
||||
*/
|
||||
|
||||
var id, token;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2015-12-22
|
||||
* 2016-12-02
|
||||
*/
|
||||
|
||||
var LS_KEY_ID = "user_name";
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2015-11-13
|
||||
* 2016-11-13
|
||||
*/
|
||||
|
||||
var LS_KEY_ID = "user_name";
|
||||
var LS_KEY_TOKEN = "token";
|
||||
var id = "";
|
||||
var token = "";
|
||||
var client = null;
|
||||
|
||||
$("#document").ready(function() {
|
||||
|
||||
@@ -39,6 +36,29 @@ function popUpHintDialog(hint) {
|
||||
$("#hint_dialog").modal();
|
||||
}
|
||||
|
||||
function navigateToPage(page, id, token) {
|
||||
var form = $("<form method='post'></form>"),
|
||||
input;
|
||||
form.attr({"action" : "/irext/nav/nav_to_url"});
|
||||
|
||||
input = $("<input type='hidden'>");
|
||||
input.attr({"name": "admin_id"});
|
||||
input.val(id);
|
||||
form.append(input);
|
||||
|
||||
input = $("<input type='hidden'>");
|
||||
input.attr({"name": "token"});
|
||||
input.val(token);
|
||||
form.append(input);
|
||||
|
||||
input = $("<input type='hidden'>");
|
||||
input.attr({"name": "page"});
|
||||
input.val(page);
|
||||
form.append(input);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function changePassword() {
|
||||
var userName = $("#user_name").val();
|
||||
if (null == userName || "" == userName) {
|
||||
@@ -95,28 +115,10 @@ function doSignIn(userName, password) {
|
||||
if (null == index) {
|
||||
window.location = "./error/auth_error.html";
|
||||
} else {
|
||||
/*
|
||||
switch (parseInt(index)) {
|
||||
case 0:
|
||||
page = "./code/index.html";
|
||||
break;
|
||||
case 1:
|
||||
page = "./doc/index.html";
|
||||
break;
|
||||
case 2:
|
||||
page = "./version/index.html";
|
||||
break;
|
||||
}
|
||||
*/
|
||||
page = "./code/index.html";
|
||||
page += "?id="+adminID+"&token="+token;
|
||||
|
||||
if (undefined != client && null != client && client == "console") {
|
||||
page += "&client="+client;
|
||||
}
|
||||
page = "code";
|
||||
}
|
||||
setTimeout(function() {
|
||||
window.location = page;
|
||||
navigateToPage(page, adminID, token);
|
||||
}, 3000);
|
||||
if($("#remember_me").is(":checked")) {
|
||||
localStorage.setItem(LS_KEY_ID, adminID);
|
||||
@@ -130,54 +132,4 @@ function doSignIn(userName, password) {
|
||||
toastr.error("登入失败,请确认密码是否正确");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function verifyToken(id, token) {
|
||||
$.ajax({
|
||||
url: "/irext/certificate/token_verify",
|
||||
type: "POST",
|
||||
data: JSON.stringify({id: id, token: token}),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
timeout: 20000,
|
||||
success: function(response) {
|
||||
if(response.status.code == 0) {
|
||||
toastr.success("登入成功,3秒后自动进入控制台");
|
||||
// make console entry according to the content of token
|
||||
var permission = token.substring(token.indexOf(",") + 1);
|
||||
var index = null;
|
||||
var page = "";
|
||||
if (null != permission && permission != "") {
|
||||
index = permission.substring(0, 1);
|
||||
}
|
||||
if (null == index) {
|
||||
window.location = "./error/auth_error.html";
|
||||
} else {
|
||||
/*
|
||||
switch (parseInt(index)) {
|
||||
case 0:
|
||||
page = "./code/index.html";
|
||||
break;
|
||||
case 1:
|
||||
page = "./doc/index.html";
|
||||
break;
|
||||
case 2:
|
||||
page = "./version/index.html";
|
||||
break;
|
||||
}
|
||||
*/
|
||||
page = "./welcome/index.html";
|
||||
page += "?id="+id+"&token="+token;
|
||||
}
|
||||
setTimeout(function() {
|
||||
window.location = page;
|
||||
}, 3000);
|
||||
} else {
|
||||
toastr.error("自动登入失败,请输入邮件地址和密码手动登入");
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
toastr.error("自动登入失败,请输入邮件地址和密码手动登入");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2016-05-01.
|
||||
*/
|
||||
|
||||
function onSignout() {
|
||||
$("#signout_confirm_dialog").modal();
|
||||
}
|
||||
|
||||
function signout() {
|
||||
localStorage.removeItem(LS_KEY_ID);
|
||||
localStorage.removeItem(LS_KEY_TOKEN);
|
||||
window.location = "../index.html";
|
||||
}
|
||||
|
||||
function showMenu(id, token, active) {
|
||||
$("#side_bar").html("<li class='sidebar-brand'>" +
|
||||
"<a href='#' onclick='gotoWelcome();'>" +
|
||||
"irext 控制台" +
|
||||
"</a>" +
|
||||
"</li>" +
|
||||
"<li>" +
|
||||
"<a id='menu_stat' style='display: none;' href='#' onclick='gotoStat();'>统计</a>" +
|
||||
"</li>" +
|
||||
"<li>" +
|
||||
"<a id='menu_remote' style='display: none;' href='#' onclick='gotoRemote();'>家电控制码管理</a>" +
|
||||
"</li>" +
|
||||
"<li>" +
|
||||
"<a id='menu_publish' style='display: none;' href='#' onclick='gotoVersion();'>版本发布</a>" +
|
||||
"</li>" +
|
||||
"<li>" +
|
||||
"<a id='menu_push' style='display: none;' href='#' onclick='gotoPush();'>消息推送</a>" +
|
||||
"</li>" +
|
||||
"<li>" +
|
||||
"<a id='menu_doc' style='display: none;' href='#' onclick='gotoDoc();'>开发者文档</a>" +
|
||||
"</li>" +
|
||||
"<li>" +
|
||||
"<hr>" +
|
||||
"</li>" +
|
||||
"<li>" +
|
||||
"<a id='sign_out' href='#' onclick='onSignout();'>退出</a>" +
|
||||
"</li>");
|
||||
|
||||
// set sidebar-active to active item
|
||||
switch (active) {
|
||||
case "stat":
|
||||
$("#menu_stat").attr("class", "sidebar-active");
|
||||
break;
|
||||
case "remote":
|
||||
$("#menu_remote").attr("class", "sidebar-active");
|
||||
break;
|
||||
case "publish":
|
||||
$("#menu_publish").attr("class", "sidebar-active");
|
||||
break;
|
||||
case "doc":
|
||||
$("#menu_doc").attr("class", "sidebar-active");
|
||||
break;
|
||||
case "push":
|
||||
$("#menu_push").attr("class", "sidebar-active");
|
||||
break;
|
||||
}
|
||||
var permissions = token.substring(token.indexOf(",") + 1);
|
||||
var menuOptions = permissions.split(",");
|
||||
if (null != menuOptions) {
|
||||
for (var i = 0; i < menuOptions.length; i++) {
|
||||
switch (parseInt(menuOptions[i])) {
|
||||
case 0:
|
||||
$("#menu_remote").show();
|
||||
break;
|
||||
case 1:
|
||||
$("#menu_doc").show();
|
||||
break;
|
||||
case 2:
|
||||
$("#menu_publish").show();
|
||||
break;
|
||||
case 3:
|
||||
$("#menu_stat").show();
|
||||
break;
|
||||
case 4:
|
||||
$("#menu_push").show();
|
||||
break;
|
||||
case 99:
|
||||
$("#publish_button").show();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function gotoWelcome() {
|
||||
window.location = "../welcome/index.html?id="+id+"&token="+token;
|
||||
}
|
||||
|
||||
function gotoDoc() {
|
||||
window.location = "../doc/index.html?id="+id+"&token="+token;
|
||||
}
|
||||
|
||||
function gotoRemote() {
|
||||
window.location = "../code/index.html?id="+id+"&token="+token;
|
||||
}
|
||||
|
||||
function gotoVersion() {
|
||||
window.location = "../version/index.html?id="+id+"&token="+token;
|
||||
}
|
||||
|
||||
function gotoStat() {
|
||||
window.location = "../stat/index.html?id="+id+"&token="+token;
|
||||
}
|
||||
|
||||
function gotoPush() {
|
||||
window.location = "../push/index.html?id="+id+"&token="+token;
|
||||
}
|
||||
|
||||
function hideSidebar() {
|
||||
$("#sidebar-wrapper").hide();
|
||||
$("#wrapper").toggleClass("toggled");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* create by strawmanbobi
|
||||
* 2015-07-30
|
||||
* 2016-11-30
|
||||
*/
|
||||
|
||||
/* Space out content a bit */
|
||||
|
||||
@@ -119,6 +119,5 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="./js/stat.js"></script>
|
||||
<script type="text/javascript" src="../js/ui.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user