Merge "add translation and cleanup resource-browser-item.html"

This commit is contained in:
Jenkins 2016-08-25 12:22:42 +00:00 committed by Gerrit Code Review
commit f7b6ecdb4c
4 changed files with 212 additions and 220 deletions

View File

@ -19,11 +19,13 @@
angular
.module('horizon.dashboard.developer.resource-browser')
.controller('horizon.dashboard.developer.resource-browser.ResourceBrowserItemController', ResourceBrowserItemController);
.controller('horizon.dashboard.developer.resource-browser.ResourceBrowserItemController',
ResourceBrowserItemController);
ResourceBrowserItemController.$inject = [
'$scope',
'horizon.dashboard.developer.resource-browser.BASE_ROUTE'
'horizon.dashboard.developer.resource-browser.BASE_ROUTE',
'horizon.framework.widgets.toast.service'
];
/**
@ -32,7 +34,7 @@
* @description
* This controller allows the launching of any actions registered for resource types
*/
function ResourceBrowserItemController($scope, baseRoute) {
function ResourceBrowserItemController($scope, baseRoute, toastService) {
/**
* Directive data (Private)
@ -85,11 +87,11 @@
* Implementation
*/
function fullySupported() {
return (supportsGenericDetailsView() &&
supportsGenericTableView() &&
hasSummaryView() &&
hasGlobalActions() &&
hasItemActions());
return supportsGenericDetailsView() &&
supportsGenericTableView() &&
hasSummaryView() &&
hasGlobalActions() &&
hasItemActions();
}
function getName() {
@ -97,13 +99,11 @@
}
function supportsGenericTableView() {
return (
getName() &&
hasListFunction() &&
hasProperties() &&
hasTableColumns() &&
hasSummaryView()
);
return getName() &&
hasListFunction() &&
hasProperties() &&
hasTableColumns() &&
hasSummaryView();
}
function hasListFunction() {
@ -112,7 +112,7 @@
function listFunctionNameLabel() {
var label = gettext("Not Set");
if ( hasListFunction() ) {
if (hasListFunction()) {
label = typeData.list.name;
}
return label;
@ -126,10 +126,6 @@
return typeData.tableColumns.length > 0;
}
function getProperties() {
return Object.keys(typeData.getProperties());
}
function getProperties() {
var properties = typeData.getProperties();
var keys = Object.keys(properties);
@ -153,12 +149,11 @@
}
function supportsGenericDetailsView() {
return (hasDetailView() &&
hasLoadFunction());
return hasDetailView() && hasLoadFunction();
}
function hasDetailView() {
return typeData.detailsViews.length > 0
return typeData.detailsViews.length > 0;
}
function getDetailViewLabels() {
@ -175,22 +170,22 @@
function loadFunctionNameLabel() {
var label = gettext("Not Set");
if ( hasLoadFunction() ) {
label = typeData.load.name
if (hasLoadFunction()) {
label = typeData.load.name;
}
return label;
}
function hasGlobalActions() {
return typeData.globalActions.length != 0
return typeData.globalActions.length !== 0;
}
function hasBatchActions() {
return typeData.batchActions.length != 0
return typeData.batchActions.length !== 0;
}
function hasItemActions() {
return typeData.itemActions.length != 0;
return typeData.itemActions.length !== 0;
}
function hasSummaryView() {
@ -219,7 +214,7 @@
}
function loadFailed(reason) {
window.alert(gettext("resource load failed" + ":" + reason));
toastService.add('error', gettext("resource load failed: " + reason));
}
}
}

View File

@ -1,191 +1,188 @@
<div class="container">
<div class="panel panel-default">
<div class="panel-heading" ng-click="ctrl.collapsed=!ctrl.collapsed">
<div class="panel-title">
<span class="fa" ng-class="ctrl.fullySupported ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
{$ ctrl.nameLabel $} ( {$ ctrl.typeLabel $} )
<span class="fa pull-right" ng-class="ctrl.collapsed ? 'fa-plus' : 'fa-minus'"></span>
</div>
</div>
<div>
<div class="panel-body" collapse="ctrl.collapsed">
<!-- Has generic table view -->
<div class="row"><label>
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.supportsGenericTableView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<a ng-href="{$ ctrl.tableUrl $}">
<label>Generic Table View:</label>
</a>
</h4>
</div>
</div>
<!-- Name(s) is set -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.nameLabel ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Names:</label>
<ul ng-repeat="label in ctrl.allNameLabels">
<li>{$ label $}</li>
</ul>
</div>
</div>
<!-- Has List function -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasListFunction ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>List Function:</label> {$ ctrl.listFunctionNameLabel $}
</div>
</div>
<!-- Has Properties -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasProperties ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Properties:</label>
<ul ng-repeat="label in ctrl.propertyLabels">
<li>{$ label $}</li>
</ul>
</div>
</div>
<!-- Has default table columns -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasTableColumns > 0 ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Table Columns:</label>
<ul ng-repeat="label in ctrl.tableColumnLabels">
<li>{$ label $}</li>
</ul>
</div>
</div>
<!-- Has drawer view -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasSummaryView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Summary Template URL:</label> {$ ctrl.summaryTemplateUrl $}
</div>
</div>
<!-- Has generic details view -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.supportsGenericDetailsView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Supports Details View:</label>
</h4>
</div>
</div>
<!-- Has Load function -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasLoadFunction ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Load Function:</label> {$ ctrl.loadFunctionNameLabel $}
</div>
</div>
<!-- Has 1 or more details views -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasDetailView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Details Views:</label>
<ul ng-repeat="label in ctrl.detailViewLabels">
<li>{$ label $}</li>
</ul>{$ ctrl.detailsViewsLabel $}
</div>
</div>
<!-- Has global actions -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.hasGlobalActions ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Global Actions:</label>
</h4>
</div>
</div>
<div ng-if="ctrl.hasGlobalActions != 0">
<div ng-repeat="action in ctrl.globalActions">
<div class="row">
<div class="col-xs-3 col-xs-offset-1">
{$ action.template.text $}
</div>
<div class="col-xs-4">
</div>
<div class="col-xs-4">
<input type="button"
value="{$ action.template.text $}"
ng-click="ctrl.onGlobalActionSelected(action)"/>
</div>
</div>
</div>
</div>
<!-- Has batch actions -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.hasBatchActions ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Batch Actions:</label>
</h4>
</div>
</div>
<div ng-if="ctrl.hasBatchActions != 0">
<div ng-repeat="action in ctrl.batchActions">
<div class="row">
<div class="col-xs-3 col-xs-offset-1">
{$ action.template.text $}
</div>
<div class="col-xs-4">
</div>
<div class="col-xs-4">
<input type="button"
value="{$ action.template.text $}"
ng-click="ctrl.onActionSelected(action)"/>
</div>
</div>
</div>
</div>
<!-- Has item actions -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.hasItemActions ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label>Item Actions:</label>
</h4>
</div>
</div>
<div ng-if="ctrl.hasItemActions">
<div class="row">
<div class="col-xs-3 col-xs-offset-1">
<div ng-repeat="action in ctrl.itemActions">
{$ action.template.text $}
</div>
</div>
<div class="col-xs-4">
<form name="resourceIdForm">
<input ng-model="ctrl.resourceId"
type="text"
placeholder="Resource ID(s)"/>
</form>
</div>
<div class="col-xs-4">
<div ng-repeat="action in ctrl.itemActions">
<input
type="button"
value="{$ action.template.text $}"
ng-click="ctrl.onActionSelected(action)"/>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" ng-click="ctrl.collapsed=!ctrl.collapsed">
<div class="panel-title">
<span class="fa" ng-class="ctrl.fullySupported ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
{$ ctrl.nameLabel $} ( {$ ctrl.typeLabel $} )
<span class="fa pull-right" ng-class="ctrl.collapsed ? 'fa-plus' : 'fa-minus'"></span>
</div>
</div>
</div>
<div>
<div class="panel-body" collapse="ctrl.collapsed">
<!-- Has generic table view -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.supportsGenericTableView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<a ng-href="{$ ctrl.tableUrl $}">
<label translate>Generic Table View:</label>
</a>
</h4>
</div>
</div>
<!-- Name(s) is set -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.nameLabel ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Names:</label>
<ul ng-repeat="label in ctrl.allNameLabels">
<li>{$ label $}</li>
</ul>
</div>
</div>
<!-- Has List function -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasListFunction ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>List Function:</label> {$ ctrl.listFunctionNameLabel $}
</div>
</div>
<!-- Has Properties -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasProperties ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Properties:</label>
<ul ng-repeat="label in ctrl.propertyLabels">
<li>{$ label $}</li>
</ul>
</div>
</div>
<!-- Has default table columns -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasTableColumns > 0 ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Table Columns:</label>
<ul ng-repeat="label in ctrl.tableColumnLabels">
<li>{$ label $}</li>
</ul>
</div>
</div>
<!-- Has drawer view -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasSummaryView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Summary Template URL:</label> {$ ctrl.summaryTemplateUrl $}
</div>
</div>
<!-- Has generic details view -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.supportsGenericDetailsView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Supports Details View:</label>
</h4>
</div>
</div>
<!-- Has Load function -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasLoadFunction ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Load Function:</label> {$ ctrl.loadFunctionNameLabel $}
</div>
</div>
<!-- Has 1 or more details views -->
<div class="row">
<div class="col-xs-offset-1 col-xs-11">
<span class="fa" ng-class="ctrl.hasDetailView ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Details Views:</label>
<ul ng-repeat="label in ctrl.detailViewLabels">
<li>{$ label $}</li>
</ul>{$ ctrl.detailsViewsLabel $}
</div>
</div>
<!-- Has global actions -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.hasGlobalActions ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Global Actions:</label>
</h4>
</div>
</div>
<div ng-if="ctrl.hasGlobalActions != 0">
<div ng-repeat="action in ctrl.globalActions">
<div class="row">
<div class="col-xs-3 col-xs-offset-1">
{$ action.template.text $}
</div>
<div class="col-xs-4"></div>
<div class="col-xs-4">
<input type="button"
value="{$ action.template.text $}"
ng-click="ctrl.onGlobalActionSelected(action)"/>
</div>
</div>
</div>
</div>
<!-- Has batch actions -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.hasBatchActions ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Batch Actions:</label>
</h4>
</div>
</div>
<div ng-if="ctrl.hasBatchActions != 0">
<div ng-repeat="action in ctrl.batchActions">
<div class="row">
<div class="col-xs-3 col-xs-offset-1">
{$ action.template.text $}
</div>
<div class="col-xs-4"></div>
<div class="col-xs-4">
<input type="button"
value="{$ action.template.text $}"
ng-click="ctrl.onActionSelected(action)"/>
</div>
</div>
</div>
</div>
<!-- Has item actions -->
<div class="row">
<div class="col-xs-12">
<h4>
<span class="fa" ng-class="ctrl.hasItemActions ? 'text-success fa-check' : 'text-warning fa-warning'"></span>
<label translate>Item Actions:</label>
</h4>
</div>
</div>
<div ng-if="ctrl.hasItemActions">
<div class="row">
<div class="col-xs-3 col-xs-offset-1">
<div ng-repeat="action in ctrl.itemActions">
{$ action.template.text $}
</div>
</div>
<div class="col-xs-4">
<form name="resourceIdForm">
<input ng-model="ctrl.resourceId"
type="text"
placeholder="{$ 'Resource ID(s)'|translate $}"/>
</form>
</div>
<div class="col-xs-4">
<div ng-repeat="action in ctrl.itemActions">
<input type="button"
value="{$ action.template.text $}"
ng-click="ctrl.onActionSelected(action)"/>
</div>
</div>
</div>
</div>
</div><!-- end of panel body -->
</div><!-- end of container div -->

View File

@ -1,4 +1,4 @@
<h2>
<h2 translate>
Registered Resource Types
</h2>
<div ng-repeat="(type, typeData) in ctrl.resourceTypes">

View File

@ -42,7 +42,7 @@
<li class="scope">
<input type="text"
class="form-control input-sm"
placeholder="Prefix"
placeholder="{$ 'PRefix'|translate $}"
ng-show="resource_type.selected"
ng-model="resource_type.prefix"/>
</li>