Skip to content

Commit

Permalink
[DEVEXP-457] Create application from source. Includes changes from jw…
Browse files Browse the repository at this point in the history
…forres, cewong, sgoodwin
  • Loading branch information
jcantrill committed Apr 10, 2015
1 parent 2401c42 commit bb87590
Show file tree
Hide file tree
Showing 57 changed files with 3,975 additions and 385 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/openshift.local.*
/.project
/.vagrant
/assets/nbproject
/examples/sample-app/openshift.local.*
/examples/sample-app/logs/openshift.log
*.swp
Expand Down
14 changes: 13 additions & 1 deletion assets/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@
<script src="scripts/services/userstore.js"></script>
<script src="scripts/services/auth.js"></script>
<script src="scripts/services/data.js"></script>
<script src="scripts/services/applicationGenerator.js"></script>
<script src="scripts/services/login.js"></script>
<script src="scripts/services/logout.js"></script>
<script src="scripts/services/navigate.js"></script>
<script src="scripts/services/nameGenerator.js"></script>
<script src="scripts/services/tasks.js"></script>
<script src="scripts/services/notification.js"></script>
<script src="scripts/controllers/projects.js"></script>
Expand All @@ -133,14 +136,23 @@
<script src="scripts/controllers/images.js"></script>
<script src="scripts/controllers/deployments.js"></script>
<script src="scripts/controllers/services.js"></script>
<script src="scripts/controllers/create/createFromImage.js"></script>
<script src="scripts/controllers/newfromtemplate.js"></script>
<script src="scripts/controllers/labels.js"></script>
<script src="scripts/controllers/tasks.js"></script>
<script src="scripts/controllers/util/oauth.js"></script>
<script src="scripts/controllers/util/error.js"></script>
<script src="scripts/controllers/util/logout.js"></script>
<script src="scripts/controllers/catalog.js"></script>
<script src="scripts/controllers/catalog/templates.js"></script>
<script src="scripts/controllers/catalog/images.js"></script>
<script src="scripts/controllers/create.js"></script>
<script src="scripts/directives/date.js"></script>
<script src="scripts/directives/oscFileInput.js"></script>
<script src="scripts/directives/oscFormSection.js"></script>
<script src="scripts/directives/oscImageSummary.js"></script>
<script src="scripts/directives/oscKeyValues.js"></script>
<script src="scripts/directives/oscResourceNameValidator.js"></script>
<script src="scripts/directives/oscRouting.js"></script>
<script src="scripts/directives/resources.js"></script>
<script src="scripts/directives/nav.js"></script>
<script src="scripts/directives/alerts.js"></script>
Expand Down
13 changes: 11 additions & 2 deletions assets/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,21 @@ angular
.when('/project/:project/browse/services', {
templateUrl: 'views/services.html'
})
.when('/project/:project/catalog', {
templateUrl: 'views/catalog.html'
.when('/project/:project/catalog/templates', {
templateUrl: 'views/catalog/templates.html'
})
.when('/project/:project/catalog/images', {
templateUrl: 'views/catalog/images.html'
})
.when('/project/:project/create', {
templateUrl: 'views/create.html'
})
.when('/project/:project/create/fromtemplate', {
templateUrl: 'views/newfromtemplate.html'
})
.when('/project/:project/create/fromimage', {
templateUrl: 'views/create/fromimage.html'
})
.when('/oauth', {
templateUrl: 'views/util/oauth.html',
controller: 'OAuthController'
Expand Down
78 changes: 78 additions & 0 deletions assets/app/scripts/controllers/catalog/images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'use strict';

/**
* @ngdoc function
* @name openshiftConsole.controller:PodsController
* @description
* # ProjectController
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('CatalogImagesController', function ($scope, DataService, $filter, LabelFilter, imageEnvFilter, $routeParams, Logger) {
$scope.projectImageRepos = {};
$scope.openshiftImageRepos = {};
$scope.builders = [];
$scope.images = [];
$scope.sourceURL = $routeParams.builderfor;

var imagesForRepos = function(imageRepos, scope) {
angular.forEach(imageRepos, function(imageRepo) {
if (imageRepo.status) {
angular.forEach(imageRepo.status.tags, function(tag) {
var imageRepoTag = tag.tag;
var image = {
imageRepo: imageRepo,
imageRepoTag: imageRepoTag,
name: imageRepo.metadata.name + ":" + imageRepoTag
};
$scope.images.push(image);

var categoryTags = [];
if(imageRepo.spec.tags){
angular.forEach(imageRepo.spec.tags, function(imageTags){
if(imageTags.annotations && imageTags.annotations.tags){
categoryTags = imageTags.annotations.tags.split(/\s*,\s*/);
}
if (categoryTags.indexOf("builder") >= 0) {
$scope.builders.push(image);
}
});
}
});
Logger.info("builders", $scope.builders);
}
});
};

