Skip to content

Commit

Permalink
deployment flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kostat committed Jan 13, 2016
1 parent af2fe81 commit d7c602e
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
if (response instanceof Array)
invokeCallback(response);
else
response.then(invokeCallback);
response.then(invokeCallback, invokeCallback);
}

function handleTimeout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ angular.module('umbraco.mocks').
return [200, testId, null];
});
}

function deploy(method, url, data, headers) {
if (!mocksUtils.checkAuth()) {
return $.when([401, null, null]);
}

return $.ajax({
url: mocksUtils.remoteBaseUrl + "run/deploy",
type: 'POST'
}).then(function () {
return [200, null, null];
}, function(failure) {
return [failure.status, failure.responseText, null];
});
}

function go(method, url, data, headers) {
if (!mocksUtils.checkAuth()) {
Expand Down Expand Up @@ -283,7 +298,11 @@ angular.module('umbraco.mocks').
.respond(returnRuntimeParameters);

$httpBackend
.whenPOST(mocksUtils.urlRegex('/umbraco/UmbracoApi/Media/Run'))
.whenPOST(mocksUtils.urlRegex('/umbraco/UmbracoApi/Media/Run/Deploy'))
.respond(deploy);

$httpBackend
.whenPOST(mocksUtils.urlRegex('/umbraco/UmbracoApi/Media/Run/Start'))
.respond(go);

$httpBackend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ angular.module('umbraco.mocks').
"buttons_relations": "Edit relations",
"buttons_save": "Save",
"buttons_test": "Test",
"buttons_deploy": "Start",
"buttons_deploy": "Deploy & Start",
"buttons_restart": "Start",
"buttons_stop": "Stop",
"buttons_saveAndPublish": "Save and publish",
Expand Down
21 changes: 12 additions & 9 deletions src/Umbraco.Web.UI.Client/src/common/resources/deploy.resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ function runResource($q, $http, umbDataFormatter, umbRequestHelper) {
});
},
deploy: function (properties) {
return umbRequestHelper.resourcePromise(
$http.post(
return $http.post(
umbRequestHelper.getApiUrl(
"mediaApiBaseUrl",
"Run",
[])),
'Failed to run test');
"Run/Deploy",
[]));
},
start: function (properties) {
return $http.post(
umbRequestHelper.getApiUrl(
"mediaApiBaseUrl",
"Run/Start",
[]));
},
getDevContent: function () {
var content = {
Expand Down Expand Up @@ -175,15 +180,13 @@ function runResource($q, $http, umbDataFormatter, umbRequestHelper) {
},
test: function (seconds) {

return umbRequestHelper.resourcePromise(
$http.post(
return $http.post(
umbRequestHelper.getApiUrl(
"mediaApiBaseUrl",
"Test",
[
{ seconds: seconds }
])),
'Failed to run test');
]));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ function StatusController($scope, mocksUtils) {
url: mocksUtils.remoteBaseUrl + "job/status",
type: 'GET'
}).then(function (data) {
$scope.status = data;
$scope.$root.status = data;
});

$scope.status = "...";
$scope.$root.status = "...";

