Add connect defaults readonly flag, closes #10
This commit is contained in:
parent
fcd204321a
commit
39641c315f
File diff suppressed because one or more lines are too long
@ -219,8 +219,18 @@ i[class*=' icon-']:before {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.connect-form h1 {
|
.connect-form h1 {
|
||||||
margin-bottom: 15px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.connect-details {
|
||||||
|
color: #999;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.connect-details h2 {
|
||||||
|
color: #6bb758;
|
||||||
}
|
}
|
||||||
|
|
||||||
.connect-form input {
|
.connect-form input {
|
||||||
|
@ -8,20 +8,24 @@ export default class Connect extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
handleSubmit = e => {
|
handleSubmit = e => {
|
||||||
const { connect, select, join } = this.props;
|
const { connect, select, join, defaults } = this.props;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
let address = e.target.address.value.trim();
|
|
||||||
const nick = e.target.nick.value.trim();
|
const nick = e.target.nick.value.trim();
|
||||||
const channels = e.target.channels.value
|
let { address, channels } = defaults;
|
||||||
|
const opts = {
|
||||||
|
name: defaults.name
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!defaults.readonly) {
|
||||||
|
address = e.target.address.value.trim();
|
||||||
|
channels = e.target.channels.value
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(s => s.trim())
|
.map(s => s.trim())
|
||||||
.filter(s => s);
|
.filter(s => s);
|
||||||
const opts = {
|
opts.name = e.target.name.value.trim();
|
||||||
name: e.target.name.value.trim(),
|
opts.tls = e.target.ssl.checked;
|
||||||
tls: e.target.ssl.checked
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.state.showOptionals) {
|
if (this.state.showOptionals) {
|
||||||
opts.realname = e.target.realname.value.trim();
|
opts.realname = e.target.realname.value.trim();
|
||||||
@ -31,6 +35,7 @@ export default class Connect extends Component {
|
|||||||
opts.password = e.target.password.value.trim();
|
opts.password = e.target.password.value.trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (address.indexOf('.') > 0 && nick) {
|
if (address.indexOf('.') > 0 && nick) {
|
||||||
connect(address, nick, opts);
|
connect(address, nick, opts);
|
||||||
@ -76,9 +81,24 @@ export default class Connect extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
let form;
|
||||||
<div className="connect">
|
|
||||||
<Navicon />
|
if (defaults.readonly) {
|
||||||
|
form = (
|
||||||
|
<form className="connect-form" onSubmit={this.handleSubmit}>
|
||||||
|
<h1>Connect</h1>
|
||||||
|
{defaults.showDetails && (
|
||||||
|
<div className="connect-details">
|
||||||
|
<h2>{defaults.address}</h2>
|
||||||
|
{defaults.channels.sort().map(channel => <p>{channel}</p>)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<input name="nick" type="text" placeholder="Nick" />
|
||||||
|
<input type="submit" value="Connect" />
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
form = (
|
||||||
<form className="connect-form" onSubmit={this.handleSubmit}>
|
<form className="connect-form" onSubmit={this.handleSubmit}>
|
||||||
<h1>Connect</h1>
|
<h1>Connect</h1>
|
||||||
<input
|
<input
|
||||||
@ -111,6 +131,13 @@ export default class Connect extends Component {
|
|||||||
</p>
|
</p>
|
||||||
<input type="submit" value="Connect" />
|
<input type="submit" value="Connect" />
|
||||||
</form>
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="connect">
|
||||||
|
<Navicon />
|
||||||
|
{form}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,9 @@ const ConnectDefaults = Record({
|
|||||||
address: '',
|
address: '',
|
||||||
channels: [],
|
channels: [],
|
||||||
ssl: false,
|
ssl: false,
|
||||||
password: false
|
password: false,
|
||||||
|
readonly: false,
|
||||||
|
showDetails: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const App = Record({
|
const App = Record({
|
||||||
|
@ -11,6 +11,10 @@ channels = [
|
|||||||
]
|
]
|
||||||
password = ""
|
password = ""
|
||||||
ssl = true
|
ssl = true
|
||||||
|
# Only allow a nick to be filled in
|
||||||
|
readonly = false
|
||||||
|
# Show server and channel info when readonly is enabled
|
||||||
|
show_details = false
|
||||||
|
|
||||||
[https]
|
[https]
|
||||||
enabled = false
|
enabled = false
|
||||||
|
@ -14,8 +14,10 @@ type connectDefaults struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Channels []string `json:"channels"`
|
Channels []string `json:"channels"`
|
||||||
Password bool `json:"password"`
|
Password bool `json:"password,omitempty"`
|
||||||
SSL bool `json:"ssl"`
|
SSL bool `json:"ssl,omitempty"`
|
||||||
|
ReadOnly bool `json:"readonly,omitempty"`
|
||||||
|
ShowDetails bool `json:"showDetails,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type indexData struct {
|
type indexData struct {
|
||||||
@ -83,6 +85,8 @@ func getIndexData(r *http.Request, session *Session) *indexData {
|
|||||||
Channels: viper.GetStringSlice("defaults.channels"),
|
Channels: viper.GetStringSlice("defaults.channels"),
|
||||||
Password: viper.GetString("defaults.password") != "",
|
Password: viper.GetString("defaults.password") != "",
|
||||||
SSL: viper.GetBool("defaults.ssl"),
|
SSL: viper.GetBool("defaults.ssl"),
|
||||||
|
ReadOnly: viper.GetBool("defaults.readonly"),
|
||||||
|
ShowDetails: viper.GetBool("defaults.show_details"),
|
||||||
}
|
}
|
||||||
|
|
||||||
server, channel := getTabFromPath(r.URL.EscapedPath())
|
server, channel := getTabFromPath(r.URL.EscapedPath())
|
||||||
|
Loading…
Reference in New Issue
Block a user