From 3e6c284757ffbb42aef34281567cf1adedd21ae9 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Wed, 27 Jul 2016 17:27:01 +0200
Subject: add contentviews to client

---
 web/src/js/components/ContentView/ContentViews.jsx | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index a1adebea..732f9f5e 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -57,4 +57,14 @@ function ViewAuto({ message, flow, readonly, onChange }) {
     return <View message={message} flow={flow} readonly={readonly} onChange={onChange}/>
 }
 
-export { ViewImage, ViewRaw, ViewAuto, ViewJSON }
+function ViewServer({contentView, content}){
+    return <div>
+            <pre>load from server this view: {contentView}</pre>
+            <pre>{content}</pre>
+        </div>
+
+}
+
+ViewServer = ContentLoader(ViewServer)
+
+export { ViewImage, ViewRaw, ViewAuto, ViewJSON, ViewServer }
-- 
cgit v1.2.3


From ad5bebeda0f1da890d8ed94b6096515e03f44a25 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Thu, 28 Jul 2016 17:10:06 +0200
Subject: mitmproxy.contentviews added

---
 web/src/js/components/ContentView/ContentViews.jsx | 42 ++++++++++------------
 1 file changed, 18 insertions(+), 24 deletions(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 732f9f5e..89e97267 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -28,26 +28,8 @@ function ViewRaw({ content, readonly, onChange }) {
 }
 ViewRaw = ContentLoader(ViewRaw)
 
-
-const isJSON = /^application\/json$/i
-ViewJSON.matches = msg => isJSON.test(MessageUtils.getContentType(msg))
-ViewJSON.propTypes = {
-    content: React.PropTypes.string.isRequired,
-}
-function ViewJSON({ content }) {
-    let json = content
-    try {
-        json = JSON.stringify(JSON.parse(content), null, 2);
-    } catch (e) {
-        // @noop
-    }
-    return <pre>{json}</pre>
-}
-ViewJSON = ContentLoader(ViewJSON)
-
-
 ViewAuto.matches = () => false
-ViewAuto.findView = msg => [ViewImage, ViewJSON, ViewRaw].find(v => v.matches(msg)) || ViewRaw
+ViewAuto.findView = msg => [ViewImage, ViewRaw].find(v => v.matches(msg)) || ViewRaw
 ViewAuto.propTypes = {
     message: React.PropTypes.object.isRequired,
     flow: React.PropTypes.object.isRequired,
@@ -57,14 +39,26 @@ function ViewAuto({ message, flow, readonly, onChange }) {
     return <View message={message} flow={flow} readonly={readonly} onChange={onChange}/>
 }
 
-function ViewServer({contentView, content}){
+function ViewServer({content, contentView}){
+    let data = JSON.parse(content)
     return <div>
-            <pre>load from server this view: {contentView}</pre>
-            <pre>{content}</pre>
+            {contentView != data.description &&
+                <div className="alert alert-warning">{data.description}</div>
+            }
+            <pre>
+                {data.lines.map((line, i) =>
+                    <div key={`line${i}`}>
+                        {line.map((tuple, j) =>
+                            <span key={`tuple${j}`} className={tuple[0]}>
+                                {tuple[1]}
+                            </span>
+                        )}
+                    </div>
+                )}
+            </pre>
         </div>
-
 }
 
 ViewServer = ContentLoader(ViewServer)
 
-export { ViewImage, ViewRaw, ViewAuto, ViewJSON, ViewServer }
+export { ViewImage, ViewRaw, ViewAuto, ViewServer }
-- 
cgit v1.2.3


From 2807329fb2ce576ae529afd991e3da3d5f81d637 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Thu, 28 Jul 2016 17:28:05 +0200
Subject: add image to mitmproxy.contentview.image

---
 web/src/js/components/ContentView/ContentViews.jsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 89e97267..a1bee54e 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -39,8 +39,11 @@ function ViewAuto({ message, flow, readonly, onChange }) {
     return <View message={message} flow={flow} readonly={readonly} onChange={onChange}/>
 }
 
-function ViewServer({content, contentView}){
+
+function ViewServer({content, contentView, message, flow}){
     let data = JSON.parse(content)
+    let showImage = isImage.test(MessageUtils.getContentType(message))
+
     return <div>
             {contentView != data.description &&
                 <div className="alert alert-warning">{data.description}</div>
@@ -56,6 +59,11 @@ function ViewServer({content, contentView}){
                     </div>
                 )}
             </pre>
+            {showImage &&
+                <div className="flowview-image">
+                    <img src={MessageUtils.getContentURL(flow, message)} alt="preview" className="img-thumbnail"/>
+                </div>
+            }
         </div>
 }
 
-- 
cgit v1.2.3


From a56c2ca731ff9c4a22438553dea0e4ecf7a51f1d Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Fri, 29 Jul 2016 09:45:15 +0200
Subject: combine clientside and serverside contentviews

---
 web/src/js/components/ContentView/ContentViews.jsx | 32 ++++++----------------
 1 file changed, 9 insertions(+), 23 deletions(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index a1bee54e..3b2af0a9 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -18,31 +18,19 @@ function ViewImage({ flow, message }) {
     )
 }
 
-
-ViewRaw.matches = () => true
-ViewRaw.propTypes = {
+Edit.propTypes = {
     content: React.PropTypes.string.isRequired,
 }
-function ViewRaw({ content, readonly, onChange }) {
-    return readonly ? <pre>{content}</pre> : <CodeEditor content={content} onChange={onChange}/>
-}
-ViewRaw = ContentLoader(ViewRaw)
 
-ViewAuto.matches = () => false
-ViewAuto.findView = msg => [ViewImage, ViewRaw].find(v => v.matches(msg)) || ViewRaw
-ViewAuto.propTypes = {
-    message: React.PropTypes.object.isRequired,
-    flow: React.PropTypes.object.isRequired,
-}
-function ViewAuto({ message, flow, readonly, onChange }) {
-    const View = ViewAuto.findView(message)
-    return <View message={message} flow={flow} readonly={readonly} onChange={onChange}/>
+function Edit({ content, onChange }) {
+    return <CodeEditor content={content} onChange={onChange}/>
 }
+Edit = ContentLoader(Edit)
 
 
-function ViewServer({content, contentView, message, flow}){
+function ViewServer(props){
+    const {content, contentView, message} = props
     let data = JSON.parse(content)
-    let showImage = isImage.test(MessageUtils.getContentType(message))
 
     return <div>
             {contentView != data.description &&
@@ -59,14 +47,12 @@ function ViewServer({content, contentView, message, flow}){
                     </div>
                 )}
             </pre>
-            {showImage &&
-                <div className="flowview-image">
-                    <img src={MessageUtils.getContentURL(flow, message)} alt="preview" className="img-thumbnail"/>
-                </div>
+            {ViewImage.matches(message) &&
+                <ViewImage {...props} />
             }
         </div>
 }
 
 ViewServer = ContentLoader(ViewServer)
 
-export { ViewImage, ViewRaw, ViewAuto, ViewServer }
+export { Edit, ViewServer, ViewImage }
-- 
cgit v1.2.3


From 34fe391afbe18f89d774137f82620024f697ab6a Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Wed, 3 Aug 2016 12:08:10 +0200
Subject: add view all button, add dropdown for contentviews

---
 web/src/js/components/ContentView/ContentViews.jsx | 75 ++++++++++++++++------
 1 file changed, 54 insertions(+), 21 deletions(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 3b2af0a9..43aece46 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -1,4 +1,6 @@
-import React, { PropTypes } from 'react'
+import React, { PropTypes, Component } from 'react'
+import { connect } from 'react-redux'
+import { setContentViewDescription, setShowFullContent } from '../../ducks/ui/flow'
 import ContentLoader from './ContentLoader'
 import { MessageUtils } from '../../flow/utils'
 import CodeEditor from './CodeEditor'
@@ -27,32 +29,63 @@ function Edit({ content, onChange }) {
 }
 Edit = ContentLoader(Edit)
 
+class ViewServer extends Component {
+    constructor(props){
+        super(props)
+        this.maxLines = 80
+    }
 
-function ViewServer(props){
-    const {content, contentView, message} = props
-    let data = JSON.parse(content)
+    componentWillMount(){
+        this.setContentView(this.props)
+    }
+    componentWillReceiveProps(nextProps){
+        this.setContentView(nextProps)
+    }
+    setContentView(props){
+        try {
+            this.data = JSON.parse(props.content)
+        }catch(err) {
+            this.data= {lines: [], description: err.message}
+        }
 
-    return <div>
-            {contentView != data.description &&
-                <div className="alert alert-warning">{data.description}</div>
-            }
-            <pre>
-                {data.lines.map((line, i) =>
-                    <div key={`line${i}`}>
-                        {line.map((tuple, j) =>
-                            <span key={`tuple${j}`} className={tuple[0]}>
-                                {tuple[1]}
-                            </span>
-                        )}
-                    </div>
-                )}
-            </pre>
+        props.setContentViewDescription(props.contentView != this.data.description ? this.data.description : '')
+
+        let isFullContentShown = this.data.lines.length < this.maxLines
+        if (isFullContentShown) props.setShowFullContent(true)
+    }
+    render() {
+        const {content, contentView, message} = this.props
+
+        let lines = this.props.showFullContent ? this.data.lines : this.data.lines.slice(0, this.maxLines)
+
+        return <div>
+                <pre>
+                    {lines.map((line, i) =>
+                        <div key={`line${i}`}>
+                            {line.map((tuple, j) =>
+                                <span key={`tuple${j}`} className={tuple[0]}>
+                                    {tuple[1]}
+                                </span>
+                            )}
+                        </div>
+                    )}
+                </pre>
             {ViewImage.matches(message) &&
-                <ViewImage {...props} />
+            <ViewImage {...this.props} />
             }
         </div>
+    }
+
 }
 
-ViewServer = ContentLoader(ViewServer)
+ViewServer = connect(
+    state => ({
+        showFullContent: state.ui.flow.showFullContent
+    }),
+    {
+        setContentViewDescription,
+        setShowFullContent
+    }
+)(ContentLoader(ViewServer))
 
 export { Edit, ViewServer, ViewImage }
-- 
cgit v1.2.3


From 9b0b007a5da75d70ec25b141c2a47b1b0010f5a3 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Fri, 5 Aug 2016 12:47:34 +0200
Subject: change some style

---
 web/src/js/components/ContentView/ContentViews.jsx | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 43aece46..3db77af4 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -30,9 +30,8 @@ function Edit({ content, onChange }) {
 Edit = ContentLoader(Edit)
 
 class ViewServer extends Component {
-    constructor(props){
-        super(props)
-        this.maxLines = 80
+    static defaultProps = {
+        maxLines: 80,
     }
 
     componentWillMount(){
@@ -50,14 +49,12 @@ class ViewServer extends Component {
 
         props.setContentViewDescription(props.contentView != this.data.description ? this.data.description : '')
 
-        let isFullContentShown = this.data.lines.length < this.maxLines
+        let isFullContentShown = this.data.lines.length < props.maxLines
         if (isFullContentShown) props.setShowFullContent(true)
     }
     render() {
-        const {content, contentView, message} = this.props
-
-        let lines = this.props.showFullContent ? this.data.lines : this.data.lines.slice(0, this.maxLines)
-
+        const {content, contentView, message, maxLines} = this.props
+        let lines = this.props.showFullContent ? this.data.lines : this.data.lines.slice(0, maxLines)
         return <div>
                 <pre>
                     {lines.map((line, i) =>
-- 
cgit v1.2.3


From adfdcc9391ed70202a1b4af65259a89634f36fa0 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Tue, 9 Aug 2016 08:40:24 +0200
Subject: added hints from mhils

---
 web/src/js/components/ContentView/ContentViews.jsx | 1 +
 1 file changed, 1 insertion(+)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 3db77af4..9feb0623 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -37,6 +37,7 @@ class ViewServer extends Component {
     componentWillMount(){
         this.setContentView(this.props)
     }
+
     componentWillReceiveProps(nextProps){
         this.setContentView(nextProps)
     }
-- 
cgit v1.2.3


From 8b43972b95f002e8a5d8a85b7a53f43f16711362 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Wed, 10 Aug 2016 10:49:27 +0200
Subject: move content to redux, add lines to view

---
 web/src/js/components/ContentView/ContentViews.jsx | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 9feb0623..cd593023 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -1,6 +1,6 @@
 import React, { PropTypes, Component } from 'react'
 import { connect } from 'react-redux'
-import { setContentViewDescription, setShowFullContent } from '../../ducks/ui/flow'
+import { setContentViewDescription, setContent } from '../../ducks/ui/flow'
 import ContentLoader from './ContentLoader'
 import { MessageUtils } from '../../flow/utils'
 import CodeEditor from './CodeEditor'
@@ -30,28 +30,25 @@ function Edit({ content, onChange }) {
 Edit = ContentLoader(Edit)
 
 class ViewServer extends Component {
-    static defaultProps = {
-        maxLines: 80,
-    }
 
     componentWillMount(){
         this.setContentView(this.props)
     }
 
     componentWillReceiveProps(nextProps){
-        this.setContentView(nextProps)
+        if (nextProps.content != this.props.content) {
+            this.setContentView(nextProps)
+        }
     }
     setContentView(props){
         try {
             this.data = JSON.parse(props.content)
         }catch(err) {
-            this.data= {lines: [], description: err.message}
+            this.data = {lines: [], description: err.message}
         }
 
         props.setContentViewDescription(props.contentView != this.data.description ? this.data.description : '')
-
-        let isFullContentShown = this.data.lines.length < props.maxLines
-        if (isFullContentShown) props.setShowFullContent(true)
+        props.setContent(this.data.lines)
     }
     render() {
         const {content, contentView, message, maxLines} = this.props
@@ -78,11 +75,12 @@ class ViewServer extends Component {
 
 ViewServer = connect(
     state => ({
-        showFullContent: state.ui.flow.showFullContent
+        showFullContent: state.ui.flow.showFullContent,
+        maxLines: state.ui.flow.maxContentLines
     }),
     {
         setContentViewDescription,
-        setShowFullContent
+        setContent
     }
 )(ContentLoader(ViewServer))
 
-- 
cgit v1.2.3

