-
Notifications
You must be signed in to change notification settings - Fork 42
/
OwnCloudArchiveEntryForm.jsx
101 lines (92 loc) · 3.16 KB
/
OwnCloudArchiveEntryForm.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import url from "url";
import React from "react";
import createWebDAVFS from "webdav-fs";
import anyFs from "any-fs";
import BaseFSArchiveEntryForm from "./BaseFSArchiveEntryForm";
import ConnectArchiveDialog from "./ConnectArchiveDialog";
class OwnCloudArchiveEntryForm extends BaseFSArchiveEntryForm {
constructor(props) {
super(props);
Object.assign(this.state, {
type: "owncloud",
owncloudAddress: "",
owncloudUsername: "",
owncloudPassword: "",
owncloudPath: ""
});
}
createFS() {
if (this.state.owncloudAddress.trim().length <= 0) {
return null;
}
let wfs;
const owncloudAddress = url.resolve(this.state.owncloudAddress, "remote.php/webdav/");
if (this.state.owncloudUsername && this.state.owncloudUsername.trim().length > 0) {
if (this.state.owncloudPassword.trim().length <= 0) {
return null;
}
wfs = createWebDAVFS(
owncloudAddress,
this.state.owncloudUsername,
this.state.owncloudPassword
);
return anyFs(wfs);
}
return null;
}
onArchiveSelected(filePath, createNew) {
this.setState({
connect: createNew ? "new" : "existing",
owncloudPath: filePath
});
}
renderFormContents() {
return <div>
{super.renderFormContents()}
<div className="row">
<input
type="text"
name="owncloudAddress"
value={this.state.owncloudAddress}
onChange={this.handleChange}
onBlur={() => this.checkFS()}
/>
<label>OwnCloud address</label>
</div>
<div className="row">
<input
type="text"
name="owncloudUsername"
value={this.state.owncloudUsername}
onChange={this.handleChange}
onBlur={() => this.checkFS()}
/>
<label>OwnCloud username</label>
</div>
<div className="row">
<input
type="password"
name="owncloudPassword"
value={this.state.owncloudPassword}
onChange={this.handleChange}
onBlur={() => this.checkFS()}
/>
<label>OwnCloud password</label>
</div>
<div className="row remotePath">
<input
type="text"
name="owncloudPath"
value={this.state.owncloudPath}
onChange={this.handleChange}
/>
<label>Remote archive path</label>
<ConnectArchiveDialog
fs={this.fs}
onArchiveSelected={(...args) => this.onArchiveSelected(...args)}
/>
</div>
</div>;
}
}
export default OwnCloudArchiveEntryForm;