Skip to content

Commit 65b20ac

Browse files
authored
Merge pull request #263 from scouter-contrib/development
Development 2.6.4
2 parents 9e6c62c + c38368a commit 65b20ac

File tree

43 files changed

+1735
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1735
-522
lines changed

builder.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
FILE1=scouter-paper.zip
3+
FILE2=./docker/$FILE1
4+
BUILDFILE=./docker/docker-compose.yml
5+
export GENERATE_SOURCEMAP=true
6+
if [ -e $FILE1 ]
7+
then
8+
echo "****1. build local file delete... "
9+
rm -f scouter-paper.zip
10+
fi
11+
12+
if [ -e $DOCKER ]
13+
then
14+
echo "****2. build docker folder local file delete... "
15+
rm -f FILE2
16+
fi
17+
18+
echo "**** Finally build file ****"
19+
npm run build
20+
21+
echo "Last JOB docker build"
22+
cd docker;docker-compose build;docker-compose push
23+

docker/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
PAPER_VERSION=2.6.4
1+
PAPER_VERSION=2.6.4-dev

docker/Dockerfile-Dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ ARG PAPER_VERSION=${PAPER_VERSION:-2.5.0}
55
RUN mkdir -p /var/www;
66
COPY default.conf /etc/nginx/conf.d/default.conf
77
WORKDIR /var/www
8-
COPY scouter-paper.zip ./
8+
COPY ./scouter-paper.zip ./
99
## install
1010
RUN apk add -U tzdata wget unzip;cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime; wget ${INSTALL_URL};unzip scouter-paper.zip;rm -f scouter-paper.zip

