)
- :
- null
- }
+ {onLanguageChange !== noop ? (
+
- {siteConfig[language].pageMenu.map((item) => (
+ {siteConfig[language].pageMenu.map(item => (
-
- {item.text}
+
+ {item.text}
+
))}
diff --git a/console/src/main/resources/static/src/layouts/MainLayout.js b/console/src/main/resources/static/src/layouts/MainLayout.js
index 5a87027d4..0f089dcde 100644
--- a/console/src/main/resources/static/src/layouts/MainLayout.js
+++ b/console/src/main/resources/static/src/layouts/MainLayout.js
@@ -12,6 +12,7 @@
*/
import React from 'react';
+import PropTypes from 'prop-types';
import { Icon } from '@alifd/next';
import siteConfig from '../config';
import Header from './Header';
@@ -19,432 +20,449 @@ import $ from 'jquery';
import { aliwareGetCookieByKeyName, setParams, aliwareIntl } from '../globalLib';
export default class MainLayout extends React.Component {
- constructor(props) {
- super(props);
- this.initNav = this.props.navList;
- this.deepNav = [];
- this.oneLevelNavArr = {}; //平行导航map
- this.state = {
- leftBarClose: false,
- showLink: null,
- navRow: [],
- noChild: false
- };
- }
+ static propTypes = {
+ navList: PropTypes.array,
+ history: PropTypes.object,
+ children: PropTypes.any,
+ };
- goBack() {
- this.props.history.goBack();
- }
-
- nacosToggleNav(id, event) {
- event.preventDefault();
- let nowNav = document.getElementById(id);
- let iconClass = nowNav.querySelector('.iconshow');
- let subNav = nowNav.querySelector('.subnavlist');
- let classList = iconClass.classList;
- let tmpClassName = 'iconshow ';
- for (let i = 0; i < classList.length; i++) {
- if (classList[i] === 'icon-arrow-down') {
- subNav.style.display = 'none';
- subNav.className += ' hidden';
- tmpClassName += 'icon-arrow-right';
- }
- if (classList[i] === 'icon-arrow-right') {
- tmpClassName += 'icon-arrow-down';
- subNav.className = subNav.className.replace(/hidden/g, '');
- subNav.style.display = 'block';
- }
- }
- iconClass.className = tmpClassName;
- }
-
- nacosGoBack(url) {
- let params = window.location.hash.split('?')[1];
- let urlArr = params.split('&') || [];
- let queryParams = [];
- for (let i = 0; i < urlArr.length; i++) {
- if (
- urlArr[i].split('=')[0] !== '_k' &&
- urlArr[i].split('=')[0] !== 'dataId' &&
- urlArr[i].split('=')[0] !== 'group'
- ) {
- if (urlArr[i].split('=')[0] === 'searchDataId') {
- queryParams.push(`dataId=${urlArr[i].split('=')[1]}`);
- } else if (urlArr[i].split('=')[0] === 'searchGroup') {
- queryParams.push(`group=${urlArr[i].split('=')[1]}`);
- } else {
- queryParams.push(urlArr[i]);
- }
- }
- }
- this.props.history.push(`/${url}?${queryParams.join('&')}`);
- }
-
- nacosEnterBack() {
- document.getElementById('backarrow').style.color = '#09c';
- }
-
- nacosOutBack() {
- document.getElementById('backarrow').style.color = '#546478';
- }
-
- nacosToggleLeftBar() {
- if (!this.nacosOutDom) return
- if (!this.state.leftBarClose) {
- //关闭
- this.nacosOutDom.className = 'viewFramework-product';
- this.nacosLeftBarDom.style.width = 0;
- this.nacosBodyDom.style.left = 0;
- this.nacosToggleIconDom.style.left = 0;
- } else {
- this.nacosOutDom.className = 'viewFramework-product viewFramework-product-col-1';
- this.nacosLeftBarDom.style.width = '180px';
- this.nacosBodyDom.style.left = '180px';
- this.nacosToggleIconDom.style.left = '160px';
- }
-
- this.setState({
- leftBarClose: !this.state.leftBarClose
- });
- }
-
- navTo(url) {
- if (url !== '/configdetail' && url !== '/configeditor') {
- //二级菜单不清空
- setParams({
- dataId: '',
- group: ''
- });
- }
-
- let params = window.location.hash.split('?')[1];
- let urlArr = params.split('&') || [];
- let queryParams = [];
- for (let i = 0; i < urlArr.length; i++) {
- if (urlArr[i].split('=')[0] !== '_k') {
- queryParams.push(urlArr[i]);
- }
- }
-
- this.props.history.push(`${url}?${queryParams.join('&')}`);
- }
-
- nacosSetSpecialNav(item) {
- item.children.forEach((_item) => {
- let obj = _item;
-
- if (obj.dontUseChild === true) {
- obj.parentName = item.title;
- obj.parentId = item.id;
- obj.parentPath = '/' + item.id;
- this.deepNav.push(obj);
- }
- if (_item.children) {
- this.nacosSetSpecialNav(_item);
- }
- });
- }
-
- nacosNavAct(serviceName, match, location) {
- if (!match) {
- let formatpath = location.pathname.substr(1); //得到当前路径
- let nowpathobj = this.oneLevelNavArr[formatpath]; //根据平行导航匹配父类
- if (nowpathobj) {
- if (nowpathobj.parent === serviceName) {
- //如果父类等于当前的导航则高亮
- return true;
- }
- }
-
- return false;
- }
- return true;
- }
-
- nacosLoopNavDeeply(data, parentServiceName) {
- //深度遍历获取所有的导航数据
- data.forEach((item) => {
- if (item) {
- let navObj = item,
- _parentServiceName = item.serviceName;
- navObj.parentServiceName = parentServiceName;
- this.oneLevelNavArr[item.serviceName] = navObj; //得到每一个层级的导航映射
- if (item.children && item.children.length > 0) {
- this.nacosLoopNavDeeply(item.children, _parentServiceName);
- }
- }
- });
- }
-
- activeNav(id) {
- if (this.preActNav) {
- this.preActNav.removeClass('active');
- }
- let nowNav = $(`#${id}`);
- nowNav.addClass('active');
- this.preActNav = nowNav;
- }
-
- nacosLoopNav(data, index = 0, parent) {
- //遍历导航,只显示2级
- let self = this;
- return data.map((item) => {
- if (!item) {
- return '';
- }
- index++;
- if (item.dontUseChild === true) {
- return '';
- }
- if (item.children && item.children.length > 0) {
- if (item.isVirtual) {
- //如果是虚拟菜单需要增加展开箭头
- let icon = item.isExtend ? (
-
- ) : (
-
- );
- let hiddenClass = item.isExtend ? '' : 'hidden';
- return (
-
-
- {self.nacosLoopNav(item.children, index)}
-
- );
- } else {
- return (
-
-
-
- {aliwareIntl.get(item.id) || item.name}
-
-
- );
- }
- }
- return (
-
-
-
- {aliwareIntl.get(item.id) || item.name}
-
-
- );
- });
- }
-
- nacosGetNav(navList) {
- let navRow = ''; //导航
- if (navList.length > 0) {
- navRow =
{this.nacosLoopNav(navList)}
;
- this.nacosLoopNavDeeply(navList); //深度遍历导航树获得平行map
- }
- return navRow;
- }
-
- UNSAFE_componentWillMount() {
- let nav = this.props.navList || [];
- let navRow = this.nacosGetNav(nav);
- this.setState({
- navRow: navRow
- });
- }
-
- componentDidMount() {
- this.nacosLeftBarDom = document.getElementById('viewFramework-product-navbar');
- this.nacosBodyDom = document.getElementById('viewFramework-product-body');
- this.nacosToggleIconDom = document.getElementById('viewFramework-product-navbar-collapse');
- this.nacosOutDom = document.getElementById('page-header-mask');
- // let parentNav = this.initNav[0] || [];
- let defaultNav = '/configurationManagement';
- // let childrenNav = parentNav.children || [];
- this.props.history.listen((location) => {
- if (this.preSimplePath && this.preSimplePath !== '/') {
- if (location.pathname.indexOf(this.preSimplePath) !== -1) {
- return;
- }
- }
- let simplePath = window.location.hash.split('?')[0];
- let navName = simplePath.substr('2');
- this.preSimplePath = simplePath;
-
- if (navName === '') {
- this.props.history.push(defaultNav);
- setTimeout(() => {
- this.activeNav('configurationManagement');
- });
- return;
- }
-
- let nowNavObj = this.oneLevelNavArr[navName];
- if (!nowNavObj) {
- this.setState({
- noChild: true
- });
- return;
- }
- this.setState({
- noChild: !!nowNavObj.dontUseChild
- });
- let parentServiceName = nowNavObj.parentServiceName,
- parentNav = this.oneLevelNavArr[parentServiceName];
- if (simplePath !== '/' && nowNavObj && parentNav && !parentNav.isVirtual) {
- this.setState({
- showLink: (
-
-
-
- ),
-
- navRow:
{this.nacosLoopNav([nowNavObj])}
- });
- setTimeout(() => {
- let navid = navName;
- this.activeNav(navid);
- });
- } else {
- this.setState({
- showLink: null,
- navRow:
{this.nacosLoopNav(this.initNav)}
- });
- setTimeout(() => {
- let navid = navName;
- this.activeNav(navid);
- });
- }
- });
- }
-
- onLanguageChange = (language) => {
- aliwareIntl.changeLanguage(language);
- document.cookie = `docsite_language=${language}`;
- window.location.reload();
+ constructor(props) {
+ super(props);
+ this.initNav = this.props.navList;
+ this.deepNav = [];
+ this.oneLevelNavArr = {}; // 平行导航map
+ this.state = {
+ leftBarClose: false,
+ showLink: null,
+ navRow: [],
+ noChild: false,
};
+ }
- render() {
- let language = aliwareGetCookieByKeyName('docsite_language') || siteConfig.defaultLanguage;
+ goBack() {
+ this.props.history.goBack();
+ }
- const { headerType, showLink, navRow, leftBarClose, noChild } = this.state;
- const headerLogo = `${process.env.NODE_ENV === 'development' ? '' : 'public/'}img/TB118jPv_mWBKNjSZFBXXXxUFXa-2000-390.svg`;
- return (
-
-
-
-
-
-
- {showLink ? (
-
- {showLink}
-
- ) : (
-
-
- {aliwareIntl.get(
- 'com.alibaba.nacos.layout.noenv.app_configuration_management_acm'
- )}
-
-
- {aliwareIntl.get(
- 'com.alibaba.nacos.layout.noenv.nacosversion'
- )}
-
-
- )}
-
-
- {navRow}
-
-
-
-
-
-
-
-
-
- {leftBarClose ? (
-
- ) : (
-
- )}
-
-
-
-
-
- {!noChild ? (
-
{this.props.children}
- ) : (
-
- {aliwareIntl.get('com.alibaba.nacos.layout.noenv.does_not_exist')}
-
- )}
-
-
-
- );
+ nacosToggleNav(id, event) {
+ event.preventDefault();
+ const nowNav = document.getElementById(id);
+ const iconClass = nowNav.querySelector('.iconshow');
+ const subNav = nowNav.querySelector('.subnavlist');
+ const { classList } = iconClass;
+ let tmpClassName = 'iconshow ';
+ for (let i = 0; i < classList.length; i++) {
+ if (classList[i] === 'icon-arrow-down') {
+ subNav.style.display = 'none';
+ subNav.className += ' hidden';
+ tmpClassName += 'icon-arrow-right';
+ }
+ if (classList[i] === 'icon-arrow-right') {
+ tmpClassName += 'icon-arrow-down';
+ subNav.className = subNav.className.replace(/hidden/g, '');
+ subNav.style.display = 'block';
+ }
}
+ iconClass.className = tmpClassName;
+ }
+
+ nacosGoBack(url) {
+ const params = window.location.hash.split('?')[1];
+ const urlArr = params.split('&') || [];
+ const queryParams = [];
+ for (let i = 0; i < urlArr.length; i++) {
+ if (
+ urlArr[i].split('=')[0] !== '_k' &&
+ urlArr[i].split('=')[0] !== 'dataId' &&
+ urlArr[i].split('=')[0] !== 'group'
+ ) {
+ if (urlArr[i].split('=')[0] === 'searchDataId') {
+ queryParams.push(`dataId=${urlArr[i].split('=')[1]}`);
+ } else if (urlArr[i].split('=')[0] === 'searchGroup') {
+ queryParams.push(`group=${urlArr[i].split('=')[1]}`);
+ } else {
+ queryParams.push(urlArr[i]);
+ }
+ }
+ }
+ this.props.history.push(`/${url}?${queryParams.join('&')}`);
+ }
+
+ nacosEnterBack() {
+ document.getElementById('backarrow').style.color = '#09c';
+ }
+
+ nacosOutBack() {
+ document.getElementById('backarrow').style.color = '#546478';
+ }
+
+ nacosToggleLeftBar() {
+ if (!this.nacosOutDom) return;
+ if (!this.state.leftBarClose) {
+ // 关闭
+ this.nacosOutDom.className = 'viewFramework-product';
+ this.nacosLeftBarDom.style.width = 0;
+ this.nacosBodyDom.style.left = 0;
+ this.nacosToggleIconDom.style.left = 0;
+ } else {
+ this.nacosOutDom.className = 'viewFramework-product viewFramework-product-col-1';
+ this.nacosLeftBarDom.style.width = '180px';
+ this.nacosBodyDom.style.left = '180px';
+ this.nacosToggleIconDom.style.left = '160px';
+ }
+
+ this.setState({
+ leftBarClose: !this.state.leftBarClose,
+ });
+ }
+
+ navTo(url) {
+ if (url !== '/configdetail' && url !== '/configeditor') {
+ // 二级菜单不清空
+ setParams({
+ dataId: '',
+ group: '',
+ });
+ }
+
+ const params = window.location.hash.split('?')[1];
+ const urlArr = params.split('&') || [];
+ const queryParams = [];
+ for (let i = 0; i < urlArr.length; i++) {
+ if (urlArr[i].split('=')[0] !== '_k') {
+ queryParams.push(urlArr[i]);
+ }
+ }
+
+ this.props.history.push(`${url}?${queryParams.join('&')}`);
+ }
+
+ nacosSetSpecialNav(item) {
+ item.children.forEach(_item => {
+ const obj = _item;
+
+ if (obj.dontUseChild === true) {
+ obj.parentName = item.title;
+ obj.parentId = item.id;
+ obj.parentPath = `/${item.id}`;
+ this.deepNav.push(obj);
+ }
+ if (_item.children) {
+ this.nacosSetSpecialNav(_item);
+ }
+ });
+ }
+
+ nacosNavAct(serviceName, match, location) {
+ if (!match) {
+ const formatpath = location.pathname.substr(1); // 得到当前路径
+ const nowpathobj = this.oneLevelNavArr[formatpath]; // 根据平行导航匹配父类
+ if (nowpathobj) {
+ if (nowpathobj.parent === serviceName) {
+ // 如果父类等于当前的导航则高亮
+ return true;
+ }
+ }
+
+ return false;
+ }
+ return true;
+ }
+
+ nacosLoopNavDeeply(data, parentServiceName) {
+ // 深度遍历获取所有的导航数据
+ data.forEach(item => {
+ if (item) {
+ const navObj = item;
+
+ const _parentServiceName = item.serviceName;
+ navObj.parentServiceName = parentServiceName;
+ this.oneLevelNavArr[item.serviceName] = navObj; // 得到每一个层级的导航映射
+ if (item.children && item.children.length > 0) {
+ this.nacosLoopNavDeeply(item.children, _parentServiceName);
+ }
+ }
+ });
+ }
+
+ activeNav(id) {
+ if (this.preActNav) {
+ this.preActNav.removeClass('active');
+ }
+ const nowNav = $(`#${id}`);
+ nowNav.addClass('active');
+ this.preActNav = nowNav;
+ }
+
+ nacosLoopNav(data, _index = 0, parent) {
+ let index = _index;
+ // 遍历导航,只显示2级
+ const self = this;
+ return data.map(item => {
+ if (!item) {
+ return '';
+ }
+ index++;
+ if (item.dontUseChild === true) {
+ return '';
+ }
+ if (item.children && item.children.length > 0) {
+ if (item.isVirtual) {
+ // 如果是虚拟菜单需要增加展开箭头
+ const icon = item.isExtend ? (
+
+ ) : (
+
+ );
+ const hiddenClass = item.isExtend ? '' : 'hidden';
+ return (
+
+
+
+ {self.nacosLoopNav(item.children, index)}
+
+
+ );
+ } else {
+ return (
+
+
+
+ {aliwareIntl.get(item.id) || item.name}
+
+
+ );
+ }
+ }
+ return (
+
+
+
+ {aliwareIntl.get(item.id) || item.name}
+
+
+ );
+ });
+ }
+
+ nacosGetNav(navList) {
+ let navRow = ''; // 导航
+ if (navList.length > 0) {
+ navRow =
{this.nacosLoopNav(navList)}
;
+ this.nacosLoopNavDeeply(navList); // 深度遍历导航树获得平行map
+ }
+ return navRow;
+ }
+
+ UNSAFE_componentWillMount() {
+ const nav = this.props.navList || [];
+ const navRow = this.nacosGetNav(nav);
+ this.setState({
+ navRow,
+ });
+ }
+
+ componentDidMount() {
+ this.nacosLeftBarDom = document.getElementById('viewFramework-product-navbar');
+ this.nacosBodyDom = document.getElementById('viewFramework-product-body');
+ this.nacosToggleIconDom = document.getElementById('viewFramework-product-navbar-collapse');
+ this.nacosOutDom = document.getElementById('page-header-mask');
+ // let parentNav = this.initNav[0] || [];
+ const defaultNav = '/configurationManagement';
+ // let childrenNav = parentNav.children || [];
+ this.props.history.listen(location => {
+ if (this.preSimplePath && this.preSimplePath !== '/') {
+ if (location.pathname.indexOf(this.preSimplePath) !== -1) {
+ return;
+ }
+ }
+ const simplePath = window.location.hash.split('?')[0];
+ const navName = simplePath.substr('2');
+ this.preSimplePath = simplePath;
+
+ if (navName === '') {
+ this.props.history.push(defaultNav);
+ setTimeout(() => {
+ this.activeNav('configurationManagement');
+ });
+ return;
+ }
+
+ const nowNavObj = this.oneLevelNavArr[navName];
+ if (!nowNavObj) {
+ this.setState({
+ noChild: true,
+ });
+ return;
+ }
+ this.setState({
+ noChild: !!nowNavObj.dontUseChild,
+ });
+ const { parentServiceName } = nowNavObj;
+
+ const parentNav = this.oneLevelNavArr[parentServiceName];
+ if (simplePath !== '/' && nowNavObj && parentNav && !parentNav.isVirtual) {
+ this.setState({
+ showLink: (
+
+
+
+ ),
+
+ navRow:
{this.nacosLoopNav([nowNavObj])}
,
+ });
+ setTimeout(() => {
+ const navid = navName;
+ this.activeNav(navid);
+ });
+ } else {
+ this.setState({
+ showLink: null,
+ navRow:
{this.nacosLoopNav(this.initNav)}
,
+ });
+ setTimeout(() => {
+ const navid = navName;
+ this.activeNav(navid);
+ });
+ }
+ });
+ }
+
+ onLanguageChange = language => {
+ aliwareIntl.changeLanguage(language);
+ document.cookie = `docsite_language=${language}`;
+ window.location.reload();
+ };
+
+ render() {
+ const language = aliwareGetCookieByKeyName('docsite_language') || siteConfig.defaultLanguage;
+
+ const { headerType, showLink, navRow, leftBarClose, noChild } = this.state;
+ const headerLogo = `${
+ process.env.NODE_ENV === 'development' ? '' : 'public/'
+ }img/TB118jPv_mWBKNjSZFBXXXxUFXa-2000-390.svg`;
+ return (
+
+
+
+
+
+
+ {showLink ? (
+
+ {showLink}
+
+ ) : (
+
+
+ {aliwareIntl.get(
+ 'com.alibaba.nacos.layout.noenv.app_configuration_management_acm'
+ )}
+
+
+ {aliwareIntl.get('com.alibaba.nacos.layout.noenv.nacosversion')}
+
+
+ )}
+
+
+ {navRow}
+
+
+
+
+
+
+
+
+
+ {leftBarClose ? (
+
+ ) : (
+
+ )}
+
+
+
+
+
+ {!noChild ? (
+
{this.props.children}
+ ) : (
+
+ {aliwareIntl.get('com.alibaba.nacos.layout.noenv.does_not_exist')}
+
+ )}
+
+
+
+ );
+ }
}
diff --git a/console/src/main/resources/static/src/lib.js b/console/src/main/resources/static/src/lib.js
index 51cc09d1d..8fce9ba4c 100644
--- a/console/src/main/resources/static/src/lib.js
+++ b/console/src/main/resources/static/src/lib.js
@@ -12,194 +12,194 @@
*/
import { getParams, request, aliwareIntl } from './globalLib';
-var hasAlert = false;
+let hasAlert = false;
-window.edasprefix = 'acm'; //固定的edas网关需要的项目名
+window.edasprefix = 'acm'; // 固定的edas网关需要的项目名
window.globalConfig = {
- isParentEdas: function () {
- try {
- if (window.parent.location.host.indexOf('edas') !== -1) {
- return true;
- }
- } catch (error) { }
- return false;
- }
+ isParentEdas() {
+ try {
+ if (window.parent.location.host.indexOf('edas') !== -1) {
+ return true;
+ }
+ } catch (error) {}
+ return false;
+ },
};
-request.middleWare(config => {
- let url = config.url;
- let tenant = window.nownamespace || getParams('namespace') || '';
- tenant = tenant === 'global' ? '' : tenant;
- let splitArr = url.split('?');
- if (splitArr.length > 1) {
- let params = splitArr[1];
- if (params.indexOf('dataId') !== -1) {
- url += '&tenant=' + tenant;
- config.url = url;
- }
+request.middleWare((_config = {}) => {
+ let config = _config;
+ let { url = '' } = config;
+ let tenant = window.nownamespace || getParams('namespace') || '';
+ tenant = tenant === 'global' ? '' : tenant;
+ const splitArr = url.split('?');
+ if (splitArr.length > 1) {
+ const params = splitArr[1];
+ if (params.indexOf('dataId') !== -1) {
+ url += `&tenant=${tenant}`;
+ config.url = url;
}
+ }
- let preSucess = config.success;
- let preErorr = config.error;
+ const preSucess = config.success;
+ const preErorr = config.error;
- config.success = function (res) {
+ config.success = function(res) {
+ if (res.code === 'ConsoleNeedLogin' && window.location.host.indexOf('acm') !== -1) {
+ window.location.reload();
+ }
+ if (res.code === 403 && !hasAlert) {
+ hasAlert = true;
+ window.Dialog.alert({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ style: { width: 400 },
+ content: res.message,
+ onOk: () => {
+ hasAlert = false;
+ },
+ onCancel: () => {
+ hasAlert = false;
+ },
+ onClose: () => {
+ hasAlert = false;
+ },
+ });
+ } else {
+ typeof preSucess === 'function' && preSucess(res);
+ }
+ };
- if (res.code === 'ConsoleNeedLogin' && window.location.host.indexOf('acm') !== -1) {
- window.location.reload();
- }
- if (res.code === 403 && !hasAlert) {
- hasAlert = true;
- window.Dialog.alert({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- style: { width: 400 },
- content: res.message,
- onOk: () => {
- hasAlert = false;
- },
- onCancel: () => {
- hasAlert = false;
- },
- onClose: () => {
- hasAlert = false;
- }
- });
- return;
- } else {
- typeof preSucess === "function" && preSucess(res);
- }
- };
+ config.error = function(res) {
+ if (res.status === 403 && !hasAlert) {
+ hasAlert = true;
- config.error = function (res) {
- if (res.status === 403 && !hasAlert) {
- hasAlert = true;
+ window.Dialog.alert({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ style: { width: 400 },
+ content: aliwareIntl.get('com.alibaba.nacos.pubshow'), // '子账号没有权限,请联系主账号负责人RAM上授权',
+ onOk: () => {
+ hasAlert = false;
+ },
+ onCancel: () => {
+ hasAlert = false;
+ },
+ onClose: () => {
+ hasAlert = false;
+ },
+ });
+ } else {
+ typeof preErorr === 'function' && preErorr(res);
+ }
+ };
- window.Dialog.alert({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- style: { width: 400 },
- content: aliwareIntl.get('com.alibaba.nacos.pubshow'), //'子账号没有权限,请联系主账号负责人RAM上授权',
- onOk: () => {
- hasAlert = false;
- },
- onCancel: () => {
- hasAlert = false;
- },
- onClose: () => {
- hasAlert = false;
- }
- });
- return;
- } else {
- typeof preErorr === "function" && preErorr(res);
- }
- };
-
- return config;
+ return config;
});
/**
* 配置 monaco
*/
-window.require.config({ paths: { 'vs': process.env.NODE_ENV === 'development' ? 'js/vs' : 'public/js/vs' } });
window.require.config({
- 'vs/nls': {
- availableLanguages: {
- '*': 'zh-cn'
- }
- }
+ paths: { vs: process.env.NODE_ENV === 'development' ? 'js/vs' : 'public/js/vs' },
+});
+window.require.config({
+ 'vs/nls': {
+ availableLanguages: {
+ '*': 'zh-cn',
+ },
+ },
});
window.require(['vs/editor/editor.main'], () => {
- // Register a new language
- window.monaco.languages.register({ id: 'properties' });
+ // Register a new language
+ window.monaco.languages.register({ id: 'properties' });
- // Register a tokens provider for the language
- window.monaco.languages.setMonarchTokensProvider('properties', {
- tokenizer: {
- root: [[/^\#.*/, 'comment'], [/.*\=/, 'key'], [/^=.*/, 'value']]
- }
- });
+ // Register a tokens provider for the language
+ window.monaco.languages.setMonarchTokensProvider('properties', {
+ tokenizer: {
+ root: [[/^\#.*/, 'comment'], [/.*\=/, 'key'], [/^=.*/, 'value']],
+ },
+ });
- // Define a new theme that constains only rules that match this language
- window.monaco.editor.defineTheme('properties', {
- base: 'vs',
- inherit: false,
- rules: [{ token: 'key', foreground: '009968' }, { token: 'value', foreground: '009968' }, { token: 'comment', foreground: '666666' }]
- });
+ // Define a new theme that constains only rules that match this language
+ window.monaco.editor.defineTheme('properties', {
+ base: 'vs',
+ inherit: false,
+ rules: [
+ { token: 'key', foreground: '009968' },
+ { token: 'value', foreground: '009968' },
+ { token: 'comment', foreground: '666666' },
+ ],
+ });
- // Register a completion item provider for the new language
- window.monaco.languages.registerCompletionItemProvider('properties', {
- provideCompletionItems: () => {
- return [{
- label: 'simpleText',
- kind: window.monaco.languages.CompletionItemKind.Text
- }, {
- label: 'testing',
- kind: window.monaco.languages.CompletionItemKind.Keyword,
- insertText: {
- value: `testing(\${1:condition})`
- }
- }, {
- label: 'ifelse',
- kind: window.monaco.languages.CompletionItemKind.Snippet,
- insertText: {
- value: [`if (\${1:condition}) {`, '\t$0', '} else {', '\t', '}'].join('\n')
- },
- documentation: 'If-Else Statement'
- }];
- }
- });
+ // Register a completion item provider for the new language
+ window.monaco.languages.registerCompletionItemProvider('properties', {
+ provideCompletionItems: () => [
+ {
+ label: 'simpleText',
+ kind: window.monaco.languages.CompletionItemKind.Text,
+ },
+ {
+ label: 'testing',
+ kind: window.monaco.languages.CompletionItemKind.Keyword,
+ insertText: {
+ value: 'testing(${1:condition})',
+ },
+ },
+ {
+ label: 'ifelse',
+ kind: window.monaco.languages.CompletionItemKind.Snippet,
+ insertText: {
+ value: ['if (${1:condition}) {', '\t$0', '} else {', '\t', '}'].join('\n'),
+ },
+ documentation: 'If-Else Statement',
+ },
+ ],
+ });
});
window.importEditor = callback => {
- window.require(['vs/editor/editor.main'], () => {
- callback && callback();
- });
+ window.require(['vs/editor/editor.main'], () => {
+ callback && callback();
+ });
};
-//同步获取命名空间地址
-
-window._getLink = function () {
- let _linkObj = {};
- // request({
- // url: "com.alibaba.nacos.service.getLinks",
- // async: false,
- // data: {},
- // success: res => {
- // if (res.code === 200) {
- // _linkObj = res.data;
- // }
- // }
- // });
- return function (linkName) {
- return _linkObj[linkName] || "";
- };
-}(window);
+// 同步获取命名空间地址
+window._getLink = (function() {
+ const _linkObj = {};
+ // request({
+ // url: "com.alibaba.nacos.service.getLinks",
+ // async: false,
+ // data: {},
+ // success: res => {
+ // if (res.code === 200) {
+ // _linkObj = res.data;
+ // }
+ // }
+ // });
+ return function(linkName) {
+ return _linkObj[linkName] || '';
+ };
+})(window);
window.addEventListener('resize', () => {
- try {
-
- if (this.timmer) {
- clearTimeout(this.timmer);
- }
- this.timmer = setTimeout(() => {
- let height = document.body.clientHeight;
- height = height > 800 ? height : 800;
- window.parent.adjustHeight && window.parent.adjustHeight(height);
- }, 500);
- } catch (e) {
-
+ try {
+ if (this.timmer) {
+ clearTimeout(this.timmer);
}
-})
-//判断是否是国际站国际用户
-window.isIntel = function () {
-
- let host = window.location.host;
- if (host.indexOf('alibabacloud.com') !== -1) {
- return true;
- } else {
- return false;
- }
-
-}
\ No newline at end of file
+ this.timmer = setTimeout(() => {
+ let height = document.body.clientHeight;
+ height = height > 800 ? height : 800;
+ window.parent.adjustHeight && window.parent.adjustHeight(height);
+ }, 500);
+ } catch (e) {}
+});
+// 判断是否是国际站国际用户
+window.isIntel = function() {
+ const { host } = window.location;
+ if (host.indexOf('alibabacloud.com') !== -1) {
+ return true;
+ } else {
+ return false;
+ }
+};
diff --git a/console/src/main/resources/static/src/menu.js b/console/src/main/resources/static/src/menu.js
index 4dd571ee8..79ef76d99 100644
--- a/console/src/main/resources/static/src/menu.js
+++ b/console/src/main/resources/static/src/menu.js
@@ -12,219 +12,219 @@
*/
module.exports = {
- "data": [
+ data: [
+ {
+ isExtend: true,
+ name: '配置管理',
+ title: '配置管理',
+ isVirtual: true,
+ projectName: 'nacos',
+ serviceName: 'configurationManagementVirtual',
+ link: 'configurationManagementVirtual',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.configurationManagementVirtual',
+ useRouter: false,
+ id: 'com.alibaba.nacos.page.configurationManagementVirtual',
+ children: [
{
- "isExtend": true,
- "name": "配置管理",
- "title": "配置管理",
- "isVirtual": true,
- "projectName": "nacos",
- "serviceName": "configurationManagementVirtual",
- "link": "configurationManagementVirtual",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.configurationManagementVirtual",
- "useRouter": false,
- "id": "com.alibaba.nacos.page.configurationManagementVirtual",
- "children": [
- {
- "isExtend": false,
- "name": "配置列表",
- "title": "配置列表",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "configurationManagement",
- "link": "configurationManagement",
- "hasFusion": true,
- "template": "",
- "dontUseChild": false,
- "registerName": "com.alibaba.nacos.page.configurationManagement",
- "useRouter": false,
- "id": "configurationManagement",
- "children": [
- {
- "isExtend": false,
- "name": "配置详情",
- "title": "配置详情",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "configdetail",
- "link": "Configdetail",
- "hasFusion": true,
- "template": "",
- "dontUseChild": false,
- "registerName": "com.alibaba.nacos.page.configdetail",
- "useRouter": false,
- "id": "configdetail"
- },
- {
- "isExtend": false,
- "name": "同步配置",
- "title": "同步配置",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "configsync",
- "link": "configsync",
- "hasFusion": true,
- "template": "",
- "dontUseChild": true,
- "registerName": "com.alibaba.nacos.page.configsync",
- "useRouter": false,
- "id": "configsync"
- },
- {
- "isExtend": false,
- "name": "配置编辑",
- "title": "配置编辑",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "configeditor",
- "link": "configeditor",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.configeditor",
- "useRouter": false,
- "id": "configeditor"
- },
- {
- "isExtend": false,
- "name": "新建配置",
- "title": "新建配置",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "newconfig",
- "link": "newconfig",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.newconfig",
- "useRouter": false,
- "id": "newconfig"
- }
- ]
- },
- {
- "isExtend": false,
- "name": "历史版本",
- "title": "历史版本",
- "isVirtual": false,
- "projectName": "nacos",
- "children": [
- {
- "isExtend": false,
- "name": "配置回滚",
- "title": "配置回滚",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "configRollback",
- "link": "configRollback",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.configRollback",
- "useRouter": false,
- "id": "configRollback"
- },
- {
- "isExtend": false,
- "name": "历史详情",
- "title": "历史详情",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "historyDetail",
- "link": "historyDetail",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.historyDetail",
- "useRouter": false,
- "id": "historyDetail"
- }
- ],
- "serviceName": "historyRollback",
- "link": "historyRollback",
- "hasFusion": true,
- "template": "",
- "dontUseChild": false,
- "registerName": "com.alibaba.nacos.page.historyRollback",
- "useRouter": false,
- "id": "historyRollback"
- },
- {
- "isExtend": false,
- "name": "监听查询",
- "title": "监听查询",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "listeningToQuery",
- "link": "listeningToQuery",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.listeningToQuery",
- "useRouter": false,
- "id": "listeningToQuery"
- }
- ]
+ isExtend: false,
+ name: '配置列表',
+ title: '配置列表',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'configurationManagement',
+ link: 'configurationManagement',
+ hasFusion: true,
+ template: '',
+ dontUseChild: false,
+ registerName: 'com.alibaba.nacos.page.configurationManagement',
+ useRouter: false,
+ id: 'configurationManagement',
+ children: [
+ {
+ isExtend: false,
+ name: '配置详情',
+ title: '配置详情',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'configdetail',
+ link: 'Configdetail',
+ hasFusion: true,
+ template: '',
+ dontUseChild: false,
+ registerName: 'com.alibaba.nacos.page.configdetail',
+ useRouter: false,
+ id: 'configdetail',
+ },
+ {
+ isExtend: false,
+ name: '同步配置',
+ title: '同步配置',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'configsync',
+ link: 'configsync',
+ hasFusion: true,
+ template: '',
+ dontUseChild: true,
+ registerName: 'com.alibaba.nacos.page.configsync',
+ useRouter: false,
+ id: 'configsync',
+ },
+ {
+ isExtend: false,
+ name: '配置编辑',
+ title: '配置编辑',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'configeditor',
+ link: 'configeditor',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.configeditor',
+ useRouter: false,
+ id: 'configeditor',
+ },
+ {
+ isExtend: false,
+ name: '新建配置',
+ title: '新建配置',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'newconfig',
+ link: 'newconfig',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.newconfig',
+ useRouter: false,
+ id: 'newconfig',
+ },
+ ],
},
{
- "isExtend": true,
- "name": "服务管理",
- "title": "服务管理",
- "isVirtual": true,
- "projectName": "nacos",
- "serviceName": "serviceManagementVirtual",
- "link": "serviceManagementVirtual",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.serviceManagementVirtual",
- "useRouter": false,
- "id": "com.alibaba.nacos.page.serviceManagementVirtual",
- "children": [
- {
- "isExtend": false,
- "name": "服务列表",
- "title": "服务列表",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "serviceManagement",
- "link": "serviceManagement",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.serviceManagement",
- "useRouter": false,
- "id": "serviceManagement",
- "children":[
- {
- "isExtend": true,
- "name": "服务详情",
- "title": "服务详情",
- "isVirtual": true,
- "projectName": "nacos",
- "serviceName": "serviceDetail",
- "link": "serviceDetail",
- "hasFusion": true,
- "template": "",
- "registerName": "com.alibaba.nacos.page.ServiceDetail",
- "useRouter": false,
- "id": "serviceDetail",
- }
- ]
- }
- ]
+ isExtend: false,
+ name: '历史版本',
+ title: '历史版本',
+ isVirtual: false,
+ projectName: 'nacos',
+ children: [
+ {
+ isExtend: false,
+ name: '配置回滚',
+ title: '配置回滚',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'configRollback',
+ link: 'configRollback',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.configRollback',
+ useRouter: false,
+ id: 'configRollback',
+ },
+ {
+ isExtend: false,
+ name: '历史详情',
+ title: '历史详情',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'historyDetail',
+ link: 'historyDetail',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.historyDetail',
+ useRouter: false,
+ id: 'historyDetail',
+ },
+ ],
+ serviceName: 'historyRollback',
+ link: 'historyRollback',
+ hasFusion: true,
+ template: '',
+ dontUseChild: false,
+ registerName: 'com.alibaba.nacos.page.historyRollback',
+ useRouter: false,
+ id: 'historyRollback',
},
{
- "isExtend": false,
- "name": "命名空间",
- "title": "命名空间",
- "isVirtual": false,
- "projectName": "nacos",
- "serviceName": "namespace",
- "link": "namespace",
- "hasFusion": true,
- "template": "",
- "dontUseChild": false,
- "registerName": "com.alibaba.nacos.page.namespace",
- "useRouter": false,
- "id": "namespace"
- }
- ],
- "defaultKey": "configurationManagement",
- "projectName": "nacos"
-}
+ isExtend: false,
+ name: '监听查询',
+ title: '监听查询',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'listeningToQuery',
+ link: 'listeningToQuery',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.listeningToQuery',
+ useRouter: false,
+ id: 'listeningToQuery',
+ },
+ ],
+ },
+ {
+ isExtend: true,
+ name: '服务管理',
+ title: '服务管理',
+ isVirtual: true,
+ projectName: 'nacos',
+ serviceName: 'serviceManagementVirtual',
+ link: 'serviceManagementVirtual',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.serviceManagementVirtual',
+ useRouter: false,
+ id: 'com.alibaba.nacos.page.serviceManagementVirtual',
+ children: [
+ {
+ isExtend: false,
+ name: '服务列表',
+ title: '服务列表',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'serviceManagement',
+ link: 'serviceManagement',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.serviceManagement',
+ useRouter: false,
+ id: 'serviceManagement',
+ children: [
+ {
+ isExtend: true,
+ name: '服务详情',
+ title: '服务详情',
+ isVirtual: true,
+ projectName: 'nacos',
+ serviceName: 'serviceDetail',
+ link: 'serviceDetail',
+ hasFusion: true,
+ template: '',
+ registerName: 'com.alibaba.nacos.page.ServiceDetail',
+ useRouter: false,
+ id: 'serviceDetail',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ isExtend: false,
+ name: '命名空间',
+ title: '命名空间',
+ isVirtual: false,
+ projectName: 'nacos',
+ serviceName: 'namespace',
+ link: 'namespace',
+ hasFusion: true,
+ template: '',
+ dontUseChild: false,
+ registerName: 'com.alibaba.nacos.page.namespace',
+ useRouter: false,
+ id: 'namespace',
+ },
+ ],
+ defaultKey: 'configurationManagement',
+ projectName: 'nacos',
+};
diff --git a/console/src/main/resources/static/src/models/error.js b/console/src/main/resources/static/src/models/error.js
index 77482a8bf..e3a5905df 100644
--- a/console/src/main/resources/static/src/models/error.js
+++ b/console/src/main/resources/static/src/models/error.js
@@ -14,32 +14,32 @@
export default {
- namespace: 'error',
+ namespace: 'error',
- state: {
- errinfo: '未知错误',
- errcode: 0,
- erralert: false,
- },
+ state: {
+ errinfo: '未知错误',
+ errcode: 0,
+ erralert: false,
+ },
- subscriptions: {
+ subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line
- },
},
+ },
- effects: {
+ effects: {
*fetch({ payload }, { call, put }) { // eslint-disable-line
- yield put({ type: 'save' });
- },
+ yield put({ type: 'save' });
},
+ },
- reducers: {
- save(state, action) {
- return { ...state, ...action.payload, errcode: 1 };
- },
- clear(state, action) {
- return { ...state, errinfo: '', errcode: 0 };
- },
+ reducers: {
+ save(state, action) {
+ return { ...state, ...action.payload, errcode: 1 };
},
+ clear(state, action) {
+ return { ...state, errinfo: '', errcode: 0 };
+ },
+ },
};
diff --git a/console/src/main/resources/static/src/models/loading.js b/console/src/main/resources/static/src/models/loading.js
index 5561ad487..19f71c7d2 100644
--- a/console/src/main/resources/static/src/models/loading.js
+++ b/console/src/main/resources/static/src/models/loading.js
@@ -14,39 +14,39 @@
export default {
- namespace: 'loading',
+ namespace: 'loading',
- state: {
- loading: false
- },
+ state: {
+ loading: false,
+ },
- subscriptions: {
+ subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line
- },
},
+ },
- effects: {
+ effects: {
- *open({ payload }, { call, put }) {
- try {
- yield put({ type: 'save', payload: { loading: true } });
- } catch (e) {
- yield put({ type: 'error/save', payload: { errinfo: e.message } })
- }
- },
- *close({ payload }, { call, put }) {
- try {
- yield put({ type: 'save', payload: { loading: false } });
- } catch (e) {
- yield put({ type: 'error/save', payload: { errinfo: e.message } })
- }
- }
+ * open({ payload }, { call, put }) {
+ try {
+ yield put({ type: 'save', payload: { loading: true } });
+ } catch (e) {
+ yield put({ type: 'error/save', payload: { errinfo: e.message } });
+ }
},
-
- reducers: {
- save(state, action) {
- return { ...state, ...action.payload };
- }
+ * close({ payload }, { call, put }) {
+ try {
+ yield put({ type: 'save', payload: { loading: false } });
+ } catch (e) {
+ yield put({ type: 'error/save', payload: { errinfo: e.message } });
+ }
},
+ },
+
+ reducers: {
+ save(state, action) {
+ return { ...state, ...action.payload };
+ },
+ },
};
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js
index d82897c41..4e13595db 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js
@@ -15,185 +15,243 @@ import React from 'react';
import './index.less';
import { getParams, request, aliwareIntl } from '../../../globalLib';
import { Button, Dialog, Field, Form, Input, Loading, Tab } from '@alifd/next';
+
const TabPane = Tab.Item;
const FormItem = Form.Item;
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class ConfigDetail extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- loading: false,
- showmore: false,
- activeKey: 'normal',
- hasbeta: false,
- ips: '',
- checkedBeta: false,
- switchEncrypt: false,
- tag: [{ title: aliwareIntl.get('com.alibaba.nacos.page.configdetail.official'), key: 'normal' }]
- };
- this.field = new Field(this);
- this.dataId = getParams('dataId') || 'yanlin';
- this.group = getParams('group') || 'DEFAULT_GROUP';
- this.ips = '';
- this.valueMap = {}; //存储不同版本的数据
- this.tenant = getParams('namespace') || '';
- this.searchDataId = getParams('searchDataId') || '';
- this.searchGroup = getParams('searchGroup') || '';
- //this.params = window.location.hash.split('?')[1]||'';
- }
+ constructor(props) {
+ super(props);
+ this.state = {
+ loading: false,
+ showmore: false,
+ activeKey: 'normal',
+ hasbeta: false,
+ ips: '',
+ checkedBeta: false,
+ switchEncrypt: false,
+ tag: [
+ { title: aliwareIntl.get('com.alibaba.nacos.page.configdetail.official'), key: 'normal' },
+ ],
+ };
+ this.field = new Field(this);
+ this.dataId = getParams('dataId') || 'yanlin';
+ this.group = getParams('group') || 'DEFAULT_GROUP';
+ this.ips = '';
+ this.valueMap = {}; // 存储不同版本的数据
+ this.tenant = getParams('namespace') || '';
+ this.searchDataId = getParams('searchDataId') || '';
+ this.searchGroup = getParams('searchGroup') || '';
+ // this.params = window.location.hash.split('?')[1]||'';
+ }
- componentDidMount() {
- if (this.dataId.startsWith("cipher-")) {
- this.setState({
- switchEncrypt: true
- });
+ componentDidMount() {
+ if (this.dataId.startsWith('cipher-')) {
+ this.setState({
+ switchEncrypt: true,
+ });
+ }
+ this.getDataDetail();
+ }
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ changeTab(value) {
+ const self = this;
+ const key = value.split('-')[0];
+ const data = this.valueMap[key];
+ this.setState({
+ activeKey: value,
+ });
+
+ self.field.setValue('content', data.content);
+
+ if (data.betaIps) {
+ self.setState({
+ ips: data.betaIps,
+ });
+ }
+ }
+
+ toggleMore() {
+ this.setState({
+ showmore: !this.state.showmore,
+ });
+ }
+
+ getDataDetail() {
+ const self = this;
+ this.serverId = getParams('serverId') || 'center';
+ this.tenant = getParams('namespace') || '';
+ this.edasAppName = getParams('edasAppName') || '';
+ this.inApp = this.edasAppName;
+ const url = `/nacos/v1/cs/configs?show=all&dataId=${this.dataId}&group=${this.group}`;
+ request({
+ url,
+ beforeSend() {
+ self.openLoading();
+ },
+ success(result) {
+ if (result != null) {
+ const data = result;
+ self.valueMap.normal = data;
+ self.field.setValue('dataId', data.dataId);
+ self.field.setValue('content', data.content);
+ self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
+ self.field.setValue('envs', self.serverId);
+ self.field.setValue('group', data.group);
+ self.field.setValue('config_tags', data.configTags);
+ self.field.setValue('desc', data.desc);
+ self.field.setValue('md5', data.md5);
+ } else {
+ Dialog.alert({
+ title: aliwareIntl.get('com.alibaba.nacos.page.configdetail.error'),
+ content: result.message,
+ language: aliwareIntl.currentLanguageCode,
+ });
}
- this.getDataDetail();
- }
- openLoading() {
- this.setState({
- loading: true
- });
- }
- closeLoading() {
- this.setState({
- loading: false
- });
- }
+ },
+ complete() {
+ self.closeLoading();
+ },
+ });
+ }
- changeTab(value) {
+ goList() {
+ this.props.history.push(
+ `/configurationManagement?serverId=${this.serverId}&group=${this.searchGroup}&dataId=${
+ this.searchDataId
+ }&namespace=${this.tenant}`
+ );
+ }
- let self = this;
- let key = value.split('-')[0];
- let data = this.valueMap[key];
- console.log(data);
- this.setState({
- activeKey: value
- });
-
- self.field.setValue('content', data.content);
-
- if (data.betaIps) {
- self.setState({
- ips: data.betaIps
- });
- }
- }
- toggleMore() {
- this.setState({
- showmore: !this.state.showmore
- });
- }
-
- getDataDetail() {
- let self = this;
- this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || '';
- this.edasAppName = getParams('edasAppName') || '';
- this.inApp = this.edasAppName;
- let url = `/nacos/v1/cs/configs?show=all&dataId=${this.dataId}&group=${this.group}`;
- request({
- url: url,
- beforeSend: function () {
- self.openLoading();
- },
- success: function (result) {
- if (result != null) {
- let data = result;
- self.valueMap['normal'] = data;
- self.field.setValue('dataId', data.dataId);
- self.field.setValue('content', data.content);
- self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
- self.field.setValue('envs', self.serverId);
- self.field.setValue('group', data.group);
- self.field.setValue('config_tags', data.configTags);
- self.field.setValue('desc', data.desc);
- self.field.setValue('md5', data.md5);
- } else {
- Dialog.alert({
- title: aliwareIntl.get('com.alibaba.nacos.page.configdetail.error'),
- content: result.message,
- language: aliwareIntl.currentLanguageCode
- });
- }
- },
- complete: function () {
- self.closeLoading();
- }
- });
- }
- goList() {
- this.props.history.push(`/configurationManagement?serverId=${this.serverId}&group=${this.searchGroup}&dataId=${this.searchDataId}&namespace=${this.tenant}`);
- }
- render() {
- const init = this.field.init;
- const formItemLayout = {
- labelCol: {
- span: 2
- },
- wrapperCol: {
- span: 22
- }
- };
- let activeKey = this.state.activeKey.split('-')[0];
- return (
-
-
- {aliwareIntl.get('com.alibaba.nacos.page.configdetail.configuration_details')}
- {this.state.hasbeta ?
-
-
- {this.state.tag.map(tab => )}
-
-
-
: ''}
-
-
+ render() {
+ const { init } = this.field;
+ const formItemLayout = {
+ labelCol: {
+ span: 2,
+ },
+ wrapperCol: {
+ span: 22,
+ },
+ };
+ const activeKey = this.state.activeKey.split('-')[0];
+ return (
+
+
+
+ {aliwareIntl.get('com.alibaba.nacos.page.configdetail.configuration_details')}
+
+ {this.state.hasbeta ? (
+
+
+ {this.state.tag.map(tab => (
+
+ ))}
+
- );
- }
+ ) : (
+ ''
+ )}
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default ConfigDetail;
\ No newline at end of file
+
+export default ConfigDetail;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/index.js
index 04cd1588d..d468d92ce 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigDetail/index.js
@@ -13,4 +13,4 @@
import ConfigDetail from './ConfigDetail';
-export default ConfigDetail;
\ No newline at end of file
+export default ConfigDetail;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js
index a03fdaf08..cedc3ee3f 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js
@@ -17,591 +17,762 @@ import { getParams, request, aliwareIntl } from '../../../globalLib';
import DiffEditorDialog from '../../../components/DiffEditorDialog';
import SuccessDialog from '../../../components/SuccessDialog';
import './index.less';
-import { Balloon, Button, Dialog, Field, Form, Icon, Input, Loading, Radio, Select, Tab, Message } from '@alifd/next';
+import {
+ Balloon,
+ Button,
+ Dialog,
+ Field,
+ Form,
+ Icon,
+ Input,
+ Loading,
+ Radio,
+ Select,
+ Tab,
+ Message,
+} from '@alifd/next';
+
const TabPane = Tab.Item;
const FormItem = Form.Item;
const { Group: RadioGroup } = Radio;
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class ConfigEditor extends React.Component {
- constructor(props) {
- super(props);
- this.edasAppName = getParams('edasAppName') || '';
- this.edasAppId = getParams('edasAppId') || '';
- this.inApp = this.edasAppName;
- this.field = new Field(this);
- this.dataId = getParams('dataId') || 'yanlin';
- this.group = getParams('group') || 'DEFAULT_GROUP';
- this.tenant = getParams('namespace') | '';
- this.state = {
- configType: 'text',
- codeValue: ``,
- envname: 'center',
- targetEnvName: '',
- envlist: [],
- envvalues: [],
- loading: false,
- showmore: false,
- activeKey: 'normal',
- hasbeta: false,
- ips: '',
- checkedBeta: false,
- tagLst: [],
- config_tags: [],
- switchEncrypt: false,
- tag: [{ title: aliwareIntl.get('com.alibaba.nacos.page.configeditor.official'), key: 'normal' }]
- };
- this.codeValue = '';
- this.mode = 'text';
- this.ips = '';
- this.valueMap = {}; //存储不同版本的数据
- this.searchDataId = getParams('searchDataId') || '';
- this.searchGroup = getParams('searchGroup') || '';
- }
- componentDidMount() {
- if (this.dataId.startsWith("cipher-")) {
- this.setState({
- switchEncrypt: true
- });
- }
- this.betaips = document.getElementById('betaips');
- this.getDataDetail();
- this.chontenttab = document.getElementById('chontenttab'); //diff标签
+ constructor(props) {
+ super(props);
+ this.edasAppName = getParams('edasAppName') || '';
+ this.edasAppId = getParams('edasAppId') || '';
+ this.inApp = this.edasAppName;
+ this.field = new Field(this);
+ this.dataId = getParams('dataId') || 'yanlin';
+ this.group = getParams('group') || 'DEFAULT_GROUP';
+ this.tenant = getParams('namespace') || '';
+ this.state = {
+ configType: 'text',
+ codeValue: '',
+ envname: 'center',
+ targetEnvName: '',
+ envlist: [],
+ envvalues: [],
+ loading: false,
+ showmore: false,
+ activeKey: 'normal',
+ hasbeta: false,
+ ips: '',
+ checkedBeta: false,
+ tagLst: [],
+ config_tags: [],
+ switchEncrypt: false,
+ tag: [
+ { title: aliwareIntl.get('com.alibaba.nacos.page.configeditor.official'), key: 'normal' },
+ ],
+ };
+ this.codeValue = '';
+ this.mode = 'text';
+ this.ips = '';
+ this.valueMap = {}; // 存储不同版本的数据
+ this.searchDataId = getParams('searchDataId') || '';
+ this.searchGroup = getParams('searchGroup') || '';
+ }
+ componentDidMount() {
+ if (this.dataId.startsWith('cipher-')) {
+ this.setState({
+ switchEncrypt: true,
+ });
}
+ this.betaips = document.getElementById('betaips');
+ this.getDataDetail();
+ this.chontenttab = document.getElementById('chontenttab'); // diff标签
+ }
- initMoacoEditor(language, value) {
- if (!window.monaco) {
- window.importEditor(() => {
- this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
- value: value,
- language: this.state.configType,
- codeLens: true,
- selectOnLineNumbers: true,
- roundedSelection: false,
- readOnly: false,
- lineNumbersMinChars: true,
- theme: 'vs-dark',
- wordWrapColumn: 120,
- folding: true,
- showFoldingControls: 'always',
- wordWrap: 'wordWrapColumn',
- cursorStyle: 'line',
- automaticLayout: true
- });
- });
+ initMoacoEditor(language, value) {
+ if (!window.monaco) {
+ window.importEditor(() => {
+ this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
+ value,
+ language: this.state.configType,
+ codeLens: true,
+ selectOnLineNumbers: true,
+ roundedSelection: false,
+ readOnly: false,
+ lineNumbersMinChars: true,
+ theme: 'vs-dark',
+ wordWrapColumn: 120,
+ folding: true,
+ showFoldingControls: 'always',
+ wordWrap: 'wordWrapColumn',
+ cursorStyle: 'line',
+ automaticLayout: true,
+ });
+ });
+ } else {
+ this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
+ value,
+ language: this.state.configType,
+ codeLens: true,
+ selectOnLineNumbers: true,
+ roundedSelection: false,
+ readOnly: false,
+ lineNumbersMinChars: true,
+ theme: 'vs-dark',
+ wordWrapColumn: 120,
+ folding: true,
+ showFoldingControls: 'always',
+ wordWrap: 'wordWrapColumn',
+ cursorStyle: 'line',
+ automaticLayout: true,
+ });
+ }
+ }
+
+ toggleMore() {
+ this.setState({
+ showmore: !this.state.showmore,
+ });
+ }
+
+ navTo(url) {
+ this.serverId = getParams('serverId') || '';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.props.history.push(
+ `${url}?serverId=${this.serverId || ''}&dataId=${this.dataId}&group=${this.group}&namespace=${
+ this.tenant
+ }`
+ );
+ }
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ getDataDetail() {
+ const self = this;
+ this.tenant = getParams('namespace') || '';
+ this.serverId = getParams('serverId') || 'center';
+ const url = `/nacos/v1/cs/configs?show=all&dataId=${this.dataId}&group=${this.group}`;
+ request({
+ url,
+ beforeSend() {
+ self.openLoading();
+ },
+ success(result) {
+ if (result != null) {
+ const data = result;
+ self.valueMap.normal = data;
+ self.field.setValue('dataId', data.dataId);
+ // self.field.setValue('content', data.content);
+ self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
+ // self.field.setValue('envs', self.serverId);
+ self.field.setValue('group', data.group);
+
+ // self.field.setValue('type', data.type);
+ self.field.setValue('desc', data.desc);
+ // self.field.setValue('md5', data.md5);
+ self.codeValue = data.content || '';
+ const type = data.type || 'text';
+ self.setState({
+ // 设置radio 高亮
+ configType: type,
+ });
+ self.initMoacoEditor(type, self.codeValue);
+
+ // self.createCodeMirror('text', self.codeValue);
+ // self.codeValue = self.commoneditor.doc.getValue();
+ if (data.configTags != null) {
+ const tagArr = data.configTags.split(',');
+ self.setConfigTags(tagArr);
+ }
+
+ const envvalues = [];
+ const env = {};
+ self.serverId = env.serverId;
+ self.targetEnvs = envvalues;
} else {
- this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
- value: value,
- language: this.state.configType,
- codeLens: true,
- selectOnLineNumbers: true,
- roundedSelection: false,
- readOnly: false,
- lineNumbersMinChars: true,
- theme: 'vs-dark',
- wordWrapColumn: 120,
- folding: true,
- showFoldingControls: 'always',
- wordWrap: 'wordWrapColumn',
- cursorStyle: 'line',
- automaticLayout: true
- });
+ Dialog.alert({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ title: aliwareIntl.get('com.alibaba.nacos.page.configeditor.wrong'),
+ content: result.message,
+ });
}
- }
+ },
+ complete() {
+ self.closeLoading();
+ },
+ });
+ }
- toggleMore() {
- this.setState({
- showmore: !this.state.showmore
+ goList() {
+ const tenant = getParams('namespace');
+ this.props.history.push(
+ `/configurationManagement?serverId=${this.serverId}&group=${this.searchGroup}&dataId=${
+ this.searchDataId
+ }&namespace=${tenant}`
+ );
+ }
+
+ createCodeMirror(mode, value) {
+ const commontarget = this.refs.commoneditor;
+ commontarget.innerHTML = '';
+ this.commoneditor = window.CodeMirror(commontarget, {
+ value,
+ mode,
+ lineNumbers: true,
+ theme: 'xq-light',
+ lint: true,
+ gutters: ['CodeMirror-lint-markers'],
+ extraKeys: {
+ F1(cm) {
+ cm.setOption('fullScreen', !cm.getOption('fullScreen'));
+ },
+ Esc(cm) {
+ if (cm.getOption('fullScreen')) cm.setOption('fullScreen', false);
+ },
+ },
+ });
+ this.commoneditor.on('change', this.codemirrorValueChanged.bind(this));
+ }
+
+ codemirrorValueChanged(doc) {
+ if (this.diffeditor) {
+ this.diffeditor.edit.doc.setValue(doc.getValue());
+ }
+ }
+
+ createDiffCodeMirror(leftCode, rightCode) {
+ const target = this.refs.diffeditor;
+ target.innerHTML = '';
+
+ this.diffeditor = window.CodeMirror.MergeView(target, {
+ value: leftCode || '',
+ origLeft: null,
+ orig: rightCode || '',
+ lineNumbers: true,
+ mode: this.mode,
+ theme: 'xq-light',
+ highlightDifferences: true,
+ connect: 'align',
+ collapseIdentical: false,
+ });
+ }
+
+ changeConfig(value) {
+ if (value === 0) {
+ this.createCodeMirror('text', this.codeValue);
+ this.mode = 'text';
+ }
+ if (value === 1) {
+ this.createCodeMirror('application/json', this.codeValue);
+ this.mode = 'application/json';
+ }
+ if (value === 2) {
+ this.createCodeMirror('xml', this.codeValue);
+ this.mode = 'xml';
+ }
+ this.setState({
+ configType: value,
+ });
+ }
+
+ setCodeValue(value) {
+ this.setState({
+ codeValue: value,
+ });
+ }
+
+ toggleDiff(checked) {
+ if (checked) {
+ this.chontenttab.style.display = 'block';
+
+ const nowvalue = this.commoneditor.doc.getValue();
+ if (!this.diffeditor) {
+ this.createDiffCodeMirror(nowvalue, this.codeValue);
+ }
+ } else {
+ this.chontenttab.style.display = 'none';
+ // this.diffeditor = null;
+ // let target = this.refs["diffeditor"];
+ // target.innerHTML = '';
+ }
+ }
+
+ publishConfig() {
+ this.field.validate((errors, values) => {
+ if (errors) {
+ return;
+ }
+ let content = '';
+ const self = this;
+ // if (this.commoneditor) {
+ // content = this.commoneditor.doc.getValue();
+ // //content = content.replace("↵", "\n\r");
+ // } else {
+ // content = this.codeValue;
+ // }
+
+ if (this.monacoEditor) {
+ content = this.monacoEditor.getValue();
+ } else {
+ content = this.codeValue;
+ }
+ if (!content) {
+ Message.error({
+ content: aliwareIntl.get('nacos.page.ConfigEditor.submit_failed'),
+ align: 'cc cc',
});
- }
- navTo(url) {
+ return;
+ }
+ this.codeValue = content;
+ this.tenant = getParams('namespace') || '';
+ this.serverId = getParams('serverId') || 'center';
- this.serverId = getParams('serverId') || '';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.props.history.push(`${url}?serverId=${this.serverId || ''}&dataId=${this.dataId}&group=${this.group}&namespace=${this.tenant}`);
- }
+ const payload = {
+ dataId: this.field.getValue('dataId'),
+ appName: this.inApp ? this.edasAppId : this.field.getValue('appName'),
+ group: this.field.getValue('group'),
+ desc: this.field.getValue('desc'),
+ config_tags: this.state.config_tags.join(),
+ type: this.state.configType,
+ content,
+ tenant: this.tenant,
+ };
+ const url = '/nacos/v1/cs/configs';
+ request({
+ type: 'post',
+ contentType: 'application/x-www-form-urlencoded',
+ url,
+ data: payload,
+ success(res) {
+ const _payload = {};
+ _payload.maintitle = aliwareIntl.get('com.alibaba.nacos.page.configeditor.toedittitle');
+ _payload.title = (
+
{aliwareIntl.get('com.alibaba.nacos.page.configeditor.toedit')}
+ );
+ _payload.content = '';
+ _payload.dataId = payload.dataId;
+ _payload.group = payload.group;
- openLoading() {
- this.setState({
- loading: true
- });
- }
- closeLoading() {
- this.setState({
- loading: false
- });
- }
- getDataDetail() {
- let self = this;
- this.tenant = getParams('namespace') || '';
- this.serverId = getParams('serverId') || 'center';
- let url = `/nacos/v1/cs/configs?show=all&dataId=${this.dataId}&group=${this.group}`;
- request({
- url: url,
- beforeSend: function () {
- self.openLoading();
- },
- success: function (result) {
-
- if (result != null) {
- let data = result;
- self.valueMap['normal'] = data;
- self.field.setValue('dataId', data.dataId);
- //self.field.setValue('content', data.content);
- self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
- //self.field.setValue('envs', self.serverId);
- self.field.setValue('group', data.group);
-
- //self.field.setValue('type', data.type);
- self.field.setValue('desc', data.desc);
- //self.field.setValue('md5', data.md5);
- self.codeValue = data.content || '';
- let type = data.type || 'text';
- self.setState({ //设置radio 高亮
- configType: type
- });
- self.initMoacoEditor(type, self.codeValue);
-
- //self.createCodeMirror('text', self.codeValue);
- //self.codeValue = self.commoneditor.doc.getValue();
- if (data.configTags != null) {
- let tagArr = data.configTags.split(",");
- self.setConfigTags(tagArr);
- }
-
- let envvalues = [];
- let env = {};
- self.serverId = env.serverId;
- self.targetEnvs = envvalues;
- } else {
- Dialog.alert({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- title: aliwareIntl.get('com.alibaba.nacos.page.configeditor.wrong'),
- content: result.message
- });
- }
- },
- complete: function () {
- self.closeLoading();
+ if (res != null) {
+ _payload.isok = true;
+ const activeKey = self.state.activeKey.split('-')[0];
+ if (activeKey === 'normal' && self.hasips === true) {
+ // 如果是在normal面板选择了beta发布
+ const sufex = new Date().getTime();
+ self.setState({
+ tag: [
+ {
+ title: aliwareIntl.get('com.alibaba.nacos.page.configeditor.official'),
+ key: `normal-${sufex}`,
+ },
+ { title: 'BETA', key: `beta-${sufex}` },
+ ],
+ hasbeta: true,
+ activeKey: `beta-${sufex}`,
+ });
+ payload.betaIps = payload.betaIps || payload.ips;
+ self.valueMap.beta = payload; // 赋值beta
+ self.changeTab(`beta-${sufex}`);
}
- });
- }
- goList() {
-
- let tenant = getParams('namespace');
- this.props.history.push(`/configurationManagement?serverId=${this.serverId}&group=${this.searchGroup}&dataId=${this.searchDataId}&namespace=${tenant}`);
- }
-
- createCodeMirror(mode, value) {
- let commontarget = this.refs["commoneditor"];
- commontarget.innerHTML = '';
- this.commoneditor = window.CodeMirror(commontarget, {
- value: value,
- mode: mode,
- lineNumbers: true,
- theme: 'xq-light',
- lint: true,
- gutters: ["CodeMirror-lint-markers"],
- extraKeys: {
- "F1": function (cm) {
- cm.setOption("fullScreen", !cm.getOption("fullScreen"));
- },
- "Esc": function (cm) {
- if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
- }
+ if (activeKey === 'normal' && self.hasips === false) {
+ // 如果是在normal面板选择了发布
+ self.valueMap.normal = payload; // 赋值正式
}
- });
- this.commoneditor.on('change', this.codemirrorValueChanged.bind(this));
- }
- codemirrorValueChanged(doc) {
- if (this.diffeditor) {
- this.diffeditor.edit.doc.setValue(doc.getValue());
- }
- }
- createDiffCodeMirror(leftCode, rightCode) {
- let target = this.refs["diffeditor"];
- target.innerHTML = '';
-
- this.diffeditor = window.CodeMirror.MergeView(target, {
- value: leftCode || '',
- origLeft: null,
- orig: rightCode || '',
- lineNumbers: true,
- mode: this.mode,
- theme: 'xq-light',
- highlightDifferences: true,
- connect: 'align',
- collapseIdentical: false
- });
- }
- changeConfig(value) {
- if (value === 0) {
- this.createCodeMirror('text', this.codeValue);
- this.mode = 'text';
- }
- if (value === 1) {
- this.createCodeMirror('application/json', this.codeValue);
- this.mode = 'application/json';
- }
- if (value === 2) {
- this.createCodeMirror('xml', this.codeValue);
- this.mode = 'xml';
- }
- this.setState({
- configType: value
- });
- }
- setCodeValue(value) {
-
- this.setState({
- codeValue: value
- });
- }
- toggleDiff(checked) {
- if (checked) {
- this.chontenttab.style.display = 'block';
-
- let nowvalue = this.commoneditor.doc.getValue();
- if (!this.diffeditor) {
- this.createDiffCodeMirror(nowvalue, this.codeValue);
+ if (activeKey === 'beta' && self.hasips === true) {
+ // 如果是在beta面板继续beta发布
+ self.valueMap.beta = payload; // 赋值beta
}
- } else {
- this.chontenttab.style.display = 'none';
- //this.diffeditor = null;
- //let target = this.refs["diffeditor"];
- //target.innerHTML = '';
+ } else {
+ _payload.isok = false;
+ _payload.message = res.message;
+ }
+ self.refs.success.openDialog(_payload);
+ },
+ error() {},
+ });
+ });
+ }
+
+ validateChart(rule, value, callback) {
+ const chartReg = /[@#\$%\^&\*]+/g;
+
+ if (chartReg.test(value)) {
+ callback(aliwareIntl.get('com.alibaba.nacos.page.configeditor.vdchart'));
+ } else {
+ callback();
+ }
+ }
+
+ changeEnv(values) {
+ this.targetEnvs = values;
+ this.setState({
+ envvalues: values,
+ });
+ }
+
+ changeBeta(selected) {
+ if (selected) {
+ this.betaips.style.display = 'block';
+ } else {
+ this.betaips.style.display = 'none';
+ }
+ this.setState({
+ checkedBeta: selected,
+ });
+ }
+
+ getIps(value) {
+ this.ips = value;
+ this.setState({
+ ips: value,
+ });
+ }
+
+ setConfigTags(value) {
+ if (value.length > 5) {
+ value.pop();
+ }
+ value.forEach((v, i) => {
+ if (v.indexOf(',') !== -1 || v.indexOf('=') !== -1) {
+ value.splice(i, 1);
+ }
+ });
+ this.setState({
+ config_tags: value,
+ });
+ }
+
+ onInputUpdate(value) {
+ if (this.inputtimmer) {
+ clearTimeout(this.inputtimmer);
+ }
+ this.inputtimmer = setTimeout(() => {
+ const { tagLst } = this.state;
+
+ let hastag = false;
+ tagLst.forEach((v, i) => {
+ if (v.value === value) {
+ hastag = true;
}
- }
- publishConfig() {
- this.field.validate((errors, values) => {
- if (errors) {
- return;
- }
- let content = '';
- let self = this;
- // if (this.commoneditor) {
- // content = this.commoneditor.doc.getValue();
- // //content = content.replace("↵", "\n\r");
- // } else {
- // content = this.codeValue;
- // }
-
- if (this.monacoEditor) {
- content = this.monacoEditor.getValue();
- } else {
- content = this.codeValue;
- }
- if (!content) {
- Message.error({
- content: aliwareIntl.get("nacos.page.ConfigEditor.submit_failed"),
- align: "cc cc"
- });
- return;
- }
- this.codeValue = content;
- this.tenant = getParams('namespace') || '';
- this.serverId = getParams('serverId') || 'center';
-
- let payload = {
- dataId: this.field.getValue('dataId'),
- appName: this.inApp ? this.edasAppId : this.field.getValue('appName'),
- group: this.field.getValue('group'),
- desc: this.field.getValue('desc'),
- config_tags: this.state.config_tags.join(),
- type: this.state.configType,
- content: content,
- tenant: this.tenant
-
- };
- let url = `/nacos/v1/cs/configs`;
- request({
- type: 'post',
- contentType: 'application/x-www-form-urlencoded',
- url: url,
- data: payload,
- success: function (res) {
- let _payload = {};
- _payload.maintitle = aliwareIntl.get('com.alibaba.nacos.page.configeditor.toedittitle');
- _payload.title =
{aliwareIntl.get('com.alibaba.nacos.page.configeditor.toedit')}
;
- _payload.content = '';
- _payload.dataId = payload.dataId;
- _payload.group = payload.group;
-
- if (res != null) {
- _payload.isok = true;
- let activeKey = self.state.activeKey.split('-')[0];
- if (activeKey === 'normal' && self.hasips === true) {
- //如果是在normal面板选择了beta发布
- let sufex = new Date().getTime();
- self.setState({
- tag: [{ title: aliwareIntl.get('com.alibaba.nacos.page.configeditor.official'), key: `normal-${sufex}` }, { title: 'BETA', key: `beta-${sufex}` }], hasbeta: true,
- activeKey: `beta-${sufex}`
- });
- payload.betaIps = payload.betaIps || payload.ips;
- self.valueMap['beta'] = payload; //赋值beta
- self.changeTab(`beta-${sufex}`);
- }
- if (activeKey === 'normal' && self.hasips === false) {
- //如果是在normal面板选择了发布
- self.valueMap['normal'] = payload; //赋值正式
- }
- if (activeKey === 'beta' && self.hasips === true) {
- //如果是在beta面板继续beta发布
- self.valueMap['beta'] = payload; //赋值beta
- }
- } else {
- _payload.isok = false;
- _payload.message = res.message;
- }
- self.refs['success'].openDialog(_payload
- );
- },
- error: function () { }
- });
+ });
+ if (!hastag) {
+ tagLst.push({
+ value,
+ label: value,
+ time: Math.random(),
});
+ }
+ this.setState({ tagLst });
+ }, 500);
+ }
+
+ openDiff(hasips) {
+ this.hasips = hasips; // 是否包含ips
+ let leftvalue = this.monacoEditor.getValue(); // this.commoneditor.doc.getValue();
+ let rightvalue = this.codeValue;
+ leftvalue = leftvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
+ rightvalue = rightvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
+ // let rightvalue = this.diffeditor.doc.getValue();
+ // console.log(this.commoneditor, leftvalue==rightvalue)
+ this.refs.diffeditor.openDialog(leftvalue, rightvalue);
+ }
+
+ changeTab(value) {
+ const self = this;
+ const key = value.split('-')[0];
+
+ const data = this.valueMap[key];
+ this.setState({
+ activeKey: value,
+ });
+ self.field.setValue('dataId', data.dataId);
+
+ self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
+ // self.field.setValue('envs', self.serverId);
+ self.field.setValue('group', data.group);
+ // self.field.setValue('md5', data.md5);
+ self.codeValue = data.content || '';
+ self.createCodeMirror('text', self.codeValue);
+ if (data.betaIps) {
+ self.getIps(data.betaIps);
+ self.changeBeta(true);
+ } else {
+ self.getIps('');
+ self.changeBeta(false);
}
- validateChart(rule, value, callback) {
- const chartReg = /[@#\$%\^&\*]+/g;
+ }
- if (chartReg.test(value)) {
- callback(aliwareIntl.get('com.alibaba.nacos.page.configeditor.vdchart'));
- } else {
- callback();
- }
+ newChangeConfig(value) {
+ this.setState({
+ configType: value,
+ });
+ this.changeModel(value);
+ }
+
+ changeModel(type, value) {
+ if (!this.monacoEditor) {
+ $('#container').empty();
+ this.initMoacoEditor(type, value);
+ return;
}
-
- changeEnv(values) {
- this.targetEnvs = values;
- this.setState({
- envvalues: values
- });
+ const oldModel = this.monacoEditor.getModel();
+ const oldValue = this.monacoEditor.getValue();
+ const newModel = window.monaco.editor.createModel(oldValue, type);
+ this.monacoEditor.setModel(newModel);
+ if (oldModel) {
+ oldModel.dispose();
}
- changeBeta(selected) {
- if (selected) {
- this.betaips.style.display = 'block';
- } else {
- this.betaips.style.display = 'none';
- }
- this.setState({
- checkedBeta: selected
- });
- }
- getIps(value) {
- this.ips = value;
- this.setState({
- ips: value
- });
- }
- setConfigTags(value) {
- if (value.length > 5) {
- value.pop();
- }
- value.forEach((v, i) => {
- if (v.indexOf(',') !== -1 || v.indexOf('=') !== -1) {
- value.splice(i, 1);
- }
- });
- this.setState({
- config_tags: value
- });
- }
- onInputUpdate(value) {
- if (this.inputtimmer) {
- clearTimeout(this.inputtimmer);
- }
- this.inputtimmer = setTimeout(() => {
- let tagLst = this.state.tagLst,
- hastag = false;
- tagLst.forEach((v, i) => {
- if (v.value === value) {
- hastag = true;
- }
- });
- if (!hastag) {
- tagLst.push({
- value: value,
- label: value,
- time: Math.random()
- });
- }
- this.setState({ tagLst: tagLst });
- }, 500);
- }
- openDiff(hasips) {
- this.hasips = hasips; //是否包含ips
- let leftvalue = this.monacoEditor.getValue(); //this.commoneditor.doc.getValue();
- let rightvalue = this.codeValue;
- leftvalue = leftvalue.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n");
- rightvalue = rightvalue.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n");
- //let rightvalue = this.diffeditor.doc.getValue();
- //console.log(this.commoneditor, leftvalue==rightvalue)
- this.refs['diffeditor'].openDialog(leftvalue, rightvalue);
- }
- changeTab(value) {
+ }
- let self = this;
- let key = value.split('-')[0];
+ render() {
+ const { init } = this.field;
+ const formItemLayout = {
+ labelCol: {
+ span: 2,
+ },
+ wrapperCol: {
+ span: 22,
+ },
+ };
- let data = this.valueMap[key];
- this.setState({
- activeKey: value
- });
- self.field.setValue('dataId', data.dataId);
+ // const list = [{
+ // value: 0,
+ // label: 'TEXT'
+ // }, {
+ // value: 1,
+ // label: 'JSON'
+ // }, {
+ // value: 2,
+ // label: 'XML'
+ // }];
+ const list = [
+ {
+ value: 'text',
+ label: 'TEXT',
+ },
+ {
+ value: 'json',
+ label: 'JSON',
+ },
+ {
+ value: 'xml',
+ label: 'XML',
+ },
+ {
+ value: 'yaml',
+ label: 'YAML',
+ },
+ {
+ value: 'html',
+ label: 'HTML',
+ },
+ {
+ value: 'properties',
+ label: 'Properties',
+ },
+ ];
+ const activeKey = this.state.activeKey.split('-')[0];
- self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
- //self.field.setValue('envs', self.serverId);
- self.field.setValue('group', data.group);
- //self.field.setValue('md5', data.md5);
- self.codeValue = data.content || '';
- self.createCodeMirror('text', self.codeValue);
- if (data.betaIps) {
- self.getIps(data.betaIps);
- self.changeBeta(true);
- } else {
- self.getIps('');
- self.changeBeta(false);
- }
- }
- newChangeConfig(value) {
- this.setState({
- configType: value
- });
- this.changeModel(value);
- }
- changeModel(type, value) {
- if (!this.monacoEditor) {
- $('#container').empty();
- this.initMoacoEditor(type, value);
- return;
- }
- let oldModel = this.monacoEditor.getModel();
- let oldValue = this.monacoEditor.getValue();
- let newModel = window.monaco.editor.createModel(oldValue, type);
- this.monacoEditor.setModel(newModel);
- if (oldModel) {
- oldModel.dispose();
- }
- }
- render() {
- const { init } = this.field;
- const formItemLayout = {
- labelCol: {
- span: 2
- },
- wrapperCol: {
- span: 22
- }
- };
-
- // const list = [{
- // value: 0,
- // label: 'TEXT'
- // }, {
- // value: 1,
- // label: 'JSON'
- // }, {
- // value: 2,
- // label: 'XML'
- // }];
- const list = [{
- value: 'text',
- label: 'TEXT'
- }, {
- value: 'json',
- label: 'JSON'
- }, {
- value: 'xml',
- label: 'XML'
- }, {
- value: 'yaml',
- label: 'YAML'
- }, {
- value: 'html',
- label: 'HTML'
- }, {
- value: 'properties',
- label: 'Properties'
- }];
- let activeKey = this.state.activeKey.split('-')[0];
-
- return (
-
-
-
-
{aliwareIntl.get('com.alibaba.nacos.page.configeditor.toedit')}
-
-
- {this.state.hasbeta ?
-
-
- {this.state.tag.map(tab => )}
-
-
-
: ''}
-
-
-
-
-
+ return (
+
+
+
+
{aliwareIntl.get('com.alibaba.nacos.page.configeditor.toedit')}
+
+ {this.state.hasbeta ? (
+
+
+ {this.state.tag.map(tab => (
+
+ ))}
+
- );
- }
+ ) : (
+ ''
+ )}
+
+
+
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default ConfigEditor;
\ No newline at end of file
+
+export default ConfigEditor;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js
index fa8be1ae6..4ddb9a0f3 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js
@@ -15,185 +15,217 @@ import React from 'react';
import './index.less';
import { getParams, request, aliwareIntl } from '../../../globalLib';
import { Button, Dialog, Field, Form, Input } from '@alifd/next';
+
const FormItem = Form.Item;
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class ConfigRollback extends React.Component {
+ constructor(props) {
+ super(props);
+ this.field = new Field(this);
+ this.dataId = getParams('dataId') || 'yanlin';
+ this.group = getParams('group') || 'DEFAULT_GROUP';
+ this.serverId = getParams('serverId') || 'center';
+ this.nid = getParams('nid') || '';
+ this.state = {
+ envName: '',
+ visible: false,
+ showmore: false,
+ };
+ // this.params = window.location.hash.split('?')[1]||'';
+ this.typeMap = {
+ // 操作映射提示
+ U: 'publish',
+ I: aliwareIntl.get('com.alibaba.nacos.page.configRollback.delete'),
+ D: 'publish',
+ };
+ this.typeMapName = {
+ // 操作映射名
+ U: aliwareIntl.get('com.alibaba.nacos.page.configRollback.updated'),
+ I: aliwareIntl.get('com.alibaba.nacos.page.configRollback.inserted'),
+ D: aliwareIntl.get('com.alibaba.nacos.page.configRollback.delete'),
+ };
+ }
- constructor(props) {
- super(props);
- this.field = new Field(this);
- this.dataId = getParams('dataId') || 'yanlin';
- this.group = getParams('group') || 'DEFAULT_GROUP';
- this.serverId = getParams('serverId') || 'center';
- this.nid = getParams('nid') || '';
- this.state = {
- envName: '',
- visible: false,
- showmore: false
- };
- //this.params = window.location.hash.split('?')[1]||'';
- this.typeMap = { //操作映射提示
- 'U': 'publish',
- 'I': aliwareIntl.get('com.alibaba.nacos.page.configRollback.delete'),
- 'D': 'publish'
- };
- this.typeMapName = { //操作映射名
- 'U': aliwareIntl.get('com.alibaba.nacos.page.configRollback.updated'),
- 'I': aliwareIntl.get('com.alibaba.nacos.page.configRollback.inserted'),
- 'D': aliwareIntl.get('com.alibaba.nacos.page.configRollback.delete')
- };
- }
+ componentDidMount() {
+ this.getDataDetail();
+ }
- componentDidMount() {
- this.getDataDetail();
- }
- toggleMore() {
- this.setState({
- showmore: !this.state.showmore
- });
- }
- getDataDetail() {
- let self = this;
- this.tenant = getParams('namespace') || '';
- this.serverId = getParams('serverId') || 'center';
- let url = `/nacos/v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`;
- request({
- url: url,
- success: function (result) {
- if (result != null) {
- let data = result;
- let envName = self.serverId;
- self.id = data.id; //详情的id
- self.field.setValue('dataId', data.dataId);
- self.field.setValue('content', data.content);
- self.field.setValue('appName', data.appName);
- self.field.setValue('opType', self.typeMapName[data.opType.trim()]);
- self.opType = data.opType; //当前回滚类型I:插入,D:删除,U:'更新'
- self.field.setValue('group', data.group);
- self.field.setValue('md5', data.md5);
- self.field.setValue('envName', envName);
- self.setState({
- envName: envName
- });
- }
- }
- });
- }
- goList() {
- let tenant = getParams('namespace');
- this.props.history.push(`/historyRollback?serverId=${this.serverId}&group=${this.group}&dataId=${this.dataId}&namespace=${tenant}`);
- }
+ toggleMore() {
+ this.setState({
+ showmore: !this.state.showmore,
+ });
+ }
- onOpenConfirm() {
- let self = this;
- let type = 'post';
- if (this.opType.trim() === 'I') {
- type = 'delete';
+ getDataDetail() {
+ const self = this;
+ this.tenant = getParams('namespace') || '';
+ this.serverId = getParams('serverId') || 'center';
+ const url = `/nacos/v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`;
+ request({
+ url,
+ success(result) {
+ if (result != null) {
+ const data = result;
+ const envName = self.serverId;
+ self.id = data.id; // 详情的id
+ self.field.setValue('dataId', data.dataId);
+ self.field.setValue('content', data.content);
+ self.field.setValue('appName', data.appName);
+ self.field.setValue('opType', self.typeMapName[data.opType.trim()]);
+ self.opType = data.opType; // 当前回滚类型I:插入,D:删除,U:'更新'
+ self.field.setValue('group', data.group);
+ self.field.setValue('md5', data.md5);
+ self.field.setValue('envName', envName);
+ self.setState({
+ envName,
+ });
}
- Dialog.confirm({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- title: aliwareIntl.get('com.alibaba.nacos.page.configRollback.please_confirm_rollback'),
- content:
-
{aliwareIntl.get('com.alibaba.nacos.page.configRollback.determine')} {aliwareIntl.get('com.alibaba.nacos.page.configRollback.the_following_configuration')}
-
- Data ID:
-
- {self.field.getValue("dataId")}
-
-
-
- Group:
-
- {self.field.getValue("group")}
-
-
+ },
+ });
+ }
-
,
- onOk: function () {
- self.tenant = getParams('namespace') || '';
- self.serverId = getParams('serverId') || 'center';
- self.dataId = self.field.getValue("dataId");
- self.group = self.field.getValue("group");
- let postData = {
- appName: self.field.getValue("appName"),
- dataId: self.dataId,
- group: self.group,
- content: self.field.getValue("content"),
- tenant: self.tenant
- };
+ goList() {
+ const tenant = getParams('namespace');
+ this.props.history.push(
+ `/historyRollback?serverId=${this.serverId}&group=${this.group}&dataId=${
+ this.dataId
+ }&namespace=${tenant}`
+ );
+ }
- let url = `/nacos/v1/cs/configs`;
- if (self.opType.trim() === 'I') {
- url = `/nacos/v1/cs/configs?dataId=${self.dataId}&group=${self.group}`;
- postData = {};
- }
-
- // ajax
- request({
- type: type,
- contentType: 'application/x-www-form-urlencoded',
- url: url,
- data: postData,
- success: function (data) {
- if (data === true) {
- Dialog.alert({ language: aliwareIntl.currentLanguageCode || 'zh-cn', content: aliwareIntl.get('com.alibaba.nacos.page.configRollback.rollback_successful') });
- }
- }
- });
- }
- });
+ onOpenConfirm() {
+ const self = this;
+ let type = 'post';
+ if (this.opType.trim() === 'I') {
+ type = 'delete';
}
-
- render() {
- const init = this.field.init;
- const formItemLayout = {
- labelCol: {
- fixedSpan: 6
- },
- wrapperCol: {
- span: 18
- }
+ Dialog.confirm({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ title: aliwareIntl.get('com.alibaba.nacos.page.configRollback.please_confirm_rollback'),
+ content: (
+
+
+ {aliwareIntl.get('com.alibaba.nacos.page.configRollback.determine')}{' '}
+ {aliwareIntl.get('com.alibaba.nacos.page.configRollback.the_following_configuration')}
+
+
+ Data ID:
+ {self.field.getValue('dataId')}
+
+
+ Group:
+ {self.field.getValue('group')}
+
+
+ ),
+ onOk() {
+ self.tenant = getParams('namespace') || '';
+ self.serverId = getParams('serverId') || 'center';
+ self.dataId = self.field.getValue('dataId');
+ self.group = self.field.getValue('group');
+ let postData = {
+ appName: self.field.getValue('appName'),
+ dataId: self.dataId,
+ group: self.group,
+ content: self.field.getValue('content'),
+ tenant: self.tenant,
};
- return (
-
-
{aliwareIntl.get('com.alibaba.nacos.page.configRollback.configuration_rollback')}
-
+ // ajax
+ request({
+ type,
+ contentType: 'application/x-www-form-urlencoded',
+ url,
+ data: postData,
+ success(data) {
+ if (data === true) {
+ Dialog.alert({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ content: aliwareIntl.get(
+ 'com.alibaba.nacos.page.configRollback.rollback_successful'
+ ),
+ });
+ }
+ },
+ });
+ },
+ });
+ }
+ render() {
+ const { init } = this.field;
+ const formItemLayout = {
+ labelCol: {
+ fixedSpan: 6,
+ },
+ wrapperCol: {
+ span: 18,
+ },
+ };
+ return (
+
+
{aliwareIntl.get('com.alibaba.nacos.page.configRollback.configuration_rollback')}
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default ConfigRollback;
\ No newline at end of file
+
+export default ConfigRollback;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/index.js
index 49e94e39e..8ce5122e0 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigRollback/index.js
@@ -13,4 +13,4 @@
import ConfigRollback from './ConfigRollback';
-export default ConfigRollback;
\ No newline at end of file
+export default ConfigRollback;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js
index 7b9ec3462..6b7dcbc70 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js
@@ -17,258 +17,306 @@ import SuccessDialog from '../../../components/SuccessDialog';
import { getParams, request, aliwareIntl } from '../../../globalLib';
import './index.less';
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class ConfigSync extends React.Component {
- constructor(props) {
- super(props);
- this.field = new Field(this);
- this.dataId = getParams('dataId') || 'yanlin';
- this.group = getParams('group') || '';
- this.serverId = getParams('serverId') || '';
+ constructor(props) {
+ super(props);
+ this.field = new Field(this);
+ this.dataId = getParams('dataId') || 'yanlin';
+ this.group = getParams('group') || '';
+ this.serverId = getParams('serverId') || '';
- this.state = {
- configType: 0,
+ this.state = {
+ configType: 0,
- envvalues: [],
- commonvalue: [],
- envComponent: '',
- envGroups: [],
- envlist: [],
- loading: false,
- showmore: false
- };
- this.codeValue = '';
- this.mode = 'text';
- this.ips = '';
- }
- componentDidMount() {
+ envvalues: [],
+ commonvalue: [],
+ envComponent: '',
+ envGroups: [],
+ envlist: [],
+ loading: false,
+ showmore: false,
+ };
+ this.codeValue = '';
+ this.mode = 'text';
+ this.ips = '';
+ }
- this.getDataDetail();
- // this.getDomain();
- }
- toggleMore() {
- this.setState({
- showmore: !this.state.showmore
- });
- }
- getEnvList(value) {
- this.setState({
- envvalues: value
- });
- this.envs = value;
- }
- getDomain() {
- let self = this;
- request({
- url: `/diamond-ops/env/domain`,
- success: function (data) {
+ componentDidMount() {
+ this.getDataDetail();
+ // this.getDomain();
+ }
- if (data.code === 200) {
- let envGroups = data.data.envGroups;
+ toggleMore() {
+ this.setState({
+ showmore: !this.state.showmore,
+ });
+ }
- self.setState({
- envGroups: envGroups
- });
- }
- }
- });
- }
- getDataDetail() {
- let self = this;
- this.tenant = getParams('namespace') || '';
- this.serverId = getParams('serverId') || 'center';
- let url = `/diamond-ops/configList/detail/serverId/${this.serverId}/dataId/${this.dataId}/group/${this.group}/tenant/${this.tenant}?id=`;
- if (this.tenant === 'global' || !this.tenant) {
- url = `/diamond-ops/configList/detail/serverId/${this.serverId}/dataId/${this.dataId}/group/${this.group}?id=`;
+ getEnvList(value) {
+ this.setState({
+ envvalues: value,
+ });
+ this.envs = value;
+ }
+
+ getDomain() {
+ const self = this;
+ request({
+ url: '/diamond-ops/env/domain',
+ success(data) {
+ if (data.code === 200) {
+ const { envGroups } = data.data;
+
+ self.setState({
+ envGroups,
+ });
}
- request({
- url: url,
- beforeSend: function () {
- self.openLoading();
- },
- success: function (result) {
- if (result.code === 200) {
- let data = result.data;
+ },
+ });
+ }
- self.field.setValue('dataId', data.dataId);
- //self.field.setValue('content', data.content);
- self.field.setValue('appName', data.appName);
- //self.field.setValue('envs', self.serverId);
- self.field.setValue('group', data.group);
- //self.field.setValue('md5', data.md5);
- self.field.setValue('content', data.content || ''
- //let envlist = [];
- // let envvalues = [];
- // for (let i = 0; i < data.envs.length; i++) {
- // let obj = data.envs[i]
- // envlist.push({
- // label: obj.name,
- // value: obj.serverId
- // })
- // envvalues.push(obj.serverId);
- // }
+ getDataDetail() {
+ const self = this;
+ this.tenant = getParams('namespace') || '';
+ this.serverId = getParams('serverId') || 'center';
+ let url = `/diamond-ops/configList/detail/serverId/${this.serverId}/dataId/${
+ this.dataId
+ }/group/${this.group}/tenant/${this.tenant}?id=`;
+ if (this.tenant === 'global' || !this.tenant) {
+ url = `/diamond-ops/configList/detail/serverId/${this.serverId}/dataId/${this.dataId}/group/${
+ this.group
+ }?id=`;
+ }
+ request({
+ url,
+ beforeSend() {
+ self.openLoading();
+ },
+ success(result) {
+ if (result.code === 200) {
+ const { data = {} } = result;
- ); let env = data.envs || [];
- let envvalues = [];
- let envlist = [];
- for (let i = 0; i < env.length; i++) {
- envlist.push({
- value: env[i].serverId,
- label: env[i].name
- });
- if (env[i].serverId === self.serverId) {
- envvalues.push(self.serverId);
- }
- }
- self.setState({
- envlist: envlist,
- envvalues: envvalues
- // self.setState({
- // envname: env.name,
- // })
- //self.serverId = env.serverId;
-
- });
- } else {
- Dialog.alert({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- title: aliwareIntl.get('com.alibaba.nacos.page.configsync.error'),
- content: result.message
- });
- }
- },
- complete: function () {
- self.closeLoading();
+ self.field.setValue('dataId', data.dataId);
+ // self.field.setValue('content', data.content);
+ self.field.setValue('appName', data.appName);
+ // self.field.setValue('envs', self.serverId);
+ self.field.setValue('group', data.group);
+ // self.field.setValue('md5', data.md5);
+ self.field.setValue('content', data.content || '');
+ const env = data.envs || [];
+ const envvalues = [];
+ const envlist = [];
+ for (let i = 0; i < env.length; i++) {
+ envlist.push({
+ value: env[i].serverId,
+ label: env[i].name,
+ });
+ if (env[i].serverId === self.serverId) {
+ envvalues.push(self.serverId);
}
- });
- }
+ }
+ self.setState({
+ envlist,
+ envvalues,
+ // self.setState({
+ // envname: env.name,
+ // })
+ // self.serverId = env.serverId;
+ });
+ } else {
+ Dialog.alert({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ title: aliwareIntl.get('com.alibaba.nacos.page.configsync.error'),
+ content: result.message,
+ });
+ }
+ },
+ complete() {
+ self.closeLoading();
+ },
+ });
+ }
- goList() {
+ goList() {
+ this.props.history.push(
+ `/configurationManagement?serverId=${this.serverId}&group=${this.group}&dataId=${this.dataId}`
+ );
+ }
- //console.log(`/configurationManagement?serverId=${this.serverId}&group=${this.group}&dataId=${this.dataId}`)
- this.props.history.push(`/configurationManagement?serverId=${this.serverId}&group=${this.group}&dataId=${this.dataId}`);
- }
-
- sync() {
-
- let self = this;
- let payload = {
- dataId: this.field.getValue('dataId'),
- appName: this.field.getValue('appName'),
- group: this.field.getValue('group'),
- content: this.field.getValue('content'),
- betaIps: this.ips,
- targetEnvs: this.envs
-
- };
- request({
- type: 'put',
- contentType: 'application/json',
- url: `/diamond-ops/configList/serverId/${this.serverId}/dataId/${payload.dataId}/group/${payload.group}?id=`,
- data: JSON.stringify(payload),
- success: function (res) {
- let _payload = {};
- _payload.maintitle = aliwareIntl.get('com.alibaba.nacos.page.configsync.sync_configuration_main');
- _payload.title = aliwareIntl.get('com.alibaba.nacos.page.configsync.sync_configuration');
- _payload.content = '';
- _payload.dataId = payload.dataId;
- _payload.group = payload.group;
- if (res.code === 200) {
- _payload.isok = true;
- } else {
- _payload.isok = false;
- _payload.message = res.message;
- }
- self.refs['success'].openDialog(_payload);
- },
- error: function () { }
- });
- }
- syncResult() {
- let dataId = this.field.getValue('dataId');
- let gruop = this.field.getValue('group');
- this.props.history.push(`/diamond-ops/static/pages/config-sync/index.html?serverId=center&dataId=${dataId}&group=${gruop}`);
- }
- changeEnv(values) {
- this.targetEnvs = values;
- this.setState({
- envvalues: values
- });
- }
- getIps(value) {
- this.ips = value;
- }
- goResult() {
- this.props.history.push(`/consistencyEfficacy?serverId=${this.serverId}&dataId=${this.dataId}&group=${this.group}`);
- }
- openLoading() {
- this.setState({
- loading: true
- });
- }
- closeLoading() {
-
- this.setState({
- loading: false
- });
- }
- render() {
- const { init } = this.field;
- const formItemLayout = {
- labelCol: {
- span: 2
- },
- wrapperCol: {
- span: 22
- }
- };
-
- return (
-
+ sync() {
+ const self = this;
+ const payload = {
+ dataId: this.field.getValue('dataId'),
+ appName: this.field.getValue('appName'),
+ group: this.field.getValue('group'),
+ content: this.field.getValue('content'),
+ betaIps: this.ips,
+ targetEnvs: this.envs,
+ };
+ request({
+ type: 'put',
+ contentType: 'application/json',
+ url: `/diamond-ops/configList/serverId/${this.serverId}/dataId/${payload.dataId}/group/${
+ payload.group
+ }?id=`,
+ data: JSON.stringify(payload),
+ success(res) {
+ const _payload = {};
+ _payload.maintitle = aliwareIntl.get(
+ 'com.alibaba.nacos.page.configsync.sync_configuration_main'
);
- }
+ _payload.title = aliwareIntl.get('com.alibaba.nacos.page.configsync.sync_configuration');
+ _payload.content = '';
+ _payload.dataId = payload.dataId;
+ _payload.group = payload.group;
+ if (res.code === 200) {
+ _payload.isok = true;
+ } else {
+ _payload.isok = false;
+ _payload.message = res.message;
+ }
+ self.refs.success.openDialog(_payload);
+ },
+ error() {},
+ });
+ }
+
+ syncResult() {
+ const dataId = this.field.getValue('dataId');
+ const gruop = this.field.getValue('group');
+ this.props.history.push(
+ `/diamond-ops/static/pages/config-sync/index.html?serverId=center&dataId=${dataId}&group=${gruop}`
+ );
+ }
+
+ changeEnv(values) {
+ this.targetEnvs = values;
+ this.setState({
+ envvalues: values,
+ });
+ }
+
+ getIps(value) {
+ this.ips = value;
+ }
+
+ goResult() {
+ this.props.history.push(
+ `/consistencyEfficacy?serverId=${this.serverId}&dataId=${this.dataId}&group=${this.group}`
+ );
+ }
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ render() {
+ const { init } = this.field;
+ const formItemLayout = {
+ labelCol: {
+ span: 2,
+ },
+ wrapperCol: {
+ span: 22,
+ },
+ };
+
+ return (
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default ConfigSync;
\ No newline at end of file
+
+export default ConfigSync;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/index.js
index b6b04286a..5d676064d 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigSync/index.js
@@ -13,4 +13,4 @@
import ConfigSync from './ConfigSync';
-export default ConfigSync;
\ No newline at end of file
+export default ConfigSync;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js
index 66a6d844d..c6967fc15 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js
@@ -12,6 +12,7 @@
*/
import React from 'react';
+import PropTypes from 'prop-types';
import BatchHandle from '../../../components/BatchHandle';
import RegionGroup from '../../../components/RegionGroup';
import ShowCodeing from '../../../components/ShowCodeing';
@@ -21,652 +22,1079 @@ import ImportDialog from '../../../components/ImportDialog';
import ExportDialog from '../../../components/ExportDialog';
import { getParams, setParams, request, aliwareIntl } from '../../../globalLib';
import './index.less';
-import { Balloon, Button, Checkbox, Collapse, Dialog, Dropdown, Field, Form, Icon, Input, Loading, Menu, Pagination, Select, Slider, Table } from '@alifd/next';
-const Accordion = Collapse;
-const FormItem = Form.Item;
+import {
+ Balloon,
+ Button,
+ Checkbox,
+ Collapse,
+ Dialog,
+ Dropdown,
+ Field,
+ Form,
+ Icon,
+ Input,
+ Loading,
+ Menu,
+ Pagination,
+ Select,
+ Slider,
+ Table,
+} from '@alifd/next';
+
const { Panel } = Collapse;
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
-const DashboardCard = ({ data, height }) =>
- {data.modeType === 'notice' ?
1 ? 20 : 10 }} arrows={false}>
- {data.modeList.map((item, index) =>
-
-
{aliwareIntl.get("nacos.page.configurationManagement.Important_reminder0") /*重要提醒*/}
+const DashboardCard = ({ data = {}, height }) => (
+
+ {data.modeType === 'notice' ? (
+
+
1 ? 20 : 10 }} arrows={false}>
+ {data.modeList.map((item, index) => (
+
- )}
-
:
-
{data.modeName}
-
- {data.modeList ? data.modeList.map(item => {
- return
-
{item.title}
- {item.tag === 'new' ?
: ''}
- {item.tag === 'hot' ?
: ''}
-
;
- }) : ''}
-
-
}
;
+ ))}
+ {' '}
+
+ ) : (
+
+
{data.modeName}
+
+ {data.modeList
+ ? data.modeList.map(item => (
+
+
+ {item.title}
+
+ {item.tag === 'new' ? (
+
+ ) : (
+ ''
+ )}
+ {item.tag === 'hot' ? (
+
+ ) : (
+ ''
+ )}
+
+ ))
+ : ''}
+
+
+ )}{' '}
+
+);
+DashboardCard.propTypes = {
+ data: PropTypes.object,
+ height: PropTypes.number,
+};
+
class ConfigurationManagement extends React.Component {
- constructor(props) {
- super(props);
- this.field = new Field(this);
- this.appName = getParams('appName') || getParams('edasAppId') || '';
- this.preAppName = this.appName;
- this.group = getParams('group') || '';
- this.preGroup = this.group;
- this.dataId = getParams('dataId') || '';
- this.preDataId = this.dataId;
- this.serverId = getParams('serverId') || 'center';
- this.edasAppId = getParams('edasAppId') || '';
- this.edasAppName = getParams('edasAppName') || '';
- this.inApp = this.edasAppId;
- this.state = {
- value: "",
- visible: false,
- total: 0,
- pageSize: 10,
- currentPage: 1,
- dataSource: [],
- fieldValue: [],
- showAppName: false,
- showgroup: false,
- dataId: this.dataId,
- group: this.group,
- appName: this.appName,
- config_tags: [],
- tagLst: [],
- selectValue: [],
- loading: false,
- groupList: [],
- groups: [],
- tenant: true,
- nownamespace_id: window.nownamespace || '',
- nownamespace_name: window.namespaceShowName || '',
- selectedRecord: [],
- selectedKeys: [],
- hasdash: false,
- isCn: true,
- contentList: [],
- isAdvancedQuery: false,
- isCheckAll: false
- };
- let obj = {
- dataId: this.dataId || '',
- group: this.preGroup || '',
- appName: this.appName || ''
- };
- setParams(obj);
- this.batchHandle = null;
- this.toggleShowQuestionnaire = this.toggleShowQuestionnaire.bind(this);
- }
+ static propTypes = {
+ history: PropTypes.object,
+ };
- componentDidMount() {
- // this.getGroup();
- if (aliwareIntl.currentLanguageCode === 'zh-cn') {
- // this.getContentList(); //在中文站获取概览页
- this.setState({
- isCn: true
- });
- } else {
- this.setState({
- isCn: false
- });
- }
- if (window._getLink && window._getLink("isCn") === "true") {
- if (!this.checkQuestionnaire()) {
- if (window.location.host === 'acm.console.aliyun.com') {
- Dialog.alert({
- title: aliwareIntl.get("nacos.page.configurationManagement.questionnaire2") /*问卷调查*/
- , style: {
- width: '60%'
- },
- content:
-
-
{aliwareIntl.get("nacos.page.configurationManagement.no_longer_display4") /*不再显示:*/}
-
-
,
- language: aliwareIntl.currentLanguageCode
- });
- }
- }
- }
- }
- /**
- * 获取概览页数据
- */
- getContentList() {
-
- request({
- url: 'com.alibaba.nacos.service.dashlist', //以 com.alibaba. 开头最终会转换为真正的url地址
- data: {},
- $data: {}, //替换请求url路径中{}占位符的内容
- success: res => {
- console.log(res);
- if (res.code === 200 && res.data) {
- if (res.data.length === 0) {
- this.setState({
- hasdash: false
- });
- } else {
- this.setState({
- hasdash: true,
- contentList: res.data
- });
- }
- }
- }
- });
- }
- toggleShowQuestionnaire(value) {
- if (value) {
- localStorage.setItem('acm_questionnaire', 1);
- } else {
- localStorage.removeItem('acm_questionnaire');
- }
- }
- checkQuestionnaire() {
-
- let acm_questionnaire = localStorage.getItem('acm_questionnaire');
- if (acm_questionnaire) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * 回车事件
- */
- keyDownSearch(e) {
- var theEvent = e || window.event;
- var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
- if (code === 13) {
- this.getData();
- return false;
- }
- return true;
- }
- navTo(url, record) {
-
- this.serverId = getParams('serverId') || '';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.props.history.push(`${url}?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${record.group}&namespace=${this.tenant}`);
- }
- openLoading() {
- this.setState({
- loading: true
- });
- }
-
- closeLoading() {
- this.setState({
- loading: false
- });
- }
- UNSAFE_componentWillMount() {
- window.addEventListener('keydown', this.keyDownSearch.bind(this), false);
- }
- componentWillUnMount() {
- window.removeEventListener('keydown', this.keyDownSearch.bind(this));
- }
- onSearch() { }
-
- onChange() { }
- cleanAndGetData(needclean = false) {
- if (needclean) {
- this.dataId = '';
- this.group = '';
- this.setState({
- group: '',
- dataId: ''
- });
- setParams({
- group: '',
- dataId: ''
- });
- }
- this.getData();
- }
- getData(pageNo = 1, clearSelect = true) {
- let self = this;
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.serverId = getParams('serverId') || '';
- let urlPrefix = "";
- if (this.dataId.indexOf("*") !== -1 || this
- .group.indexOf("*") !== -1) {
- urlPrefix = "/nacos/v1/cs/configs?search=blur";
- } else {
- urlPrefix = "/nacos/v1/cs/configs?search=accurate";
- }
-
- request({
- url: `${urlPrefix}&dataId=${this.dataId}&group=${this.group}&appName=${this.appName}&config_tags=${this.state.config_tags || ''}&pageNo=${pageNo}&pageSize=${this.state.pageSize}`,
- beforeSend: function () {
- self.openLoading();
- },
- success: function (data) {
- if (data != null) {
- self.setState({
- dataSource: data.pageItems,
- total: data.totalCount,
- currentPage: data.pageNumber
- });
- if (clearSelect) {
- self.setState({
- selectedRecord: [],
- selectedKeys: []
- });
- }
- }
- self.setState({
- tenant: self.tenant
- });
- },
- error: function (data) {
- self.setState({
- dataSource: [],
- total: 0,
- currentPage: 0
- });
- },
- complete: function () {
- self.closeLoading();
- }
- });
- }
- showMore() { }
- chooseNav(record, key) {
- let self = this;
- switch (key) {
- case 'nav1':
- self.navTo('/historyRollback', record);
- break;
- case 'nav2':
- self.navTo('/pushTrajectory', record);
- break;
- default:
- case 'nav3':
- self.navTo('/listeningToQuery', record);
- break;
- }
- }
- removeConfig(record) {
- let self = this;
- Dialog.confirm({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- title: aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.Remove_configuration'),
- content:
-
{aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.suredelete')}
-
- Data ID:
-
- {record.dataId}
-
-
-
- Group:
-
- {record.group}
-
-
-
- {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.environment')}
-
- {self.serverId || ''}
-
-
-
-
,
- onOk: () => {
- let url = `/nacos/v1/cs/configs?dataId=${record.dataId}&group=${record.group}`;
- request({
- url: url,
- type: 'delete',
- success: function (res) {
- let _payload = {};
-
- _payload.title = aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.configuration_management');
- _payload.content = '';
- _payload.dataId = record.dataId;
- _payload.group = record.group;
- if (res === true) {
- _payload.isok = true;
- } else {
- _payload.isok = false;
- _payload.message = res.message;
- }
- self.refs['delete'].openDialog(_payload);
- self.getData();
- }
- });
- }
- });
- }
- renderLastTime(value, index, record) {
- return
{aliwareIntl.intlNumberFormat(record.lastModifiedTime)}
;
- }
- showCode(record) {
- this.refs['showcode'].openDialog(record);
- }
- renderCol(value, index, record) {
-
- return
;
- }
- changePage(value) {
- this.setState({
- currentPage: value
- }, () => {
- this.getData(value, false);
- });
- }
- handlePageSizeChange(pageSize) {
- this.setState({
- pageSize
- }, () => {
- this.changePage(1);
- });
- }
- onInputUpdate() { }
- chooseFieldChange(fieldValue) {
-
- this.setState({
- fieldValue
- });
- }
- showSelect(value) {
- this.setState({
- selectValue: value
- });
- if (value.indexOf('appName') !== -1) {
- this.setState({
- showAppName: true
- });
- } else {
- this.setState({
- showAppName: false
- });
- }
- if (value.indexOf('group') !== -1) {
- this.setState({
- showgroup: true
- });
- } else {
- this.setState({
- showgroup: false
- });
- }
- this.chooseFieldChange(value);
- }
- getAppName(value) {
- this.appName = value;
- this.setState({
- appName: value
- });
- }
-
- setAppName(value) {
- this.appName = value;
- this.setState({
- appName: value
- });
- }
- getDataId(value) {
- this.dataId = value;
- this.setState({
- dataId: value
- });
- }
- setConfigTags(value) {
- this.setState({
- config_tags: value
- });
- }
- /**
- * groupId赋值
- */
- setGroup(value) {
- this.group = value || '';
- this.setState({
- group: value || ''
- });
- }
- selectAll() {
- setParams('dataId', this.dataId);
- setParams('group', this.group);
- setParams('appName', this.appName);
- this.getData();
- }
- resetAll() {
- this.dataId = '';
- this.appName = '';
- this.group = '';
- this.setState({
- selectValue: [],
- dataId: '',
- appName: '',
- group: '',
- showAppName: false,
- showgroup: false
- });
- this.selectAll();
- }
- chooseEnv(value) {
- this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.props.history.push(`/newconfig?serverId=${this.serverId || ''}&namespace=${this.tenant}&edasAppName=${this.edasAppName}&edasAppId=${this.edasAppId}&searchDataId=${this.dataId}&searchGroup=${this.group}`);
- }
- setNowNameSpace(name, id) {
- this.setState({
- nownamespace_name: name,
- nownamespace_id: id
- });
- }
- goDetail(record) {
- this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- // 点击详情到另一个页面, 返回时候要保留原来的搜索条件 比如: record.dataId为详情的, this.dataId为搜索条件的.
- this.props.history.push(`/configdetail?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${record.group}&namespace=${this.tenant}&edasAppName=${this.edasAppName}&searchDataId=${this.dataId}&searchGroup=${this.group}`);
- }
- goEditor(record) {
- this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.props.history.push(`/configeditor?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${record.group}&namespace=${this.tenant}&edasAppName=${this.edasAppName}&edasAppId=${this.edasAppId}&searchDataId=${this.dataId}&searchGroup=${this.group}`);
- }
- goConfigSync(record) {
- this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.props.history.push(`/configsync?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${record.group}&namespace=${this.tenant}`);
- }
-
- onSelectChange(...args) {
- let record = [];
- console.log(args, 'args');
- args[1].forEach(item => {
- if (args[0].indexOf(item.id) >= 0 && this.state.selectedKeys.indexOf(item.id) < 0) {
- record.push(item);
- }
- });
- this.state.selectedRecord.forEach(item => {
- if (args[0].indexOf(item.id) >= 0) {
- record.push(item);
- }
- });
- this.setState({
- selectedRecord: record,
- selectedKeys: args[0],
- isCheckAll: record.length > 0 && record.length === this.state.dataSource.length
- });
- console.log(this.state, 'this.state');
- }
-
- onPageSelectAll(selected, records) {
- console.log(this.refs["dataTable"].props.dataSource);
- }
-
- getBatchFailedContent(res) {
- return
-
{res.message}
- {"data" in res && res.data != null &&
- {"failedItems" in res.data && res.data.failedItems.length > 0 ?
-
- : }
- {"succeededItems" in res.data && res.data.succeededItems.length > 0 ?
-
- : }
- {"unprocessedItems" in res.data && res.data.unprocessedItems.length > 0 ?
-
- : }
- }
-
;
- }
- onClickBatchHandle() {
- this.batchHandle && this.batchHandle.openDialog({
- serverId: this.serverId,
- group: this.group,
- dataId: this.dataId,
- appName: this.appName,
- config_tags: this.state.config_tags || '',
- pageSize: this.state.pageSize
- });
- }
- changeAdvancedQuery = () => {
- this.setState({
- isAdvancedQuery: !this.state.isAdvancedQuery
- });
+ constructor(props) {
+ super(props);
+ this.field = new Field(this);
+ this.appName = getParams('appName') || getParams('edasAppId') || '';
+ this.preAppName = this.appName;
+ this.group = getParams('group') || '';
+ this.preGroup = this.group;
+ this.dataId = getParams('dataId') || '';
+ this.preDataId = this.dataId;
+ this.serverId = getParams('serverId') || 'center';
+ this.edasAppId = getParams('edasAppId') || '';
+ this.edasAppName = getParams('edasAppName') || '';
+ this.inApp = this.edasAppId;
+ this.state = {
+ value: '',
+ visible: false,
+ total: 0,
+ pageSize: 10,
+ currentPage: 1,
+ dataSource: [],
+ fieldValue: [],
+ showAppName: false,
+ showgroup: false,
+ dataId: this.dataId,
+ group: this.group,
+ appName: this.appName,
+ config_tags: [],
+ tagLst: [],
+ selectValue: [],
+ loading: false,
+ groupList: [],
+ groups: [],
+ tenant: true,
+ nownamespace_id: window.nownamespace || '',
+ nownamespace_name: window.namespaceShowName || '',
+ selectedRecord: [],
+ selectedKeys: [],
+ hasdash: false,
+ isCn: true,
+ contentList: [],
+ isAdvancedQuery: false,
+ isCheckAll: false,
};
- checkAllHandle(checked) {
- this.setState({
- isCheckAll: checked,
- selectedKeys: checked ? this.state.dataSource.map(item => item.id) : [],
- selectedRecord: checked ? this.state.dataSource : []
+ const obj = {
+ dataId: this.dataId || '',
+ group: this.preGroup || '',
+ appName: this.appName || '',
+ };
+ setParams(obj);
+ this.batchHandle = null;
+ this.toggleShowQuestionnaire = this.toggleShowQuestionnaire.bind(this);
+ }
+
+ componentDidMount() {
+ // this.getGroup();
+ if (aliwareIntl.currentLanguageCode === 'zh-cn') {
+ // this.getContentList(); //在中文站获取概览页
+ this.setState({
+ isCn: true,
+ });
+ } else {
+ this.setState({
+ isCn: false,
+ });
+ }
+ if (window._getLink && window._getLink('isCn') === 'true') {
+ if (!this.checkQuestionnaire()) {
+ if (window.location.host === 'acm.console.aliyun.com') {
+ Dialog.alert({
+ title: aliwareIntl.get(
+ 'nacos.page.configurationManagement.questionnaire2'
+ ) /* 问卷调查 */,
+ style: {
+ width: '60%',
+ },
+ content: (
+
+
+
+ {aliwareIntl.get(
+ 'nacos.page.configurationManagement.no_longer_display4'
+ ) /* 不再显示: */}
+
+
+
+ ),
+ language: aliwareIntl.currentLanguageCode,
+ });
+ }
+ }
+ }
+ }
+
+ /**
+ * 获取概览页数据
+ */
+ getContentList() {
+ request({
+ url: 'com.alibaba.nacos.service.dashlist', // 以 com.alibaba. 开头最终会转换为真正的url地址
+ data: {},
+ $data: {}, // 替换请求url路径中{}占位符的内容
+ success: res => {
+ if (res.code === 200 && res.data) {
+ if (res.data.length === 0) {
+ this.setState({
+ hasdash: false,
+ });
+ } else {
+ this.setState({
+ hasdash: true,
+ contentList: res.data,
+ });
+ }
+ }
+ },
+ });
+ }
+
+ toggleShowQuestionnaire(value) {
+ if (value) {
+ localStorage.setItem('acm_questionnaire', 1);
+ } else {
+ localStorage.removeItem('acm_questionnaire');
+ }
+ }
+
+ checkQuestionnaire() {
+ const acm_questionnaire = localStorage.getItem('acm_questionnaire');
+ if (acm_questionnaire) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * 回车事件
+ */
+ keyDownSearch(e) {
+ const theEvent = e || window.event;
+ const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
+ if (code === 13) {
+ this.getData();
+ return false;
+ }
+ return true;
+ }
+
+ navTo(url, record) {
+ this.serverId = getParams('serverId') || '';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.props.history.push(
+ `${url}?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${
+ record.group
+ }&namespace=${this.tenant}`
+ );
+ }
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ UNSAFE_componentWillMount() {
+ window.addEventListener('keydown', this.keyDownSearch.bind(this), false);
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener('keydown', this.keyDownSearch.bind(this));
+ }
+
+ onSearch() {}
+
+ onChange() {}
+
+ cleanAndGetData(needclean = false) {
+ if (needclean) {
+ this.dataId = '';
+ this.group = '';
+ this.setState({
+ group: '',
+ dataId: '',
+ });
+ setParams({
+ group: '',
+ dataId: '',
+ });
+ }
+ this.getData();
+ }
+
+ getData(pageNo = 1, clearSelect = true) {
+ const self = this;
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.serverId = getParams('serverId') || '';
+ let urlPrefix = '';
+ if (this.dataId.indexOf('*') !== -1 || this.group.indexOf('*') !== -1) {
+ urlPrefix = '/nacos/v1/cs/configs?search=blur';
+ } else {
+ urlPrefix = '/nacos/v1/cs/configs?search=accurate';
+ }
+
+ request({
+ url: `${urlPrefix}&dataId=${this.dataId}&group=${this.group}&appName=${
+ this.appName
+ }&config_tags=${this.state.config_tags || ''}&pageNo=${pageNo}&pageSize=${
+ this.state.pageSize
+ }`,
+ beforeSend() {
+ self.openLoading();
+ },
+ success(data) {
+ if (data != null) {
+ self.setState({
+ dataSource: data.pageItems,
+ total: data.totalCount,
+ currentPage: data.pageNumber,
+ });
+ if (clearSelect) {
+ self.setState({
+ selectedRecord: [],
+ selectedKeys: [],
+ });
+ }
+ }
+ self.setState({
+ tenant: self.tenant,
});
+ },
+ error(data) {
+ self.setState({
+ dataSource: [],
+ total: 0,
+ currentPage: 0,
+ });
+ },
+ complete() {
+ self.closeLoading();
+ },
+ });
+ }
+
+ showMore() {}
+
+ chooseNav(record, key) {
+ const self = this;
+ switch (key) {
+ case 'nav1':
+ self.navTo('/historyRollback', record);
+ break;
+ case 'nav2':
+ self.navTo('/pushTrajectory', record);
+ break;
+ default:
+ case 'nav3':
+ self.navTo('/listeningToQuery', record);
+ break;
}
- render() {
- const pubnodedata = aliwareIntl.get('pubnodata');
- const locale = {
- empty: pubnodedata
- };
- const helpDataId =
Data ID } align={"t"} style={{ marginRight: 5 }} triggerType={"hover"}>
- {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.click_to_learn_DataId')}
- ;
- const helpGroup =
Group } align={"t"} style={{ marginRight: 5 }} triggerType={"hover"}>
- {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.click_to_learn_Group')}
- ;
- return (
-
-
this.batchHandle = ref} />
-
-
-
-
-
-
-
-
- {aliwareIntl.get("nacos.page.configurationManagement.configuration_management8") /*配置管理*/}
- |
- {this.state.nownamespace_name}
- {this.state.nownamespace_id}
- {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.query_results')}
- {this.state.total}
- {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.article_meet_the_requirements')}
-
-
-
-
-
-
+ _payload.title = aliwareIntl.get(
+ 'com.alibaba.nacos.page.configurationManagement.configuration_management'
+ );
+ _payload.content = '';
+ _payload.dataId = record.dataId;
+ _payload.group = record.group;
+ if (res === true) {
+ _payload.isok = true;
+ } else {
+ _payload.isok = false;
+ _payload.message = res.message;
+ }
+ self.refs.delete.openDialog(_payload);
+ self.getData();
+ },
+ });
+ },
+ });
+ }
-
-
-
- {!this.inApp ? : }
-
-
- {this.state.dataSource.length > 0 &&
}
-
-
-
-
-
-
-
- {this.state.hasdash ?
- {this.state.contentList.map((v, i) => {
- return ;
- })}
-
: ''}
+ renderLastTime(value, index, record) {
+ return
{aliwareIntl.intlNumberFormat(record.lastModifiedTime)}
;
+ }
+
+ showCode(record) {
+ this.refs.showcode.openDialog(record);
+ }
+
+ renderCol(value, index, record) {
+ return (
+
+ );
+ }
+
+ changePage(value) {
+ this.setState(
+ {
+ currentPage: value,
+ },
+ () => {
+ this.getData(value, false);
+ }
+ );
+ }
+
+ handlePageSizeChange(pageSize) {
+ this.setState(
+ {
+ pageSize,
+ },
+ () => {
+ this.changePage(1);
+ }
+ );
+ }
+
+ onInputUpdate() {}
+
+ chooseFieldChange(fieldValue) {
+ this.setState({
+ fieldValue,
+ });
+ }
+
+ showSelect(value) {
+ this.setState({
+ selectValue: value,
+ });
+ if (value.indexOf('appName') !== -1) {
+ this.setState({
+ showAppName: true,
+ });
+ } else {
+ this.setState({
+ showAppName: false,
+ });
+ }
+ if (value.indexOf('group') !== -1) {
+ this.setState({
+ showgroup: true,
+ });
+ } else {
+ this.setState({
+ showgroup: false,
+ });
+ }
+ this.chooseFieldChange(value);
+ }
+
+ getAppName(value) {
+ this.appName = value;
+ this.setState({
+ appName: value,
+ });
+ }
+
+ setAppName(value) {
+ this.appName = value;
+ this.setState({
+ appName: value,
+ });
+ }
+
+ getDataId(value) {
+ this.dataId = value;
+ this.setState({
+ dataId: value,
+ });
+ }
+
+ setConfigTags(value) {
+ this.setState({
+ config_tags: value,
+ });
+ }
+
+ /**
+ * groupId赋值
+ */
+ setGroup(value) {
+ this.group = value || '';
+ this.setState({
+ group: value || '',
+ });
+ }
+
+ selectAll() {
+ setParams('dataId', this.dataId);
+ setParams('group', this.group);
+ setParams('appName', this.appName);
+ this.getData();
+ }
+
+ resetAll() {
+ this.dataId = '';
+ this.appName = '';
+ this.group = '';
+ this.setState({
+ selectValue: [],
+ dataId: '',
+ appName: '',
+ group: '',
+ showAppName: false,
+ showgroup: false,
+ });
+ this.selectAll();
+ }
+
+ chooseEnv(value) {
+ this.serverId = getParams('serverId') || 'center';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.props.history.push(
+ `/newconfig?serverId=${this.serverId || ''}&namespace=${this.tenant}&edasAppName=${
+ this.edasAppName
+ }&edasAppId=${this.edasAppId}&searchDataId=${this.dataId}&searchGroup=${this.group}`
+ );
+ }
+
+ setNowNameSpace(name, id) {
+ this.setState({
+ nownamespace_name: name,
+ nownamespace_id: id,
+ });
+ }
+
+ goDetail(record) {
+ this.serverId = getParams('serverId') || 'center';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ // 点击详情到另一个页面, 返回时候要保留原来的搜索条件 比如: record.dataId为详情的, this.dataId为搜索条件的.
+ this.props.history.push(
+ `/configdetail?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${
+ record.group
+ }&namespace=${this.tenant}&edasAppName=${this.edasAppName}&searchDataId=${
+ this.dataId
+ }&searchGroup=${this.group}`
+ );
+ }
+
+ goEditor(record) {
+ this.serverId = getParams('serverId') || 'center';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.props.history.push(
+ `/configeditor?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${
+ record.group
+ }&namespace=${this.tenant}&edasAppName=${this.edasAppName}&edasAppId=${
+ this.edasAppId
+ }&searchDataId=${this.dataId}&searchGroup=${this.group}`
+ );
+ }
+
+ goConfigSync(record) {
+ this.serverId = getParams('serverId') || 'center';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.props.history.push(
+ `/configsync?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${
+ record.group
+ }&namespace=${this.tenant}`
+ );
+ }
+
+ onSelectChange(...args) {
+ const record = [];
+ args[1].forEach(item => {
+ if (args[0].indexOf(item.id) >= 0 && this.state.selectedKeys.indexOf(item.id) < 0) {
+ record.push(item);
+ }
+ });
+ this.state.selectedRecord.forEach(item => {
+ if (args[0].indexOf(item.id) >= 0) {
+ record.push(item);
+ }
+ });
+ this.setState({
+ selectedRecord: record,
+ selectedKeys: args[0],
+ isCheckAll: record.length > 0 && record.length === this.state.dataSource.length,
+ });
+ }
+
+ onPageSelectAll(selected, records) {}
+
+ getBatchFailedContent(res) {
+ return (
+
+
{res.message}
+ {'data' in res && res.data != null && (
+
+ {'failedItems' in res.data && res.data.failedItems.length > 0 ? (
+
+
+
+ ) : (
+
+ )}
+ {'succeededItems' in res.data && res.data.succeededItems.length > 0 ? (
+
+
+
+ ) : (
+
+ )}
+ {'unprocessedItems' in res.data && res.data.unprocessedItems.length > 0 ? (
+
+
+
+ ) : (
+
+ )}
+
+ )}
+
+ );
+ }
+
+ onClickBatchHandle() {
+ this.batchHandle &&
+ this.batchHandle.openDialog({
+ serverId: this.serverId,
+ group: this.group,
+ dataId: this.dataId,
+ appName: this.appName,
+ config_tags: this.state.config_tags || '',
+ pageSize: this.state.pageSize,
+ });
+ }
+
+ changeAdvancedQuery = () => {
+ this.setState({
+ isAdvancedQuery: !this.state.isAdvancedQuery,
+ });
+ };
+
+ checkAllHandle(checked) {
+ this.setState({
+ isCheckAll: checked,
+ selectedKeys: checked ? this.state.dataSource.map(item => item.id) : [],
+ selectedRecord: checked ? this.state.dataSource : [],
+ });
+ }
+
+ render() {
+ const pubnodedata = aliwareIntl.get('pubnodata');
+ const locale = {
+ empty: pubnodedata,
+ };
+ const helpDataId = (
+
+ Data ID{' '}
+
+
+ }
+ align={'t'}
+ style={{ marginRight: 5 }}
+ triggerType={'hover'}
+ >
+
+ {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.click_to_learn_DataId')}
+
+
+ );
+ const helpGroup = (
+
+ Group{' '}
+
+
+ }
+ align={'t'}
+ style={{ marginRight: 5 }}
+ triggerType={'hover'}
+ >
+
+ {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.click_to_learn_Group')}
+
+
+ );
+ return (
+
+
(this.batchHandle = ref)} />
+
+
+
+
+
+
+
+
+
+ {aliwareIntl.get(
+ 'nacos.page.configurationManagement.configuration_management8'
+ ) /* 配置管理 */}
+
+ |
+
+ {this.state.nownamespace_name}
+
+
+ {this.state.nownamespace_id}
+
+ {aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.query_results')}
+ {this.state.total}
+ {aliwareIntl.get(
+ 'com.alibaba.nacos.page.configurationManagement.article_meet_the_requirements'
+ )}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {aliwareIntl.get(
+ 'nacos.page.configurationManagement.advanced_query9'
+ ) /* 高级查询 */}
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {!this.inApp ? (
+
+ ) : (
+
+ )}
+
+
+ {this.state.dataSource.length > 0 && (
+
+ )}
+
+
+
+
+
+
- );
- }
-
+ {this.state.hasdash ? (
+
+ {this.state.contentList.map((v, i) => (
+
+ ))}
+
+ ) : (
+ ''
+ )}
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default ConfigurationManagement;
\ No newline at end of file
+
+export default ConfigurationManagement;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/index.js
index efae27785..fa14c3fad 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ConfigurationManagement/index.js
@@ -13,4 +13,4 @@
import ConfigurationManagement from './ConfigurationManagement';
-export default ConfigurationManagement;
\ No newline at end of file
+export default ConfigurationManagement;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js
index b50cff2d4..bd70b0306 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js
@@ -12,113 +12,137 @@
*/
import React from 'react';
+import PropTypes from 'prop-types';
import { getParams, request, aliwareIntl } from '../../../globalLib';
import './index.less';
import { Button, Field, Form, Input } from '@alifd/next';
-const FormItem = Form.Item;
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class HistoryDetail extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- showmore: false
- };
- this.edasAppName = getParams('edasAppName');
- this.edasAppId = getParams('edasAppId');
- this.inApp = this.edasAppName;
- this.field = new Field(this);
- this.dataId = getParams('dataId') || 'yanlin';
- this.group = getParams('group') || 'DEFAULT_GROUP';
- this.serverId = getParams('serverId') || 'center';
- this.nid = getParams('nid') || '123509854';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- //this.params = window.location.hash.split('?')[1]||'';
- this.typeMap = {
- 'U': aliwareIntl.get('com.alibaba.nacos.page.historyDetail.update'),
- 'I': aliwareIntl.get('com.alibaba.nacos.page.historyDetail.insert'),
- 'D': aliwareIntl.get('com.alibaba.nacos.page.historyDetail.delete')
- };
- }
+ static propTypes = {
+ history: PropTypes.object,
+ };
- componentDidMount() {
- this.getDataDetail();
- }
- toggleMore() {
- this.setState({
- showmore: !this.state.showmore
- });
- }
- getDataDetail() {
- let self = this;
+ constructor(props) {
+ super(props);
+ this.state = {
+ showmore: false,
+ };
+ this.edasAppName = getParams('edasAppName');
+ this.edasAppId = getParams('edasAppId');
+ this.inApp = this.edasAppName;
+ this.field = new Field(this);
+ this.dataId = getParams('dataId') || 'yanlin';
+ this.group = getParams('group') || 'DEFAULT_GROUP';
+ this.serverId = getParams('serverId') || 'center';
+ this.nid = getParams('nid') || '123509854';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ // this.params = window.location.hash.split('?')[1]||'';
+ this.typeMap = {
+ U: aliwareIntl.get('com.alibaba.nacos.page.historyDetail.update'),
+ I: aliwareIntl.get('com.alibaba.nacos.page.historyDetail.insert'),
+ D: aliwareIntl.get('com.alibaba.nacos.page.historyDetail.delete'),
+ };
+ }
- request({
- url: `/nacos/v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`,
- success: function (result) {
- if (result != null) {
- let data = result;
- self.field.setValue('dataId', data.dataId);
- self.field.setValue('content', data.content);
- self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
- self.field.setValue('envs', self.serverId);
- self.field.setValue('opType', self.typeMap[data.opType.trim()]);
- self.field.setValue('group', data.group);
- self.field.setValue('md5', data.md5);
- }
- }
- });
- }
- goList() {
+ componentDidMount() {
+ this.getDataDetail();
+ }
- //console.log(`/configurationManagement?serverId=${this.serverId}&group=${this.group}&dataId=${this.dataId}`)
- this.props.history.push(`/historyRollback?serverId=${this.serverId}&group=${this.group}&dataId=${this.dataId}&namespace=${this.tenant}`);
- }
- render() {
- const init = this.field.init;
- const formItemLayout = {
- labelCol: {
- fixedSpan: 6
- },
- wrapperCol: {
- span: 18
- }
- };
- return (
-
-
{aliwareIntl.get('com.alibaba.nacos.page.historyDetail.history_details')}
-
+ request({
+ url: `/nacos/v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`,
+ success(result) {
+ if (result != null) {
+ const data = result;
+ self.field.setValue('dataId', data.dataId);
+ self.field.setValue('content', data.content);
+ self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
+ self.field.setValue('envs', self.serverId);
+ self.field.setValue('opType', self.typeMap[data.opType.trim()]);
+ self.field.setValue('group', data.group);
+ self.field.setValue('md5', data.md5);
+ }
+ },
+ });
+ }
+
+ goList() {
+ this.props.history.push(
+ `/historyRollback?serverId=${this.serverId}&group=${this.group}&dataId=${
+ this.dataId
+ }&namespace=${this.tenant}`
+ );
+ }
+
+ render() {
+ const { init } = this.field;
+ const formItemLayout = {
+ labelCol: {
+ fixedSpan: 6,
+ },
+ wrapperCol: {
+ span: 18,
+ },
+ };
+ return (
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default HistoryDetail;
\ No newline at end of file
+
+export default HistoryDetail;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/index.js
index 7f37cff52..55f6dd38d 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryDetail/index.js
@@ -13,4 +13,4 @@
import HistoryDetail from './HistoryDetail';
-export default HistoryDetail;
\ No newline at end of file
+export default HistoryDetail;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js
index 57a954ed7..52219b48d 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js
@@ -17,302 +17,391 @@ import RegionGroup from '../../../components/RegionGroup';
import { getParams, setParams, request, aliwareIntl } from '../../../globalLib';
import './index.less';
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class HistoryRollback extends React.Component {
- constructor(props) {
- super(props);
+ constructor(props) {
+ super(props);
- this.field = new Field(this);
- this.appName = getParams('appName') || '';
- this.preAppName = this.appName;
- this.group = getParams('group') || '';
- this.preGroup = this.group;
+ this.field = new Field(this);
+ this.appName = getParams('appName') || '';
+ this.preAppName = this.appName;
+ this.group = getParams('group') || '';
+ this.preGroup = this.group;
- this.dataId = getParams('dataId') || '';
- this.preDataId = this.dataId;
- this.serverId = getParams('serverId') || '';
- this.state = {
- value: "",
- visible: false,
- total: 0,
- pageSize: 10,
- currentPage: 1,
- dataSource: [],
- fieldValue: [],
- showAppName: false,
- showgroup: false,
- dataId: this.dataId,
- group: this.group,
- appName: this.appName,
- selectValue: [],
- loading: false
- };
- let obj = {
- dataId: this.dataId || '',
- group: this.preGroup || '',
- appName: this.appName || '',
- serverId: this.serverId || ''
- };
- setParams(obj);
+ this.dataId = getParams('dataId') || '';
+ this.preDataId = this.dataId;
+ this.serverId = getParams('serverId') || '';
+ this.state = {
+ value: '',
+ visible: false,
+ total: 0,
+ pageSize: 10,
+ currentPage: 1,
+ dataSource: [],
+ fieldValue: [],
+ showAppName: false,
+ showgroup: false,
+ dataId: this.dataId,
+ group: this.group,
+ appName: this.appName,
+ selectValue: [],
+ loading: false,
+ };
+ const obj = {
+ dataId: this.dataId || '',
+ group: this.preGroup || '',
+ appName: this.appName || '',
+ serverId: this.serverId || '',
+ };
+ setParams(obj);
+ }
+
+ componentDidMount() {
+ this.field.setValue('group', this.group);
+ this.field.setValue('dataId', this.dataId);
+ // this.getData()
+ }
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ /**
+ * 回车事件
+ */
+ keyDownSearch(e) {
+ const theEvent = e || window.event;
+ const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
+ if (code === 13) {
+ this.getData();
+ return false;
+ }
+ return true;
+ }
+
+ UNSAFE_componentWillMount() {
+ window.addEventListener('keydown', this.keyDownSearch.bind(this), false);
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener('keydown', this.keyDownSearch.bind(this));
+ }
+
+ onSearch() {}
+
+ onChange() {}
+
+ cleanAndGetData(needclean = false) {
+ if (needclean) {
+ this.dataId = '';
+ this.group = '';
+ this.setState({
+ group: '',
+ dataId: '',
+ });
+ setParams({
+ group: '',
+ dataId: '',
+ });
}
- componentDidMount() {
- this.field.setValue('group', this.group);
- this.field.setValue('dataId', this.dataId);
- //this.getData()
- }
- openLoading() {
- this.setState({
- loading: true
- });
- }
- closeLoading() {
- this.setState({
- loading: false
- });
- }
- /**
- * 回车事件
- */
- keyDownSearch(e) {
- var theEvent = e || window.event;
- var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
- if (code === 13) {
- this.getData();
- return false;
+ this.getData();
+ }
+
+ getData(pageNo = 1) {
+ const self = this;
+ this.serverId = getParams('serverId') || '';
+ if (!this.dataId) return false;
+ request({
+ beforeSend() {
+ self.openLoading();
+ },
+ url: `/nacos/v1/cs/history?search=accurate&dataId=${this.dataId}&group=${
+ this.group
+ }&&pageNo=${pageNo}&pageSize=${this.state.pageSize}`,
+ success(data) {
+ if (data != null) {
+ self.setState({
+ dataSource: data.pageItems || [],
+ total: data.totalCount,
+ currentPage: data.pageNumber,
+ });
}
- return true;
- }
- UNSAFE_componentWillMount() {
- window.addEventListener('keydown', this.keyDownSearch.bind(this), false);
- }
- componentWillUnMount() {
- window.removeEventListener('keydown', this.keyDownSearch.bind(this));
- }
- onSearch() { }
+ },
+ complete() {
+ self.closeLoading();
+ },
+ });
+ }
- onChange() { }
- cleanAndGetData(needclean = false) {
- if (needclean) {
- this.dataId = '';
- this.group = '';
- this.setState({
- group: '',
- dataId: ''
- });
- setParams({
- group: '',
- dataId: ''
- });
- }
+ showMore() {}
- this.getData();
- }
- getData(pageNo = 1) {
- let self = this;
- this.serverId = getParams('serverId') || '';
- if (!this.dataId) return false;
- request({
- beforeSend: function () {
- self.openLoading();
- },
- url: `/nacos/v1/cs/history?search=accurate&dataId=${this.dataId}&group=${this.group}&&pageNo=${pageNo}&pageSize=${this.state.pageSize}`,
- success: function (data) {
- if (data != null) {
- self.setState({
- dataSource: data.pageItems || [],
- total: data.totalCount,
- currentPage: data.pageNumber
- });
- }
- },
- complete: function () {
- self.closeLoading();
- }
- });
- }
- showMore() { }
- renderCol(value, index, record) {
- return
;
- }
- changePage(value) {
- this.setState({
- currentPage: value
- });
- this.getData(value);
- }
- onInputUpdate() { }
- chooseFieldChange(fieldValue) {
+ renderCol(value, index, record) {
+ return (
+
+ );
+ }
- this.setState({
- fieldValue
- });
- }
- showSelect(value) {
- this.setState({
- selectValue: value
- });
- if (value.indexOf('appName') !== -1) {
- this.setState({
- showAppName: true
- });
- } else {
- this.setState({
- showAppName: false
- });
- }
- if (value.indexOf('group') !== -1) {
- this.setState({
- showgroup: true
- });
- } else {
- this.setState({
- showgroup: false
- });
- }
- this.chooseFieldChange(value);
- }
- getAppName(value) {
- this.appName = value;
- this.setState({
- appName: value
- });
- }
- getDataId(value) {
- this.dataId = value;
- this.setState({
- dataId: value
- });
- }
- getGroup(value) {
+ changePage(value) {
+ this.setState({
+ currentPage: value,
+ });
+ this.getData(value);
+ }
- this.group = value;
- this.setState({
- group: value
- });
- }
- selectAll() {
- this.dataId = this.field.getValue("dataId");
- this.group = this.field.getValue("group");
- if (!this.dataId || !this.group) {
- return false;
- }
- if (this.dataId !== this.preDataId) {
- setParams('dataId', this.dataId);
- this.preDataId = this.dataId;
- }
- if (this.group !== this.preGroup) {
- setParams('group', this.preGroup);
- this.preGroup = this.group;
- }
- this.getData();
- }
- resetAll() {
- this.dataId = '';
- this.group = '';
- this.setState({
- selectValue: [],
- dataId: '',
- appName: '',
- group: '',
- showAppName: false,
- showgroup: false
- });
- setParams({
- group: '',
- dataId: ''
- });
- }
- chooseEnv(value) {
- console.log(value);
- }
- renderLastTime(value, index, record) {
- return aliwareIntl.intlTimeFormat(record.lastModifiedTime);
- }
- goDetail(record) {
- this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.props.history.push(`/historyDetail?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${record.group}&nid=${record.id}&namespace=${this.tenant}`);
- }
- goRollBack(record) {
- this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || ''; //为当前实例保存tenant参数
- this.props.history.push(`/configRollback?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${record.group}&nid=${record.id}&namespace=${this.tenant}&nid=${record.id}`);
- }
- render() {
- const pubnodedata = aliwareIntl.get('pubnodata');
+ onInputUpdate() {}
- const locale = {
- empty: pubnodedata
- };
+ chooseFieldChange(fieldValue) {
+ this.setState({
+ fieldValue,
+ });
+ }
- const { init } = this.field;
- this.init = init;
+ showSelect(value) {
+ this.setState({
+ selectValue: value,
+ });
+ if (value.indexOf('appName') !== -1) {
+ this.setState({
+ showAppName: true,
+ });
+ } else {
+ this.setState({
+ showAppName: false,
+ });
+ }
+ if (value.indexOf('group') !== -1) {
+ this.setState({
+ showgroup: true,
+ });
+ } else {
+ this.setState({
+ showgroup: false,
+ });
+ }
+ this.chooseFieldChange(value);
+ }
- return (
-
-
-
- {/**
+ getAppName(value) {
+ this.appName = value;
+ this.setState({
+ appName: value,
+ });
+ }
+
+ getDataId(value) {
+ this.dataId = value;
+ this.setState({
+ dataId: value,
+ });
+ }
+
+ getGroup(value) {
+ this.group = value;
+ this.setState({
+ group: value,
+ });
+ }
+
+ selectAll() {
+ this.dataId = this.field.getValue('dataId');
+ this.group = this.field.getValue('group');
+ if (!this.dataId || !this.group) {
+ return false;
+ }
+ if (this.dataId !== this.preDataId) {
+ setParams('dataId', this.dataId);
+ this.preDataId = this.dataId;
+ }
+ if (this.group !== this.preGroup) {
+ setParams('group', this.preGroup);
+ this.preGroup = this.group;
+ }
+ this.getData();
+ }
+
+ resetAll() {
+ this.dataId = '';
+ this.group = '';
+ this.setState({
+ selectValue: [],
+ dataId: '',
+ appName: '',
+ group: '',
+ showAppName: false,
+ showgroup: false,
+ });
+ setParams({
+ group: '',
+ dataId: '',
+ });
+ }
+
+ chooseEnv(value) {}
+
+ renderLastTime(value, index, record) {
+ return aliwareIntl.intlTimeFormat(record.lastModifiedTime);
+ }
+
+ goDetail(record) {
+ this.serverId = getParams('serverId') || 'center';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.props.history.push(
+ `/historyDetail?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${
+ record.group
+ }&nid=${record.id}&namespace=${this.tenant}`
+ );
+ }
+
+ goRollBack(record) {
+ this.serverId = getParams('serverId') || 'center';
+ this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
+ this.props.history.push(
+ `/configRollback?serverId=${this.serverId || ''}&dataId=${record.dataId}&group=${
+ record.group
+ }&nid=${record.id}&namespace=${this.tenant}&nid=${record.id}`
+ );
+ }
+
+ render() {
+ const pubnodedata = aliwareIntl.get('pubnodata');
+
+ const locale = {
+ empty: pubnodedata,
+ };
+
+ const { init } = this.field;
+ this.init = init;
+
+ return (
+
* */}
-
- );
- }
+
+
+ {aliwareIntl.get('com.alibaba.nacos.page.historyrollback.query')}
+
+
+
+
+
+
+ {aliwareIntl.get('com.alibaba.nacos.page.historyRollback.queryresult')}
+ {this.state.total}
+ {aliwareIntl.get('com.alibaba.nacos.page.historyRollback.article_meet')}
+
+
+
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default HistoryRollback;
\ No newline at end of file
+
+export default HistoryRollback;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/index.js
index e843afaad..8f1256db6 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/HistoryRollback/index.js
@@ -13,4 +13,4 @@
import HistoryRollback from './HistoryRollback';
-export default HistoryRollback;
\ No newline at end of file
+export default HistoryRollback;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js
index d1ab64aae..42cf00bef 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js
@@ -16,208 +16,321 @@ import RegionGroup from '../../../components/RegionGroup';
import { getParams, request, aliwareIntl } from '../../../globalLib';
import './index.less';
import { Field, Form, Grid, Input, Loading, Pagination, Select, Table } from '@alifd/next';
+
const FormItem = Form.Item;
const { Row, Col } = Grid;
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class ListeningToQuery extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- value: "",
- visible: false,
- loading: false,
- total: 0,
- pageSize: 10,
- currentPage: 1,
- dataSource: []
- };
- this.field = new Field(this);
- this.group = getParams('group') || '';
- this.dataId = getParams('dataId') || '';
- this.serverId = getParams('serverId') || '';
- this.tenant = getParams('namespace') || '';
- }
+ constructor(props) {
+ super(props);
+ this.state = {
+ value: '',
+ visible: false,
+ loading: false,
+ total: 0,
+ pageSize: 10,
+ currentPage: 1,
+ dataSource: [],
+ };
+ this.field = new Field(this);
+ this.group = getParams('group') || '';
+ this.dataId = getParams('dataId') || '';
+ this.serverId = getParams('serverId') || '';
+ this.tenant = getParams('namespace') || '';
+ }
- componentDidMount() {
- this.field.setValue('type', 0);
- this.field.setValue('group', this.group);
- this.field.setValue('dataId', this.dataId);
- }
+ componentDidMount() {
+ this.field.setValue('type', 0);
+ this.field.setValue('group', this.group);
+ this.field.setValue('dataId', this.dataId);
+ }
- onSearch() { }
+ onSearch() {}
- onChange() { }
- openLoading() {
- this.setState({
- loading: true
- });
+ onChange() {}
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ queryTrackQuery = () => {
+ const self = this;
+ let queryUrl = '';
+ const type = this.getValue('type');
+ if (type === 1) {
+ const ip = this.getValue('ip');
+ queryUrl = `/nacos/v1/cs/listener?ip=${ip}`;
+ const tenant = window.nownamespace || getParams('namespace') || '';
+ if (tenant) {
+ queryUrl += `&tenant=${tenant}`;
+ }
+ } else {
+ const dataId = this.getValue('dataId');
+ const group = this.getValue('group');
+ if (!dataId || !group) return false;
+ queryUrl = `/nacos/v1/cs/configs/listener?dataId=${dataId}&group=${group}`;
}
- closeLoading() {
- this.setState({
- loading: false
- });
- }
- queryTrackQuery() {
- var self = this;
- var queryUrl = "";
- var type = this.getValue('type');
- if (type === 1) {
- var ip = this.getValue('ip');
- queryUrl = `/nacos/v1/cs/listener?ip=${ip}`;
- let tenant = window.nownamespace || getParams('namespace') || '';
- if (tenant) {
- queryUrl += '&tenant=' + tenant;
+ request({
+ url: queryUrl,
+ beforeSend() {
+ self.openLoading();
+ },
+ success(data) {
+ if (data.collectStatus === 200) {
+ const dataSoureTmp = [];
+ const status = data.lisentersGroupkeyStatus;
+ for (const key in status) {
+ if (type === 1) {
+ const obj = {};
+ let [dataId, group] = key.split('+');
+ obj.dataId = dataId;
+ obj.group = group;
+ obj.md5 = status[key];
+ dataSoureTmp.push(obj);
+ } else {
+ const obj = {};
+ obj.ip = key;
+ obj.md5 = status[key];
+ dataSoureTmp.push(obj);
}
- } else {
- var dataId = this.getValue('dataId');
- var group = this.getValue('group');
- if (!dataId || !group) return false;
- queryUrl = `/nacos/v1/cs/configs/listener?dataId=${dataId}&group=${group}`;
+ }
+ self.setState({
+ dataSource: dataSoureTmp || [],
+ total: data.length,
+ });
}
- request({
- url: queryUrl,
- beforeSend: function () {
- self.openLoading();
- },
- success: function (data) {
- if (data.collectStatus === 200) {
- let dataSoureTmp = [];
- let status = data.lisentersGroupkeyStatus;
- for (var key in status) {
- if (type === 1) {
- let obj = {};
- obj.dataId = key.split("+")[0];
- obj.group = key.split("+")[1];
- obj.md5 = status[key];
- dataSoureTmp.push(obj);
- } else {
- let obj = {};
- obj.ip = key;
- obj.md5 = status[key];
- dataSoureTmp.push(obj);
- }
- }
- self.setState({
- dataSource: dataSoureTmp || [],
- total: data.length
- });
- }
- },
- complete: function () {
- self.closeLoading();
- }
- });
- }
+ },
+ complete() {
+ self.closeLoading();
+ },
+ });
+ };
- showMore() { }
- changePage(value) {
- this.setState({
- currentPage: value
- });
- }
- resetSearch() {
- this.field.reset();
- this.forceUpdate();
- }
- renderStatus(values, index, record) {
- return
{record.pushStatus === true ? {aliwareIntl.get('com.alibaba.nacos.page.listeningToQuery.success')} : {aliwareIntl.get('com.alibaba.nacos.page.listeningToQuery.failure')}}
-
;
- }
- getQueryLater() {
- setTimeout(() => {
- //子组件可能优先于父组件所以延迟执行
- this.queryTrackQuery();
- });
- }
- render() {
- const { init, getValue } = this.field;
- this.init = init;
- this.getValue = getValue;
- const pubnodedata = aliwareIntl.get('pubnodata');
+ showMore() {}
- const locale = {
- empty: pubnodedata
- };
- const selectDataSource = [
- {
- label: aliwareIntl.get('com.alibaba.nacos.page.listeningToQuery.configuration'),
- value: 0
- },
- {
- label: "IP",
- value: 1
- }
- ]
- return (
-
- );
- }
+ changePage = value => {
+ this.setState({
+ currentPage: value,
+ });
+ };
+
+ resetSearch() {
+ this.field.reset();
+ this.forceUpdate();
+ }
+
+ renderStatus(values, index, record) {
+ return (
+
+ {record.pushStatus === true ? (
+
+ {aliwareIntl.get('com.alibaba.nacos.page.listeningToQuery.success')}
+
+ ) : (
+
+ {aliwareIntl.get('com.alibaba.nacos.page.listeningToQuery.failure')}
+
+ )}
+
+ );
+ }
+
+ getQueryLater = () => {
+ setTimeout(() => {
+ // 子组件可能优先于父组件所以延迟执行
+ this.queryTrackQuery();
+ });
+ };
+
+ render() {
+ const { init, getValue } = this.field;
+ this.init = init;
+ this.getValue = getValue;
+ const pubnodedata = aliwareIntl.get('pubnodata');
+
+ const locale = {
+ empty: pubnodedata,
+ };
+ const selectDataSource = [
+ {
+ label: aliwareIntl.get('com.alibaba.nacos.page.listeningToQuery.configuration'),
+ value: 0,
+ },
+ {
+ label: 'IP',
+ value: 1,
+ },
+ ];
+ return (
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default ListeningToQuery;
\ No newline at end of file
+
+export default ListeningToQuery;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/index.js
index 2bdf26404..1701270f6 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/ListeningToQuery/index.js
@@ -13,4 +13,4 @@
import ListeningToQuery from './ListeningToQuery';
-export default ListeningToQuery;
\ No newline at end of file
+export default ListeningToQuery;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/NewConfig.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/NewConfig.js
index 11d99764f..e9a4eef49 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/NewConfig.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/NewConfig.js
@@ -16,399 +16,536 @@ import $ from 'jquery';
import SuccessDialog from '../../../components/SuccessDialog';
import { getParams, setParams, request, aliwareIntl } from '../../../globalLib';
import './index.less';
-import { Balloon, Button, Dialog, Field, Form, Icon, Input, Loading, Message, Select, Radio } from '@alifd/next';
+import {
+ Balloon,
+ Button,
+ Dialog,
+ Field,
+ Form,
+ Icon,
+ Input,
+ Loading,
+ Message,
+ Select,
+ Radio,
+} from '@alifd/next';
+
const FormItem = Form.Item;
const { Group: RadioGroup } = Radio;
const { AutoComplete: Combobox } = Select;
-
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class NewConfig extends React.Component {
- constructor(props) {
- super(props);
- this.field = new Field(this);
- this.edasAppName = getParams('edasAppName') || '';
- this.edasAppId = getParams('edasAppId') || '';
- this.inApp = this.edasAppName;
- this.field.setValue('appName', this.inApp ? this.edasAppName : '');
- this.inEdas = window.globalConfig.isParentEdas();
- this.dataId = getParams('dataId') || '';
- this.group = getParams('group') || 'DEFAULT_GROUP';
- this.searchDataId = getParams('searchDataId') || '';
- this.searchGroup = getParams('searchGroup') || '';
- this.state = {
- configType: 'text',
- codeValue: ``,
- envname: '',
- targetEnvName: '',
- groups: [],
- groupNames: [],
- envlist: [],
- tagLst: [],
- config_tags: [],
- envvalues: [],
- showmore: false,
- loading: false,
- encrypt: false,
- addonBefore: '',
- showGroupWarning: false
- };
- this.codeValue = '';
- this.mode = 'text';
- this.ips = '';
- }
+ constructor(props) {
+ super(props);
+ this.field = new Field(this);
+ this.edasAppName = getParams('edasAppName') || '';
+ this.edasAppId = getParams('edasAppId') || '';
+ this.inApp = this.edasAppName;
+ this.field.setValue('appName', this.inApp ? this.edasAppName : '');
+ this.inEdas = window.globalConfig.isParentEdas();
+ this.dataId = getParams('dataId') || '';
+ this.group = getParams('group') || 'DEFAULT_GROUP';
+ this.searchDataId = getParams('searchDataId') || '';
+ this.searchGroup = getParams('searchGroup') || '';
+ this.state = {
+ configType: 'text',
+ codeValue: '',
+ envname: '',
+ targetEnvName: '',
+ groups: [],
+ groupNames: [],
+ envlist: [],
+ tagLst: [],
+ config_tags: [],
+ envvalues: [],
+ showmore: false,
+ loading: false,
+ encrypt: false,
+ addonBefore: '',
+ showGroupWarning: false,
+ };
+ this.codeValue = '';
+ this.mode = 'text';
+ this.ips = '';
+ }
- componentDidMount() {
- this.betaips = document.getElementById('betaips');
- //this.createCodeMirror('text', '');
- this.chontenttab = document.getElementById('chontenttab'); //diff标签
- this.tenant = getParams('namespace') || '';
- this.field.setValue('group', this.group);
- if (!window.monaco) {
- window.importEditor(() => {
- this.initMoacoEditor();
- });
- } else {
- this.initMoacoEditor();
- }
+ componentDidMount() {
+ this.betaips = document.getElementById('betaips');
+ // this.createCodeMirror('text', '');
+ this.chontenttab = document.getElementById('chontenttab'); // diff标签
+ this.tenant = getParams('namespace') || '';
+ this.field.setValue('group', this.group);
+ if (!window.monaco) {
+ window.importEditor(() => {
+ this.initMoacoEditor();
+ });
+ } else {
+ this.initMoacoEditor();
}
- changeModel(type) {
- if (!this.monacoEditor) {
- $('#container').empty();
- this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
- model: null
- });
- return;
- }
- let oldModel = this.monacoEditor.getModel();
- let oldValue = this.monacoEditor.getValue();
- let newModel = window.monaco.editor.createModel(oldValue, type);
- this.monacoEditor.setModel(newModel);
- //this.monacoEditor.setValue('xx')
- if (oldModel) {
- oldModel.dispose();
- }
+ }
+
+ changeModel(type) {
+ if (!this.monacoEditor) {
+ $('#container').empty();
+ this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
+ model: null,
+ });
+ return;
}
- initMoacoEditor() {
+ const oldModel = this.monacoEditor.getModel();
+ const oldValue = this.monacoEditor.getValue();
+ const newModel = window.monaco.editor.createModel(oldValue, type);
+ this.monacoEditor.setModel(newModel);
+ // this.monacoEditor.setValue('xx')
+ if (oldModel) {
+ oldModel.dispose();
+ }
+ }
+ initMoacoEditor() {
+ this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
+ value: this.codeValue,
+ language: this.state.configType,
+ codeLens: true,
+ selectOnLineNumbers: true,
+ roundedSelection: false,
+ readOnly: false,
+ lineNumbersMinChars: true,
+ theme: 'vs-dark',
+ wordWrapColumn: 120,
+ folding: true,
+ showFoldingControls: 'always',
+ wordWrap: 'wordWrapColumn',
+ cursorStyle: 'line',
+ automaticLayout: true,
+ });
+ }
- this.monacoEditor = window.monaco.editor.create(document.getElementById('container'), {
- value: this.codeValue,
- language: this.state.configType,
- codeLens: true,
- selectOnLineNumbers: true,
- roundedSelection: false,
- readOnly: false,
- lineNumbersMinChars: true,
- theme: 'vs-dark',
- wordWrapColumn: 120,
- folding: true,
- showFoldingControls: 'always',
- wordWrap: 'wordWrapColumn',
- cursorStyle: 'line',
- automaticLayout: true
+ setGroup(value) {
+ this.group = value || '';
+ this.field.setValue('group', this.group);
+ if (this.inEdas) {
+ this.setState({
+ showGroupWarning: this.group !== '' && this.state.groupNames.indexOf(value) < 0,
+ });
+ }
+ }
+
+ setConfigTags(value) {
+ if (value.length > 5) {
+ value.pop();
+ }
+ value.forEach((v, i) => {
+ if (v.indexOf(',') !== -1 || v.indexOf('=') !== -1) {
+ value.splice(i, 1);
+ }
+ });
+ this.setState({
+ config_tags: value,
+ });
+ }
+
+ onInputUpdate(value) {
+ if (this.inputtimmer) {
+ clearTimeout(this.inputtimmer);
+ }
+ this.inputtimmer = setTimeout(() => {
+ const { tagLst } = this.state;
+
+ let hastag = false;
+ tagLst.forEach((v, i) => {
+ if (v.value === value) {
+ hastag = true;
+ }
+ });
+ if (!hastag) {
+ tagLst.push({
+ value,
+ label: value,
+ time: Math.random(),
});
+ }
+ this.setState({ tagLst });
+ }, 500);
+ }
+
+ toggleMore() {
+ this.setState({
+ showmore: !this.state.showmore,
+ });
+ }
+
+ goList() {
+ this.tenant = getParams('namespace') || '';
+ this.serverId = getParams('serverId') || '';
+ this.props.history.push(
+ `/configurationManagement?serverId=${this.serverId}&group=${this.searchGroup}&dataId=${
+ this.searchDataId
+ }&namespace=${this.tenant}`
+ );
+ }
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ newChangeConfig(value) {
+ this.setState({
+ configType: value,
+ });
+
+ this.changeModel(value);
+ }
+
+ setCodeValue(value) {
+ this.setState({
+ codeValue: value,
+ });
+ }
+
+ publishConfig() {
+ this.field.validate((errors, values) => {
+ if (errors) {
+ return;
+ }
+ let content = '';
+ const self = this;
+ if (this.monacoEditor) {
+ content = this.monacoEditor.getValue();
+ } else {
+ content = this.codeValue;
+ }
+ if (!content) {
+ return;
+ }
+ this.tenant = getParams('namespace') || '';
+ const payload = {
+ dataId: self.state.addonBefore + this.field.getValue('dataId'),
+ group: this.field.getValue('group'),
+ content,
+ desc: this.field.getValue('desc'),
+ config_tags: this.state.config_tags.join(),
+ type: this.state.configType,
+ appName: this.inApp ? this.edasAppId : this.field.getValue('appName'),
+ tenant: this.tenant,
+ };
+ this.serverId = getParams('serverId') || 'center';
+ const url = '/nacos/v1/cs/configs';
+ request({
+ type: 'post',
+ contentType: 'application/x-www-form-urlencoded',
+ url,
+ data: payload,
+ beforeSend: () => {
+ this.openLoading();
+ },
+ success(res) {
+ const _payload = {};
+ _payload.maintitle = aliwareIntl.get('com.alibaba.nacos.page.newconfig.new_listing_main');
+ _payload.title = aliwareIntl.get('com.alibaba.nacos.page.newconfig.new_listing');
+ _payload.content = '';
+ _payload.dataId = payload.dataId;
+ _payload.group = payload.group;
+ if (res === true) {
+ self.group = payload.group;
+ self.dataId = payload.dataId;
+ setParams({ group: payload.group, dataId: payload.dataId }); // 设置参数
+ _payload.isok = true;
+ } else {
+ _payload.isok = false;
+ _payload.message = res.message;
+ }
+ self.refs.success.openDialog(_payload);
+ },
+ complete() {
+ self.closeLoading();
+ },
+ error(res) {
+ Dialog.alert({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ content: aliwareIntl.get('com.alibaba.nacos.page.newconfig.publish_failed'),
+ });
+ self.closeLoading();
+ },
+ });
+ });
+ }
+
+ changeEnv(values) {
+ this.targetEnvs = values;
+ this.setState({
+ envvalues: values,
+ });
+ }
+
+ changeBeta(selected) {
+ if (selected) {
+ this.betaips.style.display = 'block';
+ } else {
+ this.betaips.style.display = 'none';
}
+ }
+ getIps(value) {
+ this.ips = value;
+ }
- setGroup(value) {
- this.group = value || '';
- this.field.setValue('group', this.group);
- if (this.inEdas) {
- this.setState({
- showGroupWarning: this.group !== '' && this.state.groupNames.indexOf(value) < 0
- });
- }
+ validateChart(rule, value, callback) {
+ const chartReg = /[@#\$%\^&\*]+/g;
+
+ if (chartReg.test(value)) {
+ callback(aliwareIntl.get('com.alibaba.nacos.page.newconfig.do_not_ente'));
+ } else {
+ callback();
}
+ }
- setConfigTags(value) {
- if (value.length > 5) {
- value.pop();
- }
- value.forEach((v, i) => {
- if (v.indexOf(',') !== -1 || v.indexOf('=') !== -1) {
- value.splice(i, 1);
- }
- });
- this.setState({
- config_tags: value
- });
- }
+ render() {
+ const { init } = this.field;
+ const formItemLayout = {
+ labelCol: {
+ span: 2,
+ },
+ wrapperCol: {
+ span: 22,
+ },
+ };
- onInputUpdate(value) {
- if (this.inputtimmer) {
- clearTimeout(this.inputtimmer);
- }
- this.inputtimmer = setTimeout(() => {
- let tagLst = this.state.tagLst,
- hastag = false;
- tagLst.forEach((v, i) => {
- if (v.value === value) {
- hastag = true;
+ // const list = [{
+ // value: 0,
+ // label: 'TEXT'
+ // }, {
+ // value: 1,
+ // label: 'JSON'
+ // }, {
+ // value: 2,
+ // label: 'XML'
+ // }];
+ const list = [
+ {
+ value: 'text',
+ label: 'TEXT',
+ },
+ {
+ value: 'json',
+ label: 'JSON',
+ },
+ {
+ value: 'xml',
+ label: 'XML',
+ },
+ {
+ value: 'yaml',
+ label: 'YAML',
+ },
+ {
+ value: 'text/html',
+ label: 'HTML',
+ },
+ {
+ value: 'properties',
+ label: 'Properties',
+ },
+ ];
+
+ return (
+
+
+ {aliwareIntl.get('com.alibaba.nacos.page.newconfig.new_listing')}
+
+ ) : null
}
- });
- if (!hastag) {
- tagLst.push({
- value: value,
- label: value,
- time: Math.random()
- });
- }
- this.setState({ tagLst: tagLst });
- }, 500);
- }
+ />
+
+
+
+
+
+
+ {aliwareIntl.get(
+ 'nacos.page.newconfig.Note_You_are_to_be_a_custom_packet_the_new_configuration,_make_sure_that_the_client_use_the_Pandora_version_higher_than_3._4._0,_otherwise_it_may_read_less_than_the_configuration.0'
+ )}
+
+
+
+
+
- toggleMore() {
- this.setState({
- showmore: !this.state.showmore
- });
- }
- goList() {
- this.tenant = getParams('namespace') || '';
- this.serverId = getParams('serverId') || '';
- //console.log(`/configurationManagement?serverId=${this.serverId}&group=${this.group}&dataId=${this.dataId}`)
- this.props.history.push(`/configurationManagement?serverId=${this.serverId}&group=${this.searchGroup}&dataId=${this.searchDataId}&namespace=${this.tenant}`);
- }
- openLoading() {
- this.setState({
- loading: true
- });
- }
- closeLoading() {
- this.setState({
- loading: false
- });
- }
+
+
+
+
- newChangeConfig(value) {
- this.setState({
- configType: value
- });
-
- this.changeModel(value);
- }
- setCodeValue(value) {
-
- this.setState({
- codeValue: value
- });
- }
-
- publishConfig() {
- this.field.validate((errors, values) => {
- if (errors) {
- return;
- }
- let content = '';
- let self = this;
- if (this.monacoEditor) {
- content = this.monacoEditor.getValue();
- } else {
- content = this.codeValue;
- }
- if (!content) {
- return;
- }
- this.tenant = getParams('namespace') || '';
- let payload = {
- dataId: self.state.addonBefore + this.field.getValue('dataId'),
- group: this.field.getValue('group'),
- content: content,
- desc: this.field.getValue('desc'),
- config_tags: this.state.config_tags.join(),
- type: this.state.configType,
- appName: this.inApp ? this.edasAppId : this.field.getValue('appName'),
- tenant: this.tenant
- };
- this.serverId = getParams('serverId') || 'center';
- let url = `/nacos/v1/cs/configs`;
- request({
- type: 'post',
- contentType: 'application/x-www-form-urlencoded',
- url: url,
- data: payload,
- beforeSend: () => {
- this.openLoading();
- },
- success: function (res) {
- let _payload = {};
- _payload.maintitle = aliwareIntl.get('com.alibaba.nacos.page.newconfig.new_listing_main');
- _payload.title = aliwareIntl.get('com.alibaba.nacos.page.newconfig.new_listing');
- _payload.content = '';
- _payload.dataId = payload.dataId;
- _payload.group = payload.group;
- if (res === true) {
- self.group = payload.group;
- self.dataId = payload.dataId;
- setParams({ group: payload.group, dataId: payload.dataId }); //设置参数
- _payload.isok = true;
- } else {
- _payload.isok = false;
- _payload.message = res.message;
- }
- self.refs['success'].openDialog(_payload);
- },
- complete: function () {
- self.closeLoading();
- },
- error: function (res) {
- Dialog.alert({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- content: aliwareIntl.get('com.alibaba.nacos.page.newconfig.publish_failed')
- });
- self.closeLoading();
- }
-
- });
- });
- }
-
- changeEnv(values) {
- this.targetEnvs = values;
- this.setState({
- envvalues: values
- });
- }
-
- changeBeta(selected) {
- if (selected) {
- this.betaips.style.display = 'block';
- } else {
- this.betaips.style.display = 'none';
- }
- }
- getIps(value) {
- this.ips = value;
- }
-
- validateChart(rule, value, callback) {
- const chartReg = /[@#\$%\^&\*]+/g;
-
- if (chartReg.test(value)) {
- callback(aliwareIntl.get('com.alibaba.nacos.page.newconfig.do_not_ente'));
- } else {
- callback();
- }
- }
- render() {
- const { init } = this.field;
- const formItemLayout = {
- labelCol: {
- span: 2
- },
- wrapperCol: {
- span: 22
- }
- };
-
- // const list = [{
- // value: 0,
- // label: 'TEXT'
- // }, {
- // value: 1,
- // label: 'JSON'
- // }, {
- // value: 2,
- // label: 'XML'
- // }];
- const list = [{
- value: 'text',
- label: 'TEXT'
- }, {
- value: 'json',
- label: 'JSON'
- }, {
- value: 'xml',
- label: 'XML'
- }, {
- value: 'yaml',
- label: 'YAML'
- }, {
- value: 'text/html',
- label: 'HTML'
- }, {
- value: 'properties',
- label: 'Properties'
- }];
-
- return (
-
-
- {aliwareIntl.get('com.alibaba.nacos.page.newconfig.new_listing')}
-
: null} />
-
-
-
-
-
-
-
- {aliwareIntl.get('nacos.page.newconfig.Note_You_are_to_be_a_custom_packet_the_new_configuration,_make_sure_that_the_client_use_the_Pandora_version_higher_than_3._4._0,_otherwise_it_may_read_less_than_the_configuration.0')}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{aliwareIntl.get('com.alibaba.nacos.page.newconfig.configuration_format')}} align={"t"} style={{ marginRight: 5 }} triggerType={"hover"}>
- {aliwareIntl.get('com.alibaba.nacos.page.newconfig.configure_contents_of')}
- {aliwareIntl.get('com.alibaba.nacos.page.newconfig.full_screen')}
- :} required {...formItemLayout}>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
- );
- }
+
+
+
+
+
+
+
+
+
+ {aliwareIntl.get('com.alibaba.nacos.page.newconfig.configuration_format')}
+
+ }
+ align={'t'}
+ style={{ marginRight: 5 }}
+ triggerType={'hover'}
+ >
+
+ {aliwareIntl.get('com.alibaba.nacos.page.newconfig.configure_contents_of')}
+
+ {aliwareIntl.get('com.alibaba.nacos.page.newconfig.full_screen')}
+
+ :
+
+ }
+ required
+ {...formItemLayout}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default NewConfig;
\ No newline at end of file
+
+export default NewConfig;
diff --git a/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/index.js b/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/index.js
index 9a507b9a9..377c9a0ed 100644
--- a/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/index.js
+++ b/console/src/main/resources/static/src/pages/ConfigurationManagement/NewConfig/index.js
@@ -13,4 +13,4 @@
import NewConfig from './NewConfig';
-export default NewConfig;
\ No newline at end of file
+export default NewConfig;
diff --git a/console/src/main/resources/static/src/pages/NameSpace/NameSpace.js b/console/src/main/resources/static/src/pages/NameSpace/NameSpace.js
index 793e1106c..a361eae77 100644
--- a/console/src/main/resources/static/src/pages/NameSpace/NameSpace.js
+++ b/console/src/main/resources/static/src/pages/NameSpace/NameSpace.js
@@ -20,273 +20,347 @@ import EditorNameSpace from '../../components/EditorNameSpace';
import { getParams, setParams, request, aliwareIntl } from '../../globalLib';
import './index.less';
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class NameSpace extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- loading: false,
- defaultNamespace: "",
- dataSource: []
+ constructor(props) {
+ super(props);
+ this.state = {
+ loading: false,
+ defaultNamespace: '',
+ dataSource: [],
+ };
+ }
- };
- }
+ componentDidMount() {
+ this.getNameSpaces(0);
+ }
- componentDidMount() {
- this.getNameSpaces(0);
- }
- getNameSpaces(delayTime = 2000) {
- let self = this;
- // let serverId = getParams('serverId') || 'center';
- self.openLoading();
- setTimeout(() => {
- request({
- type: 'get',
- beforeSend: function () { },
- url: `/nacos/v1/console/namespaces`,
- success: res => {
- if (res.code === 200) {
- let data = res.data || [];
- window.namespaceList = data;
+ getNameSpaces(delayTime = 2000) {
+ const self = this;
+ // let serverId = getParams('serverId') || 'center';
+ self.openLoading();
+ setTimeout(() => {
+ request({
+ type: 'get',
+ beforeSend() {},
+ url: '/nacos/v1/console/namespaces',
+ success: res => {
+ if (res.code === 200) {
+ const data = res.data || [];
+ window.namespaceList = data;
- for (var i = 0; i < data.length; i++) {
- if (data[i].type === 1) {
- this.setState({
- defaultNamespace: data[i].namespace
- });
- }
- }
-
- this.setState({
- dataSource: data
- });
- } else {
- Dialog.alert({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- title: aliwareIntl.get('com.alibaba.nacos.page.namespace.prompt'),
- content: res.message
- });
- }
- },
- complete: function () {
- self.closeLoading();
- },
- error: res => {
- window.namespaceList = [{
- "namespace": "",
- "namespaceShowName": "公共空间",
- "type": 0
- }];
- }
- });
- }, delayTime);
- }
-
- openLoading() {
- this.setState({
- loading: true
- });
- }
- closeLoading() {
- this.setState({
- loading: false
- });
- }
-
- detailNamespace(record) {
- let namespace = record.namespace; //获取ak,sk
- request({
- url: `/nacos/v1/console/namespaces?show=all&namespaceId=${namespace}`,
- beforeSend: () => {
- this.openLoading();
- },
- success: res => {
- if (res !== null) {
- Dialog.alert({
- style: { width: "500px" },
- needWrapper: false,
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- title: aliwareIntl.get('nacos.page.namespace.Namespace_details'),
- content:
-
-
- {aliwareIntl.get('nacos.page.namespace.namespace_name')}
-
- {res.namespaceShowName}
-
-
-
- {aliwareIntl.get('nacos.page.namespace.namespace_ID')}
-
- {res.namespace}
-
-
-
- {aliwareIntl.get('com.alibaba.nacos.page.namespace.configuration')}
-
- {res.configCount} / {res.quota}
-
-
-
- {aliwareIntl.get('nacos.page.configdetail.Description')}
-
- {res.namespaceDesc}
-
-
-
-
- });
- }
- },
- complete: () => {
- this.closeLoading();
- }
- });
- }
-
- removeNamespace(record) {
- // let serverId = getParams('serverId') || 'center';
- Dialog.confirm({
- title: aliwareIntl.get('nacos.page.namespace.remove_the_namespace'),
- content:
-
{aliwareIntl.get('nacos.page.namespace.sure_you_want_to_delete_the_following_namespaces?')}
-
- {aliwareIntl.get('nacos.page.namespace.namespace_name')}
-
- {record.namespaceShowName}
-
-
-
- {aliwareIntl.get('nacos.page.namespace.namespace_ID')}
-
- {record.namespace}
-
-
-
,
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- onOk: () => {
- let url = `/nacos/v1/console/namespaces?namespaceId=${record.namespace}`;
- request({
- url: url,
- type: 'delete',
- success: res => {
- let _payload = {};
- _payload.title = aliwareIntl.get('com.alibaba.nacos.page.configurationManagement.configuration_management');
- if (res === true) {
- let urlnamespace = getParams('namespace');
- if (record.namespace === urlnamespace) {
- setParams('namespace', this.state.defaultNamespace);
- }
- Dialog.confirm({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- content: aliwareIntl.get('nacos.page.namespace._Remove_the_namespace_success'),
- title: aliwareIntl.get('nacos.page.namespace.deleted_successfully')
- });
- } else {
- Dialog.confirm({
- language: aliwareIntl.currentLanguageCode || 'zh-cn',
- content: res.message,
- title: "删除失败"
- });
- }
-
- this.getNameSpaces();
- }
+ for (let i = 0; i < data.length; i++) {
+ if (data[i].type === 1) {
+ this.setState({
+ defaultNamespace: data[i].namespace,
});
+ }
}
- });
- }
- refreshNameSpace() {
- request({
- type: 'get',
- url: `/nacos/v1/console/namespaces`,
- success: res => {
- if (res.code === 200) {
- window.namespaceList = res.data;
- }
+ this.setState({
+ dataSource: data,
+ });
+ } else {
+ Dialog.alert({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ title: aliwareIntl.get('com.alibaba.nacos.page.namespace.prompt'),
+ content: res.message,
+ });
+ }
+ },
+ complete() {
+ self.closeLoading();
+ },
+ error: res => {
+ window.namespaceList = [
+ {
+ namespace: '',
+ namespaceShowName: '公共空间',
+ type: 0,
},
- error: res => {
- window.namespaceList = [{
- "namespace": "",
- "namespaceShowName": "公共空间",
- "type": 0
- }];;
+ ];
+ },
+ });
+ }, delayTime);
+ }
+
+ openLoading() {
+ this.setState({
+ loading: true,
+ });
+ }
+
+ closeLoading() {
+ this.setState({
+ loading: false,
+ });
+ }
+
+ detailNamespace(record) {
+ const { namespace } = record; // 获取ak,sk
+ request({
+ url: `/nacos/v1/console/namespaces?show=all&namespaceId=${namespace}`,
+ beforeSend: () => {
+ this.openLoading();
+ },
+ success: res => {
+ if (res !== null) {
+ Dialog.alert({
+ style: { width: '500px' },
+ needWrapper: false,
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ title: aliwareIntl.get('nacos.page.namespace.Namespace_details'),
+ content: (
+
+
+
+
+ {aliwareIntl.get('nacos.page.namespace.namespace_name')}
+
+ {res.namespaceShowName}
+
+
+
+ {aliwareIntl.get('nacos.page.namespace.namespace_ID')}
+
+ {res.namespace}
+
+
+
+ {aliwareIntl.get('com.alibaba.nacos.page.namespace.configuration')}
+
+
+ {res.configCount} / {res.quota}
+
+
+
+
+ {aliwareIntl.get('nacos.page.configdetail.Description')}
+
+ {res.namespaceDesc}
+
+
+
+ ),
+ });
+ }
+ },
+ complete: () => {
+ this.closeLoading();
+ },
+ });
+ }
+
+ removeNamespace(record) {
+ // let serverId = getParams('serverId') || 'center';
+ Dialog.confirm({
+ title: aliwareIntl.get('nacos.page.namespace.remove_the_namespace'),
+ content: (
+
+
+ {aliwareIntl.get(
+ 'nacos.page.namespace.sure_you_want_to_delete_the_following_namespaces?'
+ )}
+
+
+
+ {aliwareIntl.get('nacos.page.namespace.namespace_name')}
+
+ {record.namespaceShowName}
+
+
+
+ {aliwareIntl.get('nacos.page.namespace.namespace_ID')}
+
+ {record.namespace}
+
+
+ ),
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ onOk: () => {
+ const url = `/nacos/v1/console/namespaces?namespaceId=${record.namespace}`;
+ request({
+ url,
+ type: 'delete',
+ success: res => {
+ const _payload = {};
+ _payload.title = aliwareIntl.get(
+ 'com.alibaba.nacos.page.configurationManagement.configuration_management'
+ );
+ if (res === true) {
+ const urlnamespace = getParams('namespace');
+ if (record.namespace === urlnamespace) {
+ setParams('namespace', this.state.defaultNamespace);
+ }
+ Dialog.confirm({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ content: aliwareIntl.get('nacos.page.namespace._Remove_the_namespace_success'),
+ title: aliwareIntl.get('nacos.page.namespace.deleted_successfully'),
+ });
+ } else {
+ Dialog.confirm({
+ language: aliwareIntl.currentLanguageCode || 'zh-cn',
+ content: res.message,
+ title: '删除失败',
+ });
}
+
+ this.getNameSpaces();
+ },
});
- }
+ },
+ });
+ }
- openToEdit(record) {
- this.refs['editgroup'].openDialog(record);
- }
- renderOption(value, index, record) {
- let _delinfo =
{aliwareIntl.get('com.alibaba.nacos.page.namespace.delete')};
- if (record.type === 1 || record.type === 0) {
- _delinfo =
{aliwareIntl.get('com.alibaba.nacos.page.namespace.delete')};
+ refreshNameSpace() {
+ request({
+ type: 'get',
+ url: '/nacos/v1/console/namespaces',
+ success: res => {
+ if (res.code === 200) {
+ window.namespaceList = res.data;
}
- let _detailinfo =
{aliwareIntl.get('nacos.page.namespace.details')};
+ },
+ error: res => {
+ window.namespaceList = [
+ {
+ namespace: '',
+ namespaceShowName: '公共空间',
+ type: 0,
+ },
+ ];
+ },
+ });
+ }
- let _editinfo =
{aliwareIntl.get('com.alibaba.nacos.page.namespace.edit')};
- if (record.type === 0 || record.type === 1) {
- _editinfo =
{aliwareIntl.get('com.alibaba.nacos.page.namespace.edit')};
- }
- return
- {_detailinfo}
- {_delinfo}
- {_editinfo}
-
;
+ openToEdit(record) {
+ this.refs.editgroup.openDialog(record);
+ }
+
+ renderOption(value, index, record) {
+ let _delinfo = (
+
+ {aliwareIntl.get('com.alibaba.nacos.page.namespace.delete')}
+
+ );
+ if (record.type === 1 || record.type === 0) {
+ _delinfo = (
+
+ {aliwareIntl.get('com.alibaba.nacos.page.namespace.delete')}
+
+ );
}
- addNameSpace() {
- this.refs['newnamespace'].openDialog(this.state.dataSource);
+ const _detailinfo = (
+
+ {aliwareIntl.get('nacos.page.namespace.details')}
+
+ );
+
+ let _editinfo = (
+
+ {aliwareIntl.get('com.alibaba.nacos.page.namespace.edit')}
+
+ );
+ if (record.type === 0 || record.type === 1) {
+ _editinfo = (
+
+ {aliwareIntl.get('com.alibaba.nacos.page.namespace.edit')}
+
+ );
}
- renderName(value, index, record) {
+ return (
+
+ {_detailinfo}
+ {_delinfo}
+ {_editinfo}
+
+ );
+ }
- let name = record.namespaceShowName;
- if (record.type === 0) {
- name = aliwareIntl.get('com.alibaba.nacos.page.namespace.public');
- }
- return
{name}
;
+ addNameSpace() {
+ this.refs.newnamespace.openDialog(this.state.dataSource);
+ }
+
+ renderName(value, index, record) {
+ let name = record.namespaceShowName;
+ if (record.type === 0) {
+ name = aliwareIntl.get('com.alibaba.nacos.page.namespace.public');
}
- renderConfigCount(value, index, record) {
- return
{value} / {record.quota}
;
- }
- render() {
- const pubnodedata = aliwareIntl.get('pubnodata');
+ return
{name}
;
+ }
- const locale = {
- empty: pubnodedata
- };
- return
-
-
-
-
-
+ renderConfigCount(value, index, record) {
+ return (
+
+ {value} / {record.quota}
+
+ );
+ }
-
-
-
-
-
-
-
+ render() {
+ const pubnodedata = aliwareIntl.get('pubnodata');
-
-
-
-
+ const locale = {
+ empty: pubnodedata,
+ };
+ return (
+
+
+
+
+
+
+
+
+
-
-
-
- ;
- }
+
+
+
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
-export default NameSpace;
\ No newline at end of file
+
+export default NameSpace;
diff --git a/console/src/main/resources/static/src/pages/NameSpace/index.js b/console/src/main/resources/static/src/pages/NameSpace/index.js
index 74adf3045..b99ba6ece 100644
--- a/console/src/main/resources/static/src/pages/NameSpace/index.js
+++ b/console/src/main/resources/static/src/pages/NameSpace/index.js
@@ -13,4 +13,4 @@
import NameSpace from './NameSpace';
-export default NameSpace;
\ No newline at end of file
+export default NameSpace;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js
index 2c2804a63..c0f0aa090 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js
@@ -14,156 +14,161 @@
import React from 'react';
import { request } from '../../../globalLib';
import { Dialog, Form, Input, Switch, Select, Message } from '@alifd/next';
-import { I18N, DIALOG_FORM_LAYOUT } from './constant'
+import { I18N, DIALOG_FORM_LAYOUT } from './constant';
-const FormItem = Form.Item;
-const Option = Select.Option
-
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class EditClusterDialog extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- editCluster: {},
- editClusterDialogVisible: false
+ constructor(props) {
+ super(props);
+ this.state = {
+ editCluster: {},
+ editClusterDialogVisible: false,
+ };
+ this.show = this.show.bind(this);
+ }
+
+ show(_editCluster) {
+ let editCluster = _editCluster;
+ const { metadata = {} } = editCluster;
+ editCluster.metadataText = Object.keys(metadata)
+ .map(k => `${k}=${metadata[k]}`)
+ .join(',');
+ this.setState({
+ editCluster,
+ editClusterDialogVisible: true,
+ });
+ }
+
+ hide() {
+ this.setState({ editClusterDialogVisible: false });
+ }
+
+ onConfirm() {
+ const { openLoading, closeLoading, getServiceDetail } = this.props;
+ const {
+ name,
+ serviceName,
+ metadataText,
+ defaultCheckPort,
+ useIPPort4Check,
+ healthChecker,
+ } = this.state.editCluster;
+ request({
+ method: 'POST',
+ url: '/nacos/v1/ns/cluster/update',
+ data: {
+ serviceName,
+ clusterName: name,
+ metadata: metadataText,
+ checkPort: defaultCheckPort,
+ useInstancePort4Check: useIPPort4Check,
+ healthChecker: JSON.stringify(healthChecker),
+ },
+ dataType: 'text',
+ beforeSend: () => openLoading(),
+ success: res => {
+ if (res !== 'ok') {
+ Message.error(res);
+ return;
}
- this.show = this.show.bind(this)
- }
+ this.hide();
+ getServiceDetail();
+ },
+ complete: () => closeLoading(),
+ });
+ }
- show(editCluster) {
- const { metadata = {} } = editCluster
- editCluster.metadataText = Object.keys(metadata).map(k => `${k}=${metadata[k]}`).join(',')
- this.setState({
- editCluster,
- editClusterDialogVisible: true
- })
- }
+ onChangeCluster(changeVal) {
+ const { editCluster = {} } = this.state;
+ this.setState({
+ editCluster: Object.assign({}, editCluster, changeVal),
+ });
+ }
- hide() {
- this.setState({ editClusterDialogVisible: false })
- }
-
- onConfirm() {
- const { openLoading, closeLoading, getServiceDetail } = this.props
- const { name, serviceName, metadataText, defaultCheckPort, useIPPort4Check, healthChecker } = this.state.editCluster
- request({
- method: 'POST',
- url: '/nacos/v1/ns/cluster/update',
- data: {
- serviceName,
- clusterName: name,
- metadata: metadataText,
- checkPort: defaultCheckPort,
- useInstancePort4Check: useIPPort4Check,
- healthChecker: JSON.stringify(healthChecker)
- },
- dataType: 'text',
- beforeSend: () => openLoading(),
- success: res => {
- if (res !== 'ok') {
- Message.error(res)
- return
- }
- this.hide()
- getServiceDetail()
- },
- complete: () => closeLoading()
- })
- }
-
- onChangeCluster(changeVal) {
- const { editCluster = {} } = this.state
- this.setState({
- editCluster: Object.assign({}, editCluster, changeVal)
- })
- }
-
- render() {
- const { editCluster = {}, editClusterDialogVisible } = this.state
- const {
- healthChecker = {},
- useIPPort4Check,
- defaultCheckPort = '80',
- metadataText = ''
- } = editCluster
- const { type, path, headers } = healthChecker
- const healthCheckerChange = changeVal => this.onChangeCluster({
- healthChecker: Object.assign({}, healthChecker, changeVal)
- })
- return (
-
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
export default EditClusterDialog;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js
index a1cd34773..4c29bc6e8 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js
@@ -14,103 +14,103 @@
import React from 'react';
import { request } from '../../../globalLib';
import { Dialog, Form, Input, Switch, Message } from '@alifd/next';
-import { I18N, DIALOG_FORM_LAYOUT } from './constant'
+import { I18N, DIALOG_FORM_LAYOUT } from './constant';
-const FormItem = Form.Item;
-
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class EditInstanceDialog extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- editInstance: {},
- editInstanceDialogVisible: false
+ constructor(props) {
+ super(props);
+ this.state = {
+ editInstance: {},
+ editInstanceDialogVisible: false,
+ };
+ this.show = this.show.bind(this);
+ }
+
+ show(_editInstance) {
+ let editInstance = _editInstance;
+ const { metadata = {} } = editInstance;
+ if (Object.keys(metadata).length) {
+ editInstance.metadataText = Object.keys(metadata)
+ .map(k => `${k}=${metadata[k]}`)
+ .join(',');
+ }
+ this.setState({ editInstance, editInstanceDialogVisible: true });
+ }
+
+ hide() {
+ this.setState({ editInstanceDialogVisible: false });
+ }
+
+ onConfirm() {
+ const { serviceName, clusterName, getInstanceList, openLoading, closeLoading } = this.props;
+ const { ip, port, weight, enabled, metadataText } = this.state.editInstance;
+ request({
+ method: 'POST',
+ url: '/nacos/v1/ns/instance/update',
+ data: { serviceName, clusterName, ip, port, weight, enable: enabled, metadata: metadataText },
+ dataType: 'text',
+ beforeSend: () => openLoading(),
+ success: res => {
+ if (res !== 'ok') {
+ Message.error(res);
+ return;
}
- this.show = this.show.bind(this)
- }
+ this.hide();
+ getInstanceList();
+ },
+ complete: () => closeLoading(),
+ });
+ }
- show(editInstance) {
- const { metadata = {} } = editInstance
- if (Object.keys(metadata).length) {
- editInstance.metadataText = Object.keys(metadata).map(k => `${k}=${metadata[k]}`).join(',')
- }
- this.setState({ editInstance, editInstanceDialogVisible: true })
- }
+ onChangeCluster(changeVal) {
+ const { editInstance = {} } = this.state;
+ this.setState({
+ editInstance: Object.assign({}, editInstance, changeVal),
+ });
+ }
- hide() {
- this.setState({ editInstanceDialogVisible: false })
- }
-
- onConfirm() {
- const { serviceName, clusterName, getInstanceList, openLoading, closeLoading } = this.props
- const { ip, port, weight, enabled, metadataText } = this.state.editInstance
- request({
- method: 'POST',
- url: '/nacos/v1/ns/instance/update',
- data: { serviceName, clusterName, ip, port, weight, enable: enabled, metadata: metadataText },
- dataType: 'text',
- beforeSend: () => openLoading(),
- success: res => {
- if (res !== 'ok') {
- Message.error(res)
- return
- }
- this.hide()
- getInstanceList()
- },
- complete: () => closeLoading()
- })
- }
-
- onChangeCluster(changeVal) {
- const { editInstance = {} } = this.state
- this.setState({
- editInstance: Object.assign({}, editInstance, changeVal)
- })
- }
-
- render() {
- const { editInstanceDialogVisible, editInstance } = this.state
- return (
-
this.onConfirm()}
- onCancel={() => this.hide()}
- onClose={() => this.hide()}
- >
-
-
- )
- }
+ render() {
+ const { editInstanceDialogVisible, editInstance } = this.state;
+ return (
+
this.onConfirm()}
+ onCancel={() => this.hide()}
+ onClose={() => this.hide()}
+ >
+
+ {editInstance.ip}
+
+
+ {editInstance.port}
+
+
+ this.onChangeCluster({ weight })}
+ />
+
+
+ this.onChangeCluster({ enabled })}
+ />
+
+
+ this.onChangeCluster({ metadataText })}
+ />
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
export default EditInstanceDialog;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js
index dc04e2cea..e0248973d 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js
@@ -12,130 +12,123 @@
*/
import React from 'react';
-import {request} from '../../../globalLib';
-import {Dialog, Form, Input, Select, Message} from '@alifd/next';
-import {I18N, DIALOG_FORM_LAYOUT} from './constant'
+import { request } from '../../../globalLib';
+import { Dialog, Form, Input, Select, Message } from '@alifd/next';
+import { I18N, DIALOG_FORM_LAYOUT } from './constant';
-const FormItem = Form.Item;
-const Option = Select.Option
-
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class EditServiceDialog extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- isCreate: false,
- editService: {},
- editServiceDialogVisible: false
+ constructor(props) {
+ super(props);
+ this.state = {
+ isCreate: false,
+ editService: {},
+ editServiceDialogVisible: false,
+ };
+ this.show = this.show.bind(this);
+ }
+
+ show(_editService = {}) {
+ let editService = _editService;
+ const { metadata = {}, name } = editService;
+ if (Object.keys(metadata).length) {
+ editService.metadataText = Object.keys(metadata)
+ .map(k => `${k}=${metadata[k]}`)
+ .join(',');
+ }
+ this.setState({ editService, editServiceDialogVisible: true, isCreate: !name });
+ }
+
+ hide() {
+ this.setState({ editServiceDialogVisible: false });
+ }
+
+ onConfirm() {
+ const { isCreate } = this.state;
+ const editService = Object.assign({}, this.state.editService);
+ const { name, protectThreshold, healthCheckMode, metadataText } = editService;
+ request({
+ method: isCreate ? 'PUT' : 'POST',
+ url: `/nacos/v1/ns/service/${isCreate ? 'create' : 'update'}`,
+ data: { serviceName: name, protectThreshold, healthCheckMode, metadata: metadataText },
+ dataType: 'text',
+ beforeSend: () => this.setState({ loading: true }),
+ success: res => {
+ if (res !== 'ok') {
+ Message.error(res);
+ return;
}
- this.show = this.show.bind(this)
- }
-
- show(editService = {}) {
- const {metadata = {}, name} = editService
- if (Object.keys(metadata).length) {
- editService.metadataText = Object.keys(metadata).map(k => `${k}=${metadata[k]}`).join(',')
+ if (isCreate) {
+ this.props.queryServiceList();
+ } else {
+ this.props.getServiceDetail();
}
- this.setState({editService, editServiceDialogVisible: true, isCreate: !name})
- }
+ },
+ error: res => Message.error(res.responseText || res.statusText),
+ complete: () => this.setState({ loading: false }),
+ });
+ this.hide();
+ }
- hide() {
- this.setState({editServiceDialogVisible: false})
- }
+ onChangeCluster(changeVal) {
+ const { editService = {} } = this.state;
+ this.setState({
+ editService: Object.assign({}, editService, changeVal),
+ });
+ }
- onConfirm() {
- const {isCreate} = this.state
- const editService = Object.assign({}, this.state.editService)
- const {name, protectThreshold, healthCheckMode, metadataText} = editService
- request({
- method: isCreate ? 'PUT' : 'POST',
- url: `/nacos/v1/ns/service/${isCreate ? 'create' : 'update'}`,
- data: {serviceName: name, protectThreshold, healthCheckMode, metadata: metadataText},
- dataType: 'text',
- beforeSend: () => this.setState({loading: true}),
- success: res => {
- if (res !== 'ok') {
- Message.error(res)
- return
- }
- if (isCreate) {
- this.props.queryServiceList()
- } else {
- this.props.getServiceDetail()
- }
- },
- error: res => Message.error(res.responseText || res.statusText),
- complete: () => this.setState({loading: false})
- })
- this.hide()
- }
-
- onChangeCluster(changeVal) {
- const {editService = {}} = this.state
- this.setState({
- editService: Object.assign({}, editService, changeVal)
- })
- }
-
- render() {
- const {isCreate, editService, editServiceDialogVisible} = this.state
- const {
- name,
- protectThreshold,
- healthCheckMode,
- metadataText
- } = editService
- return (
-
this.onConfirm()}
- onCancel={() => this.hide()}
- onClose={() => this.hide()}
+ render() {
+ const { isCreate, editService, editServiceDialogVisible } = this.state;
+ const { name, protectThreshold, healthCheckMode, metadataText } = editService;
+ return (
+ this.onConfirm()}
+ onCancel={() => this.hide()}
+ onClose={() => this.hide()}
+ >
+
+ {!isCreate ? (
+ {name}
+ ) : (
+ this.onChangeCluster({ name })}
+ />
+ )}
+
+
+ this.onChangeCluster({ protectThreshold })}
+ />
+
+
+
- )
- }
+ {I18N.HEALTH_CHECK_PATTERN_SERVICE}
+ {I18N.HEALTH_CHECK_PATTERN_CLIENT}
+ {I18N.HEALTH_CHECK_PATTERN_NONE}
+
+
+
+ this.onChangeCluster({ metadataText })}
+ />
+
+
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
export default EditServiceDialog;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js
index d47bd0052..aa110e88c 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js
@@ -12,137 +12,150 @@
*/
import React from 'react';
+import PropTypes from 'prop-types';
import { request } from '../../../globalLib';
import { Button, Pagination, Table } from '@alifd/next';
-import { I18N, HEALTHY_COLOR_MAPPING } from './constant'
-import EditInstanceDialog from "./EditInstanceDialog";
+import { I18N, HEALTHY_COLOR_MAPPING } from './constant';
+import EditInstanceDialog from './EditInstanceDialog';
-
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class InstanceTable extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- loading: false,
- instance: { count: 0, list: [] },
- pageNum: 1,
- pageSize: 10
- }
- }
+ static propTypes = {
+ clusterName: PropTypes.string,
+ serviceName: PropTypes.string,
+ };
- componentDidMount() {
- this.getInstanceList()
- }
+ constructor(props) {
+ super(props);
+ this.state = {
+ loading: false,
+ instance: { count: 0, list: [] },
+ pageNum: 1,
+ pageSize: 10,
+ };
+ }
- openLoading() {
- this.setState({ loading: true })
- }
+ componentDidMount() {
+ this.getInstanceList();
+ }
- closeLoading() {
- this.setState({ loading: false })
- }
+ openLoading() {
+ this.setState({ loading: true });
+ }
- getInstanceList() {
- const { clusterName, serviceName } = this.props
- if (!clusterName) return
- const { pageSize, pageNum } = this.state
- request({
- url: '/nacos/v1/ns/catalog/instanceList',
- data: {
- serviceName,
- clusterName,
- pgSize: pageSize,
- startPg: pageNum
- },
- beforeSend: () => this.openLoading(),
- success: instance => this.setState({ instance }),
- complete: () => this.closeLoading()
- })
- }
+ closeLoading() {
+ this.setState({ loading: false });
+ }
- openInstanceDialog(instance) {
- this.refs.editInstanceDialog.show(instance)
- }
+ getInstanceList() {
+ const { clusterName, serviceName } = this.props;
+ if (!clusterName) return;
+ const { pageSize, pageNum } = this.state;
+ request({
+ url: '/nacos/v1/ns/catalog/instanceList',
+ data: {
+ serviceName,
+ clusterName,
+ pgSize: pageSize,
+ startPg: pageNum,
+ },
+ beforeSend: () => this.openLoading(),
+ success: instance => this.setState({ instance }),
+ complete: () => this.closeLoading(),
+ });
+ }
- switchState(index, record) {
- const { instance } = this.state
- const { ip, port, weight, enabled } = record
- const { clusterName, serviceName } = this.props
- const newVal = Object.assign({}, instance)
- newVal.list[index]['enabled'] = !enabled
- request({
- method: 'POST',
- url: '/nacos/v1/ns/instance/update',
- data: { serviceName, clusterName, ip, port, weight, enable: !enabled },
- dataType: 'text',
- beforeSend: () => this.openLoading(),
- success: () => this.setState({ instance: newVal }),
- complete: () => this.closeLoading()
- })
- }
+ openInstanceDialog(instance) {
+ this.refs.editInstanceDialog.show(instance);
+ }
- onChangePage(pageNum) {
- this.setState({ pageNum }, () => this.getInstanceList())
- }
+ switchState(index, record) {
+ const { instance } = this.state;
+ const { ip, port, weight, enabled } = record;
+ const { clusterName, serviceName } = this.props;
+ const newVal = Object.assign({}, instance);
+ newVal.list[index].enabled = !enabled;
+ request({
+ method: 'POST',
+ url: '/nacos/v1/ns/instance/update',
+ data: { serviceName, clusterName, ip, port, weight, enable: !enabled },
+ dataType: 'text',
+ beforeSend: () => this.openLoading(),
+ success: () => this.setState({ instance: newVal }),
+ complete: () => this.closeLoading(),
+ });
+ }
- rowColor = ({ healthy }) => ({ className: `row-bg-${HEALTHY_COLOR_MAPPING[`${healthy}`]}` })
+ onChangePage(pageNum) {
+ this.setState({ pageNum }, () => this.getInstanceList());
+ }
- render() {
- const { clusterName, serviceName } = this.props
- const { instance, pageSize, loading } = this.state
- return instance.count ? (
-
-
-
-
-
- `${val}`} />
- Object.keys(metadata).map(k => `${k}=${metadata[k]}`).join(',')}
- />
- (
-
-
-
-
- )} />
-
- {
- instance.count > pageSize
- ? (
-
this.onChangePage(currentPage)}
- />
- )
- : null
- }
- this.openLoading()}
- closeLoading={() => this.closeLoading()}
- getInstanceList={() => this.getInstanceList()}
- />
-
- ) : null
- }
+ rowColor = ({ healthy }) => ({ className: `row-bg-${HEALTHY_COLOR_MAPPING[`${healthy}`]}` });
+
+ render() {
+ const { clusterName, serviceName } = this.props;
+ const { instance, pageSize, loading } = this.state;
+ return instance.count ? (
+
+
+
+
+
+ `${val}`}
+ />
+
+ Object.keys(metadata)
+ .map(k => `${k}=${metadata[k]}`)
+ .join(',')
+ }
+ />
+ (
+
+
+
+
+ )}
+ />
+
+ {instance.count > pageSize ? (
+
this.onChangePage(currentPage)}
+ />
+ ) : null}
+ this.openLoading()}
+ closeLoading={() => this.closeLoading()}
+ getInstanceList={() => this.getInstanceList()}
+ />
+
+ ) : null;
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
export default InstanceTable;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js
index cc82bd41f..d2aa0427e 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js
@@ -14,152 +14,153 @@
import React from 'react';
import { request } from '../../../globalLib';
import { Button, Card, Form, Loading } from '@alifd/next';
-import EditServiceDialog from './EditServiceDialog'
-import EditClusterDialog from './EditClusterDialog'
-import InstanceTable from './InstanceTable'
-import queryString from 'query-string'
-import { I18N } from './constant'
-import './ServiceDetail.less'
+import EditServiceDialog from './EditServiceDialog';
+import EditClusterDialog from './EditClusterDialog';
+import InstanceTable from './InstanceTable';
+import queryString from 'query-string';
+import { I18N } from './constant';
+import './ServiceDetail.less';
const FormItem = Form.Item;
const pageFormLayout = {
- labelCol: { fixedSpan: 10 },
- wrapperCol: { span: 14 }
+ labelCol: { fixedSpan: 10 },
+ wrapperCol: { span: 14 },
};
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
+
class ServiceDetail extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- serviceName: queryString.parse(props.location.search).name,
- loading: false,
- currentPage: 1,
- clusters: [],
- instances: {},
- service: {},
- pageSize: 10,
- pageNum: {}
- }
+ constructor(props) {
+ super(props);
+ this.state = {
+ serviceName: queryString.parse(props.location.search).name,
+ loading: false,
+ currentPage: 1,
+ clusters: [],
+ instances: {},
+ service: {},
+ pageSize: 10,
+ pageNum: {},
+ };
+ }
+
+ componentDidMount() {
+ if (!this.state.serviceName) {
+ this.props.history.goBack();
+ return;
}
+ this.getServiceDetail();
+ }
- componentDidMount() {
- if (!this.state.serviceName) {
- this.props.history.goBack()
- return
- }
- this.getServiceDetail()
- }
+ getServiceDetail() {
+ const { serviceName } = this.state;
+ request({
+ url: `/nacos/v1/ns/catalog/serviceDetail?serviceName=${serviceName}`,
+ beforeSend: () => this.openLoading(),
+ success: ({ clusters = [], service = {} }) => this.setState({ service, clusters }),
+ complete: () => this.closeLoading(),
+ });
+ }
- getServiceDetail() {
- const { serviceName } = this.state
- request({
- url: `/nacos/v1/ns/catalog/serviceDetail?serviceName=${serviceName}`,
- beforeSend: () => this.openLoading(),
- success: ({ clusters = [], service = {} }) => this.setState({ service, clusters }),
- complete: () => this.closeLoading()
- })
- }
+ openLoading() {
+ this.setState({ loading: true });
+ }
- openLoading() {
- this.setState({ loading: true })
- }
+ closeLoading() {
+ this.setState({ loading: false });
+ }
- closeLoading() {
- this.setState({ loading: false })
- }
+ openEditServiceDialog() {
+ this.refs.editServiceDialog.show(this.state.service);
+ }
- openEditServiceDialog() {
- this.refs.editServiceDialog.show(this.state.service)
- }
+ openClusterDialog(cluster) {
+ this.refs.editClusterDialog.show(cluster);
+ }
- openClusterDialog(cluster) {
- this.refs.editClusterDialog.show(cluster)
- }
+ render() {
+ const { serviceName, loading, service = {}, clusters } = this.state;
+ const { metadata = {} } = service;
+ const metadataText = Object.keys(metadata).map(key => `${key}=${metadata[key]}`).join(',');
+ return (
+
+
+
+ {I18N.SERVICE_DETAILS}
+
+
+
- render() {
- const { serviceName, loading, service = {}, clusters } = this.state
- const { metadata = {} } = service
- const metadataText = Object.keys(metadata).map(key => `${key}=${metadata[key]}`).join(',')
- return (
-
-
-
- {I18N.SERVICE_DETAILS}
-
-
-
-
-
- {
+
+ {
clusters.map(cluster => (
- this.openClusterDialog(cluster)}
- >{I18N.EDIT_CLUSTER}
+ this.openClusterDialog(cluster)}
+ >{I18N.EDIT_CLUSTER}
)}
- >
-
-
+ >
+
+
))
}
-
-
this.openLoading()}
- closeLoading={() => this.closeLoading()}
- getServiceDetail={() => this.getServiceDetail()}
- />
- this.openLoading()}
- closeLoading={() => this.closeLoading()}
- getServiceDetail={() => this.getServiceDetail()}
- />
-
- );
- }
+
+
this.openLoading()}
+ closeLoading={() => this.closeLoading()}
+ getServiceDetail={() => this.getServiceDetail()}
+ />
+ this.openLoading()}
+ closeLoading={() => this.closeLoading()}
+ getServiceDetail={() => this.getServiceDetail()}
+ />
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
+
export default ServiceDetail;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/constant.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/constant.js
index b169f4b9c..926dd2c8f 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/constant.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/constant.js
@@ -13,131 +13,131 @@
import { aliwareIntl } from '../../../globalLib';
-const getI18N = (key, prefix = 'com.alibaba.nacos.page.serviceDetail.') => aliwareIntl.get(prefix + key)
-export const I18N = {}
+const getI18N = (key, prefix = 'com.alibaba.nacos.page.serviceDetail.') => aliwareIntl.get(prefix + key);
+export const I18N = {};
/**
* 服务列表
*/
-I18N.SERVICE_DETAILS = getI18N('service_details')
+I18N.SERVICE_DETAILS = getI18N('service_details');
/**
* 编辑服务
*/
-I18N.EDIT_SERVICE = getI18N('edit_service')
+I18N.EDIT_SERVICE = getI18N('edit_service');
/**
* 返回
*/
-I18N.BACK = getI18N('back')
+I18N.BACK = getI18N('back');
/**
* 服务名
*/
-I18N.SERVICE_NAME = getI18N('service_name')
+I18N.SERVICE_NAME = getI18N('service_name');
/**
* 保护阀值
*/
-I18N.PROTECT_THRESHOLD = getI18N('protect_threshold')
+I18N.PROTECT_THRESHOLD = getI18N('protect_threshold');
/**
* 健康检查模式
*/
-I18N.HEALTH_CHECK_PATTERN = getI18N('health_check_pattern')
+I18N.HEALTH_CHECK_PATTERN = getI18N('health_check_pattern');
/**
* 健康检查模式 - 服务端
*/
-I18N.HEALTH_CHECK_PATTERN_SERVICE = getI18N('health_check_pattern.service')
+I18N.HEALTH_CHECK_PATTERN_SERVICE = getI18N('health_check_pattern.service');
/**
* 健康检查模式 - 客户端
*/
-I18N.HEALTH_CHECK_PATTERN_CLIENT = getI18N('health_check_pattern.client')
+I18N.HEALTH_CHECK_PATTERN_CLIENT = getI18N('health_check_pattern.client');
/**
* 健康检查模式 - 禁止
*/
-I18N.HEALTH_CHECK_PATTERN_NONE = getI18N('health_check_pattern.none')
+I18N.HEALTH_CHECK_PATTERN_NONE = getI18N('health_check_pattern.none');
/**
* 元数据
*/
-I18N.METADATA = getI18N('metadata')
+I18N.METADATA = getI18N('metadata');
/**
* 更新服务
*/
-I18N.UPDATE_SERVICE = getI18N('update_service')
+I18N.UPDATE_SERVICE = getI18N('update_service');
/**
* 创建服务
*/
-I18N.CREATE_SERVICE = getI18N('create_service')
+I18N.CREATE_SERVICE = getI18N('create_service');
/**
* 集群
*/
-I18N.CLUSTER = getI18N('cluster')
+I18N.CLUSTER = getI18N('cluster');
/**
* 端口
*/
-I18N.PORT = getI18N('port')
+I18N.PORT = getI18N('port');
/**
* 权重
*/
-I18N.WEIGHT = getI18N('weight')
+I18N.WEIGHT = getI18N('weight');
/**
* 健康状态
*/
-I18N.HEALTHY = getI18N('healthy')
+I18N.HEALTHY = getI18N('healthy');
/**
* 操作
*/
-I18N.OPERATION = getI18N('operation')
+I18N.OPERATION = getI18N('operation');
/**
* 编辑
*/
-I18N.EDITOR = getI18N('editor')
+I18N.EDITOR = getI18N('editor');
/**
* 上线
*/
-I18N.ONLINE = getI18N('online')
+I18N.ONLINE = getI18N('online');
/**
* 下线
*/
-I18N.OFFLINE = getI18N('offline')
+I18N.OFFLINE = getI18N('offline');
/**
* 集群配置
*/
-I18N.EDIT_CLUSTER = getI18N('edit_cluster')
+I18N.EDIT_CLUSTER = getI18N('edit_cluster');
/**
* 检查类型
*/
-I18N.CHECK_TYPE = getI18N('check_type')
+I18N.CHECK_TYPE = getI18N('check_type');
/**
* 检查端口
*/
-I18N.CHECK_PORT = getI18N('check_port')
+I18N.CHECK_PORT = getI18N('check_port');
/**
* 使用IP端口检查
*/
-I18N.USE_IP_PORT_CHECK = getI18N('use_ip_port_check')
+I18N.USE_IP_PORT_CHECK = getI18N('use_ip_port_check');
/**
* 检查路径
*/
-I18N.CHECK_PATH = getI18N('check_path')
+I18N.CHECK_PATH = getI18N('check_path');
/**
* 检查头
*/
-I18N.CHECK_HEADERS = getI18N('check_headers')
+I18N.CHECK_HEADERS = getI18N('check_headers');
/**
* 更新集群
*/
-I18N.UPDATE_CLUSTER = getI18N('update_cluster')
+I18N.UPDATE_CLUSTER = getI18N('update_cluster');
/**
* 编辑实例
*/
-I18N.UPDATE_INSTANCE = getI18N('update_instance')
+I18N.UPDATE_INSTANCE = getI18N('update_instance');
/**
* 是否上线
*/
-I18N.WHETHER_ONLINE = getI18N('whether_online')
+I18N.WHETHER_ONLINE = getI18N('whether_online');
export const DIALOG_FORM_LAYOUT = {
- labelCol: { fixedSpan: 12 },
- wrapperCol: { span: 12 }
-}
+ labelCol: { fixedSpan: 12 },
+ wrapperCol: { span: 12 },
+};
export const HEALTHY_COLOR_MAPPING = {
- 'true': 'green',
- 'false': 'red'
-}
+ true: 'green',
+ false: 'red',
+};
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/index.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/index.js
index a2c730b3f..69c41cc19 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/index.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceDetail/index.js
@@ -11,6 +11,6 @@
* limitations under the License.
*/
-import ServiceDetail from './ServiceDetail'
+import ServiceDetail from './ServiceDetail';
-export default ServiceDetail
+export default ServiceDetail;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/ServiceList.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/ServiceList.js
index e096270ad..ebcac47ae 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/ServiceList.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/ServiceList.js
@@ -12,179 +12,205 @@
*/
import React from 'react';
+import PropTypes from 'prop-types';
import RegionGroup from '../../../components/RegionGroup/index';
-import {request, aliwareIntl} from '../../../globalLib';
-import {Button, Field, Form, Grid, Input, Loading, Pagination, Table, Dialog, Message} from '@alifd/next';
-import EditServiceDialog from '../ServiceDetail/EditServiceDialog'
-import {I18N, STATUS_COLOR_MAPPING} from './constant'
-import './ServiceList.less'
+import { request, aliwareIntl } from '../../../globalLib';
+import {
+ Button,
+ Field,
+ Form,
+ Grid,
+ Input,
+ Loading,
+ Pagination,
+ Table,
+ Dialog,
+ Message,
+} from '@alifd/next';
+import EditServiceDialog from '../ServiceDetail/EditServiceDialog';
+import { I18N, STATUS_COLOR_MAPPING } from './constant';
+import './ServiceList.less';
const FormItem = Form.Item;
-const {Row, Col} = Grid;
-const {Column} = Table
+const { Row, Col } = Grid;
+const { Column } = Table;
-/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class ServiceList extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- loading: false,
- total: 0,
- pageSize: 10,
- currentPage: 1,
- keyword: '',
- dataSource: []
- };
- this.field = new Field(this);
- }
+ static propTypes = {
+ history: PropTypes.object,
+ };
- openLoading() {
- this.setState({loading: true})
- }
+ constructor(props) {
+ super(props);
+ this.state = {
+ loading: false,
+ total: 0,
+ pageSize: 10,
+ currentPage: 1,
+ keyword: '',
+ dataSource: [],
+ };
+ this.field = new Field(this);
+ }
- closeLoading() {
- this.setState({loading: false})
- }
+ openLoading() {
+ this.setState({ loading: true });
+ }
- openEditServiceDialog() {
- this.refs.editServiceDialog.show(this.state.service)
- }
+ closeLoading() {
+ this.setState({ loading: false });
+ }
- queryServiceList() {
- const {currentPage, pageSize, keyword} = this.state
- const parameter = [`startPg=${currentPage}`, `pgSize=${pageSize}`, `keyword=${keyword}`]
+ openEditServiceDialog() {
+ this.refs.editServiceDialog.show(this.state.service);
+ }
+
+ queryServiceList() {
+ const { currentPage, pageSize, keyword } = this.state;
+ const parameter = [`startPg=${currentPage}`, `pgSize=${pageSize}`, `keyword=${keyword}`];
+ request({
+ url: `/nacos/v1/ns/catalog/serviceList?${parameter.join('&')}`,
+ beforeSend: () => this.openLoading(),
+ success: ({ count = 0, serviceList = [] } = {}) => {
+ this.setState({
+ dataSource: serviceList,
+ total: count,
+ });
+ },
+ error: () =>
+ this.setState({
+ dataSource: [],
+ total: 0,
+ currentPage: 0,
+ }),
+ complete: () => this.closeLoading(),
+ });
+ }
+
+ getQueryLater = () => {
+ setTimeout(() => this.queryServiceList());
+ };
+
+ deleteService(serviceName) {
+ Dialog.confirm({
+ title: I18N.PROMPT,
+ content: I18N.PROMPT_DELETE,
+ onOk: () => {
request({
- url: `/nacos/v1/ns/catalog/serviceList?${parameter.join('&')}`,
- beforeSend: () => this.openLoading(),
- success: ({count = 0, serviceList = []} = {}) => this.setState({
- dataSource: serviceList,
- total: count
- }),
- error: () => this.setState({
- dataSource: [],
- total: 0,
- currentPage: 0
- }),
- complete: () => this.closeLoading()
- });
- }
-
- getQueryLater() {
- setTimeout(() => this.queryServiceList());
- }
-
- deleteService(serviceName) {
- Dialog.confirm({
- title: I18N.PROMPT,
- content: I18N.PROMPT_DELETE,
- onOk: () => {
- request({
- method: 'DELETE',
- url: `/nacos/v1/ns/service/remove?serviceName=${serviceName}`,
- dataType: 'text',
- beforeSend: () => this.openLoading(),
- success: res => {
- if (res !== 'ok') {
- Message.error(res)
- return
- }
- this.queryServiceList()
- },
- error: res => Message.error(res.responseText || res.statusText),
- complete: () => this.closeLoading()
- })
+ method: 'DELETE',
+ url: `/nacos/v1/ns/service/remove?serviceName=${serviceName}`,
+ dataType: 'text',
+ beforeSend: () => this.openLoading(),
+ success: res => {
+ if (res !== 'ok') {
+ Message.error(res);
+ return;
}
+ this.queryServiceList();
+ },
+ error: res => Message.error(res.responseText || res.statusText),
+ complete: () => this.closeLoading(),
});
- }
+ },
+ });
+ }
- rowColor = ({status}) => ({className: `row-bg-${STATUS_COLOR_MAPPING[status]}`})
+ rowColor = ({ status }) => ({ className: `row-bg-${STATUS_COLOR_MAPPING[status]}` });
- render() {
- const {keyword} = this.state
- const {init, getValue} = this.field;
- this.init = init;
- this.getValue = getValue;
- const locale = {empty: I18N.PUBNODEDATA}
+ render() {
+ const { keyword } = this.state;
+ const { init, getValue } = this.field;
+ this.init = init;
+ this.getValue = getValue;
+ const locale = { empty: I18N.PUBNODEDATA };
- return (
-
-
-
-
-
-
-
-
-
-
- this.rowColor(row)}
- >
-
-
-
-
- (
-
-
-
- )}/>
-
-
-
-
-
this.setState({currentPage}, () => this.queryServiceList())}
- language={aliwareIntl.currentLanguageCode}
- />
+ return (
+
+
+
+
+
+
+
+
+
+
+ this.rowColor(row)}
+ >
+
+
+
+
+ (
+
+
-
- this.openLoading()}
- closeLoading={() => this.closeLoading()}
- queryServiceList={() => this.setState({currentPage: 1}, () => this.queryServiceList())}
+ )}
/>
-
- );
- }
+
+
+
+
+
+ this.setState({ currentPage }, () => this.queryServiceList())
+ }
+ language={aliwareIntl.currentLanguageCode}
+ />
+
+
+
this.openLoading()}
+ closeLoading={() => this.closeLoading()}
+ queryServiceList={() => this.setState({ currentPage: 1 }, () => this.queryServiceList())}
+ />
+
+ );
+ }
}
-/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
export default ServiceList;
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/constant.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/constant.js
index 027d1d01d..0397fb6b6 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/constant.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/constant.js
@@ -13,76 +13,76 @@
import { aliwareIntl } from '../../../globalLib';
-const getI18N = (key, prefix = 'com.alibaba.nacos.page.serviceManagement.') => aliwareIntl.get(prefix + key)
-export const I18N = {}
+const getI18N = (key, prefix = 'com.alibaba.nacos.page.serviceManagement.') => aliwareIntl.get(prefix + key);
+export const I18N = {};
/**
* 服务列表
*/
-I18N.SERVICE_LIST = getI18N('service_list')
+I18N.SERVICE_LIST = getI18N('service_list');
/**
* 服务名称
*/
-I18N.SERVICE_NAME = getI18N('service_name')
+I18N.SERVICE_NAME = getI18N('service_name');
/**
* 请输入服务名称
*/
-I18N.ENTER_SERVICE_NAME = getI18N('please_enter_the_service_name')
+I18N.ENTER_SERVICE_NAME = getI18N('please_enter_the_service_name');
/**
* 查询
*/
-I18N.QUERY = getI18N('query')
+I18N.QUERY = getI18N('query');
/**
* 查询
*/
-I18N.PUBNODEDATA = getI18N('pubnodata', '')
+I18N.PUBNODEDATA = getI18N('pubnodata', '');
/**
* 服务名
*/
-I18N.COLUMN_SERVICE_NAME = getI18N('table.column.service_name')
+I18N.COLUMN_SERVICE_NAME = getI18N('table.column.service_name');
/**
* 集群数目
*/
-I18N.COLUMN_CLUSTER_COUNT = getI18N('table.column.cluster_count')
+I18N.COLUMN_CLUSTER_COUNT = getI18N('table.column.cluster_count');
/**
* IP数目
*/
-I18N.COLUMN_IP_COUNT = getI18N('table.column.ip_count')
+I18N.COLUMN_IP_COUNT = getI18N('table.column.ip_count');
/**
* 健康程度
*/
-I18N.COLUMN_HEALTH_STATUS = getI18N('table.column.health_status')
+I18N.COLUMN_HEALTH_STATUS = getI18N('table.column.health_status');
/**
* 操作
*/
-I18N.COLUMN_OPERATION = getI18N('table.column.operation')
+I18N.COLUMN_OPERATION = getI18N('table.column.operation');
/**
* 详情
*/
-I18N.DETAIL = getI18N('detail')
+I18N.DETAIL = getI18N('detail');
/**
* 删除
*/
-I18N.DELETE = getI18N('delete')
+I18N.DELETE = getI18N('delete');
/**
* 提示
*/
-I18N.PROMPT = getI18N('prompt')
+I18N.PROMPT = getI18N('prompt');
/**
* 提示
*/
-I18N.PROMPT_DELETE = getI18N('prompt_delete')
+I18N.PROMPT_DELETE = getI18N('prompt_delete');
/**
* 删除
*/
-I18N.DELETE = getI18N('delete')
+I18N.DELETE = getI18N('delete');
/**
* 创建服务
*/
-I18N.CREATE = getI18N('create')
+I18N.CREATE = getI18N('create');
export const STATUS_COLOR_MAPPING = {
- 优: 'green',
- 良: 'light-green',
- 中: 'orange',
- 差: 'red'
-}
+ 优: 'green',
+ 良: 'light-green',
+ 中: 'orange',
+ 差: 'red',
+};
diff --git a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/index.js b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/index.js
index b48d559d4..ce5cda20b 100644
--- a/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/index.js
+++ b/console/src/main/resources/static/src/pages/ServiceManagement/ServiceList/index.js
@@ -11,6 +11,6 @@
* limitations under the License.
*/
-import ServiceList from './ServiceList'
+import ServiceList from './ServiceList';
-export default ServiceList
+export default ServiceList;
diff --git a/console/src/main/resources/static/src/router.js b/console/src/main/resources/static/src/router.js
index c3cea4025..b176f1a69 100644
--- a/console/src/main/resources/static/src/router.js
+++ b/console/src/main/resources/static/src/router.js
@@ -12,6 +12,7 @@
*/
import React from 'react';
+import PropTypes from 'prop-types';
import { Router, Route, Switch } from 'dva/router';
import './lib.js';
import App from './containers/App';
@@ -29,26 +30,29 @@ import ServiceList from './pages/ServiceManagement/ServiceList';
import ServiceDetail from './pages/ServiceManagement/ServiceDetail';
function RouterConfig({ history }) {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
}
+RouterConfig.propTypes = {
+ history: PropTypes.object,
+};
export default RouterConfig;
diff --git a/console/src/main/resources/static/src/routes/IndexPage.js b/console/src/main/resources/static/src/routes/IndexPage.js
index 5f36b3a1f..e04ebc08d 100644
--- a/console/src/main/resources/static/src/routes/IndexPage.js
+++ b/console/src/main/resources/static/src/routes/IndexPage.js
@@ -18,7 +18,7 @@ import styles from './IndexPage.css';
function IndexPage() {
return (
-
+
Yay! Welcome to dva!
diff --git a/console/src/main/resources/static/src/serviceMock.js b/console/src/main/resources/static/src/serviceMock.js
index 38888b794..0519f11cf 100644
--- a/console/src/main/resources/static/src/serviceMock.js
+++ b/console/src/main/resources/static/src/serviceMock.js
@@ -12,202 +12,202 @@
*/
module.exports = {
- "method": [
- "get",
- "post",
- "put",
- "delete",
- "patch"
- ],
- "serviceList": [
- {
- "registerName": "com.alibaba.nacos.service.dashlist",
- "name": "",
- "registerTo": null,
- "url": "/diamond-ops/info",
- "defaults": "{}",
- "params": "{}",
- "config": null,
- "initialize": null,
- "share": 0,
- "exports": null,
- "proxy": "",
- "serviceDoc": null,
- "ctime": "2018-05-19T07:24:01.000Z",
- "mtime": "2018-08-28T10:19:46.000Z",
- "author_id": 23,
- "project_id": "nacos",
- "is_mock": 0,
- "method": 0,
- "is_param": 0,
- "is_proxy": 0,
- "cookie": "{}",
- "header": "{}",
- "isJsonData": 0,
- "paramsType": "[]",
- "autoLoading": 0
- },
- {
- "registerName": "com.alibaba.nacos.service.getLink",
- "name": "getLink",
- "registerTo": null,
- "url": "/diamond-ops/viper/getLink",
- "defaults": "{}",
- "params": "{}",
- "config": null,
- "initialize": null,
- "share": 0,
- "exports": null,
- "proxy": "",
- "serviceDoc": null,
- "ctime": "2017-12-03T07:38:56.000Z",
- "mtime": "2018-08-28T10:19:46.000Z",
- "author_id": 23,
- "project_id": "nacos",
- "is_mock": 0,
- "method": 0,
- "is_param": 0,
- "is_proxy": 0,
- "cookie": "{}",
- "header": "{}",
- "isJsonData": 0,
- "paramsType": "[]",
- "autoLoading": 0
- },
- {
- "registerName": "com.alibaba.nacos.service.getLinks",
- "name": "getLinks",
- "registerTo": null,
- "url": "/diamond-ops/viper/getLinks",
- "defaults": "{}",
- "params": "{}",
- "config": null,
- "initialize": null,
- "share": 0,
- "exports": null,
- "proxy": "",
- "serviceDoc": null,
- "ctime": "2017-12-03T07:38:56.000Z",
- "mtime": "2018-08-28T10:19:46.000Z",
- "author_id": 23,
- "project_id": "nacos",
- "is_mock": 0,
- "method": 0,
- "is_param": 0,
- "is_proxy": 0,
- "cookie": "{}",
- "header": "{}",
- "isJsonData": 0,
- "paramsType": "[]",
- "autoLoading": 0
- },
- {
- "registerName": "com.alibaba.nacos.service.deleteNameSpace",
- "name": "删除命名空间",
- "registerTo": null,
- "url": "/diamond-ops/service/serverId/{serverId}/namespace/{namespace}",
- "defaults": "{}",
- "params": "{}",
- "config": null,
- "initialize": null,
- "share": 0,
- "exports": null,
- "proxy": "",
- "serviceDoc": null,
- "ctime": "2017-12-03T07:38:56.000Z",
- "mtime": "2018-08-28T10:19:46.000Z",
- "author_id": 23,
- "project_id": "nacos",
- "is_mock": 0,
- "method": 3,
- "is_param": 0,
- "is_proxy": 0,
- "cookie": "{}",
- "header": "{}",
- "isJsonData": 0,
- "paramsType": "[]",
- "autoLoading": 0
- },
- {
- "registerName": "com.alibaba.nacos.service.getMetaData",
- "name": "获取metaData",
- "registerTo": null,
- "url": "/diamond-ops/meta/data",
- "defaults": "{}",
- "params": "{}",
- "config": null,
- "initialize": null,
- "share": 0,
- "exports": null,
- "proxy": "",
- "serviceDoc": null,
- "ctime": "2017-12-03T07:38:56.000Z",
- "mtime": "2018-08-28T10:19:46.000Z",
- "author_id": 23,
- "project_id": "nacos",
- "is_mock": 0,
- "method": 0,
- "is_param": 0,
- "is_proxy": 0,
- "cookie": "{}",
- "header": "{}",
- "isJsonData": 0,
- "paramsType": "[]",
- "autoLoading": 0
- },
- {
- "registerName": "com.alibaba.nacos.service.sendVerifyCode",
- "name": "发送验证码",
- "registerTo": null,
- "url": "/diamond-ops/meta/sendVerifyCode",
- "defaults": "{}",
- "params": "{}",
- "config": null,
- "initialize": null,
- "share": 0,
- "exports": null,
- "proxy": "",
- "serviceDoc": null,
- "ctime": "2017-12-03T07:38:56.000Z",
- "mtime": "2018-08-28T10:19:46.000Z",
- "author_id": 23,
- "project_id": "nacos",
- "is_mock": 0,
- "method": 0,
- "is_param": 0,
- "is_proxy": 0,
- "cookie": "{}",
- "header": "{}",
- "isJsonData": 0,
- "paramsType": "[]",
- "autoLoading": 0
- },
- {
- "registerName": "com.alibaba.nacos.service.getDomain",
- "name": "获取region",
- "registerTo": null,
- "url": "/diamond-ops/env/domain",
- "defaults": "{}",
- "params": "{}",
- "config": null,
- "initialize": null,
- "share": 0,
- "exports": null,
- "proxy": "",
- "serviceDoc": null,
- "ctime": "2017-12-03T07:38:56.000Z",
- "mtime": "2018-08-28T10:19:46.000Z",
- "author_id": 23,
- "project_id": "nacos",
- "is_mock": 0,
- "method": 0,
- "is_param": 0,
- "is_proxy": 0,
- "cookie": "{}",
- "header": "{}",
- "isJsonData": 0,
- "paramsType": "[]",
- "autoLoading": 0
- }
- ]
-}
\ No newline at end of file
+ method: [
+ 'get',
+ 'post',
+ 'put',
+ 'delete',
+ 'patch',
+ ],
+ serviceList: [
+ {
+ registerName: 'com.alibaba.nacos.service.dashlist',
+ name: '',
+ registerTo: null,
+ url: '/diamond-ops/info',
+ defaults: '{}',
+ params: '{}',
+ config: null,
+ initialize: null,
+ share: 0,
+ exports: null,
+ proxy: '',
+ serviceDoc: null,
+ ctime: '2018-05-19T07:24:01.000Z',
+ mtime: '2018-08-28T10:19:46.000Z',
+ author_id: 23,
+ project_id: 'nacos',
+ is_mock: 0,
+ method: 0,
+ is_param: 0,
+ is_proxy: 0,
+ cookie: '{}',
+ header: '{}',
+ isJsonData: 0,
+ paramsType: '[]',
+ autoLoading: 0,
+ },
+ {
+ registerName: 'com.alibaba.nacos.service.getLink',
+ name: 'getLink',
+ registerTo: null,
+ url: '/diamond-ops/viper/getLink',
+ defaults: '{}',
+ params: '{}',
+ config: null,
+ initialize: null,
+ share: 0,
+ exports: null,
+ proxy: '',
+ serviceDoc: null,
+ ctime: '2017-12-03T07:38:56.000Z',
+ mtime: '2018-08-28T10:19:46.000Z',
+ author_id: 23,
+ project_id: 'nacos',
+ is_mock: 0,
+ method: 0,
+ is_param: 0,
+ is_proxy: 0,
+ cookie: '{}',
+ header: '{}',
+ isJsonData: 0,
+ paramsType: '[]',
+ autoLoading: 0,
+ },
+ {
+ registerName: 'com.alibaba.nacos.service.getLinks',
+ name: 'getLinks',
+ registerTo: null,
+ url: '/diamond-ops/viper/getLinks',
+ defaults: '{}',
+ params: '{}',
+ config: null,
+ initialize: null,
+ share: 0,
+ exports: null,
+ proxy: '',
+ serviceDoc: null,
+ ctime: '2017-12-03T07:38:56.000Z',
+ mtime: '2018-08-28T10:19:46.000Z',
+ author_id: 23,
+ project_id: 'nacos',
+ is_mock: 0,
+ method: 0,
+ is_param: 0,
+ is_proxy: 0,
+ cookie: '{}',
+ header: '{}',
+ isJsonData: 0,
+ paramsType: '[]',
+ autoLoading: 0,
+ },
+ {
+ registerName: 'com.alibaba.nacos.service.deleteNameSpace',
+ name: '删除命名空间',
+ registerTo: null,
+ url: '/diamond-ops/service/serverId/{serverId}/namespace/{namespace}',
+ defaults: '{}',
+ params: '{}',
+ config: null,
+ initialize: null,
+ share: 0,
+ exports: null,
+ proxy: '',
+ serviceDoc: null,
+ ctime: '2017-12-03T07:38:56.000Z',
+ mtime: '2018-08-28T10:19:46.000Z',
+ author_id: 23,
+ project_id: 'nacos',
+ is_mock: 0,
+ method: 3,
+ is_param: 0,
+ is_proxy: 0,
+ cookie: '{}',
+ header: '{}',
+ isJsonData: 0,
+ paramsType: '[]',
+ autoLoading: 0,
+ },
+ {
+ registerName: 'com.alibaba.nacos.service.getMetaData',
+ name: '获取metaData',
+ registerTo: null,
+ url: '/diamond-ops/meta/data',
+ defaults: '{}',
+ params: '{}',
+ config: null,
+ initialize: null,
+ share: 0,
+ exports: null,
+ proxy: '',
+ serviceDoc: null,
+ ctime: '2017-12-03T07:38:56.000Z',
+ mtime: '2018-08-28T10:19:46.000Z',
+ author_id: 23,
+ project_id: 'nacos',
+ is_mock: 0,
+ method: 0,
+ is_param: 0,
+ is_proxy: 0,
+ cookie: '{}',
+ header: '{}',
+ isJsonData: 0,
+ paramsType: '[]',
+ autoLoading: 0,
+ },
+ {
+ registerName: 'com.alibaba.nacos.service.sendVerifyCode',
+ name: '发送验证码',
+ registerTo: null,
+ url: '/diamond-ops/meta/sendVerifyCode',
+ defaults: '{}',
+ params: '{}',
+ config: null,
+ initialize: null,
+ share: 0,
+ exports: null,
+ proxy: '',
+ serviceDoc: null,
+ ctime: '2017-12-03T07:38:56.000Z',
+ mtime: '2018-08-28T10:19:46.000Z',
+ author_id: 23,
+ project_id: 'nacos',
+ is_mock: 0,
+ method: 0,
+ is_param: 0,
+ is_proxy: 0,
+ cookie: '{}',
+ header: '{}',
+ isJsonData: 0,
+ paramsType: '[]',
+ autoLoading: 0,
+ },
+ {
+ registerName: 'com.alibaba.nacos.service.getDomain',
+ name: '获取region',
+ registerTo: null,
+ url: '/diamond-ops/env/domain',
+ defaults: '{}',
+ params: '{}',
+ config: null,
+ initialize: null,
+ share: 0,
+ exports: null,
+ proxy: '',
+ serviceDoc: null,
+ ctime: '2017-12-03T07:38:56.000Z',
+ mtime: '2018-08-28T10:19:46.000Z',
+ author_id: 23,
+ project_id: 'nacos',
+ is_mock: 0,
+ method: 0,
+ is_param: 0,
+ is_proxy: 0,
+ cookie: '{}',
+ header: '{}',
+ isJsonData: 0,
+ paramsType: '[]',
+ autoLoading: 0,
+ },
+ ],
+};
diff --git a/console/src/main/resources/static/src/utils/ajaxrequest.js b/console/src/main/resources/static/src/utils/ajaxrequest.js
index 488fd235e..ee025115b 100644
--- a/console/src/main/resources/static/src/utils/ajaxrequest.js
+++ b/console/src/main/resources/static/src/utils/ajaxrequest.js
@@ -14,13 +14,12 @@
import $ from 'jquery';
export default function ajaxrequest(options) {
- let promise = $.ajax({
- url: options.url,
- timeout : options.timeout, //超时时间设置,单位毫秒设置为1小时
- dataType: options.dataType,//返回的数据格式
- type : options.type
- });
- return promise.done(data => ({ data }));
+ const promise = $.ajax({
+ url: options.url,
+ timeout: options.timeout, // 超时时间设置,单位毫秒设置为1小时
+ dataType: options.dataType, // 返回的数据格式
+ type: options.type,
+ });
+ return promise.done(data => ({ data }));
}
-
diff --git a/console/src/main/resources/static/src/utils/localstorage.js b/console/src/main/resources/static/src/utils/localstorage.js
index 22b51a358..0b69b4438 100644
--- a/console/src/main/resources/static/src/utils/localstorage.js
+++ b/console/src/main/resources/static/src/utils/localstorage.js
@@ -12,14 +12,14 @@
*/
module.exports = {
- set: function(key,value){
- window.localStorage.setItem(key,value);
- },
- get: function(key) {
- return window.localStorage.getItem(key);
- },
- remove: function(key) {
- window.localStorage.removeItem(key);
- }
+ set(key, value) {
+ window.localStorage.setItem(key, value);
+ },
+ get(key) {
+ return window.localStorage.getItem(key);
+ },
+ remove(key) {
+ window.localStorage.removeItem(key);
+ },
-}
\ No newline at end of file
+};
diff --git a/console/src/main/resources/static/src/utils/nacosutil.js b/console/src/main/resources/static/src/utils/nacosutil.js
index 0c97e07ed..d36fe060a 100644
--- a/console/src/main/resources/static/src/utils/nacosutil.js
+++ b/console/src/main/resources/static/src/utils/nacosutil.js
@@ -14,7 +14,7 @@
/* eslint-disable import/prefer-default-export */
export const throttle = (fn, delay) => {
let timer = null;
- return function (...args) {
+ return function(...args) {
const context = this;
clearTimeout(timer);
timer = setTimeout(() => {
@@ -26,14 +26,14 @@ export const throttle = (fn, delay) => {
export const getScrollTop = () => {
let scrollTop = 0;
if (document.documentElement && document.documentElement.scrollTop) {
- scrollTop = document.documentElement.scrollTop;
+ ({ scrollTop } = document.documentElement);
} else if (document.body) {
- scrollTop = document.body.scrollTop;
+ ({ scrollTop } = document.body);
}
return scrollTop;
};
-export const getLink = (link) => {
+export const getLink = link => {
if (`${link}`.length > 1 && /^\/[^/]/.test(`${link}`)) {
return `${window.rootPath}${link}`;
}