Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
webclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
retribute.me
webclient
Commits
80f8d93d
Verified
Commit
80f8d93d
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Better progress handling
parent
5daf1007
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Suggestions.vue
+22
-6
22 additions, 6 deletions
src/components/Suggestions.vue
src/sources/mastodon.js
+4
-1
4 additions, 1 deletion
src/sources/mastodon.js
with
26 additions
and
7 deletions
src/components/Suggestions.vue
+
22
−
6
View file @
80f8d93d
...
...
@@ -2,18 +2,26 @@
<div>
<ul
class=
"collection with-header"
>
<li
class=
"collection-header"
>
<h4>
Connected accounts
</h4>
<router-link
to=
"/connect"
class=
"secondary-content"
>
Add another account
</router-link>
<h5>
Connected accounts
</h5>
</li>
<li
class=
"collection-item avatar"
v-for=
"account in accounts"
:key=
"account.id"
>
<img
v-if=
"account._source.getAvatar(account)"
:src=
"account._source.getAvatar(account)"
alt=
""
class=
"circle"
>
<span
class=
"title"
>
{{
account
.
_source
.
getDisplayName
(
account
)
}}
</span>
<p>
{{
account
.
_source
.
label
}}
</p>
<a
href=
"#!"
class=
"secondary-content"
><i
class=
"material-icons"
>
grade
</i></a>
<div
v-if=
"isLoading && results[account.id] && results[account.id].results.isLoading"
>
<div
class=
"progress"
>
<div
v-if=
"results[account.id].results.progress === 'indeterminate'"
:class=
"indeterminate"
></div>
<div
v-else
class=
"determinate"
:style=
"
{width: `${results[account.id].results.progress}%`}">
</div>
</div>
{{
results
[
account
.
id
].
results
.
status
}}
</div>
<a
@
click=
"fetch(account.id)"
class=
"secondary-content"
><i
class=
"material-icons"
>
refresh
</i></a>
</li>
</ul>
<h2>
Suggestions
</h2>
<button
@
click=
"fetch"
@
click=
"fetch
()
"
:class=
"['waves-effect', 'waves-light',
{disabled: isLoading}, 'btn-small']" :disabled="isLoading">
<i
class=
"material-icons left"
>
refresh
</i>
Fetch data
</button>
...
...
@@ -42,10 +50,18 @@ export default {
}
},
methods
:
{
async
fetch
()
{
async
fetch
(
id
)
{
let
accounts
if
(
id
)
{
accounts
=
this
.
accounts
.
filter
((
a
)
=>
{
return
a
.
id
==
id
})
}
else
{
accounts
=
this
.
accounts
}
this
.
isLoading
=
true
this
.
accounts
.
forEach
((
a
)
=>
{
let
r
=
{}
accounts
.
forEach
((
a
)
=>
{
let
r
=
{
isLoading
:
true
,
progress
:
'
indeterminate
'
,
status
:
''
}
let
promise
=
a
.
_source
.
fetch
({
account
:
a
,
store
:
this
.
$store
,
results
:
r
,
vue
:
this
})
this
.
$set
(
this
.
results
,
a
.
id
,
{
account
:
a
,
promise
,
results
:
r
})
})
...
...
This diff is collapsed.
Click to expand it.
src/sources/mastodon.js
+
4
−
1
View file @
80f8d93d
...
...
@@ -83,7 +83,7 @@ export default {
router
.
push
({
path
:
'
/
'
})
},
async
fetch
({
account
,
cache
,
store
,
results
,
vue
})
{
console
.
log
(
`Fetching favorites
for
${
account
.
id
}
...`
)
vue
.
$set
(
results
,
'
status
'
,
`Fetching favorites...`
)
const
token
=
store
.
state
.
sources
.
mastodon
.
appTokens
[
`
${
account
.
username
}
@
${
account
.
domain
}
`
].
access_token
const
client
=
axios
.
create
({
baseURL
:
`https://
${
account
.
domain
}
`
,
...
...
@@ -92,6 +92,7 @@ export default {
const
maxFavorites
=
100
let
url
=
'
/api/v1/favourites
'
let
handledFavorites
=
0
results
.
progress
=
0
vue
.
$set
(
results
,
'
accounts
'
,
{})
while
(
handledFavorites
<
maxFavorites
)
{
let
response
=
await
client
.
get
(
url
,
{
params
:
{
limit
:
40
}})
...
...
@@ -103,6 +104,7 @@ export default {
}
else
{
results
.
accounts
[
account
]
=
1
}
results
.
progress
=
Math
.
min
(
100
,
results
.
progress
+
1
)
})
let
link
=
response
.
headers
.
link
||
''
let
parsed
=
parseLink
(
link
)
...
...
@@ -113,6 +115,7 @@ export default {
}
vue
.
$set
(
results
,
'
status
'
,
`Fetched favorites
${
handledFavorites
}
/
${
maxFavorites
}
`
)
}
results
.
isLoading
=
false
return
results
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment