c5_labsci/web/admin/ap/api.html

223 lines
9.5 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<link href="/jscss/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="/jscss/theme.js"></script>
</head>
<body>
<div class="container">
<form class="search" onsubmit="table.search(this,'btn');return false;">
<ul></ul>
<div>
<div class="sinps"></div>
<div class="sbtns">
<a class="lang btn" onclick="addnew()">新建API通道</a>
<a class="lang btn def" href="/ud/api/api.pdf" target="_blank">API文档</a>
<a class="lang btn def" href="/ud/api/api_sign.pdf" target="_blank">签名文档</a>
<a class="lang btn def" href="/ud/public.pem" onclick="">平台回调公钥下载</a>
</div>
</div>
</form>
<div class="table">
<div class="loading col-24">Loading...</div>
<div class="list"></div>
<div>
<div class="btmbtn">
<a class="lang btn def" onclick="ciyfn.select_all(table)">全选</a>
<a class="lang btn def" onclick="ciyfn.select_diff(table)">反选</a>
|
</div>
<div class="page"></div>
</div>
</div>
</div>
<div id="alert_edit" style="display:none;">
<div class="char4 row">
<div class="ciy-form col-24 col-sm-24 top">
<label class="lang">白名单IP</label>
<div>
<ciy-textarea com="ips" minheight="10em" />
</div>
</div>
</div>
</div>
<div id="alert_pubkey" style="display:none;">
<div class="char4 row">
<div class="ciy-form col-24 col-sm-24 top">
<label class="lang">公钥</label>
<div>
<ciy-textarea com="pubkey" minheight="10em" />
</div>
</div>
<div class="ciy-form col-24 col-sm-24">
<label class="lang">待签数据</label>
<div id="id_hash"></div>
</div>
<div class="ciy-form col-24 col-sm-24">
<label class="lang">签名</label>
<div>
<ciy-textarea com="sign" minheight="10em" />
</div>
</div>
<div class="ciy-form col-24 col-sm-24">
<div class="ciy-tip">
<div><kbd>签名算法</kbd>RSA  <kbd>填充方式</kbd>RSASSA-PKCS1-v1.5  <kbd>秘钥格式</kbd>PEM PKCS#8  <kbd>签名输出格式</kbd>HEX</div>
<div>生成私钥命令行 <code>openssl genpkey -algorithm RSA -out pri.pem -pkeyopt rsa_keygen_bits:2048</code></div>
<div>提取公钥命令行 <code>openssl rsa -in pri.pem -pubout -out pub.pem</code></div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="/jscss/ciy.js"></script>
<script type="text/javascript" src="/jscss/ciycmp.js"></script>
<script type="text/javascript" src="/jscss/ciytable.js"></script>
<script type="text/javascript" src="../common.js"></script>
<script type="text/javascript">
'use strict';
var table;
var Glob = {};
ciyfn.pageload(function () {
//Glob.urlp = ciyfn.urlparam();
table = new ciyclass.table({
dom: '.table'
, url: 'list'
, pagecount: 10
, fn_beforedata: function (json) {
ciyfn.fillsearch({
searchdom: '.search'
, data: json
});
return json;
}
, fn_tdcontent: function (key, datashow, field, data) {
if (key == '_btn') {
var html = '';
html += `<a class="lang btn" onclick="menubtn(this, 'edit')">设置</a>`;
html += `<a class="lang btn warn" onclick="menubtn(this, 'rekey')">重置ApiKey</a>`;
html += `<a class="lang btn dag" onclick="menubtn(this, 'del')">删除</a>`;
return html;
}
if (key == 'pubkey') {
if(data[key] == '')
return '<a class="lang btn" onclick="menubtn(this, \'pubkey\')">安装证书</a>';
return '已安装';
}
if (key == 'msg') {
if(data['apisecret'] == '')
return '<a class="lang btn def" onclick="menubtn(this, \'qa\')">质量分析</a> 接入质量较低已经暂停API请重置ApiKey恢复';
else
return '正常';
}
}
, fn_done: function (json) {
// table.mergecol('auditstatus');
// table.mergefix('总计', 'center', 6, 0, 8, 1);
// table.footertotal();
}
});
table.callpage(1);
});
async function menubtn(dom, btn) {
var id = $5(dom).parent('tr').attr('data-id');
if (btn == 'pubkey') {
var oridata = 'CIY' + tostamp();
var hash = await ciyfn.sha256(oridata);
ciyfn.alert({
title: '安装证书'
, width: 'pc'
, content: document.getElementById("alert_pubkey").innerHTML
, fn_showed: function (doc, dom) {
var dat = table.data[id];
ciycmp({ dom: $5('[com=pubkey]', dom) });
ciycmp({ dom: $5('[com=sign]', dom) });
$5('#id_hash', dom).html(hash);
}
, cb: function (opn) {
if (opn.btn == "关闭")
return opn.close();
opn.inputs.id = id;
opn.inputs.oridata = oridata;
opn.inputs.hash = hash;
if (ciyfn.throttle(opn.dombtn)) return;
ciyfn.callfunc('pubkey', opn.inputs, function (json) {
table.updateline(json);
opn.close();
ciyfn.toast('设置成功');
});
},
btns: ["提交", "*关闭"],
});
}
if (btn == 'edit') {
ciyfn.alert({
title: '设置'
, width: 'mb'
, content: document.getElementById("alert_edit").innerHTML
//, noparent:true
, fn_showed: function (doc, dom) {
var dat = table.data[id];
ciycmp({ dom: $5('[com=ips]', dom), value: dat.ips });
}
, cb: function (opn) {
if (opn.btn == "关闭")
return opn.close();
opn.inputs.id = id;
if (ciyfn.throttle(opn.dombtn)) return;
ciyfn.callfunc('edit', opn.inputs, function (json) {
table.updateline(json);
opn.close();
ciyfn.toast('提交成功');
});
},
btns: ["提交", "*关闭"],
});
}
if (btn == 'rekey') {
ciyfn.alert({
content: '是否重置appkey<br/>重置后原appkey不可用'
, btns: ["重置", '*关闭']
, cb: function (opn) {
if (opn.btn == '关闭')
return opn.close();
ciyfn.callfunc("rekey", { id: id }, function (json) {
ciyfn.alert('appid: <kbd>' + id + '</kbd><br/>appkey: <kbd>' + json.secret + '</kbd><br/>平台将不再显示,请妥善保管!');
opn.close();
});
}
});
}
if (btn == 'del') {
ciyfn.callfastfunc(dom, '是否删除?', 'del', { ids: id }, function (json) { table.delline(json) });
}
}
function getdata(id, act, cb) {
cb({ data: id == 0 ? {} : table.data[id] });
}
function addnew() {
ciyfn.alert({
content: '确认新建一条API通道'
, btns: ["新建", '*关闭']
, cb: function (opn) {
if (opn.btn == '关闭')
return opn.close();
ciyfn.callfunc("addnew", {}, function (json) {
ciyfn.alert('appid: <kbd>' + json.data.id + '</kbd><br/>appkey: <kbd>' + json.data.apisecret + '</kbd><br/>请妥善保管!');
table.updateline(json);
opn.close();
});
}
});
}
function edit(id) {
} </script>
</body>
</html>