fixed unable to fetch database issue
This commit is contained in:
@@ -18,4 +18,4 @@
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Open [http://localhost:6001](http://localhost:6001)
|
||||
Open [http://localhost:8300](http://localhost:8300)
|
||||
@@ -12,49 +12,17 @@ var enums = new Enums();
|
||||
|
||||
//noinspection JSUnresolvedVariable
|
||||
exports.setupEnvironment = function () {
|
||||
var env = process.env.NODE_ENV || 'development';
|
||||
ENV = env;
|
||||
if (undefined == typeof env || null == env || "" == env || enums.APP_PRODUCTION_MODE == env) {
|
||||
MYSQL_DB_SERVER_ADDRESS = "root";
|
||||
MYSQL_DB_NAME = "irext";
|
||||
MYSQL_DB_USER = "root";
|
||||
MYSQL_DB_PASSWORD = "root";
|
||||
FILE_TEMP_PATH = "~/home/strawmanbobi/rc_extension";
|
||||
PYTHON_PATH = "/usr/bin/python";
|
||||
LISTEN_PORT = "80";
|
||||
SERVER_ADDRESS = "localhost";
|
||||
REDIS_HOST = "localhost";
|
||||
REDIS_PORT = "6379";
|
||||
REDIS_PASSWORD = "";
|
||||
EXTERNAL_SERVER_ADDRESS = "irext.net";
|
||||
EXTERNAL_SERVER_PORT = "80"
|
||||
} else if (enums.APP_DEVELOPMENT_MODE == env) {
|
||||
MYSQL_DB_SERVER_ADDRESS = "localhost";
|
||||
MYSQL_DB_NAME = "irext";
|
||||
MYSQL_DB_USER = "root";
|
||||
MYSQL_DB_PASSWORD = "root";
|
||||
FILE_TEMP_PATH = "D:/rc_extension";
|
||||
PYTHON_PATH = "C:/Python27/python.exe";
|
||||
LISTEN_PORT = "6001";
|
||||
SERVER_ADDRESS = "localhost";
|
||||
REDIS_HOST = "localhost";
|
||||
REDIS_PORT = "6379";
|
||||
REDIS_PASSWORD = "";
|
||||
EXTERNAL_SERVER_ADDRESS = "192.168.137.128";
|
||||
EXTERNAL_SERVER_PORT = "8300"
|
||||
} else if (enums.APP_USERDEBUG_MODE == env) {
|
||||
MYSQL_DB_SERVER_ADDRESS = "localhost";
|
||||
MYSQL_DB_NAME = "irext";
|
||||
MYSQL_DB_USER = "root";
|
||||
MYSQL_DB_PASSWORD = "root";
|
||||
FILE_TEMP_PATH = "D:/rc_extension";
|
||||
PYTHON_PATH = "/usr/bin/python";
|
||||
LISTEN_PORT = "80";
|
||||
SERVER_ADDRESS = "localhost";
|
||||
REDIS_HOST = "localhost";
|
||||
REDIS_PORT = "6379";
|
||||
REDIS_PASSWORD = "";
|
||||
EXTERNAL_SERVER_ADDRESS = "www.strawmanbobi.com";
|
||||
EXTERNAL_SERVER_PORT = "8300"
|
||||
}
|
||||
MYSQL_DB_SERVER_ADDRESS = "localhost";
|
||||
MYSQL_DB_NAME = "irext";
|
||||
MYSQL_DB_USER = "root";
|
||||
MYSQL_DB_PASSWORD = "root";
|
||||
FILE_TEMP_PATH = "~/home/your_name/rc_extension";
|
||||
PYTHON_PATH = "/usr/bin/python";
|
||||
LISTEN_PORT = "80";
|
||||
SERVER_ADDRESS = "localhost";
|
||||
REDIS_HOST = "localhost";
|
||||
REDIS_PORT = "6379";
|
||||
REDIS_PASSWORD = "";
|
||||
EXTERNAL_SERVER_ADDRESS = "irext.net";
|
||||
EXTERNAL_SERVER_PORT = "80"
|
||||
};
|
||||
@@ -87,7 +87,6 @@ Category.listCategories = function(conditions, from, count, sortField, callback)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Category.getCategoryByID = function(categoryID, callback) {
|
||||
|
||||
@@ -8,4 +8,3 @@ var server = require('../irext_console.js');
|
||||
require('./navigation_routes.js');
|
||||
require('./code_manage_routes.js');
|
||||
require('./certificate_routes.js');
|
||||
require('./stat_routes.js');
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2016-11-27
|
||||
*/
|
||||
var app = require('../irext_console.js');
|
||||
var statService = require('../services/stat_service.js');
|
||||
|
||||
app.get('/irext/stat/generic_count', statService.genericCount);
|
||||
app.get('/irext/stat/stat_categories', statService.statCategories);
|
||||
app.get('/irext/stat/stat_brands', statService.statBrands);
|
||||
app.get('/irext/stat/stat_cities', statService.statCities);
|
||||
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2016-11-27
|
||||
*/
|
||||
|
||||
// system inclusion
|
||||
var constants = require('../mini_poem/configuration/constants');
|
||||
var logger = require('../mini_poem/logging/logger4js').helper;
|
||||
|
||||
var formidable = require('formidable');
|
||||
var fs = require('fs');
|
||||
|
||||
// local inclusion
|
||||
var ServiceResponse = require('../response/service_response.js');
|
||||
var StatResponse = require('../response/stat_response.js');
|
||||
var IntegerResponse = require('../response/integer_response');
|
||||
|
||||
|
||||
var statLogic = require('../work_unit/stat_logic.js');
|
||||
|
||||
var Enums = require('../constants/enums');
|
||||
var ErrorCode = require('../constants/error_code');
|
||||
|
||||
var enums = new Enums();
|
||||
var errorCode = new ErrorCode();
|
||||
|
||||
/*
|
||||
* function : Count remote of irext remote and device
|
||||
* parameter : stat_type
|
||||
* return : Customized statistics response
|
||||
*/
|
||||
exports.genericCount = function(req, res) {
|
||||
var statType = req.query.stat_type;
|
||||
|
||||
var statResponse = new StatResponse();
|
||||
statLogic.countRemoteWorkUnit(statType, function(countRemoteErr, statContent) {
|
||||
statResponse.status = countRemoteErr;
|
||||
statResponse.entity = statContent;
|
||||
res.send(statResponse);
|
||||
res.end();
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* function : Stat categories
|
||||
* parameter :
|
||||
* return : Customized statistics response
|
||||
*/
|
||||
exports.statCategories = function(req, res) {
|
||||
var statResponse = new StatResponse();
|
||||
statLogic.statCategoriesWorkUnit(function(statCategoriesErr, statCategories) {
|
||||
statResponse.status = statCategoriesErr;
|
||||
statResponse.entity = statCategories;
|
||||
res.send(statResponse);
|
||||
res.end();
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* function : Stat brands
|
||||
* parameter :
|
||||
* return : Customized statistics response
|
||||
*/
|
||||
exports.statBrands = function(req, res) {
|
||||
var categoryID = req.query.category_id;
|
||||
|
||||
var statResponse = new StatResponse();
|
||||
statLogic.statBrandsWorkUnit(categoryID, function(statBrandsErr, statBrands) {
|
||||
statResponse.status = statBrandsErr;
|
||||
statResponse.entity = statBrands;
|
||||
res.send(statResponse);
|
||||
res.end();
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* function : Stat cities
|
||||
* parameter :
|
||||
* return : Customized statistics response
|
||||
*/
|
||||
exports.statCities = function(req, res) {
|
||||
var statResponse = new StatResponse();
|
||||
statLogic.statCitiesWorkUnit(function(statCitiesErr, statCities) {
|
||||
statResponse.status = statCitiesErr;
|
||||
statResponse.entity = statCities;
|
||||
res.send(statResponse);
|
||||
res.end();
|
||||
});
|
||||
};
|
||||
@@ -20,4 +20,7 @@ bower install select2 --allow-root
|
||||
echo "bower install bootstrap-spinner"
|
||||
bower install bootstrap-spinner --allow-root
|
||||
|
||||
echo "bower install highcharts"
|
||||
bower install highcharts
|
||||
|
||||
echo "bower install done"
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* create by strawmanbobi
|
||||
* 2016-11-30
|
||||
*/
|
||||
|
||||
/* Space out content a bit */
|
||||
|
||||
body {
|
||||
padding-bottom: 20px;
|
||||
font-family: 微软雅黑, Arial;
|
||||
}
|
||||
|
||||
.starter-template {
|
||||
padding: 40px 15px;
|
||||
}
|
||||
|
||||
/* Everything but the jumbotron gets side spacing for mobile first views */
|
||||
.header,
|
||||
.marketing,
|
||||
.footer {
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
/* Custom page header */
|
||||
.header {
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
/* Make the masthead heading the same height as the navigation */
|
||||
.header h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
line-height: 40px;
|
||||
padding-bottom: 19px;
|
||||
}
|
||||
|
||||
/* Custom page footer */
|
||||
.footer {
|
||||
padding-top: 19px;
|
||||
color: #777;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
/* Customize container */
|
||||
@media (min-width: 768px) {
|
||||
}
|
||||
.container-narrow > hr {
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
/* Main marketing message and sign up button */
|
||||
.jumbotron {
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
.jumbotron .btn {
|
||||
font-size: 21px;
|
||||
padding: 14px 24px;
|
||||
}
|
||||
|
||||
/* Supporting marketing content */
|
||||
.marketing {
|
||||
margin: 40px 0;
|
||||
}
|
||||
.marketing p + h4 {
|
||||
margin-top: 28px;
|
||||
}
|
||||
|
||||
.pointer {
|
||||
cursor: pointer
|
||||
}
|
||||
|
||||
/* Responsive: Portrait tablets and up */
|
||||
@media screen and (min-width: 768px) {
|
||||
/* Remove the padding we set earlier */
|
||||
.header,
|
||||
.marketing,
|
||||
.footer {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
/* Space out the masthead */
|
||||
.header {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
/* Remove the bottom border on the jumbotron for visual effect */
|
||||
.jumbotron {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cmn">
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="screen-orientation" content="portrait"/>
|
||||
<meta name="description" content="irext application">
|
||||
<meta name="author" content="strawmanbobi">
|
||||
<title>irext 控制台</title>
|
||||
|
||||
<link href="../public_js/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="../public_js/select2/select2.min.css" rel="stylesheet">
|
||||
<link href="../public_js/bootstrap_table/dist/bootstrap-table.min.css" rel="stylesheet">
|
||||
<link href="./css/stat.css" rel="stylesheet">
|
||||
<link href="../public_js/bootstrap_sidebar/css/simple-sidebar.css" rel="stylesheet">
|
||||
|
||||
<script src="../public_js/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
<script src="../public_js/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<script src="../public_js/bower_components/bootstrap/js/modal.js"></script>
|
||||
<script src="../public_js/bower_components/highcharts/js/highcharts.js"></script>
|
||||
<script src="../public_js/utils/date_utils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="sidebar-wrapper">
|
||||
<ul class="sidebar-nav" id="side_bar">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<div class="container" id="page-content-wrapper">
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="navbar-header">
|
||||
<a id="menu_toggle" class="navbar-brand glyphicon glyphicon-transfer" href="#"></a><a class="navbar-brand" href="#"> 统计 </a>
|
||||
</div>
|
||||
</nav>
|
||||
<ul class="nav nav-tabs" id="main_tab">
|
||||
<li class="active" style="cursor: pointer;"><a data-target="#activation_stat" data-toggle="tab">激活统计</a></li>
|
||||
<li style="cursor: pointer;"><a data-target="#remote_stat" data-toggle="tab" onclick="statCategories();">家电统计</a></li>
|
||||
<!--
|
||||
<li style="cursor: pointer;"><a data-target="#scatter_stat" data-toggle="tab">分布统计</a></li>
|
||||
<li style="cursor: pointer;"><a data-target="#update_stat" data-toggle="tab">升级统计</a></li>
|
||||
-->
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="activation_stat">
|
||||
<br>
|
||||
<div class="jumbotron" id="panel_active_stat">
|
||||
<div class="container">
|
||||
<h2 style="color: #FF5F00">全世界共有 <span id="ucon_count"></span> 台 irext 成功激活</h2>
|
||||
<br><br>
|
||||
<p>底座激活数:<span id="device_count"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="jumbotron" id="panel_remote_stat">
|
||||
<div class="container">
|
||||
<h2 style="color: #FF5F00"><span id="remote_count"></span> 台家用电器已被 irext 成功控制</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="remote_stat">
|
||||
<br>
|
||||
<div class="jumbotron" id="panel_remote_index_stat">
|
||||
<div class="panel-group" role="tablist" aria-multiselectable="true" id="categories_panel">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div class="tab-pane" id="scatter_stat">
|
||||
分布统计
|
||||
</div>
|
||||
<div class="tab-pane" id="update_stat">
|
||||
升级统计
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- hint dialog -->
|
||||
<div class="modal fade" id="hint_dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" aria-hidden="true" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">提示</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="text_hint"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-danger" data-dismiss="modal">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- signout dialog -->
|
||||
<div class="modal fade" id="signout_confirm_dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">退出登录</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="signout_hint">确定要退出吗?</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-danger" onclick="signout();">确定</button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="./js/stat.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,341 +0,0 @@
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2016-01-04
|
||||
*/
|
||||
|
||||
var LS_KEY_ID = "user_name";
|
||||
var LS_KEY_TOKEN = "token";
|
||||
var id, token;
|
||||
|
||||
var categoriesStated = false;
|
||||
|
||||
var colorClass = ["default", "primary", "success", "warning", "danger", "info"];
|
||||
|
||||
// global container var
|
||||
var gCategories = [];
|
||||
// 2-dimensions brand array
|
||||
var gBrands = [];
|
||||
// 1-dimension city array
|
||||
var gCities = [];
|
||||
|
||||
$("#menu_toggle").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#wrapper").toggleClass("toggled");
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
id = localStorage.getItem(LS_KEY_ID);
|
||||
token = localStorage.getItem(LS_KEY_TOKEN);
|
||||
showMenu(id, token, "stat");
|
||||
|
||||
$("#main_tab a:first").tab("show");
|
||||
|
||||
getRemoteInstanceCount();
|
||||
getDeviceCount();
|
||||
getRemoteCount();
|
||||
});
|
||||
|
||||
///////////////////////////// Event functions /////////////////////////////
|
||||
function onStatCategories() {
|
||||
if (true == categoriesStated) {
|
||||
return;
|
||||
}
|
||||
console.debug("stat categories");
|
||||
statCategories();
|
||||
}
|
||||
|
||||
function onStatBrands(categoryIndex) {
|
||||
var categoryID = 0;
|
||||
if (true == gBrands[categoryIndex].brandStated) {
|
||||
return;
|
||||
}
|
||||
categoryID = gCategories[categoryIndex].id;
|
||||
|
||||
if (3 != categoryID) {
|
||||
statBrands(gCategories[categoryIndex].id, categoryIndex);
|
||||
} else {
|
||||
statCities(gCategories[categoryIndex].id, categoryIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////// Data functions /////////////////////////////
|
||||
function getRemoteInstanceCount() {
|
||||
$.ajax({
|
||||
url: "/irext/stat/generic_count?stat_type=0&id="+id+"&token="+token,
|
||||
type: "GET",
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
refreshActiveRemoteInstance(response.entity);
|
||||
} else {
|
||||
console.log("get remote instance count failed");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log("get remote instance count failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getDeviceCount() {
|
||||
$.ajax({
|
||||
url: "/irext/stat/generic_count?stat_type=1&id="+id+"&token="+token,
|
||||
type: "GET",
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
refreshActiveDeviceInstance(response.entity);
|
||||
} else {
|
||||
console.log("get device count failed");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log("get device count failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getRemoteCount() {
|
||||
$.ajax({
|
||||
url: "/irext/stat/generic_count?stat_type=2&id="+id+"&token="+token,
|
||||
type: "GET",
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
refreshActiveRemote(response.entity);
|
||||
} else {
|
||||
console.log("get remote count failed");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log("get remote count failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function statCategories() {
|
||||
$.ajax({
|
||||
url: "/irext/stat/stat_categories?id="+id+"&token="+token,
|
||||
type: "GET",
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
gCategories = response.entity;
|
||||
refreshCategoryList();
|
||||
} else {
|
||||
console.log("stat categories failed");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log("stat categories failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function statBrands(categoryID, categoryIndex) {
|
||||
$.ajax({
|
||||
url: "/irext/stat/stat_brands?id="+id+"&token="+token+"&category_id="+categoryID,
|
||||
type: "GET",
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
gBrands[categoryIndex].brands = response.entity;
|
||||
// console.log("brands stat result = " + JSON.stringify(gBrands[categoryIndex].brands));
|
||||
refreshBrandList(categoryID, categoryIndex);
|
||||
} else {
|
||||
console.log("stat brands failed");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log("stat brands failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function statCities(categoryID, categoryIndex) {
|
||||
$.ajax({
|
||||
url: "/irext/stat/stat_cities?id="+id+"&token="+token,
|
||||
type: "GET",
|
||||
timeout: 20000,
|
||||
success: function (response) {
|
||||
if(response.status.code == 0) {
|
||||
gCities.cities = response.entity;
|
||||
console.log("cities stat result = " + JSON.stringify(gCities.cities));
|
||||
refreshCityList(categoryID, categoryIndex);
|
||||
} else {
|
||||
console.log("stat cities failed");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log("stat cities failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////// UI functions /////////////////////////////
|
||||
function refreshActiveRemoteInstance(count) {
|
||||
var remoteInstancePanel = $("#ucon_count");
|
||||
remoteInstancePanel.empty();
|
||||
remoteInstancePanel.append(count);
|
||||
}
|
||||
|
||||
function refreshActiveDeviceInstance(count) {
|
||||
var deviceInstancePanel = $("#device_count");
|
||||
deviceInstancePanel.empty();
|
||||
deviceInstancePanel.append(count);
|
||||
}
|
||||
|
||||
function refreshActiveRemote(count) {
|
||||
var remoteCountPanel = $("#remote_count");
|
||||
remoteCountPanel.empty();
|
||||
remoteCountPanel.append(count);
|
||||
}
|
||||
|
||||
function refreshCategoryList() {
|
||||
var categoryContent = "";
|
||||
gBrands = new Array();
|
||||
for (var i = 0; i < gCategories.length; i++) {
|
||||
var category = gCategories[i];
|
||||
|
||||
if (category.id == 11) {
|
||||
category.name = "機上盒";
|
||||
}
|
||||
var panelID = "category_" + category.id;
|
||||
var collapseID = "collapse" + category.id;
|
||||
var colorSpace = i % 6;
|
||||
var includingText = "";
|
||||
if (3 != category.id) {
|
||||
includingText = "个品牌";
|
||||
} else {
|
||||
includingText = "个省份";
|
||||
}
|
||||
// console.log(colorClass[colorSpace]);
|
||||
categoryContent +=
|
||||
"<div class='panel panel-default'>" +
|
||||
"<div class='panel-heading' role='tab' id='" + panelID + "'>" +
|
||||
"<h4 class='panel-title' style='text-align:left;'>" +
|
||||
"<a style='display: block; width: 100%; text-decoration: none;'" +
|
||||
"role='button' data-toggle='collapse' data-parent='#categories_panel'" +
|
||||
"href='#" + collapseID +"' onclick='onStatBrands(" + i + ")' " +
|
||||
"aria-expanded='true' aria-controls='" + collapseID + "'>" +
|
||||
category.name + " (" + category.brands_count + " " + includingText + ")" +
|
||||
"</a>" +
|
||||
"</h4>" +
|
||||
"</div>" +
|
||||
"<div id='" + collapseID + "' class='panel-collapse collapse' role='tabpanel' aria-labelledby='headingOne'>" +
|
||||
"<div class='panel-body' style='text-align:left;' id='brand_charts_" + category.id + "'>" +
|
||||
"正在加载..." +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>";
|
||||
gBrands[i] = new Array();
|
||||
gBrands[i].brandStated = false;
|
||||
}
|
||||
$("#categories_panel").html(categoryContent);
|
||||
categoriesStated = true;
|
||||
}
|
||||
|
||||
function refreshBrandList(categoryID, categoryIndex) {
|
||||
// draw charts with highcharts
|
||||
// adjust the container of charts according to the number of brands in this category
|
||||
var containerHeight = gBrands[categoryIndex].brands.length * 30 + 200;
|
||||
console.log("container height = " + containerHeight);
|
||||
$("#brand_charts_" + categoryID).css("width", "100%");
|
||||
$("#brand_charts_" + categoryID).css("height", containerHeight + "px");
|
||||
$("#brand_charts_" + categoryID).css("padding", "0px");
|
||||
|
||||
// generate brand names and supported remote index counts
|
||||
var brandNames = [];
|
||||
var remoteIndexCounts = [];
|
||||
for (var i = 0; i < gBrands[categoryIndex].brands.length; i++) {
|
||||
brandNames[i] = gBrands[categoryIndex].brands[i].name;
|
||||
remoteIndexCounts[i] = gBrands[categoryIndex].brands[i].remote_indexes_count;
|
||||
}
|
||||
|
||||
$("#brand_charts_" + categoryID).highcharts({
|
||||
chart: {
|
||||
type: "bar",
|
||||
style: {
|
||||
fontFamily: '微软雅黑'
|
||||
},
|
||||
events: {
|
||||
load: function(event) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: gCategories[categoryIndex].name + "品牌分布"
|
||||
},
|
||||
xAxis: {
|
||||
categories: brandNames
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: '支持型号数'
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
name: '型号数',
|
||||
data: remoteIndexCounts,
|
||||
dataLabels: {
|
||||
enabled: true
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
gBrands[categoryIndex].brandStated = true;
|
||||
}
|
||||
|
||||
function refreshCityList(categoryID, categoryIndex) {
|
||||
// draw charts with highcharts
|
||||
// adjust the container of charts according to the number of brands in this category
|
||||
var containerHeight = gCities.cities.length * 30 + 200;
|
||||
console.log("container height = " + containerHeight);
|
||||
$("#brand_charts_" + categoryID).css("width", "100%");
|
||||
$("#brand_charts_" + categoryID).css("height", containerHeight + "px");
|
||||
$("#brand_charts_" + categoryID).css("padding", "0px");
|
||||
|
||||
// generate brand names and supported remote index counts
|
||||
var provinceNames = [];
|
||||
var cityCounts = [];
|
||||
for (var i = 0; i < gCities.cities.length; i++) {
|
||||
provinceNames[i] = gCities.cities[i].name;
|
||||
cityCounts[i] = gCities.cities[i].city_count;
|
||||
}
|
||||
|
||||
$("#brand_charts_" + categoryID).highcharts({
|
||||
chart: {
|
||||
type: "bar",
|
||||
style: {
|
||||
fontFamily: '微软雅黑'
|
||||
},
|
||||
events: {
|
||||
load: function(event) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: gCategories[categoryIndex].name + "地区分布"
|
||||
},
|
||||
xAxis: {
|
||||
categories: provinceNames
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: '支持城市数'
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
name: '城市数',
|
||||
data: cityCounts,
|
||||
dataLabels: {
|
||||
enabled: true
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
gBrands[categoryIndex].brandStated = true;
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/**
|
||||
* Created by strawmanbobi
|
||||
* 2016-11-27
|
||||
*/
|
||||
|
||||
// global inclusion
|
||||
require('../mini_poem/configuration/constants');
|
||||
var RequestSender = require('../mini_poem/http/request.js');
|
||||
var Map = require('../mini_poem/mem/map.js');
|
||||
var logger = require('../mini_poem/logging/logger4js').helper;
|
||||
|
||||
// local inclusion
|
||||
|
||||
var Enums = require('../constants/enums.js');
|
||||
var ErrorCode = require('../constants/error_code.js');
|
||||
|
||||
var enums = new Enums();
|
||||
var errorCode = new ErrorCode();
|
||||
|
||||
var REQUEST_APP_KEY = "d6119900556c4c1e629fd92d";
|
||||
var REQUEST_APP_TOKEN = "fcac5496cba7a12b3bae34abf061f526";
|
||||
|
||||
// out going HTTP request parameters
|
||||
var PRIMARY_SERVER_ADDRESS = "irext.net";
|
||||
// var PRIMARY_SERVER_ADDRESS = "127.0.0.1";
|
||||
var PRIMARY_SERVER_PORT = "8200";
|
||||
|
||||
var STAT_GENERIC_COUNT_SERVICE = "/irext/stat/generic_count";
|
||||
var STAT_CATEGORIES_SERVICE = "/irext/stat/stat_categories";
|
||||
var STAT_BRANDS_SERVICE = "/irext/stat/stat_brands";
|
||||
var STAT_CITIES_SERVICE = "/irext/stat/stat_cities";
|
||||
|
||||
exports.countRemoteWorkUnit = function(statType, callback) {
|
||||
if (parseInt(statType) < parseInt(enums.STAT_TYPE_REMOTE_INSTANCE_ACTIVE) ||
|
||||
parseInt(statType) > parseInt(enums.STAT_TYPE_REMOTE_ACTIVE)) {
|
||||
logger.warn("stat type might be invalid : " + statType);
|
||||
callback(errorCode.FAILED, null);
|
||||
} else {
|
||||
var options = {
|
||||
https: false
|
||||
};
|
||||
var queryParams = new Map();
|
||||
var countResult = 0;
|
||||
queryParams.put("app_key", REQUEST_APP_KEY);
|
||||
queryParams.put("app_token", REQUEST_APP_TOKEN);
|
||||
queryParams.put("stat_type", statType);
|
||||
var requestSender =
|
||||
new RequestSender(PRIMARY_SERVER_ADDRESS, PRIMARY_SERVER_PORT, STAT_GENERIC_COUNT_SERVICE, queryParams);
|
||||
requestSender.sendGetRequest(options, function(sendRequestErr, response) {
|
||||
if (sendRequestErr != errorCode.SUCCESS.code) {
|
||||
logger.error("send request error");
|
||||
callback(errorCode.FAILED, null);
|
||||
} else {
|
||||
logger.info("send request successfully, response = " + JSON.parse(response).entity);
|
||||
countResult = JSON.parse(response).entity;
|
||||
callback(errorCode.SUCCESS, countResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.statCategoriesWorkUnit = function(callback) {
|
||||
var queryParams = new Map();
|
||||
queryParams.put("app_key", REQUEST_APP_KEY);
|
||||
queryParams.put("app_token", REQUEST_APP_TOKEN);
|
||||
var options = {
|
||||
https: false
|
||||
};
|
||||
|
||||
var messagesResult = null;
|
||||
|
||||
var requestSender =
|
||||
new RequestSender(PRIMARY_SERVER_ADDRESS, PRIMARY_SERVER_PORT, STAT_CATEGORIES_SERVICE, queryParams);
|
||||
|
||||
requestSender.sendGetRequest(options, function(sendRequestErr, response) {
|
||||
if (sendRequestErr != errorCode.SUCCESS.code) {
|
||||
logger.error("send request error");
|
||||
callback(errorCode.FAILED, null);
|
||||
} else {
|
||||
messagesResult = JSON.parse(response).entity;
|
||||
callback(errorCode.SUCCESS, messagesResult);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.statBrandsWorkUnit = function(categoryID, callback) {
|
||||
var queryParams = new Map();
|
||||
queryParams.put("app_key", REQUEST_APP_KEY);
|
||||
queryParams.put("app_token", REQUEST_APP_TOKEN);
|
||||
queryParams.put("category_id", categoryID);
|
||||
var options = {
|
||||
https: false
|
||||
};
|
||||
|
||||
var messagesResult = null;
|
||||
|
||||
var requestSender =
|
||||
new RequestSender(PRIMARY_SERVER_ADDRESS, PRIMARY_SERVER_PORT, STAT_BRANDS_SERVICE, queryParams);
|
||||
|
||||
requestSender.sendGetRequest(options, function(sendRequestErr, response) {
|
||||
if (sendRequestErr != errorCode.SUCCESS.code) {
|
||||
logger.error("send request error");
|
||||
callback(errorCode.FAILED, null);
|
||||
} else {
|
||||
messagesResult = JSON.parse(response).entity;
|
||||
callback(errorCode.SUCCESS, messagesResult);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.statCitiesWorkUnit = function(callback) {
|
||||
var queryParams = new Map();
|
||||
queryParams.put("app_key", REQUEST_APP_KEY);
|
||||
queryParams.put("app_token", REQUEST_APP_TOKEN);
|
||||
var options = {
|
||||
https: false
|
||||
};
|
||||
|
||||
var messagesResult = null;
|
||||
|
||||
var requestSender =
|
||||
new RequestSender(PRIMARY_SERVER_ADDRESS, PRIMARY_SERVER_PORT, STAT_CITIES_SERVICE, queryParams);
|
||||
|
||||
requestSender.sendGetRequest(options, function(sendRequestErr, response) {
|
||||
if (sendRequestErr != errorCode.SUCCESS.code) {
|
||||
logger.error("send request error");
|
||||
callback(errorCode.FAILED, null);
|
||||
} else {
|
||||
messagesResult = JSON.parse(response).entity;
|
||||
callback(errorCode.SUCCESS, messagesResult);
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user