Initial YakPanel commit
This commit is contained in:
1339
YakPanel/static/amd/config.js
Normal file
1339
YakPanel/static/amd/config.js
Normal file
File diff suppressed because it is too large
Load Diff
101
YakPanel/static/amd/configMixin.js
Normal file
101
YakPanel/static/amd/configMixin.js
Normal file
@@ -0,0 +1,101 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
define(["require", "exports", "./public/public"], function (require, exports, public_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
public_1 = __importDefault(public_1);
|
||||
var ConfigMixin = (function (_super) {
|
||||
__extends(ConfigMixin, _super);
|
||||
function ConfigMixin() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
ConfigMixin.prototype.renderFormColumn = function (configInfo) {
|
||||
for (var key in configInfo) {
|
||||
if (Object.prototype.hasOwnProperty.call(configInfo, key)) {
|
||||
var value = configInfo[key].value;
|
||||
var el = $('input[name="' + key + '"]');
|
||||
var type = el.attr('type');
|
||||
if (type === 'checkbox') {
|
||||
el.prop('checked', value);
|
||||
}
|
||||
else {
|
||||
el.val(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
ConfigMixin.prototype.showCheckboxConfirm = function (data) {
|
||||
var _this = this;
|
||||
var e = data.e, api = data.api, config = data.config, param = data.data;
|
||||
return new Promise(function (resolve, reject) {
|
||||
_this.$confirm(__assign({}, config)).then(function (res) {
|
||||
return _this.changeCheckbox(e, api, param);
|
||||
}).then(function (res) {
|
||||
resolve(res);
|
||||
}).catch(function (err) {
|
||||
_this.changeReverseCheckbox(e);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
ConfigMixin.prototype.changeCheckbox = function (e, api, data) {
|
||||
var _this = this;
|
||||
if (data === void 0) { data = {}; }
|
||||
return new Promise(function (resolve, reject) {
|
||||
_this.$request(api, data).then(function (res) {
|
||||
if (res.status) {
|
||||
resolve(res);
|
||||
}
|
||||
else {
|
||||
throw new Error(res);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
_this.changeReverseCheckbox(e);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
ConfigMixin.prototype.changeReverseCheckbox = function (e) {
|
||||
var $this = $(e.target);
|
||||
var checked = !$this.prop('checked');
|
||||
$this.prop('checked', checked);
|
||||
};
|
||||
ConfigMixin.prototype.setLayerVerticalCenter = function (layero) {
|
||||
var window_height = $(window).height();
|
||||
var height = layero.height();
|
||||
var top = (window_height - height) / 2;
|
||||
layero.css({
|
||||
'top': top + 'px'
|
||||
});
|
||||
};
|
||||
return ConfigMixin;
|
||||
}(public_1.default));
|
||||
exports.default = ConfigMixin;
|
||||
});
|
||||
68
YakPanel/static/amd/main.js
Normal file
68
YakPanel/static/amd/main.js
Normal file
@@ -0,0 +1,68 @@
|
||||
// noinspection ES6ConvertVarToLetConst
|
||||
|
||||
/*
|
||||
* @Description: Require.js主配置文件
|
||||
* @Version: 1.0
|
||||
* @Autor: chudong
|
||||
* @Date: 2021-11-30 09:59:13
|
||||
* @LastEditors: chudong
|
||||
* @LastEditTime: 2021-12-05 22:59:36
|
||||
*/
|
||||
require.config({
|
||||
paths: {
|
||||
"jquery": "../js/jquery-2.2.4.min", // Jquery
|
||||
"layer": "../layer/layer", // 弹窗
|
||||
"utils": "./utils.min", // 工具库
|
||||
"home": "home", // 首页代码
|
||||
"site": "site", // 站点代码
|
||||
"ftp": "ftp", // ftp代码
|
||||
"database": "database", // 数据库代码
|
||||
"control": "control", // 监控
|
||||
"firewall": "firewall", // 系统安全
|
||||
"files": "files", // 文件管理
|
||||
"xterm": "xterm", // 终端管理
|
||||
"crontab": "crontab", // 计划任务
|
||||
"soft": "soft", // 软件管理
|
||||
"config": "config", // 面板设置
|
||||
"jquery.qrcode": "../js/jquery.qrcode.min", // 二维码
|
||||
"language": "../language/English/lan", // 语言包
|
||||
"clipboard": "../js/clipboard.min", // 复制
|
||||
"polyfill": "../vue/polyfill.min"
|
||||
},
|
||||
shim: {
|
||||
"language": {
|
||||
exports: "lan"
|
||||
},
|
||||
"jquery.qrcode": { // 二维码插件
|
||||
deps: ["jquery"],
|
||||
exports: "jQuery.fn.qrcode"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var requestList = ['jquery', 'layer', 'language']
|
||||
var detectBrowser = function () {
|
||||
var userAgent = navigator.userAgent,
|
||||
isLessIE11 = userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1,
|
||||
isEdge = userAgent.indexOf('Edge') > -1 && !isLessIE11,
|
||||
isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf('rv:11.0') > -1,
|
||||
IEVersionNum = 0
|
||||
if (isLessIE11) {
|
||||
var IEReg = new RegExp('MSIE (\\d+\\.\\d+);');
|
||||
IEReg.test(userAgent);
|
||||
IEVersionNum = parseFloat(RegExp['$1'])
|
||||
}
|
||||
if (IEVersionNum >= 10 || isEdge || isIE11) requestList.push('polyfill')
|
||||
}
|
||||
detectBrowser()
|
||||
requestList.push('utils')
|
||||
require(requestList, function () {
|
||||
switch (location.pathname) {
|
||||
case "/config":
|
||||
require(['config'], function (param1) {
|
||||
var Config = param1['Config']
|
||||
new Config()
|
||||
})
|
||||
break
|
||||
}
|
||||
})
|
||||
372
YakPanel/static/amd/noticeConfig.js
Normal file
372
YakPanel/static/amd/noticeConfig.js
Normal file
@@ -0,0 +1,372 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
define(["require", "exports", "./public/public"], function (require, exports, public_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
public_1 = __importDefault(public_1);
|
||||
var NoticeConfig = (function (_super) {
|
||||
__extends(NoticeConfig, _super);
|
||||
function NoticeConfig() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.apiInfo = {
|
||||
getLoginAlarm: ['config/get_login_send', 'Getting login information, please wait...'],
|
||||
setLoginAlarm: ['config/set_login_send', lan.public.the],
|
||||
clearLoginAlarm: ['config/clear_login_send', lan.public.the],
|
||||
loginIpwhite: ['config/login_ipwhite', lan.public.the],
|
||||
};
|
||||
_this.info = {};
|
||||
_this.$apiInit(_this.apiInfo);
|
||||
return _this;
|
||||
}
|
||||
NoticeConfig.prototype.init = function (data) {
|
||||
var messageChannelInfo = data.messageChannelInfo, loginAlarmInfo = data.loginAlarmInfo;
|
||||
var setName = loginAlarmInfo.msg;
|
||||
var isSet = false;
|
||||
for (var key in messageChannelInfo) {
|
||||
var item = messageChannelInfo[key];
|
||||
if (!$.isEmptyObject(item.data) && item.name == setName) {
|
||||
isSet = true;
|
||||
this.setLinkText('.setAlarmMail', "".concat(item.title, " configured"), 'btlink');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSet)
|
||||
this.setLinkText('.setAlarmMail', "Not configured", 'bt_warning');
|
||||
this.info = { messageChannelInfo: messageChannelInfo, loginAlarmInfo: loginAlarmInfo };
|
||||
};
|
||||
NoticeConfig.prototype.event = function () {
|
||||
var _this = this;
|
||||
$('.setAlarmMail, .setAlarmMailBtn').click(function () { return _this.setAlarmView(); });
|
||||
};
|
||||
NoticeConfig.prototype.setAlarmView = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var config, messageChannelInfo, isSet, key, item, error_1;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
config = this.info;
|
||||
messageChannelInfo = config.messageChannelInfo;
|
||||
isSet = false;
|
||||
for (key in messageChannelInfo) {
|
||||
item = messageChannelInfo[key];
|
||||
if (!$.isEmptyObject(item.data)) {
|
||||
isSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSet)
|
||||
return [2, this.$msg({ msg: 'Please configure at least one alarm module in [Alarm > Alarm Settings].', icon: 2 })];
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4, this.$open({
|
||||
area: ['800px', '540px'],
|
||||
title: 'Login panel alarm',
|
||||
content: "\n <div class=\"bt-w-main\" style=\"height: 498px\">\n <div class=\"bt-w-menu\" style=\"width: 140px;\">\n <p class=\"bgw\">Alarm settings</p>\n <p>IP whitelist</p>\n </div>\n <div class=\"bt-w-con pd15\" style=\"margin-left: 140px; height: 100%;\">\n <div class=\"plugin_body\">\n <div class=\"conter_box news-channel active\">\n <div class=\"bt-form-new inline\"></div> <div class=\"mt10 divtable\" id=\"config_server_table\">\n <div>\n <table class=\"table table-hover\" width=\"100%\">\n <thead>\n <tr>\n <th>Login info</th>\n <th class=\"text-right\" width=\"150\">Time</th>\n </tr>\n </thead>\n <tbody id=\"server_table\">\n <tr>\n <td class=\"text-center\" colspan=\"2\">No Data</td>\n </tr>\n </tbody>\n </table>\n </div>\n <div class=\"page\" id=\"server_table_page\"></div>\n </div>\n <ul class=\"help-info-text c7\" style=\"position: absolute; bottom: 15px; left: 15px;\">\n <li></li>\n </ul>\n </div>\n <div class=\"conter_box\" style=\"display:none;height:440px\">\n <div class=\"bt-form\">\n <div class=\"box\" style=\"display:inline-block;\">\n <input name=\"ip_write\" class=\"bt-input-text mr5\" type=\"text\" style=\"width: 220px;\" placeholder=\"Please enter the IP\" />\n <button class=\"btn btn-success btn-sm add_ip_write\">Add</button>\n </div>\n <div class=\"pull-right\">\n <button class=\"btn btn-default btn-sm text-right clear_all\">Clean All</button>\n </div>\n <div class=\"divtable mt10\">\n <table id=\"ip_write_table\" class=\"table table-hover\" width=\"100%\">\n <thead>\n <tr>\n <th width=\"60%\">IP</th>\n <th width=\"40%\" class=\"text-right\">Opt</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td class=\"text-center\" colspan=\"2\">No Data</td>\n </tr>\n </tbody>\n </table>\n </div>\n <ul class=\"help-info-text c7\" style=\"position: absolute; bottom: 15px; left: 15px;\">\n <li>Only allow to set ipv4 whitelist</li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n </div>",
|
||||
success: function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
$('.bt-w-menu p').on('click', function (ev) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var el, index;
|
||||
return __generator(this, function (_a) {
|
||||
el = $(ev.target), index = el.index();
|
||||
el.addClass('bgw').siblings().removeClass('bgw');
|
||||
switch (index) {
|
||||
case 0:
|
||||
this.renderAlarmConfig();
|
||||
this.reanderLoginTable();
|
||||
break;
|
||||
case 1:
|
||||
this.reanderLoginIpTable();
|
||||
break;
|
||||
}
|
||||
$('.conter_box').eq(index).show().siblings().hide();
|
||||
return [2];
|
||||
});
|
||||
}); });
|
||||
$('.news-channel .bt-form-new').on('change', 'input[type="checkbox"]', function (ev) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var $el, checked, type, name_1, res, error_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
$el = $(ev.currentTarget);
|
||||
checked = $el.prop('checked');
|
||||
type = $el.attr('name');
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
name_1 = checked ? 'setLoginAlarm' : 'clearLoginAlarm';
|
||||
return [4, this.$request(name_1, { type: type })];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
if (!res.status) {
|
||||
throw new Error(res);
|
||||
}
|
||||
if (checked) {
|
||||
$('.news-channel .btswitch').prop('checked', false);
|
||||
$el.prop('checked', true);
|
||||
config.loginAlarmInfo.msg = type;
|
||||
}
|
||||
else {
|
||||
config.loginAlarmInfo.msg = '';
|
||||
}
|
||||
this.init(config);
|
||||
return [3, 4];
|
||||
case 3:
|
||||
error_2 = _a.sent();
|
||||
$el.prop('checked', !checked);
|
||||
return [3, 4];
|
||||
case 4: return [2];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
$('.add_ip_write').click(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var ip_write, ip, res, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 3, , 4]);
|
||||
ip_write = $('[name="ip_write"]');
|
||||
ip = ip_write.val();
|
||||
return [4, this.$verifySubmit(!this.$checkIp(ip), 'Please enter the correct IP')];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [4, this.$request('loginIpwhite', { ip: ip, type: 'add' })];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
if (!res.status)
|
||||
return [2];
|
||||
this.$delay();
|
||||
this.reanderLoginIpTable();
|
||||
ip_write.val('');
|
||||
return [3, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
return [3, 4];
|
||||
case 4: return [2];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
$('input[name="ip_write"]').keyup(function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
$('.add_ip_write').click();
|
||||
}
|
||||
});
|
||||
$('#ip_write_table').on('click', '.del_ip_write', function (ev) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var that, ip, res, err_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
that = $(ev.target);
|
||||
ip = that.data('ip');
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 4, , 5]);
|
||||
return [4, this.$confirm({ title: 'Delete IP whitelist', msg: "Delete the IP whitelist [".concat(ip, "] and continue the operation?") })];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [4, this.$request('loginIpwhite', { ip: ip, type: 'del' })];
|
||||
case 3:
|
||||
res = _a.sent();
|
||||
if (!res.status)
|
||||
return [2];
|
||||
this.$delay();
|
||||
this.reanderLoginIpTable();
|
||||
return [3, 5];
|
||||
case 4:
|
||||
err_2 = _a.sent();
|
||||
return [3, 5];
|
||||
case 5: return [2];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
$('.clear_all').click(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var res, err_3;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 3, , 4]);
|
||||
return [4, this.$confirm({ title: 'Tips', msg: 'Whether to clear the IP whitelist?' })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [4, this.$request('loginIpwhite', { type: 'clear' })];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
if (!res.status)
|
||||
return [2];
|
||||
this.$delay();
|
||||
this.reanderLoginIpTable();
|
||||
return [3, 4];
|
||||
case 3:
|
||||
err_3 = _a.sent();
|
||||
return [3, 4];
|
||||
case 4: return [2];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
$('#server_table_page').on('click', 'a', function (ev) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var page;
|
||||
return __generator(this, function (_a) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
page = $(ev.target)
|
||||
.attr('href')
|
||||
.match(/p=([0-9]*)/)[1];
|
||||
this.reanderLoginTable(page);
|
||||
return [2];
|
||||
});
|
||||
}); });
|
||||
this.fixedTableHead('#config_server_table table', '348px');
|
||||
this.fixedTableHead('#ip_write_table', '396px');
|
||||
$('.bt-w-menu p').eq(0).click();
|
||||
return [2];
|
||||
});
|
||||
}); },
|
||||
})];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [3, 4];
|
||||
case 3:
|
||||
error_1 = _a.sent();
|
||||
return [3, 4];
|
||||
case 4: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
NoticeConfig.prototype.renderAlarmConfig = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, alarms, send, html, tits, cKey;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
return [4, Promise.all([this.$request(['config/get_msg_configs'], { loading: false, msg: false }), this.$request(['config/get_login_send'], { loading: false, msg: false })])];
|
||||
case 1:
|
||||
_a = _b.sent(), alarms = _a[0], send = _a[1];
|
||||
html = '';
|
||||
tits = [];
|
||||
cKey = send.msg;
|
||||
$.each(alarms, function (key, item) {
|
||||
var checked = cKey === item.name ? 'checked="checked"' : '';
|
||||
var title = item.title;
|
||||
html += "\n\t\t\t<div class=\"form-item\">\n\t\t\t\t<div class=\"form-label\" style=\"padding-right: 10px;\">Send to ".concat(title, "</div>\n\t\t\t\t<div class=\"form-content\">\n\t\t\t\t\t<input type=\"checkbox\" id=\"").concat(item.name, "_alarm\" class=\"btswitch btswitch-ios\" name=\"").concat(item.name, "\" ").concat(checked, " />\t\t\t\t\t<label class=\"btswitch-btn\" for=\"").concat(item.name, "_alarm\"></label>\n\t\t\t\t</div>\n\t\t\t</div>");
|
||||
tits.push(title);
|
||||
});
|
||||
$('.news-channel .bt-form-new').html(html);
|
||||
$('.news-channel .help-info-text li')
|
||||
.eq(0)
|
||||
.text("".concat(tits.join('/'), " can only open one at the same time"));
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
NoticeConfig.prototype.reanderLoginTable = function (p) {
|
||||
if (p === void 0) { p = 1; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var rdata, html, i, item;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4, this.$request(['config/get_login_log', 'Getting Logs list, please wait'], { p: p, limit: 4 })];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
if (!rdata.data)
|
||||
return [2, false];
|
||||
html = '';
|
||||
$('#server_table').empty();
|
||||
for (i = 0; i < rdata.data.length; i++) {
|
||||
item = rdata.data[i];
|
||||
html += "<tr>\n <td>\n <span title=\"".concat(item.log, "\">").concat(item.log, "</span>\n </td>\n <td class=\"text-right\">").concat(item.addtime, "</td>\n </tr>");
|
||||
}
|
||||
!html && (html = "<tr><td class=\"text-center\" colspan=\"2\">No Data</td></tr>");
|
||||
$('#server_table').html(html);
|
||||
$('#server_table_page').html(rdata.page);
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
NoticeConfig.prototype.reanderLoginIpTable = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var rdata, list, html, i, item, err_4;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4, this.$request('loginIpwhite', { type: 'get' })];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
list = rdata.msg;
|
||||
html = '';
|
||||
for (i = 0; i < list.length; i++) {
|
||||
item = list[i];
|
||||
html += "<tr>\n <td>".concat(item, "</td>\n <td class=\"text-right\">\n <a href=\"javascript:;\" class=\"btlink red del_ip_write\" data-ip=\"").concat(item, "\">Del</a>\n </td>\n </tr>");
|
||||
}
|
||||
!html && (html = "<tr><td colspan=\"2\" class=\"text-center\">No Data</td></tr>");
|
||||
$('#ip_write_table tbody').html(html);
|
||||
return [3, 3];
|
||||
case 2:
|
||||
err_4 = _a.sent();
|
||||
return [3, 3];
|
||||
case 3: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return NoticeConfig;
|
||||
}(public_1.default));
|
||||
exports.default = NoticeConfig;
|
||||
});
|
||||
831
YakPanel/static/amd/panelConfig.js
Normal file
831
YakPanel/static/amd/panelConfig.js
Normal file
@@ -0,0 +1,831 @@
|
||||
var __extends =
|
||||
(this && this.__extends) ||
|
||||
(function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics =
|
||||
Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array &&
|
||||
function (d, b) {
|
||||
d.__proto__ = b;
|
||||
}) ||
|
||||
function (d, b) {
|
||||
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
||||
};
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== 'function' && b !== null) throw new TypeError('Class extends value ' + String(b) + ' is not a constructor or null');
|
||||
extendStatics(d, b);
|
||||
function __() {
|
||||
this.constructor = d;
|
||||
}
|
||||
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter =
|
||||
(this && this.__awaiter) ||
|
||||
function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) {
|
||||
return value instanceof P
|
||||
? value
|
||||
: new P(function (resolve) {
|
||||
resolve(value);
|
||||
});
|
||||
}
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
}
|
||||
function rejected(value) {
|
||||
try {
|
||||
step(generator['throw'](value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
}
|
||||
function step(result) {
|
||||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
||||
}
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator =
|
||||
(this && this.__generator) ||
|
||||
function (thisArg, body) {
|
||||
var _ = {
|
||||
label: 0,
|
||||
sent: function () {
|
||||
if (t[0] & 1) throw t[1];
|
||||
return t[1];
|
||||
},
|
||||
trys: [],
|
||||
ops: [],
|
||||
},
|
||||
f,
|
||||
y,
|
||||
t,
|
||||
g;
|
||||
return (
|
||||
(g = { next: verb(0), throw: verb(1), return: verb(2) }),
|
||||
typeof Symbol === 'function' &&
|
||||
(g[Symbol.iterator] = function () {
|
||||
return this;
|
||||
}),
|
||||
g
|
||||
);
|
||||
function verb(n) {
|
||||
return function (v) {
|
||||
return step([n, v]);
|
||||
};
|
||||
}
|
||||
function step(op) {
|
||||
if (f) throw new TypeError('Generator is already executing.');
|
||||
while (_)
|
||||
try {
|
||||
if (((f = 1), y && (t = op[0] & 2 ? y['return'] : op[0] ? y['throw'] || ((t = y['return']) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)) return t;
|
||||
if (((y = 0), t)) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0:
|
||||
case 1:
|
||||
t = op;
|
||||
break;
|
||||
case 4:
|
||||
_.label++;
|
||||
return { value: op[1], done: false };
|
||||
case 5:
|
||||
_.label++;
|
||||
y = op[1];
|
||||
op = [0];
|
||||
continue;
|
||||
case 7:
|
||||
op = _.ops.pop();
|
||||
_.trys.pop();
|
||||
continue;
|
||||
default:
|
||||
if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) {
|
||||
_ = 0;
|
||||
continue;
|
||||
}
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
||||
_.label = op[1];
|
||||
break;
|
||||
}
|
||||
if (op[0] === 6 && _.label < t[1]) {
|
||||
_.label = t[1];
|
||||
t = op;
|
||||
break;
|
||||
}
|
||||
if (t && _.label < t[2]) {
|
||||
_.label = t[2];
|
||||
_.ops.push(op);
|
||||
break;
|
||||
}
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop();
|
||||
continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) {
|
||||
op = [6, e];
|
||||
y = 0;
|
||||
} finally {
|
||||
f = t = 0;
|
||||
}
|
||||
if (op[0] & 5) throw op[1];
|
||||
return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importDefault =
|
||||
(this && this.__importDefault) ||
|
||||
function (mod) {
|
||||
return mod && mod.__esModule ? mod : { default: mod };
|
||||
};
|
||||
define(['require', 'exports', './snabbdom', './configMixin'], function (require, exports, snabbdom_1, configMixin_1) {
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
configMixin_1 = __importDefault(configMixin_1);
|
||||
var PanelConfig = (function (_super) {
|
||||
__extends(PanelConfig, _super);
|
||||
function PanelConfig() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.apiInfo = {
|
||||
closePanel: ['config/ClosePanel', lan.public.the],
|
||||
setIpv6Status: ['config/set_ipv6_status', lan.config.setting_up],
|
||||
setLocal: ['config/set_local', lan.public.the],
|
||||
setDebug: ['config/set_debug', lan.public.the],
|
||||
getToken: ['config/get_token', lan.config.get_api],
|
||||
setToken: ['config/set_token', lan.config.is_submitting],
|
||||
setUserName: ['config/setUsername', lan.public.the],
|
||||
setPassword: ['config/setPassword', lan.public.the],
|
||||
setLanguage: ['config/set_language', lan.public.the],
|
||||
downloadLanguage: ['config/download_language', lan.public.the],
|
||||
uploadLanguage: ['config/upload_language', lan.public.the],
|
||||
getMenuList: ['config/get_menu_list', 'Getting panel menu bar, please wait...'],
|
||||
setHideMenuList: ['config/set_hide_menu_list', 'Setting panel menu bar display status, please wait...'],
|
||||
};
|
||||
_this.$apiInit(_this.apiInfo);
|
||||
return _this;
|
||||
}
|
||||
PanelConfig.prototype.init = function (data) {
|
||||
var configInfo = data.configInfo,
|
||||
menuList = data.menuList,
|
||||
bindUserInfo = data.bindUserInfo;
|
||||
var ipv6 = configInfo.ipv6,
|
||||
is_local = configInfo.is_local,
|
||||
debug = configInfo.debug,
|
||||
api = configInfo.api,
|
||||
session_timeout = configInfo.session_timeout,
|
||||
sites_path = configInfo.sites_path,
|
||||
backup_path = configInfo.backup_path,
|
||||
panel = configInfo.panel,
|
||||
systemdate = configInfo.systemdate;
|
||||
var address = (panel || {}).address;
|
||||
var bindUserStatus = bindUserInfo.status,
|
||||
bindUsername = bindUserInfo.data.username;
|
||||
var username = sessionInfo.username,
|
||||
webname = sessionInfo.title;
|
||||
var hideMenuList = [];
|
||||
menuList.forEach(function (item) {
|
||||
return !item.show && hideMenuList.push(item.title);
|
||||
});
|
||||
var hideMenuValue = hideMenuList.length > 0 ? hideMenuList.join(', ') : 'No hidden bar';
|
||||
var formColumns = {
|
||||
ipv6: { value: ipv6 === 'checked' },
|
||||
is_local: { value: is_local === 'checked' },
|
||||
debug: { value: debug === 'checked' },
|
||||
api: { value: api === 'checked' },
|
||||
webname: { value: webname },
|
||||
session_timeout: { value: session_timeout },
|
||||
sites_path: { value: sites_path },
|
||||
backup_path: { value: backup_path },
|
||||
address: { value: address },
|
||||
systemdate: { value: systemdate },
|
||||
username: { value: username },
|
||||
password: { value: '********' },
|
||||
bind_user_info: { value: bindUsername },
|
||||
menu_hide_list: { value: hideMenuValue },
|
||||
};
|
||||
this.renderFormColumn(formColumns);
|
||||
$('.seconds').text(session_timeout || 0);
|
||||
this.bindUsername = bindUserStatus ? bindUsername : '';
|
||||
|
||||
var selectHtml = '';
|
||||
$.each(configInfo.language_list, function (index, item) {
|
||||
selectHtml += `<option value="${item.name}">${item.title}</option>`;
|
||||
});
|
||||
$('select[name="language"]').html(selectHtml);
|
||||
$('select[name="language"]').val(configInfo.language);
|
||||
};
|
||||
PanelConfig.prototype.event = function () {
|
||||
var _this = this;
|
||||
$('input[name="close_panel"]').change(function (e) {
|
||||
var title = lan.config.close_panel_title;
|
||||
var msg = lan.config.close_panel_msg;
|
||||
var api = 'closePanel';
|
||||
_this
|
||||
.showCheckboxConfirm({
|
||||
e: e,
|
||||
api: api,
|
||||
config: { title: title, msg: msg },
|
||||
})
|
||||
.then(function (res) {
|
||||
_this.$refreshBrowser();
|
||||
})
|
||||
.catch(function (err) {});
|
||||
});
|
||||
$('input[name="ipv6"]').change(function (e) {
|
||||
_this.changeCheckbox(e, 'setIpv6Status').catch(function (err) {});
|
||||
});
|
||||
$('input[name="is_local"]').change(function (e) {
|
||||
var checked = $(e.target).prop('checked');
|
||||
var title = ''.concat(checked ? 'Open' : 'Close', ' developer mode');
|
||||
var msg = 'Do you confirm to '.concat(checked ? 'open' : 'close', ' developer mode?');
|
||||
var api = 'setLocal';
|
||||
_this.showCheckboxConfirm({ e: e, api: api, config: { title: title, msg: msg } }).catch(function (err) {});
|
||||
});
|
||||
$('input[name="debug"]').change(function (e) {
|
||||
var checked = $(e.target).prop('checked');
|
||||
if (checked) {
|
||||
_this.setDeveloperView(e);
|
||||
} else {
|
||||
var title = 'Close developer mode';
|
||||
var msg = 'Do you confirm to close developer mode?';
|
||||
var api = 'setDebug';
|
||||
_this
|
||||
.showCheckboxConfirm({
|
||||
e: e,
|
||||
api: api,
|
||||
config: { title: title, msg: msg },
|
||||
})
|
||||
.catch(function (err) {});
|
||||
}
|
||||
});
|
||||
$('input[name="api"]').change(function (e) {
|
||||
var checked = $(e.target).prop('checked');
|
||||
if (checked) {
|
||||
_this.setPanelApiView(checked);
|
||||
_this.$request('setToken', { t_type: 1 });
|
||||
} else {
|
||||
_this.changeCheckbox(e, 'setToken', { t_type: 2 }).catch(function (err) {});
|
||||
}
|
||||
});
|
||||
$('.sitesPath').on('click', function () {
|
||||
return _this.selectFileDir('input[name="sites_path"]', 'dir', function () {});
|
||||
});
|
||||
$('.backupPath').on('click', function () {
|
||||
return _this.selectFileDir('input[name="backup_path"]', 'dir', function () {});
|
||||
});
|
||||
$('.apiInterfaceBtn').click(function () {
|
||||
return _this.setPanelApiView();
|
||||
});
|
||||
$('.editPanelAccount').click(function () {
|
||||
return _this.setPanelUserView();
|
||||
});
|
||||
$('.editPanelPassword').click(function () {
|
||||
return _this.setPanelPawView();
|
||||
});
|
||||
$('.bindBtUser').click(function () {
|
||||
return _this.bindBtAccount(!!_this.bindUsername);
|
||||
});
|
||||
$('.unbindBtUser').click(function () {
|
||||
return _this.unbindUser();
|
||||
});
|
||||
$('.menuBarManage').click(function () {
|
||||
return _this.setPanelGroundView();
|
||||
});
|
||||
|
||||
$('select[name="language"]').change(function () {
|
||||
var $select = $(this);
|
||||
var lang = $select.val();
|
||||
_this.$request('setLanguage', { name: lang }).then(function (res) {
|
||||
if (res.status) {
|
||||
_this.$refreshBrowser(3000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 上传语言包弹框
|
||||
$('.uploadLanguage').click(function () {
|
||||
_this.$open({
|
||||
title: 'Upload my translation file',
|
||||
area: ['500px', '224px'],
|
||||
content: `
|
||||
<div style="padding: 24px;">
|
||||
<ul class="help-info-text explainDescribeList c7 pd15" style="margin-top: 0; margin-bottom: 0;">
|
||||
<li>Upload my language pack and apply it immediately</li>
|
||||
<li>Note: The uploaded language pack will be displayed as [Custom]</li>
|
||||
</ul>
|
||||
</div>
|
||||
`,
|
||||
btn: ['Upload', lan.public.cancel],
|
||||
yes: function () {
|
||||
var path = '/www/server/panel/YakPanel/static/upload_language';
|
||||
bt_upload_file.open(path, '.gz,.tar,.tar.gz,.zip', 'Upload tar.gz package', function () {
|
||||
var filePath = $('#file_input').val();
|
||||
var fileName = filePath.split('\\').pop().split('/').pop();
|
||||
$('#filesClose').click();
|
||||
_this.$request('uploadLanguage', { filename: fileName }).then(function (res) {
|
||||
if (res.status) {
|
||||
_this.$refreshBrowser(3000);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// 下载语言包弹框
|
||||
$('.downloadLanguage').click(function () {
|
||||
_this.$open({
|
||||
title: false,
|
||||
area: ['520px', '240px'],
|
||||
content: `
|
||||
<div style="padding-top: 40px;">
|
||||
<div style="margin-bottom: 20px; text-align: center; font-size: 14px;">You will download a language pack template that you can translate:</div>
|
||||
<div style="margin-bottom: 40px; text-align: center;">
|
||||
<button type="button" class="btn btn-success btn-sm download-btn">
|
||||
Download template
|
||||
</button>
|
||||
</div>
|
||||
<div style="text-align: center; font-size: 14px;">
|
||||
<div style="margin-bottom: 8px;">Translation Tools: </div>
|
||||
<div>
|
||||
<a class="btlink" href="https://translate.google.com/" target="_blank">Google Translate</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
success: function () {
|
||||
$('.download-btn').click(function () {
|
||||
_this.$request('downloadLanguage').then(function (res) {
|
||||
if (res.path) {
|
||||
window.open(`/download?filename=${res.path}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
PanelConfig.prototype.setDeveloperView = function (event) {
|
||||
var _this = this;
|
||||
this.$open({
|
||||
title: 'Turn on developer mode',
|
||||
area: ['460px', '340px'],
|
||||
btn: [lan.public.submit, lan.public.cancel],
|
||||
content: {
|
||||
data: { agreement: false },
|
||||
template: function () {
|
||||
return (0, snabbdom_1.jsx)(
|
||||
'div',
|
||||
{ class: this.$class('bt-form pd25') },
|
||||
this.$warningTitle('Risk ordinary users do not open!'),
|
||||
this.$ul({ className: 'explainDescribeList pd15' }, [
|
||||
['For development use only;', 'red'],
|
||||
['Please do not enable it in production environment;'],
|
||||
['It may take up a lot of memory after opening;'],
|
||||
]),
|
||||
this.$learnMore({ title: 'I understand and am willing to take the risk, confirm to open', model: 'agreement', id: 'checkDevelopers' })
|
||||
);
|
||||
},
|
||||
},
|
||||
yes: function (config) {
|
||||
return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, status;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
(close = config.close), (vm = config.vm);
|
||||
if (!vm.agreement) return [2, this.$tips({ msg: 'Please tick to understand the risk options', el: '#checkDevelopers' })];
|
||||
return [4, this.$request('setDebug')];
|
||||
case 1:
|
||||
status = _a.sent().status;
|
||||
if (status) {
|
||||
close();
|
||||
this.$refreshBrowser();
|
||||
}
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
cancel: function () {
|
||||
_this.changeReverseCheckbox(event);
|
||||
},
|
||||
btn2: function () {
|
||||
_this.changeReverseCheckbox(event);
|
||||
},
|
||||
}).catch(function (err) {});
|
||||
};
|
||||
PanelConfig.prototype.setPanelApiView = function (checked) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var that, $checked, rdata, error_1;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
that = this;
|
||||
$checked = $('input[name="api"]');
|
||||
return [4, this.$request('getToken')];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
_a.label = 2;
|
||||
case 2:
|
||||
_a.trys.push([2, 4, , 5]);
|
||||
return [
|
||||
4,
|
||||
this.$open({
|
||||
area: '522px',
|
||||
title: lan.config.set_api,
|
||||
content: {
|
||||
data: {
|
||||
api: typeof checked === 'undefined' ? rdata.open : checked,
|
||||
panelTokenValue: rdata.token,
|
||||
apiLimitAddr: rdata.limit_addr,
|
||||
},
|
||||
template: function () {
|
||||
var lineWidth = '125px',
|
||||
helpHref = 'https://www.yakpanel.com/forum/d/482-api-interface-tutorial';
|
||||
return (0, snabbdom_1.jsx)(
|
||||
'div',
|
||||
{ class: this.$class('bt-form'), style: this.$style('padding: 15px 25px;') },
|
||||
this.$line({ title: lan.config.api, width: lineWidth }, this.$switch({ model: 'api', change: this.setPanelApi.bind(this) })),
|
||||
this.$line(
|
||||
{ title: lan.config.int_sk, width: lineWidth },
|
||||
this.$box(
|
||||
this.$input({ model: 'panelTokenValue', disabled: true, style: { width: '310px' } }),
|
||||
this.$button({ size: 'xs', click: this.resetInterface.bind(this), style: 'margin-left: -56px;', title: lan.config.reset })
|
||||
)
|
||||
),
|
||||
this.$line(
|
||||
{
|
||||
title: (0, snabbdom_1.jsx)('span', null, lan.config.ip_white_list, (0, snabbdom_1.jsx)('br', null), '(', lan.config.one_per_line, ')'),
|
||||
width: lineWidth,
|
||||
style: 'overflow: initial;height:20px;line-height:20px;',
|
||||
},
|
||||
this.$textarea({ model: 'apiLimitAddr', style: 'width: 310px;height:80px;line-height: 20px;padding: 5px 8px;' })
|
||||
),
|
||||
this.$line({ title: '', width: lineWidth }, this.$button({ size: 'sm', click: this.savePanelApiIp.bind(this), title: lan.config.save })),
|
||||
this.$ul({ style: { marginLeft: '16px' } }, [
|
||||
[lan.config.help1],
|
||||
[lan.config.help2],
|
||||
[(0, snabbdom_1.jsx)('span', null, lan.config.help3, ': ', this.$link({ title: helpHref, href: helpHref }))],
|
||||
])
|
||||
);
|
||||
},
|
||||
methods: {
|
||||
setPanelApi: function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var res;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
return [4, that.$request('setToken', { t_type: 2 })];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (res.status) {
|
||||
$checked.prop('checked', this.api);
|
||||
} else {
|
||||
this.api = !this.api;
|
||||
}
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
resetInterface: function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
that
|
||||
.$confirm({
|
||||
title: 'Reset key',
|
||||
msg: 'Are you sure you want to reset your current key?<br><span style="color: red; ">After the key is reset, the associated key product will be invalid. Please re-add the new key to the product.</span>',
|
||||
})
|
||||
.then(function (res) {
|
||||
return that.$request('setToken', { t_type: 1 }, false);
|
||||
})
|
||||
.then(function (res) {
|
||||
if (res.status) {
|
||||
_this.panelTokenValue = res.msg;
|
||||
that.$msg({ msg: lan.config.create_int_key_success, time: 0, closeBtn: 2 });
|
||||
} else {
|
||||
throw new Error(res);
|
||||
}
|
||||
})
|
||||
.catch(function (err) {});
|
||||
return [2];
|
||||
});
|
||||
});
|
||||
},
|
||||
savePanelApiIp: function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
return [4, that.$request('setToken', { t_type: 3, limit_addr: this.apiLimitAddr })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
success: function (layers, indexs, vm) {
|
||||
return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
this.setLayerVerticalCenter(layers);
|
||||
$('.btswitch-btn').css('margin-bottom', '0');
|
||||
if (!(typeof checked === 'boolean' && checked)) return [3, 2];
|
||||
return [4, that.$request('setToken', { t_type: 2 })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
_a.label = 2;
|
||||
case 2:
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
}),
|
||||
];
|
||||
case 3:
|
||||
_a.sent();
|
||||
return [3, 5];
|
||||
case 4:
|
||||
error_1 = _a.sent();
|
||||
return [3, 5];
|
||||
case 5:
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
PanelConfig.prototype.setPanelUserView = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var error_2;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [
|
||||
4,
|
||||
this.$open({
|
||||
title: lan.bt.user_title,
|
||||
area: ['380px', '235px'],
|
||||
btn: [lan.public.edit, lan.public.close],
|
||||
content: {
|
||||
data: { username1: sessionInfo.username, username2: '' },
|
||||
template: function () {
|
||||
var lineWidth = '110px',
|
||||
inputWidth = '210px';
|
||||
return (0, snabbdom_1.jsx)(
|
||||
'div',
|
||||
{ class: this.$class('bt-form pd25') },
|
||||
this.$line({ title: lan.bt.user, width: lineWidth }, this.$input({ model: 'username1', width: inputWidth })),
|
||||
this.$line({ title: lan.bt.user_new, width: lineWidth }, this.$input({ model: 'username2', width: inputWidth }))
|
||||
);
|
||||
},
|
||||
},
|
||||
yes: function (config) {
|
||||
return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, username1, username2, weakCipher, rdata;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
(close = config.close), (vm = config.vm);
|
||||
(username1 = vm.username1), (username2 = vm.username2);
|
||||
weakCipher = ['admin', 'root', 'admin123', '123456'];
|
||||
return [
|
||||
4,
|
||||
this.$verifySubmitList([
|
||||
[username1.length <= 3, lan.bt.user_len],
|
||||
[weakCipher.indexOf(username1) > -1, lan.public.usually_username_ban],
|
||||
[username1 !== username2, lan.bt.user_err_re],
|
||||
]),
|
||||
];
|
||||
case 1:
|
||||
_a.sent();
|
||||
username1 = rsa.encrypt_public(encodeURIComponent(username1));
|
||||
username2 = rsa.encrypt_public(encodeURIComponent(username2));
|
||||
return [4, this.$request('setUserName', { username1: username1, username2: username2 })];
|
||||
case 2:
|
||||
rdata = _a.sent();
|
||||
rdata.status && close() && this.$refreshBrowser('/login?dologin=True');
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
}),
|
||||
];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [3, 3];
|
||||
case 2:
|
||||
error_2 = _a.sent();
|
||||
return [3, 3];
|
||||
case 3:
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
PanelConfig.prototype.setPanelPawView = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var that_1, error_3;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
that_1 = this;
|
||||
return [
|
||||
4,
|
||||
this.$open({
|
||||
title: lan.bt.pass_title,
|
||||
area: ['410px', '235px'],
|
||||
btn: [lan.public.edit, lan.public.close],
|
||||
content: {
|
||||
data: { password1: '', password2: '' },
|
||||
template: function () {
|
||||
var lineWidth = '110px',
|
||||
inputWidth = '210px';
|
||||
return (0, snabbdom_1.jsx)(
|
||||
'div',
|
||||
{ class: { 'bt-form': true, pd25: true } },
|
||||
this.$line(
|
||||
{ title: lan.public.pass, width: lineWidth },
|
||||
this.$box(this.$input({ model: 'password1', width: inputWidth }), this.$icon({ type: 'repeat', click: this.showPaw.bind(this), class: 'ml5' }))
|
||||
),
|
||||
this.$line({ title: lan.bt.pass_new_title, width: lineWidth }, this.$input({ model: 'password2', width: inputWidth }))
|
||||
);
|
||||
},
|
||||
methods: {
|
||||
showPaw: function () {
|
||||
this.password1 = that_1.$getRandom(10);
|
||||
this.password2 = this.password1;
|
||||
},
|
||||
},
|
||||
},
|
||||
yes: function (config) {
|
||||
return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, password1, password2, weakCipher, rdata;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
(close = config.close), (vm = config.vm);
|
||||
(password1 = vm.password1), (password2 = vm.password2);
|
||||
weakCipher = this.$checkWeakCipher(password1);
|
||||
return [
|
||||
4,
|
||||
this.$verifySubmitList([
|
||||
[password1.length < 8, lan.bt.pass_err_len],
|
||||
[!weakCipher.status, lan.bt.pass_err + weakCipher.msg],
|
||||
[password1 !== password2, lan.bt.pass_err_re],
|
||||
]),
|
||||
];
|
||||
case 1:
|
||||
_a.sent();
|
||||
password1 = rsa.encrypt_public(encodeURIComponent(password1));
|
||||
password2 = rsa.encrypt_public(encodeURIComponent(password2));
|
||||
return [4, this.$request('setPassword', { password1: password1, password2: password2 })];
|
||||
case 2:
|
||||
rdata = _a.sent();
|
||||
rdata.status && close() && this.$refreshBrowser('/login?dologin=True');
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
}),
|
||||
];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [3, 3];
|
||||
case 2:
|
||||
error_3 = _a.sent();
|
||||
return [3, 3];
|
||||
case 3:
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
PanelConfig.prototype.unbindUser = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var rdata, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 3, , 4]);
|
||||
return [
|
||||
4,
|
||||
this.$confirm({
|
||||
title: 'Unbind YakPanel account',
|
||||
msg: 'Unbind the YakPanel account and continue!',
|
||||
}),
|
||||
];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [4, this.$request('unbindUserInfo')];
|
||||
case 2:
|
||||
rdata = _a.sent();
|
||||
if (rdata.status) {
|
||||
this.$removeCookie('bt_user_info');
|
||||
this.$refreshBrowser();
|
||||
}
|
||||
return [3, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
return [3, 4];
|
||||
case 4:
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
PanelConfig.prototype.setPanelGroundView = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var rdata, html, is_option, that, arry, isEdit;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
return [4, this.$request('getMenuList')];
|
||||
case 1:
|
||||
(rdata = _a.sent()), (html = ''), (is_option = ''), (that = this);
|
||||
arry = ['dologin', 'memuAconfig', 'memuAsoft', 'memuA'];
|
||||
rdata.map(function (item, index) {
|
||||
is_option = '<div class="index-item" style="float:right;"><input class="btswitch btswitch-ios" id="'
|
||||
.concat(item.id, '-')
|
||||
.concat(index, '" name="')
|
||||
.concat(item.id, '" type="checkbox" ')
|
||||
.concat(item.show ? 'checked' : '', '><label class="btswitch-btn" for="')
|
||||
.concat(item.id, '-')
|
||||
.concat(index, '"></label></div>');
|
||||
arry.indexOf(item.id) > -1 && (is_option = 'Inoperable');
|
||||
html += '<tr><td>'.concat(item.title, '</td><td><div style="float:right;">').concat(is_option, '</div></td></tr>');
|
||||
});
|
||||
isEdit = false;
|
||||
return [
|
||||
4,
|
||||
this.$open({
|
||||
title: 'Manage panel menu bar',
|
||||
area: ['350px', '598px'],
|
||||
content:
|
||||
'\n <div class="divtable softlist" id="panel_menu_tab" style="padding: 20px 15px;">\n <table class="table table-hover">\n <thead>\n <tr>\n <th>Menu bar</th>\n <th class="text-right" style="width:120px;">Display</th>\n </tr>\n </thead>\n <tbody>'.concat(
|
||||
html,
|
||||
'</tbody>\n </table>\n </div>\n '
|
||||
),
|
||||
success: function () {
|
||||
$('#panel_menu_tab input').click(function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var arry;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
arry = [];
|
||||
$(this)
|
||||
.parents('tr')
|
||||
.siblings()
|
||||
.each(function (index, el) {
|
||||
if ($(this).find('input').length > 0 && !$(this).find('input').prop('checked')) {
|
||||
arry.push($(this).find('input').attr('name'));
|
||||
}
|
||||
});
|
||||
!$(this).prop('checked') && arry.push($(this).attr('name'));
|
||||
return [4, that.$request('setHideMenuList', { hide_list: JSON.stringify(arry) })];
|
||||
case 1:
|
||||
_a.sent();
|
||||
isEdit = true;
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
cancel: function () {
|
||||
isEdit && that.$refreshBrowser(0);
|
||||
},
|
||||
}),
|
||||
];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return PanelConfig;
|
||||
})(configMixin_1.default);
|
||||
exports.default = PanelConfig;
|
||||
});
|
||||
0
YakPanel/static/amd/public.js
Normal file
0
YakPanel/static/amd/public.js
Normal file
5
YakPanel/static/amd/require.min.js
vendored
Normal file
5
YakPanel/static/amd/require.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
992
YakPanel/static/amd/safeConfig.js
Normal file
992
YakPanel/static/amd/safeConfig.js
Normal file
@@ -0,0 +1,992 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
define(["require", "exports", "./snabbdom", "./configMixin"], function (require, exports, snabbdom_1, configMixin_1) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
configMixin_1 = __importDefault(configMixin_1);
|
||||
var SafeConfig = (function (_super) {
|
||||
__extends(SafeConfig, _super);
|
||||
function SafeConfig() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.apiInfo = {
|
||||
getCertSource: ['config/get_cert_source', lan.public.the],
|
||||
setPanelSsl: ['config/SetPanelSSL', lan.public.the],
|
||||
getPanelSsl: ['config/GetPanelSSL', lan.config.get_cert],
|
||||
savePanelSsl: ['config/SavePanelSSL', lan.config.ssl_msg],
|
||||
setBasicAuth: ['config/set_basic_auth', lan.config.set_basicauth],
|
||||
setTwoStepAuth: ['config/set_two_step_auth', lan.public.the],
|
||||
getQrcodeData: ['config/get_qrcode_data', lan.public.the],
|
||||
getTwoStepKey: ['config/get_key', lan.public.the],
|
||||
setPasswordSafe: ['config/set_password_safe', lan.public.the],
|
||||
setAdminPath: ['config/set_admin_path', lan.config.config_save],
|
||||
setNotAuthStatus: ['config/set_not_auth_status', lan.config.panel_entrance_err],
|
||||
setPawExpire: ['config/set_password_expire', 'Setting password expiration time, please wait...'],
|
||||
getPasswordConfig: ['config/get_password_config', 'Setting password complexity verification status, please wait...'],
|
||||
getTempAuthList: ['config/get_temp_login', 'Getting temporary authorization list, please wait...'],
|
||||
setTempAuthLink: ['config/set_temp_login', 'Setting temporary links, please wait...'],
|
||||
removeTempAuthLink: ['config/remove_temp_login', 'Deleting temporary authorization record, please wait...'],
|
||||
clearTempAuth: ['config/clear_temp_login', 'Forcing user to log out, please wait...'],
|
||||
getTempOperationLogs: ['config/get_temp_login_logs', 'Getting operation log, please wait...'],
|
||||
};
|
||||
_this.statusCodeList = [
|
||||
{ label: 'security entry error', value: 0 },
|
||||
{ label: '403', value: 403 },
|
||||
{ label: '404', value: 404 },
|
||||
{ label: '416', value: 416 },
|
||||
{ label: '408', value: 408 },
|
||||
{ label: '400', value: 400 },
|
||||
{ label: '401', value: 401 },
|
||||
];
|
||||
_this.$apiInit(_this.apiInfo);
|
||||
return _this;
|
||||
}
|
||||
SafeConfig.prototype.init = function (data) {
|
||||
var configInfo = data.configInfo, twoStep = data.twoStep, pawComplexity = data.pawComplexity;
|
||||
var basic_auth = configInfo.basic_auth, panel = configInfo.panel;
|
||||
var open = (basic_auth || {}).open;
|
||||
var _a = panel || {}, port = _a.port, admin_path = _a.admin_path, domain = _a.domain, limitip = _a.limitip;
|
||||
var googleStatus = twoStep.status;
|
||||
var password_safe = pawComplexity.password_safe, expire = pawComplexity.expire, expire_time = pawComplexity.expire_time, expire_day = pawComplexity.expire_day;
|
||||
var isHttps = location.protocol.indexOf('https:') > -1;
|
||||
var statusCodeTips = this.getStatusCodeTips();
|
||||
var paw_expire_time = expire > 0 ? "".concat(this.$formatTime(expire_time), " (Exp in ").concat(expire_day, " days)") : lan.config.not_set;
|
||||
var formColumns = {
|
||||
ssl: { value: isHttps },
|
||||
basic_auth: { value: open },
|
||||
check_two_step: { value: googleStatus },
|
||||
paw_complexity: { value: password_safe },
|
||||
port: { value: port },
|
||||
admin_path: { value: admin_path },
|
||||
status_code: { value: statusCodeTips },
|
||||
domain: { value: domain },
|
||||
limitip: { value: limitip },
|
||||
paw_expire_time: { value: paw_expire_time, day: expire_day },
|
||||
};
|
||||
this.renderFormColumn(formColumns);
|
||||
this.formColumns = formColumns;
|
||||
};
|
||||
SafeConfig.prototype.event = function () {
|
||||
var _this = this;
|
||||
$('input[name="ssl"]').change(function (e) {
|
||||
var checked = $(e.target).prop('checked');
|
||||
if (checked) {
|
||||
_this.setPanelSslView(e);
|
||||
}
|
||||
else {
|
||||
var title = 'Tips';
|
||||
var msg = 'Whether to close the panel SSL certificate?';
|
||||
var api = 'setPanelSsl';
|
||||
_this.showCheckboxConfirm({
|
||||
e: e,
|
||||
api: api,
|
||||
config: { title: title, msg: msg },
|
||||
})
|
||||
.then(function (res) {
|
||||
if (res.status)
|
||||
return _this.$request('restartPanel', { loading: false, msg: false });
|
||||
})
|
||||
.then(function (res) {
|
||||
res.status && _this.$refreshBrowser(location.href.replace(/^https:/, 'http:'), 800);
|
||||
})
|
||||
.catch(function (err) { });
|
||||
}
|
||||
});
|
||||
$('.panelSslConfig').on('click', function () { return _this.setPanelSslConfigView(); });
|
||||
$('input[name="basic_auth"]').change(function (e) {
|
||||
var checked = $(e.target).prop('checked');
|
||||
if (checked) {
|
||||
_this.setBasicAuthView(e);
|
||||
}
|
||||
else {
|
||||
var title = 'Turn off BasicAuth authentication';
|
||||
var msg = 'After BasicAuth authentication is disabled, panel login will no longer verify BasicAuth base authentication, which will cause panel security to decline. Do you want to continue?';
|
||||
var api = 'setBasicAuth';
|
||||
_this.showCheckboxConfirm({
|
||||
e: e,
|
||||
api: api,
|
||||
config: { title: title, msg: msg },
|
||||
data: { open: 'False', basic_user: '', basic_pwd: '' },
|
||||
})
|
||||
.then(function (res) {
|
||||
_this.$refreshBrowser();
|
||||
})
|
||||
.catch(function (err) { });
|
||||
}
|
||||
});
|
||||
$('input[name="check_two_step"]').change(function (e) {
|
||||
var checked = $(e.target).prop('checked');
|
||||
if (checked) {
|
||||
_this.setGoogleAuthView(e);
|
||||
}
|
||||
else {
|
||||
var title = 'Google authentication';
|
||||
var msg = 'Turn off Google authentication, do you want to continue?';
|
||||
var api = 'setTwoStepAuth';
|
||||
_this.showCheckboxConfirm({
|
||||
e: e,
|
||||
api: api,
|
||||
config: { title: title, msg: msg },
|
||||
data: { act: false },
|
||||
}).catch(function (err) { });
|
||||
}
|
||||
});
|
||||
$('.checkTwoStepConfig').click(function () { return _this.googleAuthRelationView(); });
|
||||
$('input[name="paw_complexity"]').change(function (e) {
|
||||
var checked = $(e.target).is(':checked');
|
||||
var title = checked ? lan.config.open_strong_password : lan.config.close_strong_password;
|
||||
var msg = checked ? "".concat(lan.config.strong_password_desc1, "<span style=\"color:red;\">").concat(lan.config.strong_password_desc2, "</span>") : lan.config.strong_password_desc3;
|
||||
var api = 'setPasswordSafe';
|
||||
_this.showCheckboxConfirm({
|
||||
e: e,
|
||||
api: api,
|
||||
config: { title: title, msg: msg },
|
||||
})
|
||||
.then(function (res) {
|
||||
res.status && _this.$refreshBrowser();
|
||||
})
|
||||
.catch(function (err) { });
|
||||
});
|
||||
$('.setSafetyEntrance').click(function () { return _this.setSafetyEntranceView(); });
|
||||
$('.setStatusCodeView').click(function () { return _this.setStatusCodeView(); });
|
||||
$('.setPawExpiration').click(function () { return _this.setPawExpirationView(); });
|
||||
$('.setTempAuthView').on('click', function () { return _this.setTempAuthView(); });
|
||||
};
|
||||
SafeConfig.prototype.getStatusCodeTips = function () {
|
||||
var statusCodeTips = lan.config.response_msg1;
|
||||
var statusCode = sessionInfo.statusCode;
|
||||
var code = parseInt(statusCode);
|
||||
for (var i = 0; i < this.statusCodeList.length; i++) {
|
||||
var item = this.statusCodeList[i];
|
||||
if (item.value === code) {
|
||||
statusCodeTips = item.label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return statusCodeTips;
|
||||
};
|
||||
SafeConfig.prototype.setPanelSslView = function (e) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var certSource, _a, certPem, privateKey, err_1;
|
||||
var _this = this;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_b.trys.push([0, 4, , 5]);
|
||||
return [4, this.$request('getCertSource')];
|
||||
case 1:
|
||||
certSource = _b.sent();
|
||||
return [4, this.$request('getPanelSsl')];
|
||||
case 2:
|
||||
_a = _b.sent(), certPem = _a.certPem, privateKey = _a.privateKey;
|
||||
return [4, this.$open({
|
||||
title: 'Panel SSL',
|
||||
area: '560px',
|
||||
btn: ['Submit', 'Close'],
|
||||
skin: 'panel-ssl',
|
||||
content: {
|
||||
data: { cert_type: certSource.cert_type ? parseInt(certSource.cert_type) : 1, email: certSource.email || '', certPem: certPem, privateKey: privateKey, agreement: false },
|
||||
template: function () {
|
||||
var lineWidth = '80px', inputWidth = '280px', helpHref = 'https://www.yakpanel.com/forum/d/167-common-problems-after-opening-the-panel-certificate';
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('bt-form'), style: this.$style('padding: 20px 50px;') },
|
||||
this.$warningTitle(lan.config.ssl_open_ps),
|
||||
this.$ul({ className: 'explainDescribeList pd15' }, [
|
||||
[lan.config.ssl_open_ps_1, 'red'],
|
||||
[lan.config.ssl_open_ps_2],
|
||||
[(0, snabbdom_1.jsx)("span", null,
|
||||
"If panel is not accessible, you can click the ",
|
||||
this.$link({ title: 'link', href: helpHref }),
|
||||
" below to find solutions")],
|
||||
]),
|
||||
(0, snabbdom_1.jsx)("div", { class: { pt10: true } },
|
||||
this.$line({ title: 'Cert Type', width: lineWidth }, this.$select({
|
||||
model: 'cert_type',
|
||||
width: inputWidth,
|
||||
options: [
|
||||
{ label: 'Self-signed certificate', value: 1 },
|
||||
{ label: "Let's Encrypt", value: 2 },
|
||||
{ label: 'I have certficate', value: 3 },
|
||||
],
|
||||
})),
|
||||
this.$line({ title: 'E-Mail', width: lineWidth, hide: parseInt(this.cert_type) !== 2 }, this.$input({ model: 'email', width: inputWidth, placeholder: 'Admin E-Mail' })),
|
||||
this.$line({ title: 'Key', width: lineWidth, hide: parseInt(this.cert_type) !== 3 }, this.$textarea({ model: 'privateKey', width: inputWidth, height: '100px', style: 'line-height: 16px;padding: 5px 8px;' })),
|
||||
this.$line({ title: 'Certificate', width: lineWidth, hide: parseInt(this.cert_type) !== 3 }, this.$textarea({ model: 'certPem', width: inputWidth, height: '100px', style: 'line-height: 16px;padding: 5px 8px;' })),
|
||||
this.$learnMore({
|
||||
model: 'agreement',
|
||||
id: 'checkSSL',
|
||||
title: (0, snabbdom_1.jsx)("span", null, lan.config.ssl_open_ps_4),
|
||||
link: this.$link({ title: lan.config.ssl_open_ps_5, href: 'https://www.yakpanel.com/forum/d/167-common-problems-after-opening-the-panel-certificate' }),
|
||||
}))));
|
||||
},
|
||||
},
|
||||
success: function (layers) {
|
||||
layers[0].style.height = 'auto';
|
||||
layers[0].querySelector('.layui-layer-content').style.height = 'auto';
|
||||
_this.setLayerVerticalCenter(layers);
|
||||
$('select[name="cert_type"]').change(function (e) {
|
||||
_this.setLayerVerticalCenter(layers);
|
||||
});
|
||||
},
|
||||
yes: function (config) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, cert_type, email, privateKey, certPem, agreement, _a, res, rdata;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
close = config.close, vm = config.vm;
|
||||
cert_type = vm.cert_type, email = vm.email, privateKey = vm.privateKey, certPem = vm.certPem, agreement = vm.agreement;
|
||||
if (!agreement)
|
||||
return [2, this.$tips({ el: '#agreement_more', msg: 'Please confirm the risk first!' })];
|
||||
return [4, this.$verifySubmitList([
|
||||
[cert_type === '3' && (!certPem || !privateKey), 'Please enter certificate information'],
|
||||
[cert_type === '2' && !email, 'Please enter administrator email'],
|
||||
])];
|
||||
case 1:
|
||||
_b.sent();
|
||||
_a = cert_type === '3';
|
||||
if (!_a) return [3, 3];
|
||||
return [4, this.$request('savePanelSsl', { privateKey: privateKey, certPem: certPem }, false)];
|
||||
case 2:
|
||||
_a = (_b.sent());
|
||||
_b.label = 3;
|
||||
case 3:
|
||||
_a;
|
||||
return [4, this.$request('setPanelSsl', Object.assign({ cert_type: cert_type }, vm.cert_type === '2' ? { email: email } : {}))];
|
||||
case 4:
|
||||
res = _b.sent();
|
||||
if (!res.status) return [3, 6];
|
||||
return [4, this.$request('restartPanel', { loading: false, msg: false })];
|
||||
case 5:
|
||||
rdata = _b.sent();
|
||||
rdata.status && close() && this.$refreshBrowser(location.href.replace(/^http:/, 'https:'), 800);
|
||||
_b.label = 6;
|
||||
case 6: return [2];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
cancel: function () {
|
||||
_this.changeReverseCheckbox(e);
|
||||
},
|
||||
btn2: function () {
|
||||
_this.changeReverseCheckbox(e);
|
||||
},
|
||||
})];
|
||||
case 3:
|
||||
_b.sent();
|
||||
return [3, 5];
|
||||
case 4:
|
||||
err_1 = _b.sent();
|
||||
return [3, 5];
|
||||
case 5: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
SafeConfig.prototype.setPanelSslConfigView = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var that_1, _a, certPem, privateKey, error_1;
|
||||
var _this = this;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_b.trys.push([0, 3, , 4]);
|
||||
that_1 = this;
|
||||
return [4, this.$request('getPanelSsl')];
|
||||
case 1:
|
||||
_a = _b.sent(), certPem = _a.certPem, privateKey = _a.privateKey;
|
||||
return [4, this.$open({
|
||||
title: lan.config.custom_panel_cert,
|
||||
area: '740px',
|
||||
content: {
|
||||
data: { certPem: certPem, privateKey: privateKey },
|
||||
template: function () {
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('bt-form pd20') },
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('myKeyCon') },
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('ssl-con-key pull-left mr20'), style: { width: '48%' } },
|
||||
lan.config.key,
|
||||
(0, snabbdom_1.jsx)("br", null),
|
||||
this.$textarea({ model: 'privateKey' })),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('ssl-con-key pull-left'), style: { width: '48%' } },
|
||||
lan.config.pem_cert,
|
||||
(0, snabbdom_1.jsx)("br", null),
|
||||
this.$textarea({ model: 'certPem' })),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('ssl-btn pull-left mtb15'), style: { width: '100%' } }, this.$button({ title: lan.config.save, click: this.savePanelSsl.bind(this) }))),
|
||||
this.$ul({ style: 'clear: both;' }, [
|
||||
[
|
||||
(0, snabbdom_1.jsx)("span", null,
|
||||
lan.config.ps,
|
||||
" ",
|
||||
this.$link({ title: "[".concat(lan.config.help, "]"), href: 'https://www.yakpanel.com/bbs/thread-704-1-1.html' }),
|
||||
"."),
|
||||
],
|
||||
[lan.config.ps1],
|
||||
[lan.config.ps2],
|
||||
])));
|
||||
},
|
||||
methods: {
|
||||
savePanelSsl: function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, certPem, privateKey;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_a = this, certPem = _a.certPem, privateKey = _a.privateKey;
|
||||
return [4, that_1.$verifySubmitList([[!certPem || !privateKey, 'Please enter certificate information']])];
|
||||
case 1:
|
||||
_b.sent();
|
||||
return [4, that_1.$request('savePanelSsl', { privateKey: privateKey, certPem: certPem })];
|
||||
case 2:
|
||||
_b.sent();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
success: function (layero) {
|
||||
_this.setLayerVerticalCenter(layero);
|
||||
},
|
||||
})];
|
||||
case 2:
|
||||
_b.sent();
|
||||
return [3, 4];
|
||||
case 3:
|
||||
error_1 = _b.sent();
|
||||
return [3, 4];
|
||||
case 4: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
SafeConfig.prototype.setBasicAuthView = function (e) {
|
||||
var _this = this;
|
||||
this.$open({
|
||||
title: 'Risk reminder',
|
||||
area: '650px',
|
||||
btn: ['Submit', 'Close'],
|
||||
content: {
|
||||
data: { agreement: false },
|
||||
template: function () {
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('bt-form pd25') },
|
||||
this.$warningTitle('Warning! Do not understand this feature, do not open!'),
|
||||
this.$ul({ className: 'explainDescribeList pd15' }, [
|
||||
['You must use and understand this feature to decide if you want to open it!', 'red'],
|
||||
['After opening, access the panel in any way, you will be asked to enter the BasicAuth username and password first.'],
|
||||
['After being turned on, it can effectively prevent the panel from being scanned and found, but it cannot replace the account password of the panel itself.'],
|
||||
['Please remember the BasicAuth password, but forget that you will not be able to access the panel.'],
|
||||
['If you forget your password, you can disable BasicAuth authentication by using the bt command in SSH.'],
|
||||
]),
|
||||
this.$learnMore({
|
||||
title: (0, snabbdom_1.jsx)("span", null, "I already know the details and are willing to take risks"),
|
||||
model: 'agreement',
|
||||
id: 'checkBasicAuth',
|
||||
link: this.$link({ title: 'What is BasicAuth authentication?', href: 'https://www.yakpanel.com/bbs/thread-34374-1-1.html' }),
|
||||
})));
|
||||
},
|
||||
},
|
||||
success: function (layers) {
|
||||
_this.setLayerVerticalCenter(layers);
|
||||
},
|
||||
yes: function (config) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm;
|
||||
return __generator(this, function (_a) {
|
||||
close = config.close, vm = config.vm;
|
||||
if (!vm.agreement)
|
||||
return [2, this.$tips({ el: '#checkBasicAuth', msg: 'Please read and agree to the risk' })];
|
||||
close();
|
||||
this.setBasicAuthConfigView(e);
|
||||
return [2];
|
||||
});
|
||||
}); },
|
||||
cancel: function () {
|
||||
_this.changeReverseCheckbox(e);
|
||||
},
|
||||
btn2: function () {
|
||||
_this.changeReverseCheckbox(e);
|
||||
},
|
||||
}).catch(function (err) { });
|
||||
};
|
||||
SafeConfig.prototype.setBasicAuthConfigView = function (e) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var that;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
that = this;
|
||||
this.$open({
|
||||
title: 'Configure BasicAuth authentication',
|
||||
area: '500px',
|
||||
content: {
|
||||
data: { open: true, basic_user: '', basic_pwd: '' },
|
||||
template: function () {
|
||||
var inputWidth = '280px';
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('bt-form pd25') },
|
||||
this.$line({ title: lan.public.server_status }, this.$switch({ model: 'open' })),
|
||||
this.$line({ title: lan.public.username }, this.$input({ model: 'basic_user', placeholder: lan.config.set_username, width: inputWidth })),
|
||||
this.$line({ title: lan.public.pass }, this.$input({ model: 'basic_pwd', placeholder: lan.config.set_passwd, width: inputWidth })),
|
||||
this.$line({ title: '' }, this.$button({ title: lan.public.save, click: this.saveBasicAuth.bind(this) })),
|
||||
this.$ul([[lan.config.basic_auth_tips1, 'red'], [lan.config.basic_auth_tips2], [lan.config.basic_auth_tips3]])));
|
||||
},
|
||||
methods: {
|
||||
saveBasicAuth: function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, basic_user, basic_pwd, open, rdata;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_a = this, basic_user = _a.basic_user, basic_pwd = _a.basic_pwd, open = _a.open;
|
||||
return [4, that.$request('setBasicAuth', { basic_user: basic_user, basic_pwd: basic_pwd, open: open ? 'True' : 'False' })];
|
||||
case 1:
|
||||
rdata = _b.sent();
|
||||
if (rdata.status) {
|
||||
this.$closeLayer();
|
||||
that.$refreshBrowser();
|
||||
}
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
success: function (layers) {
|
||||
_this.setLayerVerticalCenter(layers);
|
||||
},
|
||||
cancel: function () {
|
||||
_this.changeReverseCheckbox(e);
|
||||
},
|
||||
btn2: function () {
|
||||
_this.changeReverseCheckbox(e);
|
||||
},
|
||||
}).catch(function (err) { });
|
||||
return [2];
|
||||
});
|
||||
});
|
||||
};
|
||||
SafeConfig.prototype.setGoogleAuthView = function (e) {
|
||||
var _this = this;
|
||||
this.$open({
|
||||
title: 'Google authentication binding',
|
||||
area: ['660px', '390px'],
|
||||
btn: ['Submit', 'Close'],
|
||||
content: {
|
||||
data: { agreement: false },
|
||||
template: function () {
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('bt-form pd25') },
|
||||
this.$warningTitle('Warning! Do not understand this feature, do not open!'),
|
||||
this.$ul({ className: 'explainDescribeList pd15' }, [
|
||||
['You must use and understand this feature to decide if you want to open it!', 'red'],
|
||||
['If it is not possible to verify, enter "bt 24" on the command line to cancel Google authentication.', 'red'],
|
||||
['Once the service is turned on, bind it immediately to avoid the panel being inaccessible.'],
|
||||
['After opening, the panel will not be accessible. You can click the link below to find out the solution.'],
|
||||
]),
|
||||
this.$learnMore({
|
||||
title: 'I already know the details and are willing to take risks',
|
||||
model: 'agreement',
|
||||
id: 'checkAuthenticator',
|
||||
link: this.$link({ title: 'Learn more', href: 'https://www.yakpanel.com/forum/d/357-how-to-use-google-authenticator-in-the-yakpanel' }),
|
||||
})));
|
||||
},
|
||||
},
|
||||
yes: function (config) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, rdata, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
close = config.close, vm = config.vm;
|
||||
if (!vm.agreement)
|
||||
return [2, this.$tips({ el: '#checkAuthenticator', msg: 'Please read and agree to the risk' })];
|
||||
return [4, this.$request('setTwoStepAuth', { act: 1 })];
|
||||
case 1:
|
||||
rdata = _b.sent();
|
||||
_a = rdata.status && close();
|
||||
if (!_a) return [3, 3];
|
||||
return [4, this.googleAuthRelationView()];
|
||||
case 2:
|
||||
_a = (_b.sent());
|
||||
_b.label = 3;
|
||||
case 3:
|
||||
_a;
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
cancel: function () {
|
||||
e && _this.changeReverseCheckbox(e);
|
||||
},
|
||||
btn2: function () {
|
||||
e && _this.changeReverseCheckbox(e);
|
||||
},
|
||||
}).catch(function (err) { });
|
||||
};
|
||||
SafeConfig.prototype.googleAuthRelationView = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var that, checked;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
that = this;
|
||||
checked = $('input[name="check_two_step"]').is(':checked');
|
||||
if (!checked)
|
||||
return [2, this.$msg({ msg: 'Please turn on Google authentication first.', icon: 0 })];
|
||||
this.$open({
|
||||
title: 'Google authentication binding',
|
||||
area: ['600px', '660px'],
|
||||
content: {
|
||||
data: {
|
||||
username: '--',
|
||||
key: '--',
|
||||
type: 'Time based',
|
||||
},
|
||||
template: function () {
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('bt-form'), style: this.$style('padding:20px 35px;') },
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_title') }, "Login authentication based on Google Authenticator"),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_item') },
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_vice_title') }, "1. Key binding"),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_conter') },
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_box') },
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_box_line') },
|
||||
"Account: ",
|
||||
(0, snabbdom_1.jsx)("span", null, this.username)),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_box_line') },
|
||||
"Key: ",
|
||||
(0, snabbdom_1.jsx)("span", null, this.key)),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_box_line') },
|
||||
"Type: ",
|
||||
(0, snabbdom_1.jsx)("span", null, this.type))))),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_item') },
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_vice_title') }, "2. Scan code binding (Using Google Authenticator APP scan)"),
|
||||
(0, snabbdom_1.jsx)("div", { class: this.$class('verify_conter'), style: this.$style('text-align:center;padding-top:10px;') },
|
||||
(0, snabbdom_1.jsx)("div", { props: { id: 'verify_qrcode' }, key: 'verifyQrcode' }))),
|
||||
this.$ul({ className: 'verify_tips' }, [
|
||||
[
|
||||
(0, snabbdom_1.jsx)("span", null,
|
||||
"Tips: Please use the \"Google Authenticator APP\" binding to support Android, IOS system.",
|
||||
this.$link({ title: 'Use tutorial', href: 'https://www.yakpanel.com/forum/d/357-how-to-use-google-authenticator-in-the-yakpanel' })),
|
||||
],
|
||||
['Once you have turned on the service, use the Google Authenticator app binding now to avoid having to sign in.', 'red'],
|
||||
])));
|
||||
},
|
||||
mounted: function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var loadT;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
loadT = that.$load(lan.public.the);
|
||||
Promise.all([that.$request('getTwoStepKey', false), that.$request('getQrcodeData', { act: 1 }, false), that.$require('jquery.qrcode')])
|
||||
.then(function (resArr) {
|
||||
var keyRes = resArr[0], qrcodeRes = resArr[1];
|
||||
var username = keyRes.username, key = keyRes.key;
|
||||
_this.username = username;
|
||||
_this.key = key;
|
||||
$('#verify_qrcode').qrcode({ render: 'canvas', width: 150, height: 150, text: qrcodeRes });
|
||||
})
|
||||
.catch(function (err) {
|
||||
_this.$error(err.msg || 'Server Error');
|
||||
})
|
||||
.finally(function () {
|
||||
loadT.close();
|
||||
});
|
||||
return [2];
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
success: function (layers) { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.setLayerVerticalCenter(layers);
|
||||
return [2];
|
||||
});
|
||||
}); },
|
||||
}).catch(function (err) { });
|
||||
return [2];
|
||||
});
|
||||
});
|
||||
};
|
||||
SafeConfig.prototype.setSafetyEntranceView = function () {
|
||||
var _this = this;
|
||||
this.$open({
|
||||
title: lan.config.change_safe_entry,
|
||||
area: ['420px', '180px'],
|
||||
btn: [lan.config.submit, lan.config.turn_off],
|
||||
content: {
|
||||
data: { expire: this.formColumns.admin_path.value },
|
||||
template: function () {
|
||||
return (0, snabbdom_1.jsx)("div", { class: this.$class('pd20 bt-form') }, this.$line({ title: lan.config.entry_addr }, this.$input({ model: 'expire', width: '240px' })));
|
||||
},
|
||||
},
|
||||
yes: function (content) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, admin_path, rdata;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
close = content.close, vm = content.vm, admin_path = vm.expire;
|
||||
return [4, this.$verifySubmit(!admin_path, 'Entrance address cannot be empty')];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [4, this.$request('setAdminPath', { admin_path: rsa.encrypt_public(admin_path) })];
|
||||
case 2:
|
||||
rdata = _a.sent();
|
||||
if (rdata.status) {
|
||||
close();
|
||||
$('input[name="admin_path"]').val(admin_path);
|
||||
this.formColumns.admin_path.value = admin_path;
|
||||
}
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
}).catch(function (err) { });
|
||||
};
|
||||
SafeConfig.prototype.setStatusCodeView = function () {
|
||||
var _this = this;
|
||||
this.$open({
|
||||
title: lan.config.panel_entrance_err,
|
||||
area: ['420px', '250px'],
|
||||
btn: ['Confirm', 'Cancel'],
|
||||
content: {
|
||||
data: { status_code: parseInt(sessionInfo.statusCode) },
|
||||
template: function () {
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('pd20 bt-form') },
|
||||
this.$line({ title: lan.config.response, width: '80px' }, this.$select({
|
||||
model: 'status_code',
|
||||
width: '250px',
|
||||
options: [
|
||||
{ label: lan.config.response_msg1, value: 0 },
|
||||
{ label: '403', value: 403 },
|
||||
{ label: '404', value: 404 },
|
||||
{ label: '416', value: 416 },
|
||||
{ label: '408', value: 408 },
|
||||
{ label: '400', value: 400 },
|
||||
{ label: '401', value: 401 },
|
||||
],
|
||||
})),
|
||||
this.$ul([[lan.config.response_desc, 'red']])));
|
||||
},
|
||||
},
|
||||
yes: function (config) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, rdata;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
close = config.close, vm = config.vm;
|
||||
return [4, this.$request('setNotAuthStatus', { status_code: vm.status_code })];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
rdata.status && close() && this.$refreshBrowser();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
}).catch(function (err) { });
|
||||
};
|
||||
SafeConfig.prototype.setPawExpirationView = function () {
|
||||
var _this = this;
|
||||
var day = this.formColumns.paw_expire_time.day || 0;
|
||||
this.$open({
|
||||
title: lan.config.set_password_expiration_time,
|
||||
area: ['350px', '245px'],
|
||||
btn: [lan.public.confirm, lan.public.cancel],
|
||||
content: {
|
||||
data: { expire: day },
|
||||
template: function () {
|
||||
return ((0, snabbdom_1.jsx)("div", { class: this.$class('pd20 bt-form') },
|
||||
this.$line({ title: lan.config.expire_time }, this.$box(this.$input({ model: 'expire', placeholder: '', width: '120px' }), (0, snabbdom_1.jsx)("span", null, "Days"))),
|
||||
this.$ul([[lan.config.expire_password_desc1, 'red'], [lan.config.expire_password_desc2]])));
|
||||
},
|
||||
},
|
||||
yes: function (config) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var close, vm, expire, rdata, _a, expire_time, expire_day, val, err_2;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
close = config.close, vm = config.vm, expire = vm.expire;
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 4, , 5]);
|
||||
return [4, this.$request('setPawExpire', { expire: expire })];
|
||||
case 2:
|
||||
rdata = _b.sent();
|
||||
if (!rdata.status)
|
||||
throw new Error(rdata);
|
||||
return [4, this.$request('getPasswordConfig', false)];
|
||||
case 3:
|
||||
_a = _b.sent(), expire_time = _a.expire_time, expire_day = _a.expire_day;
|
||||
close();
|
||||
val = expire > 0 ? "".concat(this.$formatTime(expire_time), " ( Exp in ").concat(expire_day, " days )") : lan.config.not_set;
|
||||
$('input[name="paw_expire_time"]').val(val);
|
||||
this.formColumns.paw_expire_time.day = expire;
|
||||
return [3, 5];
|
||||
case 4:
|
||||
err_2 = _b.sent();
|
||||
return [3, 5];
|
||||
case 5: return [2];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
}).catch(function (err) { });
|
||||
};
|
||||
SafeConfig.prototype.setTempAuthView = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
this.$open({
|
||||
area: ['700px', '600px'],
|
||||
title: 'Temporary authorization management',
|
||||
content: "<div class=\"login_view_table pd15\">\n <button class=\"btn btn-success btn-sm va0 create_temp_login\">Create authorization</button>\n <div class=\"divtable mt10\">\n <table class=\"table table-hover\">\n <thead>\n <tr>\n <th>Login IP</th>\n <th>Status</th>\n <th>Login time</th>\n <th>Expiration time</th>\n <th style=\"text-align:right;\">Opt</th>\n </tr>\n </thead>\n <tbody id=\"temp_login_view_tbody\">\n <tr>\n <td class=\"text-center\" colspan=\"5\">No Data</td>\n </tr>\n </tbody>\n </table>\n <div class=\"temp_login_view_page page\"></div>\n </div>\n </div>",
|
||||
success: function () {
|
||||
_this.reanderTempAuthList();
|
||||
$('.create_temp_login').on('click', function () {
|
||||
_this.$confirm({
|
||||
title: 'Risk tips',
|
||||
msg: "<span style=\"color:red\">Note 1: Abuse of temporary authorization may lead to security risks.</br>Note 2: Not publish temporary authorized connections in public</span></br>Temporary authorization connection is about to be created. Continue?",
|
||||
})
|
||||
.then(function (res) {
|
||||
return _this.$open({
|
||||
area: '570px',
|
||||
title: 'Create temporary authorization',
|
||||
content: "<div class=\"bt-form create_temp_view\">\n <div class=\"line\">\n <span class=\"tname\">Temporary authorized address</span>\n <div class=\"info-r ml0\">\n <textarea id=\"temp_link\" class=\"bt-input-text mr20\" style=\"margin: 0px;width: 500px;height: 50px;line-height: 19px;\"></textarea>\n </div>\n </div>\n <div class=\"line\">\n <button type=\"submit\" class=\"btn btn-success btn-sm btn-copy-temp-link\" data-clipboard-text=\"\">Copy address</button>\n </div>\n <ul class=\"help-info-text c7\">\n <li>The temporary authorization is valid within 1 hour after it is generated. It is a one-time authorization and will be invalid immediately after use</li>\n <li>Use temporary authorization to log in to the panel within 1 hour. Do not publish temporary authorization connection in public</li>\n <li>The authorized connection information is only displayed here once. If you forget it before use, please regenerate it</li>\n </ul>\n </div>",
|
||||
success: function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var rdata, temp_link, clipboard, clipboards;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4, this.$request('setTempAuthLink')];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
temp_link = "".concat(location.origin, "/login?tmp_token=").concat(rdata.token);
|
||||
$('#temp_link').val(temp_link);
|
||||
$('.btn-copy-temp-link').attr('data-clipboard-text', temp_link);
|
||||
this.reanderTempAuthList();
|
||||
return [4, this.$require('clipboard')];
|
||||
case 2:
|
||||
clipboard = (_a.sent()).clipboard;
|
||||
clipboards = new clipboard('.btn');
|
||||
clipboards.on('success', function (ev) {
|
||||
_this.$msg({ status: true, msg: 'Copy succeeded!!' });
|
||||
ev.clearSelection();
|
||||
});
|
||||
clipboards.on('error', function (ev) {
|
||||
_this.$msg({ status: false, msg: 'Copy failed, please copy address manually' });
|
||||
});
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
}); },
|
||||
});
|
||||
})
|
||||
.catch(function (err) { });
|
||||
});
|
||||
$('#temp_login_view_tbody').on('click', '.logs_temp_login', function (ev) {
|
||||
var _a = $(ev.target).data(), id = _a.id, ip = _a.ip;
|
||||
_this.$open({
|
||||
area: ['700px', '550px'],
|
||||
title: "Operation logs [".concat(ip, "]"),
|
||||
content: "<div class=\"pd15\">\n <button class=\"btn btn-default btn-sm va0 refresh_login_logs\">Refresh logs</button>\n <div class=\"divtable mt10 tablescroll\">\n <table class=\"table table-hover\" id=\"logs_login_view_table\">\n <thead>\n <tr>\n <th width=\"90px\">Operation</th>\n <th width=\"140px\">Time</th>\n <th>logs</th>\n </tr>\n </thead>\n <tbody>\n <tr><td class=\"text-center\" colspan=\"3\">No Data</td></tr>\n </tbody>\n </table>\n </div>\n </div>",
|
||||
success: function () {
|
||||
_this.reanderTempLogsList(id);
|
||||
$('.refresh_login_logs').click(function () {
|
||||
_this.reanderTempLogsList(id);
|
||||
});
|
||||
_this.fixedTableHead('#logs_login_view_table', '420px');
|
||||
},
|
||||
}).catch(function (err) { });
|
||||
});
|
||||
$('#temp_login_view_tbody').on('click', '.remove_temp_login', function (ev) {
|
||||
_this.$confirm({
|
||||
title: 'Remove unused licenses',
|
||||
msg: 'Delete unused authorization record, continue?',
|
||||
})
|
||||
.then(function (res) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var id, rdata;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
id = $(ev.target).data().id;
|
||||
return [4, this.$request('removeTempAuthLink', { id: id })];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
return [4, this.$delay()];
|
||||
case 2:
|
||||
_a.sent();
|
||||
rdata.status && this.reanderTempAuthList();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
}); })
|
||||
.catch(function (err) { });
|
||||
});
|
||||
$('#temp_login_view_tbody').on('click', '.clear_temp_login', function (ev) {
|
||||
var _a = $(ev.target).data(), id = _a.id, ip = _a.ip;
|
||||
_this.$confirm({
|
||||
title: 'Force logout [ ' + ip + ' ]',
|
||||
msg: 'Confirm to force logout [ ' + ip + ' ] ?',
|
||||
})
|
||||
.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var rdata;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4, this.$request('clearTempAuth', { id: id })];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
return [4, this.$delay()];
|
||||
case 2:
|
||||
_a.sent();
|
||||
rdata.status && this.reanderTempAuthList();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
}); })
|
||||
.catch(function (err) { });
|
||||
});
|
||||
$('.temp_login_view_page').on('click', 'a', function (ev) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
var href = $(ev.target).attr('href');
|
||||
var reg = /([0-9]*)$/;
|
||||
var p = reg.exec(href)[0];
|
||||
_this.reanderTempAuthList(p);
|
||||
});
|
||||
},
|
||||
}).catch(function (err) { });
|
||||
return [2];
|
||||
});
|
||||
});
|
||||
};
|
||||
SafeConfig.prototype.reanderTempAuthList = function (p) {
|
||||
if (p === void 0) { p = 1; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var html, rdata, data, page, _loop_1, this_1, i, err_3;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
html = '';
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4, this.$request('getTempAuthList', { p: p, rows: 10 })];
|
||||
case 2:
|
||||
rdata = _a.sent();
|
||||
data = rdata.data, page = rdata.page;
|
||||
if (data.length > 0) {
|
||||
_loop_1 = function (i) {
|
||||
var item = data[i];
|
||||
html += "<tr>\n <td>".concat(item.login_addr || 'Not login', "</td>\n <td>").concat((function () {
|
||||
switch (item.state) {
|
||||
case 0:
|
||||
return '<a style="color:green;">Not login</a>';
|
||||
case 1:
|
||||
return '<a style="color:brown;">Logged in</a>';
|
||||
case -1:
|
||||
return '<a>Expired</a>';
|
||||
}
|
||||
})(), "</td>\n <td>").concat(item.login_time == 0 ? 'Not login' : this_1.$formatTime(item.login_time), "</td>\n <td>").concat(this_1.$formatTime(item.expire), "</td>\n <td style=\"text-align:right;\">").concat((function () {
|
||||
if (item.state != 1)
|
||||
return "<a href=\"javascript:;\" class=\"btlink remove_temp_login\" data-ip=\"".concat(item.login_addr, "\" data-id=\"").concat(item.id, "\">Del</a>");
|
||||
if (item.online_state)
|
||||
return "<a href=\"javascript:;\" class=\"btlink clear_temp_login\" style=\"color:red\" data-ip=\"".concat(item.login_addr, "\" data-id=\"").concat(item.id, "\">Force logout</a> | \n <a href=\"javascript:;\" class=\"btlink logs_temp_login\" data-ip=\"").concat(item.login_addr, "\" data-id=\"").concat(item.id, "\">Logs</a>");
|
||||
return "<a href=\"javascript:;\" class=\"btlink logs_temp_login\" data-ip=\"".concat(item.login_addr, "\" data-id=\"").concat(item.id, "\">Logs</a>");
|
||||
})(), "</td>\n </tr>");
|
||||
};
|
||||
this_1 = this;
|
||||
for (i = 0; i < data.length; i++) {
|
||||
_loop_1(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
html = '<tr><td class="text-center" colspan="5">No Data</td></tr>';
|
||||
}
|
||||
$('#temp_login_view_tbody').html(html);
|
||||
$('.temp_login_view_page').html(page);
|
||||
return [3, 4];
|
||||
case 3:
|
||||
err_3 = _a.sent();
|
||||
return [3, 4];
|
||||
case 4: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
SafeConfig.prototype.reanderTempLogsList = function (id) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var html, rdata, i, item, err_4;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
html = '';
|
||||
return [4, this.$request('getTempOperationLogs', { id: id })];
|
||||
case 1:
|
||||
rdata = _a.sent();
|
||||
if (rdata.length > 0) {
|
||||
for (i = 0; i < rdata.length; i++) {
|
||||
item = rdata[i];
|
||||
html += "<tr>\n <td>".concat(item.type, "</td>\n <td>").concat(item.addtime, "</td>\n <td><span title=\"").concat(item.log, "\" style=\"white-space: pre;\">").concat(item.log, "</span></td>\n </tr>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
html = '<tr><td class="text-center" colspan="3">No Data</td></tr>';
|
||||
}
|
||||
$('#logs_login_view_table tbody').html(html);
|
||||
return [3, 3];
|
||||
case 2:
|
||||
err_4 = _a.sent();
|
||||
return [3, 3];
|
||||
case 3: return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return SafeConfig;
|
||||
}(configMixin_1.default));
|
||||
exports.default = SafeConfig;
|
||||
});
|
||||
3053
YakPanel/static/amd/utils.min.js
vendored
Normal file
3053
YakPanel/static/amd/utils.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user