Remainder of the controllers from vector
							parent
							
								
									49c5f7cb95
								
							
						
					
					
						commit
						980ce7fdae
					
				|  | @ -0,0 +1,47 @@ | |||
| /* | ||||
| Copyright 2015 OpenMarket Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
| You may obtain a copy of the License at | ||||
| 
 | ||||
|     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| 
 | ||||
| Unless required by applicable law or agreed to in writing, software | ||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| var React = require('react'); | ||||
| 
 | ||||
| module.exports = { | ||||
|     propTypes: { | ||||
|         // Specifying a homeserver will make magical things happen when you,
 | ||||
|         // e.g. start typing in the room alias box.
 | ||||
|         homeserver: React.PropTypes.string, | ||||
|         alias: React.PropTypes.string, | ||||
|         onChange: React.PropTypes.func, | ||||
|     }, | ||||
| 
 | ||||
|     getDefaultProps: function() { | ||||
|         return { | ||||
|             onChange: function() {}, | ||||
|             alias: '', | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     getAliasLocalpart: function() { | ||||
|         var room_alias = this.props.alias; | ||||
| 
 | ||||
|         if (room_alias && this.props.homeserver) { | ||||
|             var suffix = ":" + this.props.homeserver; | ||||
|             if (room_alias.startsWith("#") && room_alias.endsWith(suffix)) { | ||||
|                 room_alias = room_alias.slice(1, -suffix.length); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return room_alias; | ||||
|     }, | ||||
| }; | ||||
|  | @ -0,0 +1,69 @@ | |||
| /* | ||||
| Copyright 2015 OpenMarket Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
| You may obtain a copy of the License at | ||||
| 
 | ||||
|     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| 
 | ||||
| Unless required by applicable law or agreed to in writing, software | ||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| var React = require('react'); | ||||
| var MatrixClientPeg = require("../../MatrixClientPeg"); | ||||
| 
 | ||||
| var dis = require("../../dispatcher"); | ||||
| 
 | ||||
| module.exports = { | ||||
|     propTypes: { | ||||
|         onFinished: React.PropTypes.func, | ||||
|         initialAvatarUrl: React.PropTypes.string.isRequired, | ||||
|     }, | ||||
| 
 | ||||
|     Phases: { | ||||
|         Display: "display", | ||||
|         Uploading: "uploading", | ||||
|         Error: "error", | ||||
|     }, | ||||
| 
 | ||||
|     getDefaultProps: function() { | ||||
|         return { | ||||
|             onFinished: function() {}, | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     getInitialState: function() { | ||||
|         return { | ||||
|             avatarUrl: this.props.initialAvatarUrl, | ||||
|             phase: this.Phases.Display, | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     setAvatarFromFile: function(file) { | ||||
|         var newUrl = null; | ||||
| 
 | ||||
|         this.setState({ | ||||
|             phase: this.Phases.Uploading | ||||
|         }); | ||||
|         var self = this; | ||||
|         MatrixClientPeg.get().uploadContent(file).then(function(url) { | ||||
|             newUrl = url; | ||||
|             return MatrixClientPeg.get().setAvatarUrl(url); | ||||
|         }).done(function() { | ||||
|             self.setState({ | ||||
|                 phase: self.Phases.Display, | ||||
|                 avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(newUrl) | ||||
|             }); | ||||
|         }, function(error) { | ||||
|             self.setState({ | ||||
|                 phase: this.Phases.Error | ||||
|             }); | ||||
|             self.onError(error); | ||||
|         }); | ||||
|     }, | ||||
| } | ||||
|  | @ -0,0 +1,78 @@ | |||
| /* | ||||
| Copyright 2015 OpenMarket Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
| You may obtain a copy of the License at | ||||
| 
 | ||||
|     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| 
 | ||||
| Unless required by applicable law or agreed to in writing, software | ||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| 'use strict'; | ||||
| 
 | ||||
| var React = require('react'); | ||||
| var MatrixClientPeg = require("../../MatrixClientPeg"); | ||||
| 
 | ||||
| var dis = require("../../dispatcher"); | ||||
| 
 | ||||
| module.exports = { | ||||
|     propTypes: { | ||||
|         onFinished: React.PropTypes.func, | ||||
|     }, | ||||
| 
 | ||||
|     Phases: { | ||||
|         Edit: "edit", | ||||
|         Uploading: "uploading", | ||||
|         Error: "error", | ||||
|         Success: "Success" | ||||
|     }, | ||||
| 
 | ||||
|     getDefaultProps: function() { | ||||
|         return { | ||||
|             onFinished: function() {}, | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     getInitialState: function() { | ||||
|         return { | ||||
|             phase: this.Phases.Edit, | ||||
|             errorString: '' | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     changePassword: function(old_password, new_password) { | ||||
|         var cli = MatrixClientPeg.get(); | ||||
| 
 | ||||
|         var authDict = { | ||||
|             type: 'm.login.password', | ||||
|             user: cli.credentials.userId, | ||||
|             password: old_password | ||||
|         }; | ||||
| 
 | ||||
|         this.setState({ | ||||
|             phase: this.Phases.Uploading, | ||||
|             errorString: '', | ||||
|         }) | ||||
| 
 | ||||
|         var d = cli.setPassword(authDict, new_password); | ||||
| 
 | ||||
|         var self = this; | ||||
|         d.then(function() { | ||||
|             self.setState({ | ||||
|                 phase: self.Phases.Success, | ||||
|                 errorString: '', | ||||
|             }) | ||||
|         }, function(err) { | ||||
|             self.setState({ | ||||
|                 phase: self.Phases.Error, | ||||
|                 errorString: err.toString() | ||||
|             }) | ||||
|         }); | ||||
|     }, | ||||
| } | ||||
|  | @ -0,0 +1,33 @@ | |||
| /* | ||||
| Copyright 2015 OpenMarket Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
| You may obtain a copy of the License at | ||||
| 
 | ||||
|     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| 
 | ||||
| Unless required by applicable law or agreed to in writing, software | ||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| var dis = require("../../dispatcher"); | ||||
| 
 | ||||
| module.exports = { | ||||
|     logOut: function() { | ||||
|         dis.dispatch({action: 'logout'}); | ||||
|         if (this.props.onFinished) { | ||||
|             this.props.onFinished(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     cancelPrompt: function() { | ||||
|         if (this.props.onFinished) { | ||||
|             this.props.onFinished(); | ||||
|         } | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
|  | @ -0,0 +1,37 @@ | |||
| /* | ||||
| Copyright 2015 OpenMarket Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
| You may obtain a copy of the License at | ||||
| 
 | ||||
|     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| 
 | ||||
| Unless required by applicable law or agreed to in writing, software | ||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| var React = require("react"); | ||||
| 
 | ||||
| module.exports = { | ||||
|     propTypes: { | ||||
|         title: React.PropTypes.string, | ||||
|         description: React.PropTypes.string, | ||||
|         button: React.PropTypes.string, | ||||
|         focus: React.PropTypes.bool, | ||||
|         onFinished: React.PropTypes.func.isRequired, | ||||
|     }, | ||||
| 
 | ||||
|     getDefaultProps: function() { | ||||
|         var self = this; | ||||
|         return { | ||||
|             title: "", | ||||
|             description: "", | ||||
|             button: "OK", | ||||
|             focus: true, | ||||
|         }; | ||||
|     }, | ||||
| }; | ||||
|  | @ -0,0 +1,68 @@ | |||
| /* | ||||
| Copyright 2015 OpenMarket Ltd | ||||
| 
 | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
| You may obtain a copy of the License at | ||||
| 
 | ||||
|     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| 
 | ||||
| Unless required by applicable law or agreed to in writing, software | ||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| var MatrixClientPeg = require("../../MatrixClientPeg"); | ||||
| var React = require("react"); | ||||
| var q = require('q'); | ||||
| var dis = require("../../dispatcher"); | ||||
| var version = require('../../../package.json').version; | ||||
| 
 | ||||
| module.exports = { | ||||
|     Phases: { | ||||
|         Loading: "loading", | ||||
|         Display: "display", | ||||
|     }, | ||||
| 
 | ||||
|     getInitialState: function() { | ||||
|         return { | ||||
|             displayName: null, | ||||
|             avatarUrl: null, | ||||
|             threePids: [], | ||||
|             clientVersion: version, | ||||
|             phase: this.Phases.Loading, | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     changeDisplayname: function(new_displayname) { | ||||
|         if (this.state.displayName == new_displayname) return; | ||||
| 
 | ||||
|         var self = this; | ||||
|         return MatrixClientPeg.get().setDisplayName(new_displayname).then( | ||||
|             function() { self.setState({displayName: new_displayname}); }, | ||||
|             function(err) { console.err(err); } | ||||
|         ); | ||||
|     }, | ||||
| 
 | ||||
|     componentWillMount: function() { | ||||
|         var self = this; | ||||
|         var cli = MatrixClientPeg.get(); | ||||
| 
 | ||||
|         var profile_d = cli.getProfileInfo(cli.credentials.userId); | ||||
|         var threepid_d = cli.getThreePids(); | ||||
| 
 | ||||
|         q.all([profile_d, threepid_d]).then( | ||||
|             function(resps) { | ||||
|                 self.setState({ | ||||
|                     displayName: resps[0].displayname, | ||||
|                     avatarUrl: resps[0].avatar_url, | ||||
|                     threepids: resps[1].threepids, | ||||
|                     phase: self.Phases.Display, | ||||
|                 }); | ||||
|             }, | ||||
|             function(err) { console.err(err); } | ||||
|         ); | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	 David Baker
						David Baker