Fixes to CA panel.

This commit is contained in:
Pino de Candia 2018-01-14 18:21:17 -06:00
parent 1b7c4ecd70
commit dfbfadd1c6
29 changed files with 127 additions and 124 deletions

View File

@ -1,16 +0,0 @@
# (c) Copyright <year(s)> Hewlett Packard Enterprise Development LP
#
# 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.
"""REST API for Horizon dashboard Javascript code.
"""
from tatudashboard.api import passthrough

View File

@ -0,0 +1,16 @@
# Copyright (c) 2017 Huawei, Inc.
#
# 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.
"""REST API for Horizon dashboard Javascript code.
"""
from . import passthrough # noqa

View File

@ -1,25 +0,0 @@
# (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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 django.utils.translation import ugettext_lazy as _
import horizon
from openstack_dashboard.dashboards.project import dashboard
class Hosts(horizon.Panel):
name = _("SSH Hosts")
slug = 'ssh_hosts'
permissions = ('openstack.services.dns',)
dashboard.Project.register(Hosts)

View File

@ -1,25 +0,0 @@
# (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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 django.utils.translation import ugettext_lazy as _
import horizon
from openstack_dashboard.dashboards.project import dashboard
class Hosts(horizon.Panel):
name = _("SSH Hosts")
slug = 'sshhosts'
permissions = ('openstack.services.dns',)
dashboard.Project.register(Hosts)

View File

@ -1,22 +0,0 @@
# (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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 django.conf.urls import url
from tatudashboard.dashboards.project.hosts import views
urlpatterns = [
url('', views.IndexView.as_view(), name='index'),
]

View File

@ -1,19 +0,0 @@
# (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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 django.views import generic
class IndexView(generic.TemplateView):
template_name = 'angular.html'

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import horizon
from django.utils.translation import ugettext_lazy as _
import horizon
from tatudashboard import dashboard
from tatudashboard.dashboards.tatu import dashboard
class CA(horizon.Panel):

View File

@ -16,7 +16,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url('', views.IndexView.as_view(), name='index'),
]

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import horizon
from django.utils.translation import ugettext_lazy as _
import horizon
from tatudashboard import dashboard
from tatudashboard.dashboards.tatu import dashboard
class Host(horizon.Panel):

View File

@ -16,7 +16,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url('', views.IndexView.as_view(), name='index'),
]

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import horizon
from django.utils.translation import ugettext_lazy as _
import horizon
from tatudashboard import dashboard
from tatudashboard.dashboards.tatu import dashboard
class User(horizon.Panel):

View File

@ -16,7 +16,6 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url('', views.IndexView.as_view(), name='index'),
]

View File

@ -19,7 +19,7 @@ PANEL_DASHBOARD = 'tatu'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
ADD_PANEL = 'tatudashboard.panels.ca.panel.CA'
ADD_PANEL = 'tatudashboard.dashboards.tatu.ca.panel.CA'
ADD_ANGULAR_MODULES = ['tatudashboard']

View File

@ -19,7 +19,7 @@ PANEL_DASHBOARD = 'tatu'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
ADD_PANEL = 'tatudashboard.panels.user.panel.User'
ADD_PANEL = 'tatudashboard.dashboards.tatu.user.panel.User'
ADD_ANGULAR_MODULES = ['tatudashboard']

View File

@ -19,7 +19,7 @@ PANEL_DASHBOARD = 'tatu'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
ADD_PANEL = 'tatudashboard.panels.host.panel.CA'
ADD_PANEL = 'tatudashboard.dashboards.tatu.host.panel.Host'
ADD_ANGULAR_MODULES = ['tatudashboard']

View File

@ -0,0 +1,86 @@
/**
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* 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('tatudashboard.resources.os-tatu-ca')
.factory('tatudashboard.resources.os-tatu-ca.api', apiService);
apiService.$inject = [
'tatudashboard.apiPassthroughUrl',
'horizon.framework.util.http.service',
'horizon.framework.widgets.toast.service'
];
/**
* @ngdoc service
* @param {Object} httpService
* @param {Object} toastService
* @name apiService
* @description Provides direct access to Tatu ca APIs.
* @returns {Object} The service
*/
function apiService(apiPassthroughUrl, httpService, toastService) {
var service = {
get: get,
list: list,
};
return service;
///////////////
/**
* @name list
* @description
* Get a list of CA's.
*
* The listing result is an object with property "items." Each item is
* a CA.
*
* @param {Object} params
* Query parameters. Optional.
*
* @returns {Object} The result of the API call
*/
function list(params) {
var config = params ? {'params': params} : {};
return httpService.get(apiPassthroughUrl + 'noauth/authorities/', config)
.error(function () {
toastService.add('error', gettext('Unable to retrieve the CAs.'));
});
}
/**
* @name get
* @description
* Get a single CA by ID.
*
* @param {string} id
* Specifies the id of the CA to request.
*
* @returns {Object} The result of the API call
*/
function get(id) {
return httpService.get(apiPassthroughUrl + 'noauth/authorities/' + id + '/')
.error(function () {
toastService.add('error', gettext('Unable to retrieve the CA.'));
});
}
}
}());

View File

@ -30,16 +30,20 @@
'ngRoute',
])
.constant(
'tatudashboard.resources.os-tatu-host.resourceType', 'OS::Tatu::CA')
'tatudashboard.resources.os-tatu-ca.resourceType', 'OS::Tatu::CA')
.run(run);
run.$inject = [
'horizon.framework.conf.resource-type-registry.service',
'tatudashboard.resources.os-tatu-host.resourceType'
'tatudashboard.resources.os-tatu-ca.api',
'tatudashboard.resources.os-tatu-ca.resourceType',
'tatudashboard.resources.util'
];
function run(registry,
resourceTypeString) {
caApi
resourceTypeString,
util) {
var resourceType = registry.getResourceType(resourceTypeString);
resourceType
.setNames(gettext('SSH CA'), gettext('SSH CAs'))
@ -70,8 +74,15 @@
});
function listHosts() {
return [];
function listCAs() {
return caApi.list().then(function onList(response) {
// listFunctions are expected to return data in "items"
response.data.items = response.data.CAs;
util.addTimestampIds(response.data.items, 'updated_at');
return response;
});
}
}