-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OAuth - Web clients, app download modal
- Loading branch information
1 parent
0bc52a8
commit 062b144
Showing
15 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// modified https://github.com/jprichardson/react-qr/blob/master/index.js | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import qrImage from 'qr-image' | ||
|
||
export default class ReactQR extends Component { | ||
static propTypes = { | ||
text: PropTypes.string.isRequired | ||
} | ||
|
||
render() { | ||
const pngBuffer = qrImage.imageSync(this.props.text, { type: 'png', size: this.props.size || 2, margin: 1 }) | ||
const dataURI = 'data:image/png;base64,' + pngBuffer.toString('base64') | ||
return ( | ||
<img className='react-qr' src={dataURI} /> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from 'react' | ||
import tt from 'counterpart' | ||
import CloseButton from 'react-foundation-components/lib/global/close-button' | ||
import Reveal from 'react-foundation-components/lib/global/reveal' | ||
|
||
import AppDownload from '@/modules/app/AppDownload' | ||
|
||
class WebClients extends React.Component { | ||
static propTypes = { | ||
} | ||
|
||
state = { | ||
} | ||
|
||
showAppDownload = (e) => { | ||
e.preventDefault() | ||
this.setState({ | ||
show_app_download_modal: true | ||
}) | ||
} | ||
|
||
hideAppDownload = () => { | ||
this.setState({ | ||
show_app_download_modal: false | ||
}) | ||
} | ||
|
||
render() { | ||
const { web_clients } = this.props | ||
|
||
const isEng = tt.getLocale() !== 'ru' | ||
|
||
let appList = null | ||
const webs = Object.entries(web_clients || {}) | ||
if (webs.length) { | ||
appList = [] | ||
for (const [en, data] of webs) { | ||
if (en === '_desktop') continue | ||
const { img, ru, url } = data | ||
appList.push(<a key={url} className='web-client' href={url} target='_blank' rel='noopener noreferrer'> | ||
<img src={img} /><br/> | ||
<div className='web-label'>{isEng ? en : ru}</div> | ||
</a>) | ||
} | ||
|
||
let desktop | ||
const { _desktop } = web_clients | ||
let desktopHost | ||
if (_desktop) { | ||
desktopHost = _desktop.host | ||
desktop = <div className='desktop'> | ||
{tt('web_clients_jx.or_desktop')} | ||
<a href='#' onClick={this.showAppDownload}>{tt('web_clients_jx.or_desktop_link')}</a> | ||
{tt('web_clients_jx.or_desktop2')} | ||
</div> | ||
} | ||
|
||
const modalStyle = { | ||
borderRadius: '8px', | ||
boxShadow: '0 0 19px 3px rgba(0,0,0, 0.2)', | ||
overflow: 'hidden', | ||
} | ||
|
||
const { show_app_download_modal } = this.state | ||
appList = <div className='WebClients'> | ||
<h3>{tt('web_clients_jx.title')}</h3> | ||
{appList} | ||
{desktop} | ||
<hr/> | ||
<Reveal revealStyle={{ ...modalStyle, }} | ||
onHide={this.hideAppDownload} show={show_app_download_modal}> | ||
<CloseButton onClick={this.hideAppDownload} /> | ||
<AppDownload host={desktopHost} /> | ||
</Reveal> | ||
</div> | ||
} | ||
return appList | ||
} | ||
} | ||
|
||
export default WebClients |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.WebClients { | ||
.web-client { | ||
display: inline-block; | ||
vertical-align: top; | ||
width: 150px; | ||
height: 80px; | ||
position: relative; | ||
|
||
img { | ||
max-width: 100%; | ||
max-height: 100%; | ||
} | ||
.web-label { | ||
position: absolute; | ||
left: 0.25rem; | ||
bottom: 0.25rem; | ||
} | ||
} | ||
|
||
.desktop { | ||
margin-top: 0.5rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react' | ||
import tt from 'counterpart' | ||
|
||
import QRCode from '@/elements/QrCode' | ||
|
||
class AppDownload extends React.Component { | ||
componentDidMount() { | ||
} | ||
|
||
render() { | ||
const updaterHost = this.props.host | ||
if (!updaterHost) return null | ||
const winUrl = new URL('/api/exe/desktop/windows/latest', updaterHost).toString() | ||
const linuxUrl = new URL('/api/exe/desktop/linux/latest', updaterHost).toString() | ||
const androidUrl = new URL('/api/exe/messenger/android/latest', updaterHost).toString() | ||
return <div> | ||
<h4>{tt('app_download.title')}</h4> | ||
<a href={winUrl} target='_blank' rel='nofollow noreferrer' title={tt('app_download.download_for') + ' Windows'}> | ||
<img src={'/images/windows.png'} /> | ||
Windows | ||
</a><br /> | ||
<a href={linuxUrl} title={tt('app_download.download_for') + ' Linux'}> | ||
<img src={'/images/linux.png'} /> | ||
Linux (deb) | ||
</a><br /> | ||
<a href={androidUrl} title={tt('app_download.download_for') + ' Android'}> | ||
<img src={'/images/android48x48.png'} /> | ||
{tt('app_download.messenger')}Android | ||
<QRCode text={androidUrl} size={2} /> | ||
</a> | ||
</div> | ||
} | ||
} | ||
|
||
export default AppDownload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters