Initial checkin

This adds most of the files from app-catalog-ui into this common
location so it can be shared soon with app-catalog-ui and
apps.openstack.org. Its currently only usable by apps.openstack.org
and will need further work to be shared. But its a start.

Change-Id: I63bff3be6180ff12ab0055c15ff04fd4a7631684
This commit is contained in:
Kevin Fox 2015-11-09 16:04:47 -08:00
parent 07b5a5b324
commit 601ce85d38
20 changed files with 1159 additions and 0 deletions

180
LICENSE Normal file
View File

@ -0,0 +1,180 @@
Some icons from here:
http://jxnblk.com/ - License: MIT
The rest is Apache 2.0:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

8
MANIFEST.in Normal file
View File

@ -0,0 +1,8 @@
include AUTHORS
include ChangeLog
exclude .gitignore
exclude .gitreview
recursive-include xstatic/pkg/app_catalog_common *
global-exclude *.pyc

23
setup.cfg Normal file
View File

@ -0,0 +1,23 @@
[metadata]
name = app-catalog-common
description = 'OpenStack Application Catalog Common code for the OpenStack Dashboard',
author = OpenStack Foundation
author_email = openstack-dev@lists.openstack.org
description-file = README.rst
classifier =
Development Status :: 4 - Beta
Environment :: OpenStack
Framework :: Django
Intended Audience :: Developers
Intended Audience :: System Administrators
Intended Audience :: Information Technology
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Topic :: Internet :: WWW/HTTP
[files]
packages =
xstatic

21
setup.py Normal file
View File

@ -0,0 +1,21 @@
#! /usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from setuptools import setup
setup(
setup_requires=['pbr>=1.3'],
pbr=True,
)

1
xstatic/__init__.py Executable file
View File

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

1
xstatic/pkg/__init__.py Executable file
View File

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -0,0 +1,49 @@
"""
XStatic resource package
See package 'XStatic' for documentation and basic tools.
"""
DISPLAY_NAME = 'app-catalog-common' # official name, upper/lowercase allowed, no spaces
PACKAGE_NAME = 'app-catalog-common' # name used for PyPi
NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar')
# please use a all-lowercase valid python
# package name
VERSION = '0.0.1' # version of the packaged files, please use the upstream
# version number
BUILD = '1' # our package build number, so we can release new builds
# with fixes for xstatic stuff.
PACKAGE_VERSION = VERSION + '.' + BUILD # version used for PyPi
DESCRIPTION = "%s %s (XStatic packaging standard)" % (DISPLAY_NAME, VERSION)
PLATFORMS = 'any'
CLASSIFIERS = []
KEYWORDS = '%s xstatic' % NAME
# XStatic-* package maintainer:
MAINTAINER = 'Kevin Fox'
MAINTAINER_EMAIL = 'kevin@efox.cc'
# this refers to the project homepage of the stuff we packaged:
HOMEPAGE = 'https://apps.openstack.org'
# this refers to all files:
LICENSE = '(same as %s)' % DISPLAY_NAME
from os.path import join, dirname
BASE_DIR = join(dirname(__file__), 'data')
# linux package maintainers just can point to their file locations like this:
#BASE_DIR = '/usr/share/javascript/jquery'
LOCATIONS = {
# CDN locations (if no public CDN exists, use an empty dict)
# if value is a string, it is a base location, just append relative
# path/filename. if value is a dict, do another lookup using the
# relative path/filename you want.
# your relative path/filenames should usually be without version
# information, because either the base dir/url is exactly for this
# version or the mapping will care for accessing this version.
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

View File

@ -0,0 +1,47 @@
<div>
<dl class="dl-horizontal">
<dt>
<div style="
width:64px;
height:64px;
overflow: hidden;
">
<img style="
margin: {$ asset.icon.top/2 $}px 0px 0px {$ asset.icon.left/2 $}px;
height: {$ asset.icon.height/2 $}px;
" src="{$ asset.icon.url $}">
</div>
</dt>
<dd>
<div>{$ asset.name $}</div>
<div>{$ asset.provided_by.company $}</div>
<div ng-switch="appaction" style="float:right">
<div ng-switch-when='true' app-action ng-scope ng-init='extraclasses="btn-lg";installclasses="btn-primary";launchclasses="btn-success"'></div>
</div>
</dd>
<dt>License</dt>
<dd ng-switch="asset.license_url || '_undefined_'">
<div>{$ asset.license $}</div>
<a ng-switch-default class="btn btn-default btn-sm" target="_blank" href="{$ asset.license_url $}">License Details</a>
<div ng-switch-when="_undefined_"></div>
</dd>
<dt>Description</dt>
<dd>{$ asset.description $}</dd>
<dt ng-switch="asset.depends || '_undefined_'">
<div ng-switch-default>Dependencies</div>
<div ng-switch-when="_undefined_"></div>
</dt>
<dd ng-switch="asset.depends || '_undefined_'">
<div ng-switch-default>
<table>
<tr ng-repeat="dep in asset.depends">
<td>{$ dep.asset.name $}</td>
<td><div app-action ng-scope ng-init='extraclasses="btn-sm";no_launch=true;asset=dep.asset'></div></td>
</tr>
</table>
<div ng-switch-when="_undefined_"></div>
</dd>
</dl>
</div>

View File

@ -0,0 +1,51 @@
<div ng-switch="asset.disabled">
<div ng-switch-when="true">
<a ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Unsupported</a>
</div>
<div ng-switch-default ng-switch="asset.service.type">
<div ng-switch-when="heat" ng-switch="asset.validated">
<a ng-switch-default ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/}">Checking</a>
<a ng-switch-when="error" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Error</a>
<a ng-switch-when="unsupported" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Unsupported</a>
<div ng-switch-when="true" ng-switch="asset.service.environment || '_undefined_'">
<a ng-switch-when="_undefined_" ng-class="[extraclasses, launchclasses]" class="btn btn-default ajax-modal" href="{$ WEBROOT $}project/stacks/select_template?template_source=url&template_url={$ asset.attributes.url | encodeURIComponent $}">Launch</a>
<a ng-switch-default ng-class="[extraclasses, launchclasses]" class="btn btn-default ajax-modal" href="{$ WEBROOT $}project/stacks/select_template?template_source=url&template_url={$ asset.attributes.url | encodeURIComponent $}&environment_source=raw&environment_data={$ asset.service.environment | encodeURIComponent $}">Launch</a>
</div>
</div>
<div ng-switch-when="glance" ng-switch="asset.attributes.indirect_url || '_undefined_'">
<a ng-switch-default ng-class="[extraclasses, installclasses]" class="btn btn-default" target="_blank" href="{$ asset.attributes.indirect_url $}">Install Instructions</a>
<div ng-switch-when="_undefined_" ng-switch="asset.installed">
<a ng-switch-default ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Checking</a>
<a ng-switch-when="false" ng-class="[extraclasses, installclasses]" class="btn btn-default ajax-modal" href="{$ WEBROOT $}project/images/create/?name={$ asset.name | encodeURIComponent $}&source_type=url&image_url={$ asset.attributes.url | encodeURIComponent $}&disk_format={$ asset.service.disk_format $}&architecture={$ asset.service.architecture $}&minimum_disk={$ asset.service.min_disk $}&minimum_ram={$ asset.service.min_ram $}&description={$ asset.description $}">Install</a>
<div ng-switch-when="true" ng-switch="no_launch || '_undefined_'">
<a ng-switch-when="true" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Installed</a>
<a ng-switch-default ng-class="[extraclasses, launchclasses]" class="btn btn-default ajax-modal" href="{$ WEBROOT $}project/instances/launch?source_type=image_id&source_id={$ asset.installed_id $}">Launch</a>
</div>
</div>
</div>
<div ng-switch-when="murano" ng-switch="asset.has_murano">
<a ng-switch-when="false" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Unsupported</a>
<div ng-switch-when="true" ng-switch="asset.installed">
<a ng-switch-default ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Checking</a>
<a ng-switch-when="false" ng-class="[extraclasses, installclasses]" class="btn btn-default ajax-modal" href="{$ WEBROOT $}murano/packages/upload?repo_name={$ asset.service.package_name | encodeURIComponent $}&import_type=by_name">Install</a>
<div ng-switch-when="true" ng-switch="no_launch || '_undefined_'">
<a ng-switch-when="true" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Installed</a>
<a ng-switch-default ng-class="[extraclasses, launchclasses]" class="btn btn-default ajax-modal" href="{$ WEBROOT $}murano/catalog/quick-add/{$ asset.service.murano_id $}">Launch</a>
</div>
</div>
</div>
<div ng-switch-when="bundle" ng-switch="asset.service.murano_package_name || '_undefined_'">
<div ng-switch-when="_undefined_"></div>
<div ng-switch-default ng-switch="asset.has_murano">
<a ng-switch-when="false" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Unsupported</a>
<div ng-switch-when="true" ng-switch="asset.installed || '_undefined_'">
<a ng-switch-default ng-class="[extraclasses, installclasses] class="btn btn-default ajax-modal" href="{$ WEBROOT $}murano/packages/import_bundle?name={$ asset.service.murano_package_name | encodeURIComponent $}&import_type=by_repo">Install</a>
<a ng-switch-when="true" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Installed</a>
</div>
</div>
</div>
<div ng-switch-default>
<a ng-switch-when="false" ng-class="extraclasses" class="btn btn-default disabled ajax-modal" href="/">Unsupported</a>
</div>
</div>
</div>