http/xflow.http

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// XLogDataController.java
22
// SingleXLogRequest
3+
###
4+
GET http://demo.scouterapm.com:6188/scouter/v1/kv/__scouter_paper_layout/
5+
Accept: application/json
6+
###
37
GET http://demo.scouterapm.com:6188/scouter/v1/xlog-data/{yyyymmdd}/{txid}
48
#
59
###

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"babel-loader": "7.1.2",
1212
"babel-preset-react-app": "^3.1.0",
1313
"babel-runtime": "6.26.0",
14+
"big-integer": "^1.6.48",
1415
"body-scroll-lock": "^2.6.1",
1516
"bootstrap": "^3.4.0",
1617
"case-sensitive-paths-webpack-plugin": "2.1.1",
@@ -82,7 +83,7 @@
8283
"scripts": {
8384
"start": "node scripts/start.js",
8485
"build": "node scripts/build.js",
85-
"postbuild": "cd build; zip -r ../scouter-paper.zip *",
86+
"postbuild": "cd build; zip -r ../scouter-paper.zip *;cp ../scouter-paper.zip ../docker/",
8687
"test": "node scripts/test.js --env=jsdom"
8788
},
8889
"jest": {

src/App.js

Lines changed: 73 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,39 @@ import './App.css';
33
import './Theme.css';
44
import './fonts/technology-icons-gh-pages/styles/technology-icons.css';
55
import './fonts/glyphter/css/Glyphter.css';
6-
import {
7-
Settings,
8-
Paper,
9-
Loading,
10-
RequestBar,
11-
Menu,
12-
Login,
13-
Overlay,
14-
Message,
15-
ContentWrapper
16-
} from './components';
17-
import {Route, Switch} from 'react-router-dom';
6+
import {ContentWrapper, Loading, Login, Menu, Message, Overlay, Paper, RequestBar, Settings} from './components';
7+
import {Route, Switch, withRouter} from 'react-router-dom';
188
import {connect} from 'react-redux';
19-
import {withRouter} from 'react-router-dom';
20-
import {setSupported, setConfig, addRequest, clearAllMessage, setControlVisibility, setUserId, setUserData, pushMessage, setCounterInfo, setAlert} from './actions';
9+
import {
10+
addRequest,
11+
clearAllMessage,
12+
pushMessage,
13+
setAlert,
14+
setConfig,
15+
setControlVisibility,
16+
setCounterInfo,
17+
setServerId,
18+
setSupported,
19+
setUserData,
20+
setUserId
21+
} from './actions';
2122
import {detect} from 'detect-browser';
2223
import Unsupport from "./components/Unsupport/Unsupport";
2324
import jQuery from "jquery";
25+
import * as common from './common/common';
2426
import {
2527
errorHandler,
26-
mergeDeep,
28+
getCurrentUser,
29+
getDefaultServerConfig,
30+
getHttpProtocol,
2731
getParam,
28-
setAuthHeader,
2932
getWithCredentials,
30-
getHttpProtocol,
31-
getDefaultServerConfig,
32-
getCurrentUser,
33-
getDefaultServerId
33+
mergeDeep,
34+
setAuthHeader
3435
} from './common/common';
3536

3637
import Home from "./components/Home/Home";
3738
import Topology from "./components/Topology/Topology";
38-
import * as common from "./common/common";
3939
import Debug from "./components/Debug/Debug";
4040
import Controller from "./components/Controller/Controller";
4141
import _ from "lodash";
@@ -66,7 +66,7 @@ class App extends Component {
6666
this.props.addRequest();
6767

6868
let origin = getHttpProtocol(config);
69-
const conf = common.confBuilder(getHttpProtocol(config),config,user,getDefaultServerId(config));
69+
const conf = common.confBuilder(getHttpProtocol(config),config,user,this.getScouterApiServerId());
7070
ScouterApi.isAuthentification(conf)
7171
.done((msg) => {
7272
if (msg && Number(msg.status) === 200) {
@@ -118,7 +118,8 @@ class App extends Component {
118118
return server.default;
119119
});
120120
if (JSON.stringify(currentApiServer) !== JSON.stringify(nextApiServer)) {
121-
this.getCounterModel(nextProps.config, nextProps.user, true);
121+
122+
this.getCounterModel(nextProps.config, nextProps.user, true, this.getScouterApiServerId());
122123
}
123124

124125

@@ -129,10 +130,15 @@ class App extends Component {
129130
let nextUser = nextProps.user[origin];
130131
let currentUser = this.props.user[origin];
131132
if (nextUser && (JSON.stringify(currentUser) !== JSON.stringify(nextUser))) {
132-
this.getCounterModel(nextProps.config, nextProps.user, true);
133+
this.getCounterModel(nextProps.config, nextProps.user, true,nextProps.serverId.server[0].id);
133134
}
134135
}
135136
}
137+
if (this.props.serverId.server) {
138+
if( this.props.serverId.server[0].id !== nextProps.serverId.server[0].id) {
139+
this.getCounterModel(nextProps.config, nextProps.user, true,nextProps.serverId.server[0].id);
140+
}
141+
}
136142

137143

138144
if (JSON.stringify(this.props.objects) !== JSON.stringify(nextProps.objects) || JSON.stringify(this.props.user) !== JSON.stringify(nextProps.user) || JSON.stringify(this.props.config) !== JSON.stringify(nextProps.config)) {
@@ -161,7 +167,9 @@ class App extends Component {
161167
}, seconds * 1000);
162168
}
163169
};
164-
170+
getScouterApiServerId = () => {
171+
return this.props.serverId.server ? this.props.serverId.server[0].id : getParam(this.props,'activesid');
172+
};
165173
getRealTimeAlert = (objects) => {
166174
const that = this;
167175

@@ -180,7 +188,7 @@ class App extends Component {
180188
jQuery.ajax({
181189
method: "GET",
182190
async: true,
183-
url: getHttpProtocol(this.props.config) + "/scouter/v1/alert/realTime/" + offset1 + "/" + offset2 + "?objType=" + objType,
191+
url: getHttpProtocol(this.props.config) + "/scouter/v1/alert/realTime/" + offset1 + "/" + offset2 + `?serverId=${this.getScouterApiServerId()}&objType=` + objType,
184192
xhrFields: getWithCredentials(that.props.config),
185193
beforeSend: function (xhr) {
186194
setAuthHeader(xhr, that.props.config, getCurrentUser(that.props.config, that.props.user));
@@ -222,16 +230,19 @@ class App extends Component {
222230
}
223231
});
224232

225-
if (Notification && this.props.config.alert.notification === "Y" && Notification.permission === "granted") {
226-
for (let i=0; i<alert.data.length; i++) {
227-
if (Number(alert.data[i].time) > this.mountTime && !alert.data[i]["_notificated"]) {
228-
alert.data[i]["_notificated"] = true;
229-
230-
var options = {
231-
body: alert.data[i].objName + "\n" + alert.data[i].message,
232-
icon: notificationIcon
233-
};
234-
new Notification("[" + alert.data[i].level + "]" + alert.data[i].title, options);
233+
if (this.props.config.alert.notification === "Y") {
234+
if( typeof Notification === 'function' && Notification.hasOwnProperty('permission')) {
235+
if(Notification.permission === "granted"){
236+
for (let i=0; i<alert.data.length; i++) {
237+
if (Number(alert.data[i].time) > this.mountTime && !alert.data[i]["_notificated"]) {
238+
alert.data[i]["_notificated"] = true;
239+
const options = {
240+
body: alert.data[i].objName + "\n" + alert.data[i].message,
241+
icon: notificationIcon
242+
};
243+
new Notification("[" + alert.data[i].level + "]" + alert.data[i].title, options);
244+
}
245+
}
235246
}
236247
}
237248
}
@@ -249,45 +260,28 @@ class App extends Component {
249260
}
250261
};
251262

252-
getCounterModel = (config, user, handleError) => {
263+
getCounterModel = (config, user, handleError,serverId) => {
253264

254-
const _conf = common.confBuilder(getHttpProtocol(config),config,user,getDefaultServerId(config));
255-
ScouterApi.getSyncConnectedServer(_conf)
256-
.done(msg =>{
265+
const _conf = common.confBuilder(getHttpProtocol(config),config,user,serverId);
266+
ScouterApi.getCounterModel(_conf)
267+
.done((msg) => {
257268
if (Number(msg.status) === 200) {
258-
Promise.all(msg.result.map(ser =>{
259-
const _serConfig = common.confBuilder(getHttpProtocol(config),config,user,ser.id);
260-
return ScouterApi.getCounterModel(_serConfig)
261-
}))
262-
.then(msg =>{
263-
const _f = [];
264-
const _o = [];
265-
_.forEach(msg,iter => {
266-
_f.push(iter.result.families);
267-
_o.push(iter.result.objTypes);
268-
269-
});
270-
//- family info merge
271-
const _rf = _.flatMapDeep(_f);
272-
//- objectType merge
273-
const _ro = _.flatMapDeep(_o);
274-
this.props.setSupported(true);
275-
this.props.setCounterInfo(_rf, _ro);
276-
}).catch(_err =>{
277-
if(handleError) {
278-
this.props.setSupported(false);
279-
this.props.pushMessage("error", "Not Supported", "failed to get matrix information. paper 2.0 is available only on scouter 2.0 and later.");
280-
this.props.setControlVisibility("Message", true);
281-
}
282-
console.error(_err);
283-
})
284-
}
285-
})
286-
.fail((xhr, textStatus, errorThrown)=>{
287-
if(handleError) {
288-
errorHandler(xhr, textStatus, errorThrown, this.props, "getCounterModel", true);
269+
this.props.setSupported(true);
270+
if(msg.result) {
271+
this.props.setCounterInfo(msg.result.families, msg.result.objTypes);
272+
}
289273
}
290-
});
274+
}).fail((xhr, textStatus, errorThrown) => {
275+
if (handleError) {
276+
if (xhr.status === 404) {
277+
this.props.setSupported(false);
278+
this.props.pushMessage("error", "Not Supported", "failed to get matrix information. paper 2.0 is available only on scouter 2.0 and later.");
279+
this.props.setControlVisibility("Message", true);
280+
} else {
281+
errorHandler(xhr, textStatus, errorThrown, this.props, "getCounterModel", true);
282+
}
283+
}
284+
});
291285
};
292286

293287
getNotice = () => {
@@ -318,6 +312,7 @@ class App extends Component {
318312
componentWillMount() {
319313
let config = null;
320314
let str = localStorage.getItem("config");
315+
321316
if (str) {
322317
config = JSON.parse(str);
323318
config = mergeDeep(this.props.config, config); //for added config's properties on later versions.
@@ -372,8 +367,8 @@ class App extends Component {
372367
config.others.xlogClassicMode = paramXlogClassicMode;
373368
}
374369

375-
376370
this.props.setConfig(config);
371+
377372
if (localStorage) {
378373
localStorage.setItem("config", JSON.stringify(config));
379374
}
@@ -407,7 +402,7 @@ class App extends Component {
407402
this.setFontSetting(this.props.config.fontSetting);
408403

409404
// 처음 카운터 모델을 조회하는데, 에러 처리는 하지 않는다
410-
this.getCounterModel(this.props.config, this.props.user, false);
405+
this.getCounterModel(this.props.config, this.props.user, false,this.getScouterApiServerId());
411406

412407
// Notice를 조회한다. 이미 조회한 Notice인지 확인하여 하루에 한번만 보여주던지..
413408
// X-Scouter-Notice-Token 응답 헤더는 LocalStorage에 저장하여 다음 요청 헤더로 사용한다.
@@ -534,7 +529,8 @@ let mapStateToProps = (state) => {
534529
user: state.user,
535530
supported : state.supported,
536531
objects: state.target.objects,
537-
alert: state.alert
532+
alert: state.alert,
533+
serverId: state.serverId
538534
};
539535
};
540536

@@ -549,7 +545,8 @@ let mapDispatchToProps = (dispatch) => {
549545
pushMessage: (category, title, content) => dispatch(pushMessage(category, title, content)),
550546
setCounterInfo: (families, objTypes) => dispatch(setCounterInfo(families, objTypes)),
551547
setSupported: (supported) => dispatch(setSupported(supported)),
552-
setAlert: (alert) => dispatch(setAlert(alert))
548+
setAlert: (alert) => dispatch(setAlert(alert)),
549+
setServerId: (serverId) => dispatch(setServerId(serverId))
553550
};
554551
};
555552

src/App.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from './App';
44

5-
it('renders without crashing', () => {
5+
test('renders without crashing', () => {
66
const div = document.createElement('div');
77
ReactDOM.render(<App />, div);
88
});

src/actions/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const SET_LAYOUT_NAME = 'SET_LAYOUT_NAME';
4545

4646

4747
export const SET_TIME_FOCUS = 'SET_TIME_FOCUS';
48+
export const SET_SERVER_ID = 'SET_SERVER_ID';
4849

4950
export function setTemplateName(preset, layout) {
5051
return {
@@ -377,4 +378,10 @@ export function setTimeFocus(active,time,boxKey,keep=false){
377378
keep : keep
378379
}
379380

381+
}
382+
export function setServerId(activeServerIdObj){
383+
return {
384+
type : SET_SERVER_ID,
385+
serverId: activeServerIdObj
386+
}
380387
}

0 commit comments

Comments
 (0)