Merge branch 'master' of github.com:strawmanbobi/irext
This commit is contained in:
@@ -80,6 +80,7 @@ function tokenValidation (req, res, next) {
|
||||
// request of content type of multipart/form-data would be validated inside each service
|
||||
next();
|
||||
} else {
|
||||
console.log("adminID = " + adminID + ", token = " + token);
|
||||
certificateLogic.verifyTokenWorkUnit(adminID, token, function(validateTokenErr) {
|
||||
if(errorCode.SUCCESS.code != validateTokenErr.code) {
|
||||
var fakeResponse = {
|
||||
|
||||
@@ -28,7 +28,7 @@ var Category = dbOrm.define('category',
|
||||
}
|
||||
);
|
||||
|
||||
Category.createCategory = function (category, callback) {
|
||||
Category.createCategory = function(category, callback) {
|
||||
var date = dateUtils.formatDate(new Date(), "yyyy-MM-dd hh:mm:ss");
|
||||
var newCategory = new Category({
|
||||
name: category.name,
|
||||
@@ -49,7 +49,7 @@ Category.createCategory = function (category, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
Category.findCategoryByConditions = function (conditions, callback) {
|
||||
Category.findCategoryByConditions = function(conditions, callback) {
|
||||
Category.find(conditions)
|
||||
.run(function (error, categories) {
|
||||
if (error) {
|
||||
@@ -62,8 +62,8 @@ Category.findCategoryByConditions = function (conditions, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
Category.listCategories = function (conditions, from, count, sortField, callback) {
|
||||
if ("id" == sortField && 0 != from) {
|
||||
Category.listCategories = function(conditions, from, count, sortField, callback) {
|
||||
if("id" == sortField && 0 != from) {
|
||||
conditions.id = orm.gt(from);
|
||||
Category.find(conditions).limit(parseInt(count)).orderRaw("?? ASC", [sortField])
|
||||
.run(function (listCategoriesErr, categories) {
|
||||
@@ -90,8 +90,8 @@ Category.listCategories = function (conditions, from, count, sortField, callback
|
||||
|
||||
};
|
||||
|
||||
Category.getCategoryByID = function (categoryID, callback) {
|
||||
Category.get(categoryID, function (error, category) {
|
||||
Category.getCategoryByID = function(categoryID, callback) {
|
||||
Category.get(categoryID, function(error, category) {
|
||||
if (error) {
|
||||
logger.error("get category by ID error : " + error);
|
||||
callback(errorCode.FAILED, null);
|
||||
@@ -103,8 +103,8 @@ Category.getCategoryByID = function (categoryID, callback) {
|
||||
};
|
||||
|
||||
/* For internal use only */
|
||||
Category.listRemoteCategories = function (conditions, from, count, sortField, callback) {
|
||||
if ("id" == sortField && 0 != from) {
|
||||
Category.listRemoteCategories = function(conditions, from, count, sortField, callback) {
|
||||
if("id" == sortField && 0 != from) {
|
||||
conditions.id = orm.gt(from);
|
||||
Category.find(conditions).limit(parseInt(count)).orderRaw("?? ASC", [sortField])
|
||||
.run(function (listCategoriesErr, categories) {
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
// system inclusion
|
||||
var constants = require('../mini_poem/configuration/constants');
|
||||
var logger = require('../mini_poem/logging/logger4js').helper;
|
||||
|
||||
// local inclusion
|
||||
var ServiceResponse = require('../response/service_response.js');
|
||||
var LoginResponse = require('../response/login_response.js');
|
||||
|
||||
var logger = require('../mini_poem/logging/logger4js').helper;
|
||||
|
||||
var certificateLogic = require('../work_unit/certificate_logic.js');
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
// 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');
|
||||
|
||||
@@ -17,8 +19,6 @@ var CityResponse = require('../response/city_response.js');
|
||||
var OperatorResponse = require('../response/operator_response.js');
|
||||
var RemoteIndexResponse = require('../response/remote_index_response.js');
|
||||
|
||||
var logger = require('../mini_poem/logging/logger4js').helper;
|
||||
|
||||
var internalLogic = require('../work_unit/internal_logic.js');
|
||||
|
||||
var Enums = require('../constants/enums');
|
||||
@@ -437,7 +437,7 @@ exports.createProtocol = function (req, res) {
|
||||
}).on('error', function(err) {
|
||||
logger.error("formidable parse form error : " + err);
|
||||
res.send("<html>" +
|
||||
"<body> " +
|
||||
"<body>" +
|
||||
"<div style='width: 100%; text-align: center; color: #FF0000'>协议文件提交失败</div>" +
|
||||
"</body>" +
|
||||
"</html>");
|
||||
@@ -458,18 +458,19 @@ exports.createProtocol = function (req, res) {
|
||||
internalLogic.createProtocolWorkUnit(protocol, filePath, contentType, adminID, function (createProtocolErr) {
|
||||
if(errorCode.SUCCESS.code == createProtocolErr.code) {
|
||||
res.send("<html>" +
|
||||
"<body> " +
|
||||
"<body>" +
|
||||
"<div style='width: 100%; text-align: center;'>协议文件提交成功</div>" +
|
||||
"</body>" +
|
||||
"</html>");
|
||||
res.end();
|
||||
} else {
|
||||
res.send("<html>" +
|
||||
"<body> " +
|
||||
"<body>" +
|
||||
"<div style='width: 100%; text-align: center; color: #FF0000'>协议文件提交失败</div>" +
|
||||
"</body>" +
|
||||
"</html>");
|
||||
res.end();
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
// 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');
|
||||
|
||||
@@ -13,7 +15,6 @@ var ServiceResponse = require('../response/service_response.js');
|
||||
var StatResponse = require('../response/stat_response.js');
|
||||
var IntegerResponse = require('../response/integer_response');
|
||||
|
||||
var logger = require('../mini_poem/logging/logger4js').helper;
|
||||
|
||||
var statLogic = require('../work_unit/stat_logic.js');
|
||||
|
||||
|
||||
@@ -22,10 +22,7 @@
|
||||
<div class="header clearfix">
|
||||
<nav>
|
||||
<ul class="nav nav-pills pull-right">
|
||||
<li role="presentation"><a href="#" onclick="gotoIndex();">主页</a></li>
|
||||
<li role="presentation" class="active"><a href="#">控制台</a></li>
|
||||
<li role="presentation"><a href="#">文档</a></li>
|
||||
<li role="presentation"><a href="https://github.com/strawmanbobi/irext">Github</a></li>
|
||||
<li role="presentation"><a href="#" onclick="gotoIndex();">退出</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<h3>IRext</h3>
|
||||
@@ -88,7 +85,7 @@
|
||||
<span class="glyphicon glyphicon-download" style="vertical-align:middle; margin-bottom: 3px;"></span>
|
||||
</button>
|
||||
</div>
|
||||
<button id="publish_button" class="btn btn-normal btn-success" onclick="onPublishRemote();" style="font-size: 14px; display: none;">
|
||||
<button id="publish_button" class="btn btn-normal btn-success" onclick="onPublishRemote();" style="font-size: 14px;">
|
||||
<span class="glyphicon glyphicon-send" style="vertical-align:middle; margin-bottom: 3px;"></span>
|
||||
</button>
|
||||
<button id="search_bin_button" class="btn btn-normal btn-default" onclick="onSearchRemote();" style="font-size: 14px;">
|
||||
@@ -320,7 +317,7 @@
|
||||
<div id="publish_hint"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-info" onclick="publishUnpublished();">报表</button>
|
||||
<!-- <button type="button" class="btn btn-info" onclick="publishUnpublished();">报表</button> -->
|
||||
<button type="button" class="btn btn-success" onclick="publishBrands();">确定</button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
|
||||
</div>
|
||||
|
||||
@@ -86,9 +86,6 @@ $(document).ready(function() {
|
||||
id = localStorage.getItem(LS_KEY_ID);
|
||||
token = localStorage.getItem(LS_KEY_TOKEN);
|
||||
client = getParameter('client');
|
||||
if (null != client && client == 'console') {
|
||||
hideSidebar();
|
||||
}
|
||||
|
||||
// showMenu(id, token, 'remote');
|
||||
initializeSelectors();
|
||||
@@ -1763,5 +1760,5 @@ function translateToTC(textID, targetTextID) {
|
||||
}
|
||||
|
||||
function gotoIndex() {
|
||||
window.location = '../index.html?admin_id='+id+'&token='+token;
|
||||
window.location = '../';
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
body {
|
||||
font-family: 微软雅黑, Arial
|
||||
}
|
||||
|
||||
.starter-template {
|
||||
padding: 40px 15px;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Created by Strawmanbobi
|
||||
* 2016-12-01
|
||||
*/
|
||||
|
||||
var id, token;
|
||||
var LS_KEY_ID = "user_name";
|
||||
var LS_KEY_TOKEN = "token";
|
||||
|
||||
$(document).ready(function() {
|
||||
id = localStorage.getItem(LS_KEY_ID);
|
||||
token = localStorage.getItem(LS_KEY_TOKEN);
|
||||
showMenu(id, token, "doc");
|
||||
});
|
||||
|
||||
$("#menu_toggle").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#wrapper").toggleClass("toggled");
|
||||
});
|
||||
|
||||
function navigation(anchor) {
|
||||
$.mobile.navigate("#"+anchor);
|
||||
}
|
||||
@@ -16,111 +16,25 @@
|
||||
<body>
|
||||
<div class="navbar container">
|
||||
<div class="header clearfix">
|
||||
<nav>
|
||||
<ul class="nav nav-pills pull-right">
|
||||
<li role="presentation" class="active"><a href="#">主页</a></li>
|
||||
<li role="presentation"><a href="#" onclick="onSignIn();">控制台</a></li>
|
||||
<li role="presentation"><a href="#">文档</a></li>
|
||||
<li role="presentation"><a href="https://github.com/strawmanbobi/irext">Github</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<h3>IRext</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main jumbotron for a primary marketing message or call to action -->
|
||||
<div class="jumbotron" style="background: #3FAF7F">
|
||||
<div class="container">
|
||||
<h1 style="text-shadow: none; color: #FFF;">IRext</h1>
|
||||
<p class="lead" style="text-shadow: none; color: #FFF;">开源家用电器红外的编码、解码和索引方案.</p>
|
||||
<br>
|
||||
<p><a class="btn btn-default" style="color: #000;" href="#" role="button">看看数据先</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row marketing">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h2>红外编码</h2>
|
||||
<p>基于XML的编码输入语言</p>
|
||||
<p>支持远程录入</p>
|
||||
<p>支持红外分析仪插件</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>红外解码</h2>
|
||||
<p>支持多种平台下的解码</p>
|
||||
<p>极小的内存开销</p>
|
||||
<p>高性能解码</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>码库索引</h2>
|
||||
<p>利用Web控制台录入码库</p>
|
||||
<p>规范的码库审核和发布流程</p>
|
||||
<p>支持协议扩充</p>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="form-signin">
|
||||
<h4 class="text-muted">登入</h4>
|
||||
<label for="user_name" class="sr-only">邮件地址</label>
|
||||
<input type="email" id="user_name" class="form-control" placeholder="邮件地址" required autofocus>
|
||||
<label for="password" class="sr-only">密码</label>
|
||||
<input type="password" id="password" class="form-control" placeholder="密码" required>
|
||||
<button class="btn btn-lg btn-primary btn-block" onclick="signIn();">确定</button>
|
||||
<br>
|
||||
<div style="font-size: 12px; color: #AAA;"><a href="#" onclick="onChangePassword();">更改密码</a></div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h2>码库支持</h2>
|
||||
<p>支持13种电器类型</p>
|
||||
<p>支持数百个品牌</p>
|
||||
<p>支持上万种型号家电</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>扩展功能</h2>
|
||||
<p>支持基于开源硬件的IR学习</p>
|
||||
<p>提供远程编码服务</p>
|
||||
<p>代码完全开源</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>易于上手</h2>
|
||||
<p>仅需几步就能移植到您的项目</p>
|
||||
<p>Web服务接口文档</p>
|
||||
<p>提供开放式控制台和示例代码</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<p>Strawmanbobi, 2016</p>
|
||||
</footer>
|
||||
</div> <!-- /container -->
|
||||
</div>
|
||||
|
||||
<!-- dialogs -->
|
||||
<div class="modal fade" id="signin_dialog" 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" style="color: #000; text-shadow: none;">登入控制台</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-signin">
|
||||
<label for="user_name" class="sr-only">邮件地址</label>
|
||||
<input type="email" id="user_name" class="form-control" placeholder="邮件地址" required autofocus>
|
||||
<label for="password" class="sr-only">密码</label>
|
||||
<input type="password" id="password" class="form-control" placeholder="密码" required>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input id="remember_me" type="checkbox" checked="true">
|
||||
<div style="font-size: 12px; color: #000; text-decoration: none; text-shadow: none;">
|
||||
记住我
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<button class="btn btn-normal btn-success" onclick="signIn();">确定</button>
|
||||
<button class="btn btn-normal btn-primary" onclick="onChangePassword();">忘记密码</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="changepw_confirm_dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
|
||||
@@ -121,10 +121,8 @@ function doSignIn(userName, password) {
|
||||
setTimeout(function() {
|
||||
navigateToPage(page, adminID, token);
|
||||
}, 3000);
|
||||
if($("#remember_me").is(":checked")) {
|
||||
localStorage.setItem(LS_KEY_ID, adminID);
|
||||
localStorage.setItem(LS_KEY_TOKEN, token);
|
||||
}
|
||||
localStorage.setItem(LS_KEY_ID, adminID);
|
||||
localStorage.setItem(LS_KEY_TOKEN, token);
|
||||
} else {
|
||||
toastr.error("登入失败,请确认密码是否正确");
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ exports.adminLoginWorkUnit = function (userName, password, callback) {
|
||||
timeStamp,
|
||||
name;
|
||||
timeStamp = new Date().getTime();
|
||||
token = MD5.MD5(password + timeStamp);
|
||||
token += "," + admin.permissions;
|
||||
token = admin.token;
|
||||
key = "admin_" + admin.id;
|
||||
adminAuth.setAuthInfo(key, token, ttl, function(setAdminAuthErr) {
|
||||
if (errorCode.SUCCESS.code == setAdminAuthErr.code) {
|
||||
|
||||
@@ -537,8 +537,6 @@ exports.createRemoteIndexWorkUnit = function(remoteIndex, filePath, contentType,
|
||||
exports.deleteRemoteIndexWorkUnit = function (remoteIndex, adminID, callback) {
|
||||
// delete remote information from release server first
|
||||
var queryParams = new Map();
|
||||
queryParams.put("app_key", REQUEST_APP_KEY);
|
||||
queryParams.put("app_token", REQUEST_APP_TOKEN);
|
||||
|
||||
var key = "admin_name_" + adminID;
|
||||
adminAuth.getAuthInfo(key, function(getAdminAuthErr, result) {
|
||||
@@ -548,9 +546,11 @@ exports.deleteRemoteIndexWorkUnit = function (remoteIndex, adminID, callback) {
|
||||
callback(errorCode.FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
remoteIndex.admin_id = adminID;
|
||||
var requestSender =
|
||||
new RequestSender(PRIMARY_SERVER_ADDRESS,
|
||||
PRIMARY_SERVER_PORT,
|
||||
new RequestSender(EXTERNAL_SERVER_ADDRESS,
|
||||
EXTERNAL_SERVER_PORT,
|
||||
DELETE_REMOTE_INDEX_SERVICE,
|
||||
queryParams);
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
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 logger = require('../mini_poem/logging/logger4js').helper;
|
||||
|
||||
var enums = new Enums();
|
||||
var errorCode = new ErrorCode();
|
||||
|
||||
Reference in New Issue
Block a user