2014-08-24 23:00:05 +02:00
|
|
|
define([
|
2014-08-25 01:02:34 +02:00
|
|
|
'app',
|
|
|
|
'factories/playbook'
|
2014-08-24 23:00:05 +02:00
|
|
|
], function(app) {
|
2014-08-25 01:02:34 +02:00
|
|
|
app.config(function($stateProvider, $couchPotatoProvider) {
|
2014-08-24 23:00:05 +02:00
|
|
|
$stateProvider
|
|
|
|
.state('addPlaybook', {
|
|
|
|
url: '/add',
|
|
|
|
pageTitle: 'Add Playbook',
|
2014-08-25 01:02:34 +02:00
|
|
|
templateUrl: "/view/playbook/add",
|
|
|
|
controller: 'AddPlaybookCtrl',
|
|
|
|
resolve: {
|
|
|
|
dummy: $couchPotatoProvider.resolve(['controllers/playbook/add'])
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
.state('playbook', {
|
|
|
|
abstract: true,
|
|
|
|
url: '/playbook/:playbook_id',
|
2014-08-25 21:41:05 +02:00
|
|
|
templateUrl: '/view/playbook/view',
|
2014-08-25 01:02:34 +02:00
|
|
|
controller: function ($scope, playbook) {
|
|
|
|
$scope.playbook = playbook;
|
|
|
|
},
|
|
|
|
resolve: {
|
2014-08-25 01:24:40 +02:00
|
|
|
playbook: function (Playbook, $stateParams, $q, $state) {
|
2014-08-25 01:02:34 +02:00
|
|
|
var deferred = $q.defer();
|
|
|
|
|
|
|
|
var playbook = new Playbook($stateParams.playbook_id, function (err, errStatus) {
|
2014-08-25 01:24:40 +02:00
|
|
|
if (err && errStatus == 404) {
|
|
|
|
$state.transitionTo('homepage');
|
|
|
|
return deferred.reject();
|
|
|
|
}
|
|
|
|
|
2014-08-25 01:02:34 +02:00
|
|
|
deferred.resolve(playbook);
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
.state('playbook.view', {
|
|
|
|
url: '/',
|
|
|
|
controller: 'PlaybookCtrl',
|
|
|
|
resolve: {
|
2014-08-25 21:41:05 +02:00
|
|
|
dummy: $couchPotatoProvider.resolve(['controllers/playbook/playbook',
|
|
|
|
'controllers/host/hosts'])
|
|
|
|
},
|
|
|
|
views: {
|
|
|
|
tasks: {
|
|
|
|
templateUrl: '/view/task/tasks'
|
|
|
|
},
|
|
|
|
jobs: {
|
|
|
|
templateUrl: '/view/job/jobs'
|
|
|
|
},
|
|
|
|
hosts: {
|
|
|
|
templateUrl: '/view/host/hosts',
|
|
|
|
controller: 'HostsCtrl'
|
|
|
|
}
|
2014-08-25 01:02:34 +02:00
|
|
|
}
|
2014-08-24 23:00:05 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|