4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import React from 'react';
20 import './crash.scss';
21 import TreeView from 'react-treeview';
22 import '../node_modules/react-treeview/react-treeview.css';
23 import AppHeader from 'widgets/header/header.jsx';
24 var crashActions = require('./crashActions.js');
25 var crashStore = require('./crashStore.js');
26 // var MissionControlStore = require('../missioncontrol/missionControlStore.js');
27 function openDashboard() {
28 window.location.hash = "#/";
30 class CrashDetails extends React.Component {
34 this.state = crashStore.getState();
35 crashStore.listen(this.storeListener);
37 storeListener = (data) => {
40 noDebug:!this.hasDebugData(data.crashList)
43 componentWillUnmount(){
44 crashStore.unlisten(this.storeListener);
46 componentWillMount() {
51 if (list && list.length > 0) {
52 for (let i = 0; i < list.length; i++) {
53 var trace = list[i].backtrace;
54 for (let j = 0; j < trace.length; j++) {
56 if (trace[j].detail) {
64 downloadFile(fileName, urlData) {
65 var replacedNewLines = urlData.replace(/\\n/g, '\n');
66 var replacedTabs = replacedNewLines.replace(/\\t/g, '\t');
67 var replacedQuotes= replacedTabs.replace(/\\"/g, '"');
68 var textFileBlob = new Blob([replacedQuotes], {type: 'text/plain;charset=UTF-8'});
69 var aLink = document.createElement('a');
70 var evt = document.createEvent("HTMLEvents");
71 evt.initEvent("click");
72 aLink.download = fileName;
73 aLink.href = window.URL.createObjectURL(textFileBlob);
74 aLink.dispatchEvent(evt);
79 if (this.state != null) {
80 var tree = <div style={{'marginLeft':'auto', 'marginRight':'auto', 'width':'230px', 'padding':'90px'}}> No Debug Information Available </div>;
81 if (!this.state.noDebug)
83 var tree = this.state.list && this.state.list.map((node, i) => {
85 var vm_label = <span>{vm}</span>;
86 var backtrace = node.backtrace;
88 <TreeView key={vm + '|' + i} nodeLabel={vm_label} defaultCollapsed={false}>
89 {backtrace.map(details => {
91 //Needed to decode HTML
92 var text_temp = document.createElement("textarea")
93 text_temp.innerHTML = details.detail;
94 var text_temp = text_temp.value;
95 var arr = text_temp.split(/\n/);
97 for (let i = 0; i < arr.length; i++) {
103 <TreeView nodeLabel={<span>{details.id}</span>} key={vm + '||' + details.id} defaultCollapsed={false}>
112 <div className="crash-details-wrapper">
113 <div className="form-actions">
114 <button role="button" className="dark" onClick={this.state.noDebug ? false : this.downloadFile.bind(this, 'crash.txt', 'data:text;charset=UTF-8,' + decodeURIComponent(JSON.stringify(this.state.list, null, 2)))}> Download Crash Details</button>
116 <div className="crash-container">
117 <h2> Debug Information </h2>
118 <div className="tree">{tree}</div>
123 html = <div className="crash-container"></div>
125 let refPage = window.sessionStorage.getItem('refPage');
126 refPage = JSON.parse(refPage);
128 <div className="crash-app">
134 export default CrashDetails;