ソースを参照

Update ImageList.js

AY 4 年 前
コミット
c607e8aa31
1 ファイル変更17 行追加7 行削除
  1. 17 7
      photo/src/ImageList.js

+ 17 - 7
photo/src/ImageList.js

@@ -44,14 +44,15 @@ class imageList extends React.Component {
 
             open: false,
             //for modal
-            uuid: "https://arozos.com/share/not_found",
+            uuid: "not_found",
+            mode: "nil",
             permission: "anyone",
             ShareError: null,
         };
 
         this.onCurrentImageChange = this.onCurrentImageChange.bind(this);
         this.shareImage = this.shareImage.bind(this);
-
+        this.handleDialogClose = this.handleDialogClose.bind(this);
         //this.onChangeValue = this.onChangeValue.bind(this);
     }
 
@@ -59,9 +60,14 @@ class imageList extends React.Component {
         this.setState({ currentImage: index });
     }
 
+    handleDialogClose() {
+        this.setState({
+            open: false
+        });
+    }
+
     shareImage() {
         this.setState({ open: true, currentImagePath: this.state.images[this.state.currentImage].src });
-        console.log(this.state.currentImagePath)
         fetch("/backend_test/share?path=" + this.state.currentImagePath, {})
             .then(res => res.json())
             .then(
@@ -70,6 +76,7 @@ class imageList extends React.Component {
                         uuid: result.UUID,
                         permission: result.permission,
                     });
+                    console.log(this.state.uuid);
                 },
                 // Note: it's important to handle errors here
                 // instead of a catch() block so that we don't swallow
@@ -88,7 +95,9 @@ class imageList extends React.Component {
         console.log(event.target.value);
     }
 */
-    handleChange(event) {
+    handleChange = (event) => {
+        this.setState({ mode: event.target.value });
+
         var uuid = this.state.uuid;
         var mode = event.target.value;
         var path = this.state.currentImagePath;
@@ -113,8 +122,8 @@ class imageList extends React.Component {
                 .then((response) => response.json())
                 .then((data) => data);
         }
-    };
-
+    }
+    
     componentDidMount() {
         fetch("/backend_test/listFile", {})
         /*
@@ -188,6 +197,7 @@ class imageList extends React.Component {
                         open={this.state.open}
                         maxWidth="md"
                         fullWidth="true"
+                        onClose={this.handleDialogClose}
                     >
                         <DialogTitle>
                                    <List>
@@ -249,7 +259,7 @@ class imageList extends React.Component {
                                 ))}
                             </TextField>
                             <br /><br/>
-                            <Button variant="contained" color="primary">
+                            <Button variant="contained" color="primary" onClick={this.handleDialogClose}>
                                 Done
 </Button>
                         </DialogContent>