DataService.list("imageStreams", $scope, function(imageRepos) {
$scope.projectImageRepos = imageRepos.by("metadata.name");
imagesForRepos($scope.projectImageRepos, $scope);

Logger.info("project image repos", $scope.projectImageRepos);
});

DataService.list("imageStreams", {namespace: "openshift"}, function(imageRepos) {
$scope.openshiftImageRepos = imageRepos.by("metadata.name");
imagesForRepos($scope.openshiftImageRepos, {namespace: "openshift"});

Logger.info("openshift image repos", $scope.openshiftImageRepos);
});


var templatesByTag = function() {
$scope.templatesByTag = {};
angular.forEach($scope.templates, function(template) {
if (template.metadata.annotations && template.metadata.annotations.tags) {
var tags = template.metadata.annotations.tags.split(",");
angular.forEach(tags, function(tag){
tag = $.trim(tag);
// not doing this as a map since we are dealing with things across namespaces that could have collisions on name
$scope.templatesByTag[tag] = $scope.templatesByTag[tag] || [];
$scope.templatesByTag[tag].push(template);
});
}
});

Logger.info("templatesByTag", $scope.templatesByTag);
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ angular.module('openshiftConsole')
$scope.templatesByTag = {};
$scope.templates = [];

$scope.instantApps = [];

DataService.list("templates", $scope, function(templates) {
$scope.projectTemplates = templates.by("metadata.name");
allTemplates();
Expand Down
62 changes: 62 additions & 0 deletions assets/app/scripts/controllers/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

/**
* @ngdoc function
* @name openshiftConsole.controller:PodsController
* @description
* # ProjectController
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('CreateController', function ($scope, DataService, $filter, LabelFilter, $location, Logger) {
$scope.projectTemplates = {};
$scope.openshiftTemplates = {};

$scope.templatesByTag = {};

$scope.sourceURLPattern = /^(ftp|http|https|git):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;

DataService.list("templates", $scope, function(templates) {
$scope.projectTemplates = templates.by("metadata.name");
templatesByTag();
Logger.info("project templates", $scope.projectTemplates);
});

DataService.list("templates", {namespace: "openshift"}, function(templates) {
$scope.openshiftTemplates = templates.by("metadata.name");
templatesByTag();
Logger.info("openshift templates", $scope.openshiftTemplates);
});

var templatesByTag = function() {
$scope.templatesByTag = {};
var fn = function(template) {
if (template.metadata.annotations && template.metadata.annotations.tags) {
var tags = template.metadata.annotations.tags.split(",");
angular.forEach(tags, function(tag){
tag = $.trim(tag);
// not doing this as a map since we are dealing with things across namespaces that could have collisions on name
$scope.templatesByTag[tag] = $scope.templatesByTag[tag] || [];
$scope.templatesByTag[tag].push(template);
});
}
};

angular.forEach($scope.projectTemplates, fn);
angular.forEach($scope.openshiftTemplates, fn);

Logger.info("templatesByTag", $scope.templatesByTag);
};

$scope.createFromSource = function() {
if($scope.from_source_form.$valid) {
var createURI = URI.expand("/project/{project}/catalog/images{?q*}", {
project: $scope.projectName,
q: {
builderfor: $scope.from_source_url
}
});
$location.url(createURI.toString());
}
};
});
Loading

0 comments on commit bb87590

Please sign in to comment.