View File

@ -0,0 +1,583 @@
/*
* Copyright 2015 IBM Corp.
* Copyright 2015 Kevin Fox.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function() {
'use strict';
angular
.module('horizon.dashboard.project.app_catalog', [])
.filter('encodeURIComponent', function() {
return window.encodeURIComponent;
}).directive('appAction', function () {
return {
restrict: 'EA',
templateUrl: STATIC_URL + 'lib/app-catalog-common/action.html'
};
}).directive('appCatalogMagicSearch', [
'horizon.framework.widgets.basePath',
appCatalogMagicSearchBar
]).controller('appCatalogTableCtrl', [
'$scope',
'$http',
'$timeout',
'$modal',
'horizon.framework.widgets.toast.service',
'appCatalogModel',
appCatalogTableCtrl
]).controller('appComponentCatalogTableCtrl', [
'$scope',
'$http',
'$timeout',
'$modal',
'horizon.framework.widgets.toast.service',
'appCatalogModel',
appComponentCatalogTableCtrl
]).service('appCatalogModel', [
'$http',
'$injector',
'horizon.app.core.openstack-service-api.heat',
'horizon.app.core.openstack-service-api.glance',
'horizon.app.core.openstack-service-api.serviceCatalog',
appCatalogModel
]).directive('stars', stars);
function appCatalogModel($http, $injector, heatAPI, glanceAPI, serviceCatalog) {
var $scope = this;
var callbacks = {
update: [],
error: [],
deprecated: [],
retired: []
};
this.assets = [];
this.assets_filtered = [];
//FIXME reduce duplication here....
this.supported_service_type_to_label = {
heat: 'Orchestration',
glance: 'Images',
murano: 'Murano'
};
this.service_filters = [
{id:'heat', name:'Orchestration'},
{id:'glance', name: 'Images'},
{id:'murano', name: 'Murano'}
];
this.service_filters_selections = {
'heat':false,
'glance':false,
'murano':false
};
var notifyUpdate = function() {
angular.forEach(callbacks.update, function(callback) {
callback();
});
};
var notifyError = function(message) {
angular.forEach(callbacks.error, function(callback) {
callback(message);
});
};
var notifyDeprecated = function(message) {
angular.forEach(callbacks.deprecated, function(callback) {
callback(message);
});
};
var notifyRetired = function() {
angular.forEach(callbacks.retired, function(callback) {
callback();
});
};
var muranoAPI;
$scope.has_murano = false;
$scope.selected_facets = [];
$scope.selected_text = "";
if ($injector.has('horizon.app.core.openstack-service-api.murano')) {
muranoAPI = $injector.get('horizon.app.core.openstack-service-api.murano');
$scope.has_murano = true;
}
//FIXME [{'name':'heat', 'type':'orchestration'}, {'name':'glance', 'type':'image'}]
serviceCatalog.get().then(function(catalog) {
angular.forEach(catalog, function(entry) {
if (entry.name in $scope.supported_service_type_to_label) {
$scope.service_filters_selections[entry.name] = true;
}
});
$scope.catalog = catalog;
$scope.update_assets_filtered();
});
this.update_assets_filtered = function() {
//FIXME this is not ideal...
var textSearchableFields = [
['name'],
['provided_by', 'name'],
['provided_by', 'company'],
['supported_by', 'name'],
['description'],
['license'],
['service', 'type'],
['service', 'container_format'],
['service', 'disk_format'],
['service', 'package_name'],
['service', 'murano_package_name']
];
$scope.assets_filtered.length = 0;
angular.forEach($scope.assets, function(asset) {
if ($scope.service_filters_selections[asset.service.type] == true ||
asset.service.type == 'bundle') {
var filteredOut = false;
angular.forEach(asset.depends, function(dep) {
if ($scope.service_filters_selections[dep.asset.service.type] == false) {
filteredOut = true;
}
});
if ($scope.selected_facets.length != 0) {
angular.forEach($scope.selected_facets, function(filter) {
var val = filter[0].split('.').reduce(function(obj,i) {return obj[i];}, asset);
if (val.toLowerCase().indexOf(filter[1].toLowerCase()) == -1) {
filteredOut = true;
}
});
}
if ($scope.selected_text != '') {
var found = false;
angular.forEach(textSearchableFields, function(field) {
try {
var val = field.reduce(function(obj,i) {return obj[i];}, asset);
if (val.toLowerCase().indexOf($scope.selected_text.toLowerCase()) != -1) {
found = true;
}
} catch (e) {}
});
if (!found) {
filteredOut = true;
}
}
if (!filteredOut) {
$scope.assets_filtered.push(asset);
}
}
});
var types = {};
angular.forEach($scope.assets_filtered, function(asset) {
types[asset.service.type] = true;
});
//FIXME dedup some of this later.
var map = {'heat': 'Orchestration', 'glance': 'Images'};
var options = [];
angular.forEach(types, function(type) {
if (type in map) {
options.push({'key':type, 'label':map[type]});
}
});
angular.forEach($scope.asset_filter_facets, function(facet) {
if (facet.name == 'service.type') {
//FIXME Doesn't seem to work currently
// facet['options'] = options;
}
});
notifyUpdate();
};
this.toggle_service_filter = function(serviceName) {
var value = $scope.service_filters_selections[serviceName];
if (value) {
value = false;
} else {
value = true;
}
$scope.service_filters_selections[serviceName] = value;
$scope.update_assets_filtered();
};
this.register_callback = function(type, callback) {
callbacks[type].push(callback);
};
var semver_compare = function(a, b) {
var v = a[0] - b[0]
if (v === 0) {
v = a[1] - b[1];
if (v === 0) {
v = a[2] - b[2];
}
}
return v;
};
$scope.eversion_check = function(asset, version) {
if (!( 'ever' in asset.service)) {
return true;
}
var matched = false;
angular.forEach(asset.service.ever, function(ever) {
var has_min = 'min' in ever;
var has_max = 'max' in ever;
if(has_max && has_min) {
if (semver_compare(ever.min, version) <= 0 &&
semver_compare(version, ever.max) <= 0) {
matched = true;
}
} else if (has_max) {
if (semver_compare(version, ever.max) <= 0) {
matched = true;
}
} else if (has_min) {
if (semver_compare(ever.min, version) <= 0) {
matched = true;
}
}
});
return matched;
};
this.init = function(appCatalogSettings) {
//FIXME move this to a test file.
// test_evars($scope);
var tver = appCatalogSettings.APP_CATALOG_VERSION.VER;
var defaultVersion = [2015, 2, 0]; //Mitaka
if (tver.indexOf('8.') === 0) {
defaultVersion = [2015,1,0]; //Liberty
}
var appCatalogUrl = appCatalogSettings.APP_CATALOG_URL;
$scope.heat_release = appCatalogSettings.HEAT_VERSION.REL;
$scope.heat_version = appCatalogSettings.HEAT_VERSION.VER;
if($scope.heat_version) {
$scope.heat_version = $scope.heat_version.split('.', 3).map(Number);
} else {
$scope.heat_version = defaultVersion;
}
$scope.murano_release = appCatalogSettings.MURANO_VERSION.REL;
$scope.murano_version = appCatalogSettings.MURANO_VERSION.VER;
if($scope.murano_version) {
$scope.murano_version = $scope.murano_version.split('.', 3).map(Number);
} else {
$scope.murano_version = defaultVersion;
}
var req = {
url: appCatalogUrl + '/api/v1/assets',
headers: {
'X-Requested-With': undefined,
'X-App-Catalog-Versions': [
appCatalogSettings.HORIZON_VERSION.VER,
appCatalogSettings.HORIZON_VERSION.REL,
appCatalogSettings.APP_CATALOG_VERSION.VER,
appCatalogSettings.APP_CATALOG_VERSION.REL
].join(' ')
}
};
$http(req).success(function(data) {
if ('deprecated' in data) {
notifyDeprecated(data.deprecated);
}
if ('retired' in data) {
notifyRetired();
}
var process = function(asset) {
var url = asset.attributes.url;
var args = {'template_url': url};
if ($scope.eversion_check(asset, $scope.heat_version) != true) {
asset.disabled = true;
notifyUpdate();
return;
}
if ('environment' in asset.service ) {
args['environment'] = asset.service.environment;
}
heatAPI.validate(args, true).success(function(data) {
asset.validated = true;
notifyUpdate();
}).error(function(data, status) {
var str = 'ERROR: Could not retrieve template:';
asset.disabled = true;
asset.validated = 'unsupported';
if (status == 400 && data.slice(0, str.length) == str) {
asset.validated = 'error';
}
notifyUpdate();
});
};
angular.forEach(data.assets, function(asset) {
$scope.assets.push(asset);
if ('version' in asset.service && asset.service.version > 1) {
asset.disabled = true;
} else if (asset.service.type == 'heat') {
process(asset);
} else if (asset.service.type == 'murano') {
asset.validated = true;
asset.disabled = !$scope.has_murano;
if ($scope.eversion_check(asset, $scope.murano_version) != true) {
asset.disabled = true;
}
} else if (asset.service.type != 'glance' && asset.service.type != 'bundle') {
asset.disabled = true;
}
asset.has_murano = $scope.has_murano;
});
$scope.glance_loaded = true;
$scope.murano_loaded = true;
updateFoundAssets($scope);
}).error(function() {
notifyError('There was an error while retrieving entries from the Application Catalog.');
});
if ($scope.has_murano) {
muranoAPI.getPackages().success(function(data) {
$scope.murano_packages = data;
var muranoPackageDefinitions = {};
angular.forEach(data.packages, function(pkg) {
angular.forEach(pkg.class_definitions, function(definition) {
muranoPackageDefinitions[definition] = {'id': pkg.id};
});
});
$scope.murano_package_definitions = muranoPackageDefinitions;
updateFoundAssets($scope);
});
}
glanceAPI.getImages().success(function(data) {
$scope.glance_images = data;
var glanceNames = {};
angular.forEach(data.items, function(item) {
glanceNames[item.name] = {'id': item.id};
});
$scope.glance_names = glanceNames;
updateFoundAssets($scope);
});
};
this.update_selected_facets = function(selectedFacets) {
$scope.selected_facets.length = 0;
if (selectedFacets != undefined) {
angular.forEach(selectedFacets, function(facet) {
$scope.selected_facets.push(facet);
});
}
$scope.update_assets_filtered();
};
this.update_selected_text = function(selectedText) {
$scope.selected_text = selectedText;
$scope.update_assets_filtered();
};
this.asset_filter_strings = {
cancel: gettext('Cancel'),
prompt: gettext('Search'),
remove: gettext('Remove'),
text: gettext('Text')
};
this.asset_filter_facets = [
{
name: 'name',
label: gettext('Name'),
singleton: true
},
{
name: 'license',
label: gettext('License'),
singleton: true
},
{
name: 'service.type',
label: gettext('Service Type'),
//FIXME make dynamic later.
options: [
{key: 'heat', label: 'Orchestration'},
{key: 'glance', label: 'Images'},
{key: 'murano', label: 'Murano'}
],
singleton: true
}];
}
function commonInit($scope, $modal, toast, appCatalogModel) {
$scope.WEBROOT = WEBROOT;
$scope.STATIC_URL = STATIC_URL;
$scope.toggle_service_filter = appCatalogModel.toggle_service_filter;
$scope.service_filters = appCatalogModel.service_filters;
$scope.service_filters_selections = appCatalogModel.service_filters_selections;
$scope.asset_filter_strings = appCatalogModel.asset_filter_strings;
$scope.asset_filter_facets = appCatalogModel.asset_filter_facets;
$scope.init = appCatalogModel.init;
var retired = function() {
var newscope = $scope.$new();
var modal = $modal.open({
templateUrl: STATIC_URL + "lib/app-catalog-common/retired_panel.html",
scope: newscope
});
newscope.cancel = function() {
modal.dismiss('');
};
};
var error = function(message) {
toast.add('error', message);
};
var deprecated = function(message) {
toast.add('warning', message);
};
appCatalogModel.register_callback('error', error);
appCatalogModel.register_callback('deprecated', deprecated);
appCatalogModel.register_callback('retired', retired);
//FIXME probably belongs in its own directive...
var textSearchWatcher = $scope.$on('textSearch', function(event, text) {
appCatalogModel.update_selected_text(text);
});
var textSearchWatcher2 = $scope.$on('searchUpdated', function(event, query) {
var selectedFacets;
if (query != '') {
selectedFacets = query.split('&');
for (var i = 0; i < selectedFacets.length; i++) {
var s = selectedFacets[i];
var idx = s.indexOf('=');
selectedFacets[i] = [s.slice(0, idx), s.slice(idx + 1)];
}
}
appCatalogModel.update_selected_facets(selectedFacets);
});
}
function appCatalogMagicSearchBar(basePath) {
var directive = {
compile: function (element, attrs) {
/**
* Need to set template here since MagicSearch template
* attribute is not interpolated. Can't hardcode the
* template location and need to use basePath.
*/
var templateUrl = basePath + 'magic-search/magic-search.html';
element.find('magic-search').attr('template', templateUrl);
element.addClass('hz-magic-search-bar');
},
restrict: 'E',
templateUrl: STATIC_URL + "lib/app-catalog-common/magic_search.html"
};
return directive;
}
function appCatalogTableCtrl($scope, $http, $timeout, $modal, toast, appCatalogModel) {
$scope.assets = [];
var update = function() {
$scope.assets = [];
angular.forEach(appCatalogModel.assets_filtered, function(asset) {
if (typeof asset.tags !== "undefined" && asset.tags.indexOf('app') > -1) {
$scope.assets.push(asset);
}
});
};
appCatalogModel.register_callback('update', update);
commonInit($scope, $modal, toast, appCatalogModel);
$scope.switcher = {pannel: 'app', active: 'grid'};
$scope.changeActivePanel = function(name) {
$scope.switcher.active = name;
};
$scope.details = function(asset) {
var newscope = $scope.$new();
newscope.asset = asset;
var modal = $modal.open({
templateUrl: STATIC_URL + "lib/app-catalog-common/details_panel.html",
scope: newscope
});
newscope.cancel = function() {
modal.dismiss('');
};
};
}
function appComponentCatalogTableCtrl($scope, $http, $timeout, $modal, toast, appCatalogModel) {
$scope.assets = appCatalogModel.assets_filtered;
var update = function() {
$timeout(function() {
$scope.assets = appCatalogModel.assets_filtered;
}, 0, false);
};
appCatalogModel.register_callback('update', update);
commonInit($scope, $modal, toast, appCatalogModel);
$scope.switcher = {pannel: 'component', active: 'list'};
}
function updateFoundAssets($scope) {
var i;
if ('glance_loaded' in $scope && 'glance_names' in $scope) {
for (i in $scope.assets) {
if ($scope.assets[i].service.type != 'glance') {
continue;
}
var name = $scope.assets[i].name;
var isInstalled = name in $scope.glance_names;
$scope.assets[i].installed = isInstalled;
if (isInstalled) {
$scope.assets[i].installed_id = $scope.glance_names[name].id;
}
}
}
if ('murano_loaded' in $scope && 'murano_package_definitions' in $scope) {
for (i in $scope.assets) {
if ($scope.assets[i].service.type != 'murano') {
continue;
}
var definition = $scope.assets[i].service.package_name;
var isInstalled = definition in ($scope.murano_package_definitions);
$scope.assets[i].installed = isInstalled;
if (isInstalled) {
$scope.assets[i].service.murano_id = $scope.murano_package_definitions[definition].id;
}
}
}
var assetNameToAsset = {};
angular.forEach($scope.assets, function(asset) {
assetNameToAsset[asset.name] = asset;
});
angular.forEach($scope.assets, function(asset) {
asset.disabled = false;
if ('depends' in asset) {
angular.forEach(asset.depends, function(dep) {
dep.asset = assetNameToAsset[dep.name];
if('disabled' in asset && dep.asset.disabled) {
asset.disabled = true;
}
});
}
});
$scope.update_assets_filtered();
}
function stars() {
var star = angular.element('<i>');
star.addClass('fa fa-star');
star.css({ color: 'goldenrod' });
return {
restrict: 'E',
scope: { value: '=' },
link: function(scope, element) {
for (var i = 0; i < scope.value; i++) {
element.append(star.clone());
}
}
};
}
/*FIXME move out to testing file.*/
function test_evars($scope) {
var assert = function(t, a, b) {
if (!t) {
console.log("Failed", a, b);
}
}
assert($scope.eversion_check({service:{}}, [2014,1,1]), [], [2014,1,1]);
assert($scope.eversion_check({service:{ever:[{min:[2014,1,1]}]}}, [2014,1,1]), [2014,1,1], [2014,1,1]);
assert($scope.eversion_check({service:{ever:[{max:[2014,1,1]}]}}, [2014,1,1]), [2014,1,1], [2014,1,1]);
assert(!$scope.eversion_check({service:{ever:[{max:[2014,1,1]}]}}, [2015,1,1]), [2014,1,1], [2015,1,1]);
assert($scope.eversion_check({service:{ever:[{max:[2014,1,1]}]}}, [2013,1,1]), [2014,1,1], [2013,1,1]);
assert(!$scope.eversion_check({service:{ever:[{min:[2016,1,1]}]}}, [2015,1,1]), [2016,1,1], [2015,1,1]);
assert($scope.eversion_check({service:{ever:[{min:[2013,1,1]}]}}, [2014,1,1]), [2013,1,1], [2014,1,1]);
assert($scope.eversion_check({service:{ever:[{min:[2013,1,1],max:[2015,1,1]}]}}, [2014,1,1]), [2013,2015], [2014,1,1]);
assert(!$scope.eversion_check({service:{ever:[{min:[2013,1,1],max:[2015,1,1]}]}}, [2011,1,1]), [2013,2015], [2011,1,1]);
assert(!$scope.eversion_check({service:{ever:[{min:[2013,1,1],max:[2015,1,1]}]}}, [2016,1,1]), [2013,2015], [2016,1,1]);
}
})();

