Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Moecube Accounts Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Moecube Accounts Web
Commits
eecf89f3
Commit
eecf89f3
authored
Apr 07, 2017
by
nano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avatar
parent
d1332cc2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
6 deletions
+20
-6
src/components/UserPanel.js
src/components/UserPanel.js
+1
-1
src/models/upload.js
src/models/upload.js
+8
-0
src/routes/Profiles.js
src/routes/Profiles.js
+11
-5
No files found.
src/components/UserPanel.js
View file @
eecf89f3
...
@@ -6,7 +6,7 @@ import { FormattedMessage as Format } from 'react-intl';
...
@@ -6,7 +6,7 @@ import { FormattedMessage as Format } from 'react-intl';
const
defaultAvatar
=
require
(
'
../../public/default_avatar.jpg
'
);
const
defaultAvatar
=
require
(
'
../../public/default_avatar.jpg
'
);
function
UserPanel
({
dispatch
,
user
,
token
})
{
function
UserPanel
({
dispatch
,
user
})
{
const
{
avatar
}
=
user
;
const
{
avatar
}
=
user
;
const
menu
=
(
const
menu
=
(
<
Menu
trigger
=
{[
'
click
'
]}
>
<
Menu
trigger
=
{[
'
click
'
]}
>
...
...
src/models/upload.js
View file @
eecf89f3
...
@@ -17,6 +17,14 @@ export default {
...
@@ -17,6 +17,14 @@ export default {
},
},
};
};
},
},
abort
(
state
)
{
return
{
...
state
,
...{
isUpload
:
false
,
},
};
},
getfile
(
state
,
action
)
{
getfile
(
state
,
action
)
{
return
{
return
{
...
state
,
...
action
.
payload
,
...
state
,
...
action
.
payload
,
...
...
src/routes/Profiles.js
View file @
eecf89f3
...
@@ -49,14 +49,21 @@ class Profiles extends React.Component {
...
@@ -49,14 +49,21 @@ class Profiles extends React.Component {
};
};
onGetFile
=
(
e
)
=>
{
onGetFile
=
(
e
)
=>
{
let
files
;
let
files
=
[]
;
if
(
e
.
dataTransfer
)
{
if
(
e
.
dataTransfer
)
{
files
=
e
.
dataTransfer
.
files
;
files
=
e
.
dataTransfer
.
files
;
}
else
if
(
e
.
target
)
{
}
else
if
(
e
.
target
)
{
files
=
e
.
target
.
files
;
files
=
e
.
target
.
files
;
}
}
if
(
files
.
length
<=
0
)
{
this
.
props
.
dispatch
({
type
:
'
upload/abort
'
})
return
}
const
reader
=
new
FileReader
();
const
reader
=
new
FileReader
();
reader
.
onload
=
()
=>
{
reader
.
onload
=
()
=>
{
this
.
props
.
dispatch
({
type
:
'
upload/start
'
})
this
.
props
.
dispatch
({
type
:
'
upload/getfile
'
,
payload
:
{
imageUrl
:
reader
.
result
}
});
this
.
props
.
dispatch
({
type
:
'
upload/getfile
'
,
payload
:
{
imageUrl
:
reader
.
result
}
});
};
};
reader
.
readAsDataURL
(
files
[
0
]);
reader
.
readAsDataURL
(
files
[
0
]);
...
@@ -69,13 +76,12 @@ class Profiles extends React.Component {
...
@@ -69,13 +76,12 @@ class Profiles extends React.Component {
const
{
user
:
{
id
}
}
=
this
.
props
;
const
{
user
:
{
id
}
}
=
this
.
props
;
this
.
cropper
.
getCroppedCanvas
().
toBlob
((
blob
)
=>
{
this
.
cropper
.
getCroppedCanvas
().
toBlob
((
blob
)
=>
{
console
.
log
(
blob
);
this
.
props
.
dispatch
({
type
:
'
upload/upload
'
,
payload
:
{
image
:
blob
,
user_id
:
id
}
});
this
.
props
.
dispatch
({
type
:
'
upload/upload
'
,
payload
:
{
image
:
blob
,
user_id
:
id
}
});
});
});
};
};
render
()
{
render
()
{
const
{
dispatch
,
form
,
user
,
loading
,
imageUrl
,
isUpload
}
=
this
.
props
;
const
{
form
,
user
,
loading
,
imageUrl
,
isUpload
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
const
{
getFieldDecorator
}
=
form
;
const
{
name
,
avatar
}
=
user
;
const
{
name
,
avatar
}
=
user
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
...
@@ -119,8 +125,8 @@ class Profiles extends React.Component {
...
@@ -119,8 +125,8 @@ class Profiles extends React.Component {
<
div
style
=
{{
display
:
!
isUpload
?
'
flex
'
:
'
none
'
,
flexDirection
:
'
column
'
}}
>
<
div
style
=
{{
display
:
!
isUpload
?
'
flex
'
:
'
none
'
,
flexDirection
:
'
column
'
}}
>
<
img
alt
=
"
avatar
"
src
=
{
avatar
||
imageUrl
||
defaultAvatar
}
/
>
<
img
alt
=
"
avatar
"
src
=
{
avatar
||
imageUrl
||
defaultAvatar
}
/
>
<
Button
onClick
=
{()
=>
{
dispatch
({
type
:
'
upload/start
'
});
}}
>
<
Button
style
=
{{
padding
:
'
4px 0
'
}}
>
<
label
>
<
label
style
=
{{
display
:
'
flex
'
,
flex
:
1
,
justifyContent
:
'
center
'
,
alignItems
:
'
center
'
}}
>
<
Icon
type
=
"
plus
"
/><
Format
id
=
"
Change-Avatar
"
/>
<
Icon
type
=
"
plus
"
/><
Format
id
=
"
Change-Avatar
"
/>
<
input
<
input
type
=
"
file
"
onChange
=
{
this
.
onGetFile
}
ref
=
{(
file
)
=>
{
type
=
"
file
"
onChange
=
{
this
.
onGetFile
}
ref
=
{(
file
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment