Skip to content

Commit

Permalink
- update blueprints-catalog plugin version;
Browse files Browse the repository at this point in the history
- exclude dist folder of the plugin from .gitignore;
  • Loading branch information
adubouski committed Oct 2, 2015
1 parent 37ef624 commit 3099b49
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,6 +6,7 @@
source/_site/*
Gemfile.lock
dist
!source/bower_components/blueprints-catalog/dist
node_modules
.sass-cache
_site/*
Expand Down
2 changes: 1 addition & 1 deletion source/bower.json
Expand Up @@ -16,6 +16,6 @@
"dependencies": {
"angular": "~1.3.1",
"cloudify-widget-angular-controller": "~0.0.0",
"blueprints-catalog": "git@github.com:adubovsky/blueprints-catalog.git#v0.0.1"
"blueprints-catalog": "git@github.com:adubovsky/blueprints-catalog.git#v0.0.2"
}
}
13 changes: 6 additions & 7 deletions source/bower_components/blueprints-catalog/.bower.json
@@ -1,20 +1,19 @@
{
"name": "blueprints-catalog",
"description": "AngularJS directive that displays the list of repositories containing blueprints that are ready to deploy.",
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://github.com/adubovsky/blueprints-catalog",
"private": false,
"dependencies": {
"angular": ">= 1.2.0"
},
"_release": "0.0.1",
"_release": "0.0.2",
"_resolution": {
"type": "version",
"tag": "v0.0.1",
"commit": "579e6b5a3c5de06793823f7c781871966a1a7e5a"
"tag": "v0.0.2",
"commit": "cf805d7f9e62958d2015c58bad7888677d4419ad"
},
"_source": "git@github.com:adubovsky/blueprints-catalog.git",
"_target": "v0.0.1",
"_originalSource": "git@github.com:adubovsky/blueprints-catalog.git",
"_direct": true
"_target": "v0.0.2",
"_originalSource": "git@github.com:adubovsky/blueprints-catalog.git"
}
9 changes: 6 additions & 3 deletions source/bower_components/blueprints-catalog/README.md
Expand Up @@ -30,12 +30,13 @@ If you would like to use the widget on the page without AngularJS, you would nee

## Add Widget to the Page

Add the following markup to the your page to initialize widget:
Add the following markup to the your page to initialize widget (add the `ng-app="blueprintingCatalogApp"` attribute to any parent element if you had not used AngularJS on the page):
```html
<div blueprinting-catalog
data-catalog-list-title="Cloudify Examples"
data-catalog-list-description='These are example blueprint archives that are ready to deploy. Click on "Upload to Manager" to publish to an existing manager and create a deployment now, or you can download and customize to your needs. Click on the "Source" to see the source at GitHub. Click on the name of the blueprint for more information about what it does.'
data-catalog-github-query="/search/repositories?q=*-example+user:cloudify-cosmo">
data-catalog-github-query="/search/repositories?q=*-example+user:cloudify-examples"
data-catalog-default-manager="https://getcloudify.org">
</div>
```
The following options are supported:
Expand All @@ -46,6 +47,8 @@ The following options are supported:

`data-catalog-github-query` - Defines the github search query to be used to retrieve the repositories list (_Default:_ `'/search/repositories?q=*-example+user:cloudify-cosmo'`)

`data-catalog-default-manager` - Defines the default value for "Manager Endpoint" field (_Default:_ `''`)

## Styling

The widget contains only the basic set of css rules so you can easly change the widget look & feel using css.
The widget contains only the basic set of css rules so you can easily change the widget look & feel using css.
@@ -0,0 +1,8 @@
'use strict';

angular.module('blueprintingCatalogApp', ['blueprintingCatalogWidget'])

.config(['$compileProvider', '$logProvider', function ($compileProvider, $logProvider) {
$compileProvider.debugInfoEnabled(false);
$logProvider.debugEnabled(false);
}]);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,71 @@
.bl-catalog {
margin-bottom: 30px;
}

.bl-catalog table {
width: 100%;
}

.bl-catalog ul {
display: inline;
list-style-type: none;
margin: 0;
}

.bl-catalog ul li {
display: inline;
padding-right: 10px;
}

.bl-catalog .action-links {
float: right;
}

.bl-catalog .to-list {
float: left;
}

.bl-catalog .to-list:before {
content: '\3008';
}

.bl-catalog .upload-backdrop {
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
opacity: 0.5;
z-index: 3000;
background-color: #000;
}

.bl-catalog .upload-popup {
position: fixed;
top: 30px;
left: 0;
right: 0;
width: 400px;
margin: auto;
z-index: 3001;
background-color: #fff;
border-radius: 3px;
padding: 10px 15px;
overflow: hidden;
}

.bl-catalog .upload-popup .close-popup {
float: right;
}

.bl-catalog .upload-popup .upload-content form label {
display: block;
}

.bl-catalog .upload-popup .upload-content form select {
width: 314px;
}

.bl-catalog .upload-popup .upload-content form input {
width: 300px;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,207 @@
'use strict';

(function () {
var catalog = angular.module('blueprintingCatalogWidget', []);

var LOG_TAG = 'BLUEPRINTING CATALOG WIDGET';
var defaultError = 'unexpected error occurred';

var endpoint = 'https://api.github.com';
var githubQuery = '/search/repositories?q=*-example+user:cloudify-examples';
var blueprintsEndpoint = '';

catalog.directive('blueprintingCatalog', ['Github', 'CloudifyManager', 'CatalogHelper', '$log', function (Github, CloudifyManager, CatalogHelper, $log) {

return {
restrict: 'A',
scope: {
githubQuery: '@catalogGithubQuery',
listTitle: '@catalogListTitle',
listDescription: '@catalogListDescription',
blueprintsEndpoint: '@catalogDefaultManager'
},
templateUrl: 'blueprinting_catalog_widget_tpl.html',
link: function ($scope) {
if ($scope.githubQuery) {
githubQuery = $scope.githubQuery;

$log.debug(LOG_TAG, 'default search query was overridden with', githubQuery);
}
if ($scope.blueprintsEndpoint) {
blueprintsEndpoint = $scope.blueprintsEndpoint;

$log.debug(LOG_TAG, 'default manager endpoint was overridden with', blueprintsEndpoint);
}

$scope.loading = true;
Github.getRepositories().then(function (response) {
$log.debug(LOG_TAG, 'fetched repos', response);

$scope.repos = response.data && response.data.items || [];
}).finally(function () {
$scope.loading = false;
});

$scope.showDetails = function (repo) {
$log.debug(LOG_TAG, 'show details', repo);

CatalogHelper.fillTags(repo);
CatalogHelper.fillReadme(repo);

$scope.currentRepo = repo;
};

$scope.showList = function () {
$scope.currentRepo = undefined;
};

$scope.showUpload = function (repo) {
$log.debug(LOG_TAG, 'show upload', repo);

CatalogHelper.fillTags(repo);
CatalogHelper.fillBranches(repo);

$scope.managerEndpoint = blueprintsEndpoint;
$scope.blueprint = {
path: 'blueprint.yaml',
id: repo.name,
url: repo.html_url + '/archive/' + repo.default_branch + '.zip'
};

$scope.uploadRepo = repo;
};

$scope.closeUpload = function () {
$scope.uploadRepo = undefined;
};

$scope.uploadBlueprint = function () {
$log.debug(LOG_TAG, 'do upload');

if ($scope.blueprintForm.$valid) {

$scope.processing = true;
$scope.error = undefined;
CloudifyManager.upload($scope.managerEndpoint, $scope.blueprint)
.then(function () {
$scope.uploadRepo = undefined;
}, function (response) {
$scope.error = CatalogHelper.getErrorFromResponse(response);
})
.finally(function () {
$scope.processing = false;
});
}
};
}
};

}]);

catalog.factory('CatalogHelper', ['Github', '$sce', function (Github, $sce) {

return {
fillTags: function (repo) {
if (!repo.tagsList) {
Github.getTags(repo.url).then(function (response) {
repo.tagsList = response.data || [];
}, function () {
repo.tagsList = [];
});
}
},
fillBranches: function (repo) {
if (!repo.branchesList) {
Github.getBranches(repo.url).then(function (response) {
repo.branchesList = response.data || [];
}, function () {
repo.branchesList = [];
});
}
},
fillReadme: function (repo) {
if (!repo.readmeContent) {
Github.getReadme(repo.url).then(function (response) {
repo.readmeContent = $sce.trustAsHtml(response.data || 'No Readme File');
}, function () {
repo.readmeContent = $sce.trustAsHtml('No Readme File');
});
}
},

getErrorFromResponse: function (response) {
if (response && response.data) {
if (typeof response.data === 'string') {
return response.data;
} else {
return response.data.message || defaultError;
}
} else {
return defaultError;
}
}
};
}]);

catalog.factory('Github', ['$http', function ($http) {

return {
getRepositories: function () {
return $http({
method: 'GET',
url: endpoint + githubQuery
});
},
getTags: function (repo_url) {
return $http({
method: 'GET',
url: repo_url + '/tags'
});
},
getBranches: function (repo_url) {
return $http({
method: 'GET',
url: repo_url + '/branches'
});
},
getReadme: function (repo_url) {
return $http({
method: 'GET',
url: repo_url + '/readme',
headers: {
'Accept': 'application/vnd.github.html+json'
}
});
}
};
}]);

catalog.factory('CloudifyManager', ['$http', function ($http) {

return {
upload: function doUpload(endpoint, blueprint) {
var queryParams = [], query;
if (blueprint.path) {
queryParams.push('application_file_name=' + encodeURIComponent(blueprint.path));
}
if (blueprint.url) {
queryParams.push('blueprint_archive_url=' + encodeURIComponent(blueprint.url));
}
query = queryParams.length ? ('?' + queryParams.join('&')) : '';

return $http({
method: 'PUT',
url: endpoint + '/blueprints/' + encodeURIComponent(blueprint.id) + query
});
}
};
}]);
})();
angular.module('blueprintingCatalogWidget').run(['$templateCache', function($templateCache) {
'use strict';

$templateCache.put('blueprinting_catalog_widget_tpl.html',
"<section class=\"bl-catalog\"> <div ng-show=\"!currentRepo\"> <div> <h1>{{::listTitle}}</h1> <p>{{::listDescription}}</p> </div> <div> <table> <thead> <tr> <th>Name</th> <th>Description</th> <th>Source</th> <th>Action</th> </tr> </thead> <tr ng-show=\"!loading && !repos.length\"> <td colspan=\"4\">No Data Found</td> </tr> <tr ng-show=\"loading\"> <td colspan=\"4\">Loading...</td> </tr> <tr ng-repeat=\"repo in repos\"> <td> <a href ng-click=\"showDetails(repo);\">{{::repo.name}}</a> </td> <td> {{::repo.description}} </td> <td> <a href=\"{{::repo.html_url}}\" target=\"_tab_{{::repo.id}}\">Source</a> </td> <td> <a href ng-click=\"showUpload(repo);\">Upload to Manager</a> </td> </tr> </table> </div> </div> <div ng-show=\"currentRepo\"> <div> <a href ng-click=\"showList();\" class=\"to-list\">Back</a> <h1>{{currentRepo.name}}</h1> <ul class=\"action-links\"> <li><a href=\"{{currentRepo.html_url}}\" target=\"_tab_{{currentRepo.id}}\">Source</a></li> <li><a href=\"{{currentRepo.html_url}}/archive/{{currentRepo.default_branch}}.zip\">Download</a></li> <li><a href ng-click=\"showUpload(currentRepo);\">Upload to Manager</a></li> </ul> </div> <section> <div> README <hr> </div> <div ng-bind-html=\"currentRepo.readmeContent\"></div> </section> <section> <label>Available Tags:</label> <ul> <li ng-show=\"!currentRepo.tagsList.length\">(None)</li> <li ng-repeat=\"tag in currentRepo.tagsList\"> <span class=\"label\">{{tag.name}}</span> </li> </ul> </section> </div> <div ng-show=\"uploadRepo\" class=\"upload-backdrop\"></div> <div ng-show=\"uploadRepo\" class=\"upload-popup\"> <div class=\"upload-content\"> <div class=\"upload-header\"> <a href ng-click=\"closeUpload();\" class=\"close-popup\">&times;</a> </div> <div class=\"upload-content\"> <form novalidate name=\"blueprintForm\"> <label> Blueprint Name<br> <input type=\"text\" ng-model=\"blueprint.id\" placeholder=\"enter blueprint name\" required> </label> <label> Manager Endpoint URL<br> <input type=\"text\" ng-model=\"managerEndpoint\" placeholder=\"enter manager url\" required> </label> <label> Blueprint File Name<br> <input type=\"text\" ng-model=\"blueprint.path\" placeholder=\"enter blueprint file name\" required> </label> <label> Source<br> <select ng-model=\"blueprint.url\"> <optgroup label=\"Branches\"> <option ng-repeat=\"b in uploadRepo.branchesList\" value=\"{{uploadRepo.html_url}}/archive/{{b.name}}.zip\" ng-selected=\"b.name === uploadRepo.default_branch\"> {{b.name}} </option> </optgroup> <optgroup label=\"Tags\"> <option ng-repeat=\"tag in uploadRepo.tagsList\" value=\"{{uploadRepo.html_url}}/archive/{{tag.name}}.zip\"> {{tag.name}} </option> </optgroup> </select> </label> <div class=\"alert alert-error\">{{error}}</div> </form> </div> <div class=\"upload-buttons\"> <button class=\"btn btn-default\" ng-disabled=\"processing\" ng-click=\"closeUpload();\">Cancel</button> <button class=\"btn btn-primary\" ng-disabled=\"processing || blueprintForm.$invalid\" ng-click=\"uploadBlueprint();\"> <span ng-show=\"processing\">Uploading...</span> <span ng-hide=\"processing\">Upload</span> </button> </div> </div> </div> </section>"
);

}]);

0 comments on commit 3099b49

Please sign in to comment.