diff --git a/tatudashboard/api/__init__.py b/tatudashboard/api/__init__.py index 7d3b2dc..e69de29 100644 --- a/tatudashboard/api/__init__.py +++ b/tatudashboard/api/__init__.py @@ -1,16 +0,0 @@ -# (c) Copyright 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 diff --git a/tatudashboard/api/rest/__init__.py b/tatudashboard/api/rest/__init__.py new file mode 100644 index 0000000..0295f36 --- /dev/null +++ b/tatudashboard/api/rest/__init__.py @@ -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 diff --git a/tatudashboard/api/passthrough.py b/tatudashboard/api/rest/passthrough.py similarity index 100% rename from tatudashboard/api/passthrough.py rename to tatudashboard/api/rest/passthrough.py diff --git a/tatudashboard/dashboards/project/dummy/panel.py b/tatudashboard/dashboards/project/dummy/panel.py deleted file mode 100644 index 1ecfa5e..0000000 --- a/tatudashboard/dashboards/project/dummy/panel.py +++ /dev/null @@ -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) diff --git a/tatudashboard/dashboards/project/hosts/panel.py b/tatudashboard/dashboards/project/hosts/panel.py deleted file mode 100644 index 9c8b270..0000000 --- a/tatudashboard/dashboards/project/hosts/panel.py +++ /dev/null @@ -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) diff --git a/tatudashboard/dashboards/project/hosts/urls.py b/tatudashboard/dashboards/project/hosts/urls.py deleted file mode 100644 index 415036d..0000000 --- a/tatudashboard/dashboards/project/hosts/urls.py +++ /dev/null @@ -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'), -] diff --git a/tatudashboard/dashboards/project/hosts/views.py b/tatudashboard/dashboards/project/hosts/views.py deleted file mode 100644 index e072aea..0000000 --- a/tatudashboard/dashboards/project/hosts/views.py +++ /dev/null @@ -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' diff --git a/tatudashboard/dashboards/project/__init__.py b/tatudashboard/dashboards/tatu/__init__.py similarity index 100% rename from tatudashboard/dashboards/project/__init__.py rename to tatudashboard/dashboards/tatu/__init__.py diff --git a/tatudashboard/dashboards/project/dummy/__init__.py b/tatudashboard/dashboards/tatu/ca/__init__.py similarity index 100% rename from tatudashboard/dashboards/project/dummy/__init__.py rename to tatudashboard/dashboards/tatu/ca/__init__.py diff --git a/tatudashboard/panels/ca/panel.py b/tatudashboard/dashboards/tatu/ca/panel.py similarity index 90% rename from tatudashboard/panels/ca/panel.py rename to tatudashboard/dashboards/tatu/ca/panel.py index 0a68676..02fb5ba 100644 --- a/tatudashboard/panels/ca/panel.py +++ b/tatudashboard/dashboards/tatu/ca/panel.py @@ -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): diff --git a/tatudashboard/panels/user/urls.py b/tatudashboard/dashboards/tatu/ca/urls.py similarity index 99% rename from tatudashboard/panels/user/urls.py rename to tatudashboard/dashboards/tatu/ca/urls.py index 74e443d..ebf95d4 100644 --- a/tatudashboard/panels/user/urls.py +++ b/tatudashboard/dashboards/tatu/ca/urls.py @@ -16,7 +16,6 @@ from django.conf.urls import url from . import views - urlpatterns = [ url('', views.IndexView.as_view(), name='index'), ] diff --git a/tatudashboard/panels/ca/views.py b/tatudashboard/dashboards/tatu/ca/views.py similarity index 100% rename from tatudashboard/panels/ca/views.py rename to tatudashboard/dashboards/tatu/ca/views.py diff --git a/tatudashboard/dashboard.py b/tatudashboard/dashboards/tatu/dashboard.py similarity index 100% rename from tatudashboard/dashboard.py rename to tatudashboard/dashboards/tatu/dashboard.py diff --git a/tatudashboard/dashboards/project/hosts/__init__.py b/tatudashboard/dashboards/tatu/host/__init__.py similarity index 100% rename from tatudashboard/dashboards/project/hosts/__init__.py rename to tatudashboard/dashboards/tatu/host/__init__.py diff --git a/tatudashboard/panels/host/panel.py b/tatudashboard/dashboards/tatu/host/panel.py similarity index 90% rename from tatudashboard/panels/host/panel.py rename to tatudashboard/dashboards/tatu/host/panel.py index 5fc206f..8d14718 100644 --- a/tatudashboard/panels/host/panel.py +++ b/tatudashboard/dashboards/tatu/host/panel.py @@ -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): diff --git a/tatudashboard/panels/ca/urls.py b/tatudashboard/dashboards/tatu/host/urls.py similarity index 99% rename from tatudashboard/panels/ca/urls.py rename to tatudashboard/dashboards/tatu/host/urls.py index 74e443d..ebf95d4 100644 --- a/tatudashboard/panels/ca/urls.py +++ b/tatudashboard/dashboards/tatu/host/urls.py @@ -16,7 +16,6 @@ from django.conf.urls import url from . import views - urlpatterns = [ url('', views.IndexView.as_view(), name='index'), ] diff --git a/tatudashboard/panels/host/views.py b/tatudashboard/dashboards/tatu/host/views.py similarity index 100% rename from tatudashboard/panels/host/views.py rename to tatudashboard/dashboards/tatu/host/views.py diff --git a/tatudashboard/panels/__init__.py b/tatudashboard/dashboards/tatu/user/__init__.py similarity index 100% rename from tatudashboard/panels/__init__.py rename to tatudashboard/dashboards/tatu/user/__init__.py diff --git a/tatudashboard/panels/user/panel.py b/tatudashboard/dashboards/tatu/user/panel.py similarity index 90% rename from tatudashboard/panels/user/panel.py rename to tatudashboard/dashboards/tatu/user/panel.py index 4d06ea9..751619e 100644 --- a/tatudashboard/panels/user/panel.py +++ b/tatudashboard/dashboards/tatu/user/panel.py @@ -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): diff --git a/tatudashboard/panels/host/urls.py b/tatudashboard/dashboards/tatu/user/urls.py similarity index 99% rename from tatudashboard/panels/host/urls.py rename to tatudashboard/dashboards/tatu/user/urls.py index 74e443d..ebf95d4 100644 --- a/tatudashboard/panels/host/urls.py +++ b/tatudashboard/dashboards/tatu/user/urls.py @@ -16,7 +16,6 @@ from django.conf.urls import url from . import views - urlpatterns = [ url('', views.IndexView.as_view(), name='index'), ] diff --git a/tatudashboard/panels/user/views.py b/tatudashboard/dashboards/tatu/user/views.py similarity index 100% rename from tatudashboard/panels/user/views.py rename to tatudashboard/dashboards/tatu/user/views.py diff --git a/tatudashboard/enabled/_3981_tatu_ca_panel.py b/tatudashboard/enabled/_3981_tatu_ca_panel.py index aaf9d87..c62c794 100644 --- a/tatudashboard/enabled/_3981_tatu_ca_panel.py +++ b/tatudashboard/enabled/_3981_tatu_ca_panel.py @@ -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'] diff --git a/tatudashboard/enabled/_3982_tatu_user_panel.py b/tatudashboard/enabled/_3982_tatu_user_panel.py index 15cd510..7a68296 100644 --- a/tatudashboard/enabled/_3982_tatu_user_panel.py +++ b/tatudashboard/enabled/_3982_tatu_user_panel.py @@ -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'] diff --git a/tatudashboard/enabled/_3983_tatu_host_panel.py b/tatudashboard/enabled/_3983_tatu_host_panel.py index be0a55a..3511c28 100644 --- a/tatudashboard/enabled/_3983_tatu_host_panel.py +++ b/tatudashboard/enabled/_3983_tatu_host_panel.py @@ -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'] diff --git a/tatudashboard/panels/ca/__init__.py b/tatudashboard/panels/ca/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tatudashboard/panels/host/__init__.py b/tatudashboard/panels/host/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tatudashboard/panels/user/__init__.py b/tatudashboard/panels/user/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-ca/api.service.js b/tatudashboard/static/tatudashboard/resources/os-tatu-ca/api.service.js new file mode 100644 index 0000000..1ec5965 --- /dev/null +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-ca/api.service.js @@ -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.')); + }); + } + + } +}()); diff --git a/tatudashboard/static/tatudashboard/resources/os-tatu-ca/os-tatu-ca.module.js b/tatudashboard/static/tatudashboard/resources/os-tatu-ca/os-tatu-ca.module.js index 4928407..0ad141d 100644 --- a/tatudashboard/static/tatudashboard/resources/os-tatu-ca/os-tatu-ca.module.js +++ b/tatudashboard/static/tatudashboard/resources/os-tatu-ca/os-tatu-ca.module.js @@ -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; + }); } }