Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3ae93c72
Commit
3ae93c72
authored
Mar 06, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Toggle, Repair and Remove actions async
parent
30227d7d
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
369 additions
and
27 deletions
+369
-27
ee/app/assets/javascripts/geo_nodes/components/app.vue
ee/app/assets/javascripts/geo_nodes/components/app.vue
+115
-12
spec/javascripts/geo_nodes/components/app_spec.js
spec/javascripts/geo_nodes/components/app_spec.js
+254
-15
No files found.
ee/app/assets/javascripts/geo_nodes/components/app.vue
View file @
3ae93c72
<
script
>
<
script
>
import
{
s__
}
from
'
~/locale
'
;
import
Flash
from
'
~/flash
'
;
import
statusCodes
from
'
~/lib/utils/http_status
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
modal
from
'
~/vue_shared/components/modal.vue
'
;
import
SmartInterval
from
'
~/smart_interval
'
;
import
SmartInterval
from
'
~/smart_interval
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
import
{
NODE_ACTIONS
}
from
'
../constants
'
;
import
geoNodesList
from
'
./geo_nodes_list.vue
'
;
import
geoNodesList
from
'
./geo_nodes_list.vue
'
;
export
default
{
export
default
{
components
:
{
components
:
{
loadingIcon
,
loadingIcon
,
modal
,
geoNodesList
,
geoNodesList
,
},
},
props
:
{
props
:
{
...
@@ -33,6 +40,12 @@
...
@@ -33,6 +40,12 @@
return
{
return
{
isLoading
:
true
,
isLoading
:
true
,
hasError
:
false
,
hasError
:
false
,
showModal
:
false
,
targetNode
:
null
,
targetNodeActionType
:
''
,
modalKind
:
'
warning
'
,
modalMessage
:
''
,
modalActionLabel
:
''
,
errorMessage
:
''
,
errorMessage
:
''
,
};
};
},
},
...
@@ -43,17 +56,34 @@
...
@@ -43,17 +56,34 @@
},
},
created
()
{
created
()
{
eventHub
.
$on
(
'
pollNodeDetails
'
,
this
.
initNodeDetailsPolling
);
eventHub
.
$on
(
'
pollNodeDetails
'
,
this
.
initNodeDetailsPolling
);
eventHub
.
$on
(
'
showNodeActionModal
'
,
this
.
showNodeActionModal
);
eventHub
.
$on
(
'
repairNode
'
,
this
.
repairNode
);
},
},
mounted
()
{
mounted
()
{
this
.
fetchGeoNodes
();
this
.
fetchGeoNodes
();
},
},
beforeDestroy
()
{
beforeDestroy
()
{
eventHub
.
$off
(
'
pollNodeDetails
'
,
this
.
initNodeDetailsPolling
);
eventHub
.
$off
(
'
pollNodeDetails
'
,
this
.
initNodeDetailsPolling
);
eventHub
.
$off
(
'
showNodeActionModal
'
,
this
.
showNodeActionModal
);
eventHub
.
$off
(
'
repairNode
'
,
this
.
repairNode
);
if
(
this
.
nodePollingInterval
)
{
if
(
this
.
nodePollingInterval
)
{
this
.
nodePollingInterval
.
stopTimer
();
this
.
nodePollingInterval
.
stopTimer
();
}
}
},
},
methods
:
{
methods
:
{
setNodeActionStatus
(
node
,
status
)
{
Object
.
assign
(
node
,
{
nodeActionActive
:
status
});
},
initNodeDetailsPolling
(
node
)
{
this
.
nodePollingInterval
=
new
SmartInterval
({
callback
:
this
.
fetchNodeDetails
.
bind
(
this
,
node
),
startingInterval
:
30000
,
maxInterval
:
120000
,
hiddenInterval
:
240000
,
incrementByFactorOf
:
15000
,
immediateExecution
:
true
,
});
},
fetchGeoNodes
()
{
fetchGeoNodes
()
{
this
.
hasError
=
false
;
this
.
hasError
=
false
;
this
.
service
.
getGeoNodes
()
this
.
service
.
getGeoNodes
()
...
@@ -67,8 +97,9 @@
...
@@ -67,8 +97,9 @@
this
.
errorMessage
=
err
;
this
.
errorMessage
=
err
;
});
});
},
},
fetchNodeDetails
(
nodeId
)
{
fetchNodeDetails
(
node
)
{
return
this
.
service
.
getGeoNodeDetails
(
nodeId
)
const
nodeId
=
node
.
id
;
return
this
.
service
.
getGeoNodeDetails
(
node
)
.
then
(
res
=>
res
.
data
)
.
then
(
res
=>
res
.
data
)
.
then
((
nodeDetails
)
=>
{
.
then
((
nodeDetails
)
=>
{
const
primaryNodeVersion
=
this
.
store
.
getPrimaryNodeVersion
();
const
primaryNodeVersion
=
this
.
store
.
getPrimaryNodeVersion
();
...
@@ -80,19 +111,82 @@
...
@@ -80,19 +111,82 @@
eventHub
.
$emit
(
'
nodeDetailsLoaded
'
,
this
.
store
.
getNodeDetails
(
nodeId
));
eventHub
.
$emit
(
'
nodeDetailsLoaded
'
,
this
.
store
.
getNodeDetails
(
nodeId
));
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
if
(
err
.
response
&&
err
.
response
.
status
===
statusCodes
.
NOT_FOUND
)
{
this
.
store
.
setNodeDetails
(
nodeId
,
{
geo_node_id
:
nodeId
,
health
:
err
.
message
,
health_status
:
'
Unknown
'
,
missing_oauth_application
:
false
,
sync_status_unavailable
:
true
,
storage_shards_match
:
null
,
});
eventHub
.
$emit
(
'
nodeDetailsLoaded
'
,
this
.
store
.
getNodeDetails
(
nodeId
));
}
else
{
eventHub
.
$emit
(
'
nodeDetailsLoadFailed
'
,
nodeId
,
err
);
eventHub
.
$emit
(
'
nodeDetailsLoadFailed
'
,
nodeId
,
err
);
}
});
});
},
},
initNodeDetailsPolling
(
nodeId
)
{
repairNode
(
targetNode
)
{
this
.
nodePollingInterval
=
new
SmartInterval
({
this
.
setNodeActionStatus
(
targetNode
,
true
);
callback
:
this
.
fetchNodeDetails
.
bind
(
this
,
nodeId
),
this
.
service
.
repairNode
(
targetNode
)
startingInterval
:
30000
,
.
then
(()
=>
{
maxInterval
:
120000
,
this
.
setNodeActionStatus
(
targetNode
,
false
);
hiddenInterval
:
240000
,
Flash
(
s__
(
'
GeoNodes|Node Authentication was successfully repaired.
'
),
'
notice
'
);
incrementByFactorOf
:
15000
,
})
immediateExecution
:
true
,
.
catch
(()
=>
{
this
.
setNodeActionStatus
(
targetNode
,
false
);
Flash
(
s__
(
'
GeoNodes|Something went wrong while repairing node
'
));
});
});
},
},
toggleNode
(
targetNode
)
{
this
.
setNodeActionStatus
(
targetNode
,
true
);
this
.
service
.
toggleNode
(
targetNode
)
.
then
(
res
=>
res
.
data
)
.
then
((
node
)
=>
{
Object
.
assign
(
targetNode
,
{
enabled
:
node
.
enabled
,
nodeActionActive
:
false
});
})
.
catch
(()
=>
{
this
.
setNodeActionStatus
(
targetNode
,
false
);
Flash
(
s__
(
'
GeoNodes|Something went wrong while changing node status
'
));
});
},
removeNode
(
targetNode
)
{
this
.
setNodeActionStatus
(
targetNode
,
true
);
this
.
service
.
removeNode
(
targetNode
)
.
then
(()
=>
{
this
.
store
.
removeNode
(
targetNode
);
Flash
(
s__
(
'
GeoNodes|Node was successfully removed.
'
),
'
notice
'
);
})
.
catch
(()
=>
{
this
.
setNodeActionStatus
(
targetNode
,
false
);
Flash
(
s__
(
'
GeoNodes|Something went wrong while removing node
'
));
});
},
handleNodeAction
()
{
this
.
showModal
=
false
;
if
(
this
.
targetNodeActionType
===
NODE_ACTIONS
.
TOGGLE
)
{
this
.
toggleNode
(
this
.
targetNode
);
}
else
if
(
this
.
targetNodeActionType
===
NODE_ACTIONS
.
REMOVE
)
{
this
.
removeNode
(
this
.
targetNode
);
}
},
showNodeActionModal
({
actionType
,
node
,
modalKind
=
'
warning
'
,
modalMessage
,
modalActionLabel
})
{
this
.
targetNode
=
node
;
this
.
targetNodeActionType
=
actionType
;
this
.
modalKind
=
modalKind
;
this
.
modalMessage
=
modalMessage
;
this
.
modalActionLabel
=
modalActionLabel
;
if
(
actionType
===
NODE_ACTIONS
.
TOGGLE
&&
!
node
.
enabled
)
{
this
.
toggleNode
(
this
.
targetNode
);
}
else
{
this
.
showModal
=
true
;
}
},
hideNodeActionModal
()
{
this
.
showModal
=
false
;
},
},
},
};
};
</
script
>
</
script
>
...
@@ -120,5 +214,14 @@
...
@@ -120,5 +214,14 @@
>
>
{{
errorMessage
}}
{{
errorMessage
}}
</p>
</p>
<modal
v-show=
"showModal"
:title=
"__('Are you sure?')"
:kind=
"modalKind"
:text=
"modalMessage"
:primary-button-label=
"modalActionLabel"
@
cancel=
"hideNodeActionModal"
@
submit=
"handleNodeAction"
/>
</div>
</div>
</
template
>
</
template
>
spec/javascripts/geo_nodes/components/app_spec.js
View file @
3ae93c72
This diff is collapsed.
Click to expand it.
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