Skip to content

Commit a28585a

Browse files
author
Martin Kennish
authored
Merge pull request #53 from can-anierzad/feat/start-again
Start a new session
2 parents 9978385 + b0525e2 commit a28585a

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

PolyDeploy/Clients/Deploy/src/js/controllers/ResultController.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
module.exports = ['$scope', 'SessionService',
2-
function ($scope, SessionService) {
1+
module.exports = ['$scope', '$state','SessionService',
2+
function ($scope, $state, SessionService) {
33

44
// Wait for session.
55
SessionService.sessionPromise.then(
@@ -18,6 +18,29 @@
1818
}
1919
});
2020

21+
// Start a new deploy.
22+
$scope.restart = function () {
23+
24+
// Create a new session.
25+
SessionService.newSession()
26+
.then(function () {
27+
28+
// Navigate back to beginning.
29+
$state.go('install.upload');
30+
});
31+
};
32+
33+
// Is the install complete?
34+
$scope.isComplete = function () {
35+
36+
var session = $scope.session;
37+
38+
// Is the session complete?
39+
return session
40+
&& session.Status
41+
&& session.Status === 2;
42+
};
43+
2144
// Current status.
2245
$scope.currentStatus = function (session) {
2346

@@ -80,8 +103,6 @@
80103
panelClass = modPackage.Success ? 'panel-success' : 'panel-danger';
81104
}
82105

83-
console.log(panelClass);
84-
85106
return panelClass;
86107
};
87108

PolyDeploy/Clients/Deploy/src/js/services/SessionService.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
// Gets a new session from the API.
1313
function newSession() {
1414

15+
// Is there an interval promise?
16+
if (sessionRefreshInterval) {
17+
18+
// Cancel it.
19+
$interval.cancel(sessionRefreshInterval);
20+
}
21+
1522
// Get a session from the API.
1623
sessionPromise = SessionDataService.create().then(
1724
function (session) {
@@ -36,6 +43,16 @@
3643
return SessionDataService.get(session.Guid).then(
3744
function (sessionUpdate) {
3845

46+
// Do we need to stop refreshing?
47+
if (sessionUpdate
48+
&& sessionUpdate.Status
49+
&& sessionUpdate.Status === 2) {
50+
51+
// Complete, no need to continue refreshing.
52+
$interval.cancel(sessionRefreshInterval);
53+
}
54+
55+
// Replace current session data.
3956
replace(sessionObject, sessionUpdate);
4057

4158
return sessionObject;
@@ -51,7 +68,6 @@
5168
function (session) {
5269

5370
// Get session summary.
54-
console.log('GetSummary: ' + session.Guid);
5571
return SessionDataService.summary(session.Guid);
5672
});
5773
}

PolyDeploy/Clients/Deploy/src/js/templates/result.html

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ <h2>Installing</h2>
1919
<h4>{{ currentStatus(session) }}</h4>
2020
<!-- /Current -->
2121

22+
<button
23+
type="button"
24+
class="btn btn-primary"
25+
ng-disabled="!isComplete()"
26+
ng-click="restart()">New Session</button>
27+
2228
<div class="row">
2329

2430
<!-- Packages -->

0 commit comments

Comments
 (0)