summaryrefslogtreecommitdiff
path: root/lib/awprint/client
diff options
context:
space:
mode:
Diffstat (limited to 'lib/awprint/client')
-rw-r--r--lib/awprint/client/components/App.jsx35
-rw-r--r--lib/awprint/client/index.jsx13
2 files changed, 48 insertions, 0 deletions
diff --git a/lib/awprint/client/components/App.jsx b/lib/awprint/client/components/App.jsx
new file mode 100644
index 0000000..46886a3
--- /dev/null
+++ b/lib/awprint/client/components/App.jsx
@@ -0,0 +1,35 @@
+import React from 'react'
+
+export default class App extends React.Component {
+ constructor(props) {
+ super()
+ this.state = {
+ prints: []
+ }
+ fetch('/_services/awprint/index')
+ .then( res => {
+ return res.json()
+ }).then( prints => {
+ this.setState({ prints })
+ }).catch( e => {
+ console.error(e)
+ })
+ }
+ render() {
+ const prints = this.state.prints.map( (print,i) => {
+ const className = print.printed ? 'print printed' : 'print'
+ const date = print.date.replace(/T/,' - ').replace(/:\d\d\..*/,'')
+ return (
+ <div key={i} className={className} onClick={() => this.print(print)}>
+ <img src={print.url} />
+ <div className='date'>{date}</div>
+ </div>
+ )
+ })
+ return (
+ <div>
+ {prints}
+ </div>
+ )
+ }
+} \ No newline at end of file
diff --git a/lib/awprint/client/index.jsx b/lib/awprint/client/index.jsx
new file mode 100644
index 0000000..136f3ff
--- /dev/null
+++ b/lib/awprint/client/index.jsx
@@ -0,0 +1,13 @@
+import React from 'react'
+import ReactDOM from 'react-dom'
+import App from './components/App.jsx'
+
+const isIphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))
+const isIpad = (navigator.userAgent.match(/iPad/i))
+const isAndroid = (navigator.userAgent.match(/Android/i))
+const isMobile = isIphone || isIpad || isAndroid
+const isDesktop = ! isMobile
+
+document.body.classList.add(isDesktop ? 'desktop' : 'mobile')
+
+ReactDOM.render(<App />, document.getElementById('react-root'))