View File

@ -0,0 +1,11 @@
.app_catalog_grid_item_hidden {
height: 172px;
width: 182px;
margin: -170px 0px 0px -10px;
opacity: 1;
overflow: hidden;
display: block;
position: relative;
background: rgba(0, 0, 0, .25);
z-index: 100;
}

View File

@ -0,0 +1,11 @@
<div>
<div class="modal-header">
<h3 class="modal-title">Details</h3>
</div>
<div class="modal-body">
<ng-include src="STATIC_URL + 'lib/app-catalog-common/_details_panel.html'" onload="appaction=true"></ng-include>
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="cancel()">Close</button>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,12 @@
<div class="magic-search-bar">
<div class="input-group input-group-sm">
<span class="input-group-addon">
<span class="fa fa-search"></span>
</span>
<magic-search
template="/static/framework/widgets/magic-search/magic-search.html"
strings="asset_filter_strings"
facets="{$ asset_filter_facets $}">
</magic-search>
</div>
</div>

View File

@ -0,0 +1,150 @@
<div style="margin-bottom: 4px;">
Service Types:
<label ng-repeat="service in service_filters">
<input
type="checkbox"
name="selected_filters[]"
value="{$ service.id $}"
ng-checked="service_filters_selections[service.id]"
ng-click="toggle_service_filter(service.id)"
> {$ service.name $}
</label>
<span ng-switch="switcher.pannel" style="float:right">
<span ng-switch-when="app" style="float: right" class="toggleView btn-group">
<img class="btn btn-default" ng-class="{active: (switcher.active == 'grid')}" ng-src="{$ STATIC_URL $}/lib/app-catalog-common/1439233859_grid.png" ng-click="changeActivePanel('grid')"/>
<img class="btn btn-default" ng-class="{active: (switcher.active == 'list')}" ng-src="{$ STATIC_URL $}/lib/app-catalog-common/1439233889_list.png" ng-click="changeActivePanel('list')"/>
</span>
</span>
</div>
<div ng-switch="switcher.active">
<app-catalog-magic-search></app-catalog-magic-search>
<div ng-switch-when="grid" style="
background-color:#f9f9f9;
overflow: auto;
border-color:#cccccc; border-width:1px; border-style: solid;
">
<div ng-repeat="asset in assets | orderBy:'name':false" style="border:1px;
margin: 10px;
width: 200px; height: 180px; float: left;
">
<div ng-click="details(asset)" style="
margin:10px;
border-color:#cccccc; border-width:1px;
border-radius: 2px;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
padding:8px;
height: 170px;
overflow: hidden;
background-color:#ffffff;
position: relative;
">
<div style="">
<div style="
width:128px;
height:128px;
overflow: hidden;
margin-left: auto; margin-right:auto;
">
<img style="
margin: {$ asset.icon.top $}px 0px 0px {$ asset.icon.left $}px;
height: {$ asset.icon.height $}px;
" src="{$ asset.icon.url $}">
</div>
<!--FIXME Move images out to common repo.-->
<span style="
max-height: 100%;
width: 23px;
height: 23px;
top: 0;
right: 0;
position: absolute;
background: rgba(0, 0, 0, 0) url('{$ STATIC_URL $}/lib/app-catalog-common/featured-corner-{$ asset.service.type $}.png') no-repeat scroll right top;
">
</span>
</div>
<div title="{$ asset.name $}" style="
overflow: hidden;
white-space: nowrap;
position: relative;
line-height: 18px;
font-size: 16px;
"> {$ asset.name $}
<span style="
max-height: 100%;
width: 40px;
height: 20px;
bottom: 0;
right: 0;
position: absolute;
background: rgba(0, 0, 0, 0) linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)) repeat scroll 0 0;
">
</span>
</div>
<div title="{$ asset.provided_by.name $}" style="
overflow: hidden;
white-space: nowrap;
position: relative;
line-height: 14px;
font-size: 12px;
"> {$ asset.provided_by.name $}
<span style="
max-height: 100%;
width: 40px;
height: 20px;
bottom: 0;
right: 0;
position: absolute;
background: rgba(0, 0, 0, 0) linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)) repeat scroll 0 0;
">
</span>
</div>
<div ng-switch="asset.disabled">
<div ng-switch-when="true" class="app_catalog_grid_item_hidden"></div>
</div>
</div>
</div>
</div>
<div ng-switch-when="list">
<table hz-table ng-cloak st-table="dispassets" st-safe-src="assets"
class="table-striped table-rsp table-detail modern">
<thead>
<tr>
<th class="expander"></th>
<th st-sort="name" st-sort-default="true" class="rsp-p1">Name</th>
<th st-sort='license' class="rsp-p1">License</th>
<th class="rsp-p1"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="asset in dispassets track by asset.name">
<td class="expander">
<i class="fa fa-chevron-right" hz-expand-detail duration="200"></i>
</td>
<td class="rsp-p1">{$ asset.name $}</td>
<td class="rsp-p2">{$ asset.license $}</td>
<td class="rsp-p2"><div app-action ng-scope ng-init="extraclasses='btn-sm';installclasses='btn-primary';launchclasses='btn-success'"></div></td>
</tr>
<tr ng-repeat-end class="detail-row">
<td class="detail" colspan="4">
<ng-include src="STATIC_URL + 'lib/app-catalog-common/_details_panel.html'"></ng-include>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5" class="text-center">
<div st-pagination="" st-items-by-page="itemsByPage" st-displayed-pages="7"></div>
</td>
</tr>
</tfoot>
</table>
</div>
</div>

View File

@ -0,0 +1,11 @@
<div>
<div class="modal-header">
<h3 class="modal-title">Retired</h3>
</div>
<div class="modal-body">
The OpenStack App Catalog no longer supports this version of the Horizon plugin. Please contact your Cloud Administrator for an upgraded version.
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="cancel()">Close</button>
</div>
</div>