diff --git a/jsapp/js/components/RESTServices.js b/jsapp/js/components/RESTServices.js deleted file mode 100644 index 4e7d34c06e..0000000000 --- a/jsapp/js/components/RESTServices.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import autoBind from 'react-autobind'; -import DocumentTitle from 'react-document-title'; -import RESTServicesList from './RESTServices/RESTServicesList'; -import RESTServiceLogs from './RESTServices/RESTServiceLogs'; -import './RESTServices.scss'; - -export default class RESTServices extends React.Component { - constructor(props){ - super(props); - autoBind(this); - } - - render() { - const docTitle = this.props.asset.name || t('Untitled'); - return ( - - - {this.props.hookUid && - - } - {!this.props.hookUid && - - } - - - ); - } -} diff --git a/jsapp/js/components/RESTServices/RESTServiceLogs.js b/jsapp/js/components/RESTServices/RESTServiceLogs.js deleted file mode 100644 index 652854663d..0000000000 --- a/jsapp/js/components/RESTServices/RESTServiceLogs.js +++ /dev/null @@ -1,364 +0,0 @@ -import React from 'react'; -import autoBind from 'react-autobind'; -import reactMixin from 'react-mixin'; -import Reflux from 'reflux'; -import alertify from 'alertifyjs'; -import pageState from 'js/pageState.store'; -import bem from 'js/bem'; -import LoadingSpinner from 'js/components/common/loadingSpinner'; -import {actions} from '../../actions'; -import mixins from '../../mixins'; -import {dataInterface} from '../../dataInterface'; -import {formatTime, notify} from 'utils'; -import { - HOOK_LOG_STATUSES, - MODAL_TYPES -} from '../../constants'; -import Button from 'js/components/common/button'; - -export default class RESTServiceLogs extends React.Component { - constructor(props){ - super(props); - this.state = { - hookName: null, - isHookActive: false, - assetUid: props.assetUid, - hookUid: props.hookUid, - isLoadingHook: true, - isLoadingLogs: true, - logs: [], - nextPageUrl: null - }; - autoBind(this); - } - - componentDidMount() { - this.listenTo( - actions.hooks.getLogs.completed, - this.onLogsUpdated - ); - - dataInterface.getHook(this.state.assetUid, this.state.hookUid) - .done((data) => { - this.setState({ - isLoadingHook: false, - hookName: data.name, - isHookActive: data.active - }); - }) - .fail(() => { - this.setState({ - isLoadingHook: false - }); - notify.error(t('Could not load REST Service')); - }); - - actions.hooks.getLogs( - this.state.assetUid, - this.state.hookUid, - { - onComplete: (data) => { - this.setState({ - isLoadingLogs: false, - logs: data.results, - nextPageUrl: data.next, - totalLogsCount: data.count - }); - }, - onFail: () => { - this.setState({ - isLoadingLogs: false - }); - notify.error(t('Could not load REST Service logs')); - } - } - ); - } - - loadMore() { - this.setState({isLoadingLogs: false}); - - dataInterface.loadNextPageUrl(this.state.nextPageUrl) - .done((data) => { - const newLogs = [].concat(this.state.logs, data.results); - this.setState({ - isLoadingLogs: false, - logs: newLogs, - nextPageUrl: data.next, - totalLogsCount: data.count - }); - }) - .fail(() => { - this.setState({isLoadingLogs: false}); - notify.error(t('Could not load REST Service logs')); - }); - } - - onLogsUpdated(data) { - this.setState({logs: data.results}); - } - - retryAll() { - const failedLogUids = []; - this.state.logs.forEach((log) => { - if (log.status === HOOK_LOG_STATUSES.FAILED) { - failedLogUids.push(log.uid); - } - }); - this.overrideLogsStatus(failedLogUids, HOOK_LOG_STATUSES.PENDING); - - actions.hooks.retryLogs( - this.state.assetUid, - this.state.hookUid, - { - onComplete: (response) => { - this.overrideLogsStatus(response.pending_uids, HOOK_LOG_STATUSES.PENDING); - } - } - ); - } - - retryLog(log) { - // make sure to allow only retrying failed logs - if (log.status !== HOOK_LOG_STATUSES.FAILED) { - return; - } - - this.overrideLogsStatus([log.uid], HOOK_LOG_STATUSES.PENDING); - - actions.hooks.retryLog( - this.state.assetUid, - this.state.hookUid, - log.uid, { - onFail: (response) => { - if (response.responseJSON && response.responseJSON.detail) { - this.overrideLogMessage(log.uid, response.responseJSON.detail); - } - this.overrideLogsStatus([log.uid], HOOK_LOG_STATUSES.FAILED); - } - } - ); - } - - overrideLogMessage(logUid, newMessage) { - const currentLogs = this.state.logs; - currentLogs.forEach((currentLog) => { - if (currentLog.uid === logUid) { - currentLog.message = newMessage; - } - }); - this.setState({ - logs: currentLogs - }); - } - - // useful to mark logs as pending, before BE tells about it - // NOTE: logUids is an array - overrideLogsStatus(logUids, newStatus) { - const currentLogs = this.state.logs; - currentLogs.forEach((currentLog) => { - if (logUids.includes(currentLog.uid)) { - currentLog.status = newStatus; - } - }); - this.setState({ - logs: currentLogs - }); - } - - showLogInfo(log) { - const title = t('Submission Failure Detail (##id##)').replace('##id##', log.submission_id); - const escapedMessage = $('
').text(log.message).html(); - alertify.alert(title, `
${escapedMessage}
`); - } - - openSubmissionModal(log) { - const currentAsset = this.currentAsset(); - pageState.switchModal({ - type: MODAL_TYPES.SUBMISSION, - sid: log.submission_id, - asset: currentAsset, - ids: [log.submission_id] - }); - } - - hasAnyFailedLogs() { - let hasAny = false; - this.state.logs.forEach((log) => { - if (log.status === HOOK_LOG_STATUSES.FAILED) { - hasAny = true; - } - }); - return hasAny; - } - - hasInfoToDisplay(log) { - return log.status !== HOOK_LOG_STATUSES.SUCCESS && log.message.length > 0; - } - - /* - * rendering methods - */ - - renderHeader() { - return ( -
-
- ); - } - - renderLoadMoreButton() { - if (this.state.nextPageUrl === null) { - return null; - } - - return ( -