Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Update settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Ito committed Jan 18, 2016
1 parent 415c571 commit 2fcdb0c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
26 changes: 25 additions & 1 deletion src/components/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,31 @@ import React from "react"; // eslint-disable-line
import { Component } from "flumpt";

export class SettingsComponent extends Component {
handleSubmit(e) {
e.preventDefault();
this.dispatch("updateSettings",
this.refs.channelId.value.trim(), this.refs.upstreamToken.value.trim());
return false;
}
render() {
return <div>Settings</div>;
return (
<div className="pane-more">
<form onSubmit={this.handleSubmit.bind(this)}>
<div className="form-group">
<label>チャネルID</label>
<input type="text" className="form-control"
ref="channelId" defaultValue={this.props.settings.channelId} />
</div>
<div className="form-group">
<label>配信用トークン</label>
<input type="text" className="form-control"
ref="upstreamToken" defaultValue={this.props.settings.upstreamToken} />
</div>
<div className="form-actions">
<button type="submit" className="btn btn-form btn-primary">保存</button>
</div>
</form>
</div>
);
}
}
23 changes: 21 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ class Decap extends Flux {
return state;
});
});
this.on("updateSettings", (channelId, upstreamToken) => {
return this.update(state => {
state.settings = {
channelId: channelId,
upstreamToken: upstreamToken
};
window.localStorage.setItem(
"decapSettings", JSON.stringify(state.settings));
return state;
});
});
}
render(state) {
return <DecapComponent {...state} />;
Expand All @@ -56,10 +67,18 @@ const decap = new Decap({
activeSourceId: "",
isPlaying: false,
anzu: null,
sources: []
sources: [],
settings: {
}
},
middlewares: [
]
});

decap.update(state => (state));
decap.update(state => {
let settings = JSON.parse(window.localStorage.getItem("decapSettings"));
if (settings !== null) {
state.settings = settings;
}
return state;
});

0 comments on commit 2fcdb0c

Please sign in to comment.