Skip to content

Commit 5254514

Browse files
committed
Merge conflicts
2 parents a74fc01 + 0436099 commit 5254514

File tree

6 files changed

+73
-82
lines changed

6 files changed

+73
-82
lines changed

etapes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
modifier etc host
2+
ajouter reverse proxy en local

reverse-proxy/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "reverse-proxy",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "server.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"start": "node server.js"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"cors": "^2.8.5",
14+
"express": "^4.17.1",
15+
"express-http-proxy": "^1.5.1",
16+
"http-proxy": "^1.17.0"
17+
}
18+
}

reverse-proxy/server.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var express = require('express')
2+
var cors = require('cors')
3+
const proxy = require('express-http-proxy');
4+
5+
var app = express()
6+
7+
var corsOptions = {
8+
origin: true,
9+
optionsSuccessStatus: 200,
10+
credentials: true
11+
}
12+
13+
app.use(cors(corsOptions));
14+
app.use(proxy('argos2.test.hypertopic.org'));
15+
16+
17+
18+
19+
app.listen(80, function () {
20+
console.log('CORS-enabled web server listening on port 80')
21+
})

src/components/Duplication/Duplicator.jsx

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Duplicator extends Component {
2121
this.handleConfirm = this.handleConfirm.bind(this);
2222
this.onChangeCheckBox = this.onChangeCheckBox.bind(this);
2323
this.closeToast = this.closeToast.bind(this)
24+
this.addUserToEntity = this.addUserToEntity.bind(this)
2425
}
2526

2627
handleClose() {
@@ -41,40 +42,43 @@ class Duplicator extends Component {
4142
}
4243
}
4344

44-
handleConfirm() {
45-
let db = hypertopic([
46-
"http://argos2.test.hypertopic.org",
47-
"http://steatite.hypertopic.org"
48-
]);
49-
50-
const _error = (x) => console.error(x.message);
45+
async handleConfirm() {
46+
this.setState({ showModalConfirmation: false, showToast: true });
5147

48+
var ids = this.state.viewpoints.concat(this.state.corpora)
5249
let that = this
5350

51+
await Promise.all(ids.map(id => that.addUserToEntity(id)))
52+
//refresh page
53+
this.setState({showToast: false });
54+
window.location.replace("http://" + this.nameDuplicatedPortfolio + ".local:3000");
5455

55-
this.state.viewpoints.forEach(function(viewpoint) {
56-
db.getView('/viewpoint/' + viewpoint)
57-
.then( (x) => {
58-
x[viewpoint].user.push(that.nameDuplicatedPortfolio)
59-
return x
60-
})
61-
.then(db.post)
62-
.catch(_error);
63-
});
56+
}
6457

65-
this.state.corpora.forEach(function(corpus) {
66-
db.getView('/corpus/' + corpus)
67-
.then( (x) => {
68-
x[corpus].user.push(that.nameDuplicatedPortfolio)
69-
return x
70-
})
71-
.then(db.post)
72-
.catch(_error);
73-
});
58+
addUserToEntity(user){
59+
let db = hypertopic([
60+
"http://localhost",
61+
"http://steatite.hypertopic.org"
62+
]);
63+
64+
const _error = (x) => {
65+
console.error(x.message)
66+
return x
67+
};
7468

75-
this.setState({ showModalConfirmation: false, showToast: true});
76-
document.location = 'http://'+ this.nameDuplicatedPortfolio +'.porphyry.org/'
69+
return db.get({_id:user})
70+
.then( (x) => {
71+
if(!x.users.includes(this.nameDuplicatedPortfolio))
72+
x.users.push(this.nameDuplicatedPortfolio)
73+
return x
74+
})
75+
.then(db.post)
76+
.then((x) => {
77+
console.log(x)
78+
})
79+
.catch(_error);
7780
}
81+
7882
closeToast() {
7983
this.setState(() => {
8084
return {

src/components/Duplication/Toast.jsx

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/config/config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"user": "vitraux",
32
"services": [
4-
"http://argos2.test.hypertopic.org",
3+
"http://localhost",
54
"http://steatite.hypertopic.org"
65
]
76
}

0 commit comments

Comments
 (0)