diff --git a/otoroshi/javascript/src/pages/RouteDesigner/ImportServiceDescriptor.js b/otoroshi/javascript/src/pages/RouteDesigner/ImportServiceDescriptor.js
index 0109d97c86..ef4bf6ac9f 100644
--- a/otoroshi/javascript/src/pages/RouteDesigner/ImportServiceDescriptor.js
+++ b/otoroshi/javascript/src/pages/RouteDesigner/ImportServiceDescriptor.js
@@ -3,11 +3,53 @@ import { NgSelectRenderer } from '../../components/nginputs';
import { FeedbackButton } from './FeedbackButton';
import { convertAsRoute } from '../../services/BackOfficeServices';
import { useHistory } from 'react-router-dom';
+import * as BackOfficeServices from "../../services/BackOfficeServices";
+import moment from 'moment';
export function ImportServiceDescriptor({ hide }) {
const [service, setService] = useState();
const history = useHistory();
+ function conversion() {
+ return convertAsRoute(service).then((res) => {
+ return BackOfficeServices
+ .fetchService("prod", service)
+ .then(fullService => {
+ const newService = {
+ ...fullService,
+ name: '[MIGRATED TO ROUTE, PENDING DELETION] ' + fullService.name,
+ enabled: false,
+ metadata: {
+ ...fullService.metadata,
+ converted_to_route_by: window.__user.email + ' - ' + window.__user.name,
+ converted_to_route_at: moment().format('YYYY-MM-DD hh:mm:ss')
+ }
+ };
+ return BackOfficeServices.updateService(newService.id, newService).then(() => {
+ return BackOfficeServices.nextClient
+ .forEntity('routes')
+ .create({
+ ...res,
+ metadata: {
+ ...res.metadata,
+ converted_from_service_by: window.__user.email + ' - ' + window.__user.name,
+ converted_from_service_at: moment().format('YYYY-MM-DD hh:mm:ss')
+ }
+ })
+ .then(() => {
+ history.push(`/routes/${res.id}?tab=informations`);
+ });
+ });
+ })
+ });
+ /*
+ convertAsRoute(service).then((res) => {
+ history.push(`/routes/${res.id}?tab=informations`, {
+ routeFromService: res,
+ });
+ })*/
+ }
+
return (
@@ -38,13 +80,7 @@ export function ImportServiceDescriptor({ hide }) {
disabled={!service}
text="Migrate and start editing"
className="mt-3"
- onPress={() =>
- convertAsRoute(service).then((res) => {
- history.push(`/routes/${res.id}?tab=informations`, {
- routeFromService: res,
- });
- })
- }
+ onPress={() => conversion()}
icon={() => }
/>
diff --git a/otoroshi/javascript/src/pages/ServicePage.js b/otoroshi/javascript/src/pages/ServicePage.js
index 5374fef786..c4ad24b578 100644
--- a/otoroshi/javascript/src/pages/ServicePage.js
+++ b/otoroshi/javascript/src/pages/ServicePage.js
@@ -2,6 +2,7 @@ import React, { Component, Suspense } from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import YAML from 'yaml';
+import moment from 'moment';
import cloneDeep from 'lodash/cloneDeep';
import merge from 'lodash/merge';
@@ -1159,21 +1160,34 @@ export class ServicePage extends Component {
convertToRoute = () => {
window.newConfirm(
- "Are you sure you want to do that ? your current service will be disabled, but you'll have to delete it yourself.",
- (ok) => {
+ "Are you sure you want to do that ? your current service will be disabled, but you'll have to delete it yourself."
+ ).then((ok) => {
if (ok) {
BackOfficeServices.convertAsRoute(this.state.service.id).then((res) => {
- BackOfficeServices.nextClient
+ BackOfficeServices
+ .nextClient
.forEntity('routes')
- .create(res)
+ .create({
+ ...res,
+ metadata: {
+ ...res.metadata,
+ converted_from_service_by: window.__user.email + ' - ' + window.__user.name,
+ converted_from_service_at: moment().format('YYYY-MM-DD hh:mm:ss')
+ }
+ })
.then(() => {
const newService = {
...this.state.service,
name: '[MIGRATED TO ROUTE, PENDING DELETION] ' + this.state.service.name,
enabled: false,
+ metadata: {
+ ...this.state.service.metadata,
+ converted_to_route_by: window.__user.email + ' - ' + window.__user.name,
+ converted_to_route_at: moment().format('YYYY-MM-DD hh:mm:ss')
+ }
};
this.setState({ service: newService }, () => {
- BackOfficeServices.saveService(newService).then(() => {
+ BackOfficeServices.updateService(newService.id, newService).then(() => {
this.props.history.push(`/routes/${res.id}?tab=informations`);
});
});