$scope.$root.$on("JOB-STATUS", function(e, status) {
$scope.$root.status = status;
});

}
//register it
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.UI.Client/src/less/alerts.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.alert h4,
.alert a {
// Specified for the h4 to prevent conflicts of changing @headingsColor
color: @warningText;
// color: @warningText;
}
.alert h4 {
margin: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div ng-controller="Umbraco.Notifications.ConfirmRouteChangeController">
<h4>You have unsaved changes</h4>
<p>Are you sure you want to navigate away from this page? - you have unsaved changes</p>

<!--<p>Are you sure you want to navigate away from this page? - you have unsaved changes</p>-->
<br/>
<button class="btn btn-warning" ng-click="discard(notification)">Discard changes</button>
<button class="btn" ng-click="stay(notification)">Stay</button>
<button class="btn btn-link" ng-click="stay(notification)">Cancel</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//used for the media picker dialog
angular.module("umbraco").controller("Umbraco.Notifications.DeployErrorController",
function ($scope, $location, $log, notificationsService) {

$scope.close = function(not){
notificationsService.remove(not);
};

$scope.link = function(target, not){
notificationsService.remove(not);
$location.path(target);
};

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div ng-controller="Umbraco.Notifications.DeployErrorController">
<h3>{{notification.args.message}}</h3>
<h4><a ng-click="link('run/run/edit/test', notification)" href="#" prevent-default>Test</a> job before deployment</h4>
<br/>
<br/>
<button class="btn btn-link" ng-click="close(notification)">Cancel</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
localize="placeholder"
placeholder="@placeholders_search"
ng-keydown="navigateResults($event)"/> -->
<h1 class="headline">Job Status: {{status}}</h3>
<h1 class="headline">Job Status: <strong>{{$root.status}}</strong></h3>

</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function CodeEditorController($scope, $element, assetsService, dialogService, $t
.then(function () {

var editor = ace.edit($element[0]);
editor.$blockScrolling = Infinity;
if ($scope.model.value) {
editor.getSession().setValue($scope.model.value);

Expand Down
27 changes: 18 additions & 9 deletions src/Umbraco.Web.UI.Client/src/views/run/deploy.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @name Umbraco.Editors.Content.EditController
* @function
*/
function RunDeployController($scope, $element, $routeParams, deployResource, notificationsService, serverValidationManager, contentEditingHelper, editorState, navigationService, formHelper) {
function RunDeployController($scope, $element, $routeParams, deployResource, notificationsService, serverValidationManager, contentEditingHelper, editorState, navigationService, formHelper, $location) {

function init(content) {
editorState.set($scope.content);
Expand Down Expand Up @@ -34,7 +34,7 @@ function RunDeployController($scope, $element, $routeParams, deployResource, not

$scope.busy = true;

deployResource.saveDeployContent($scope.content).then(function () {
return deployResource.saveDeployContent($scope.content).then(function () {
formHelper.resetForm({ scope: $scope });
}).always(function () {
$scope.busy = false;
Expand All @@ -43,15 +43,24 @@ function RunDeployController($scope, $element, $routeParams, deployResource, not

$scope.deploy = function () {

if ($scope.busy)
return;

$scope.busy = true;
this.save().then(function () {

deployResource.deploy().then(function (runId) {
$scope.busy = true;

}).always(function () {
$scope.busy = false;
deployResource.deploy().success(function () {
$scope.$root.$emit("JOB-STATUS", "Stopped");
return deployResource.start().then(function () {
$scope.$root.$emit("JOB-STATUS", "Started");
$location.path("run/run/production/production");
});
}).error(function (failure) {
if (!notificationsService.hasView()) {
var msg = { view: "deployerror", args: { message: failure } };
notificationsService.add(msg);
}
}).always(function () {
$scope.busy = false;
});
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.UI.Client/src/views/run/deploy.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1>{{content.name}}</h1>
</div>
<div class="btn-group" style="margin-left:50px">
<button type="submit" class="btn btn-success">
<localize key="buttons_deploy">Start</localize>
<localize key="buttons_deploy">Deploy & Start</localize>
</button>
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions src/Umbraco.Web.UI.Client/src/views/run/production.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<umb-header tabs="content.tabs">

<div class="umb-headline-editor-wrapper span12">
<h1>{{content.name}}</h1>
<h1>Production</h1>
</div>
<!--<div class="span7">
<umb-content-name placeholder="@placeholders_entername"
Expand All @@ -29,7 +29,9 @@ <h1>{{content.name}}</h1>

</umb-header>

<umb-tab-view>
<umb-tab-view ng-switch="$root.status">
<h3 style="margin-left:30px" ng-switch-when="New">Job is not <a href="#/run/run/deploy/deploy">deployed</a></h3>
<div ng-switch-default>
<umb-tab id="tab{{tab.id}}" rel="{{tab.id}}" ng-repeat="tab in content.tabs">
<div class="umb-pane">
<umb-property property="property"
Expand Down Expand Up @@ -58,8 +60,7 @@ <h1>{{content.name}}</h1>
</div>

</div>
</umb-tab>

</umb-tab></div>
</umb-tab-view>
</umb-panel>
</form>

0 comments on commit d7c602e

Please sign in to comment.