Move panels into Tatu panel group under Project.

This commit is contained in:
Pino de Candia 2018-01-15 23:08:47 +00:00
parent dfbfadd1c6
commit 42222f641f
25 changed files with 43 additions and 1222 deletions

View File

@ -15,11 +15,11 @@
import horizon
from django.utils.translation import ugettext_lazy as _
from tatudashboard.dashboards.tatu import dashboard
from openstack_dashboard.dashboards.project import dashboard
class CA(horizon.Panel):
name = _("Certificate Authorities")
slug = 'ca'
slug = 'tatu_ca'
dashboard.Tatu.register(CA)
dashboard.Project.register(CA)

View File

@ -15,11 +15,11 @@
import horizon
from django.utils.translation import ugettext_lazy as _
from tatudashboard.dashboards.tatu import dashboard
from openstack_dashboard.dashboards.project import dashboard
class Host(horizon.Panel):
name = _("Hosts")
slug = 'host'
slug = 'tatu_host'
dashboard.Tatu.register(Host)
dashboard.Project.register(Host)

View File

@ -15,11 +15,10 @@
import horizon
from django.utils.translation import ugettext_lazy as _
from tatudashboard.dashboards.tatu import dashboard
from openstack_dashboard.dashboards.project import dashboard
class User(horizon.Panel):
name = _("Users")
slug = 'user'
slug = 'tatu_user'
dashboard.Tatu.register(User)
dashboard.Project.register(User)

View File

@ -1,25 +0,0 @@
# 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.
# The name of the dashboard to be added to HORIZON['dashboards']. Required.
DASHBOARD = 'tatu'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
ADD_INSTALLED_APPS = ['tatudashboard']
# Automatically discover static resources in installed apps
AUTO_DISCOVER_STATIC_FILES = True

View File

@ -12,13 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import horizon
class Tatu(horizon.Dashboard):
name = "Tatu (SSH)"
slug = "tatu"
default_panel = "ca"
horizon.register(Tatu)
# The name of the panel group to be added to HORIZON_CONFIG. Required.
PANEL_GROUP = 'tatu'
# The display name of the PANEL_GROUP. Required.
PANEL_GROUP_NAME = 'Tatu'
# The name of the dashboard the PANEL_GROUP associated with. Required.
PANEL_GROUP_DASHBOARD = 'project'

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
PANEL = 'ca'
PANEL_GROUP = 'default'
PANEL_DASHBOARD = 'tatu'
PANEL = 'tatu_ca'
PANEL_GROUP = 'tatu'
PANEL_DASHBOARD = 'project'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
@ -23,4 +23,4 @@ ADD_PANEL = 'tatudashboard.dashboards.tatu.ca.panel.CA'
ADD_ANGULAR_MODULES = ['tatudashboard']
AUTO_DISCOVER_STATIC_FILES = True
AUTO_DISCOVER_STATIC_FILES = True

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
PANEL = 'user'
PANEL_GROUP = 'default'
PANEL_DASHBOARD = 'tatu'
PANEL = 'tatu_user'
PANEL_GROUP = 'tatu'
PANEL_DASHBOARD = 'project'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
PANEL = 'host'
PANEL_GROUP = 'default'
PANEL_DASHBOARD = 'tatu'
PANEL = 'tatu_host'
PANEL_GROUP = 'tatu'
PANEL_DASHBOARD = 'project'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False

View File

@ -1,4 +0,0 @@
<hz-resource-panel resource-type-name="OS::Tatu::Host">
<hz-resource-table resource-type-name="OS::Tatu::Host"
track-by="_timestampId"></hz-resource-table>
</hz-resource-panel>

View File

@ -37,7 +37,7 @@
function apiService(apiPassthroughUrl, httpService, toastService) {
var service = {
get: get,
list: list,
list: list
};
return service;

View File

@ -27,12 +27,20 @@
*/
angular
.module('tatudashboard.resources.os-tatu-ca', [
'ngRoute',
'ngRoute'
])
.constant(
'tatudashboard.resources.os-tatu-ca.resourceType', 'OS::Tatu::CA')
.config(config)
.run(run);
config.$inject = ['$provide', '$windowProvider'];
function config($provide, $windowProvider) {
var path = $windowProvider.$get().STATIC_URL + 'tatudashboard/resources/os-tatu-ca/';
$provide.constant('tatudashboard.resources.os-tatu-ca.basePath', path);
}
run.$inject = [
'horizon.framework.conf.resource-type-registry.service',
'tatudashboard.resources.os-tatu-ca.api',
@ -41,7 +49,7 @@
];
function run(registry,
caApi
caApi,
resourceTypeString,
util) {
var resourceType = registry.getResourceType(resourceTypeString);
@ -52,10 +60,10 @@
label: gettext('CA ID')
})
.setProperty('host_pub_key', {
label: gettext('Host Public Key'),
label: gettext('Host Public Key')
})
.setProperty('user_pub_key', {
label: gettext('User Public Key'),
label: gettext('User Public Key')
});
resourceType
@ -66,11 +74,11 @@
})
.append({
id: 'host_pub_key',
priority: 2,
priority: 2
})
.append({
id: 'user_pub_key',
priority: 2,
priority: 2
});

View File

@ -1,76 +0,0 @@
/**
* (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';
/**
* @ngdoc overview
* @ngname tatudashboard.resources.os-tatu-host.actions
*
* @description
* Provides all of the actions for SSH hosts.
*/
angular.module('tatudashboard.resources.os-tatu-host.actions', [
'horizon.framework.conf',
'horizon.app.core'
])
.run(run);
run.$inject = [
'horizon.framework.conf.resource-type-registry.service',
'tatudashboard.resources.os-tatu-host.resourceType',
'tatudashboard.resources.os-tatu-host.actions.create',
'tatudashboard.resources.os-tatu-host.actions.delete',
'tatudashboard.resources.os-tatu-host.actions.update'
];
function run(registry,
resourceTypeString,
createAction,
deleteAction,
updateAction) {
var resourceType = registry.getResourceType(resourceTypeString);
resourceType
.globalActions
.append({
id: 'create',
service: createAction,
template: {
text: gettext('Create host')
}
});
resourceType
.itemActions
.append({
id: 'update',
service: updateAction,
template: {
text: gettext('Update')
}
})
.append({
id: 'delete',
service: deleteAction,
template: {
text: gettext('Delete'),
type: 'delete'
}
});
}
})();

View File

@ -1,49 +0,0 @@
/**
*
* 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';
describe('host actions module', function() {
var registry;
beforeEach(module('tatudashboard'));
beforeEach(inject(function($injector) {
registry = $injector.get('horizon.framework.conf.resource-type-registry.service');
}));
it('registers Create Host as a global action', function() {
var actions = registry.getResourceType('OS::Tatu::Host').globalActions;
expect(actionHasId(actions, 'create')).toBe(true);
});
it('registers Update Host as a item action', function() {
var actions = registry.getResourceType('OS::Tatu::Host').itemActions;
expect(actionHasId(actions, 'update')).toBe(true);
});
function actionHasId(list, value) {
return list.filter(matchesId).length === 1;
function matchesId(action) {
if (action.id === value) {
return true;
}
}
}
});
})();

View File

@ -1,120 +0,0 @@
/**
*
* (c) Copyright 2016 Hewlett Packard Enterprise Development Company LP
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use self 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-host.actions')
.factory('tatudashboard.resources.os-tatu-host.actions.common-forms', service);
service.$inject = [
];
/**
* Service to return a schema form config for action forms. Especially useful for forms
* like create and update that differ only in the readonly state of certain form fields.
*
* @returns {object} A schema form config
*/
function service() {
var service = {
getCreateFormConfig: getCreateFormConfig,
getUpdateFormConfig: getUpdateFormConfig
};
return service;
/////////////////
/**
* Returns the create host form config
* @returns {{schema, form, model}|*}
*/
function getCreateFormConfig() {
return getCreateUpdateFormConfig(false);
}
/**
* Return the update host form config
* @returns {{schema, form, model}|*}
*/
function getUpdateFormConfig() {
return getCreateUpdateFormConfig(true);
}
/**
* Return the create/update host form. The two forms are identical except for
* during update, some fields are read-only.
*
* @param readonly - sets readonly value on form fields that change between update and create
* @returns {object} a schema form config, including default model
*/
function getCreateUpdateFormConfig(readonly) {
return {
"schema": {
"type": "object",
"properties": {
"hostname": {
"type": "string",
},
"instance_id": {
"type": "string",
},
"proj_id": {
"type": "string",
},
"proj_name": {
"type": "string",
},
"cert": {
"type": "string",
},
"pat": {
"type": "string",
},
"srv_url": {
"type": "string",
}
}
},
"form": [
{
"key": "hostname",
"readonly": readonly,
"title": gettext("Hostname"),
"description": gettext("Foobar fudd"),
"type": "text",
"required": true
},
{
"key": "proj_name",
"readonly": readonly,
"title": gettext("Project Name"),
"description": gettext("Confounded JS noobie."),
"type": "text",
"required": true
}
],
"model": {
"proj_name": "Project24",
"hostname": "pluto"
}
};
}
}
})();

View File

@ -1 +0,0 @@
<h1>CREATE TEMPLATE</h1>

View File

@ -1,126 +0,0 @@
/**
*
* (c) Copyright 2016 Hewlett Packard Enterprise Development Company LP
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use self 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-host.actions')
.factory('tatudashboard.resources.os-tatu-host.actions.create', action);
action.$inject = [
'$q',
'tatudashboard.resources.os-tatu-host.actions.common-forms',
'tatudashboard.resources.os-tatu-host.api',
'tatudashboard.resources.os-tatu-host.resourceType',
'horizon.app.core.openstack-service-api.policy',
'horizon.app.core.openstack-service-api.serviceCatalog',
'horizon.framework.widgets.form.ModalFormService',
'horizon.framework.widgets.toast.service',
'horizon.framework.widgets.modal-wait-spinner.service'
];
/**
* @ngDoc factory
* @name tatudashboard.resources.os-tatu-host.actions.create
*
* @Description
* Brings up the Create Host modal.
*/
function action($q,
forms,
api,
resourceTypeName,
policy,
serviceCatalog,
schemaFormModalService,
toast,
waitSpinner) {
var createHostPolicy, sshServiceEnabled;
var title = gettext("Create Host");
var message = {
success: gettext('Host %s was successfully created.')
};
var service = {
initScope: initScope,
allowed: allowed,
perform: perform
};
return service;
/////////////////
function initScope() {
createHostPolicy = policy.ifAllowed({rules: [['ssh', 'create_host']]});
sshServiceEnabled = serviceCatalog.ifTypeEnabled('ssh');
}
function allowed() {
return $q.all([
createHostPolicy,
sshServiceEnabled
]);
}
function perform() {
var formConfig = forms.getCreateFormConfig();
formConfig.title = title;
return schemaFormModalService.open(formConfig).then(onSubmit, onCancel);
}
function onSubmit(context) {
var hostModel = angular.copy(context.model);
// schema form doesn't appear to support populating the masters array directly
// Map the masters objects to simple array of addresses
if (context.model.hasOwnProperty("masters")) {
var masters = context.model.masters.map(function (item) {
return item.address;
});
hostModel.masters = masters;
}
waitSpinner.showModalSpinner(gettext('Creating Host'));
return api.create(hostModel).then(onSuccess, onFailure);
}
function onCancel() {
waitSpinner.hideModalSpinner();
}
function onSuccess(response) {
waitSpinner.hideModalSpinner();
var host = response.data;
toast.add('success', interpolate(message.success, [host.name]));
// To make the result of this action generically useful, reformat the return
// from the deleteModal into a standard form
return {
created: [{type: resourceTypeName, id: host.id}],
updated: [],
deleted: [],
failed: []
};
}
function onFailure() {
waitSpinner.hideModalSpinner();
}
}
})();

View File

@ -1,169 +0,0 @@
/**
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use self 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-host.actions')
.factory('tatudashboard.resources.os-tatu-host.actions.delete', action);
action.$inject = [
'$q',
'tatudashboard.resources.os-tatu-host.api',
'tatudashboard.resources.util',
'horizon.app.core.openstack-service-api.policy',
'horizon.framework.util.actions.action-result.service',
'horizon.framework.util.i18n.gettext',
'horizon.framework.util.q.extensions',
'horizon.framework.widgets.modal.deleteModalService',
'horizon.framework.widgets.toast.service',
'tatudashboard.resources.os-tatu-host.resourceType'
];
/*
* @ngdoc factory
* @name tatudashboard.resources.os-tatu-host.actions.delete
*
* @Description
* Brings up the delete host confirmation modal dialog.
* On submit, delete given host.
* On cancel, do nothing.
*/
function action(
$q,
hostApi,
util,
policy,
actionResultService,
gettext,
$qExtensions,
deleteModal,
toast,
resourceType
) {
var scope, context, deleteHostPromise;
var notAllowedMessage = gettext("You are not allowed to delete hosts: %s");
var service = {
initScope: initScope,
allowed: allowed,
perform: perform
};
return service;
//////////////
function initScope(newScope) {
scope = newScope;
context = { };
deleteHostPromise = policy.ifAllowed({rules: [['ssh', 'delete_host']]});
}
function perform(items) {
var hosts = angular.isArray(items) ? items : [items];
context.labels = labelize(hosts.length);
context.deleteEntity = deleteHost;
return $qExtensions.allSettled(hosts.map(checkPermission)).then(afterCheck);
}
function allowed(host) {
// only row actions pass in host
// otherwise, assume it is a batch action
if (host) {
return $q.all([
deleteHostPromise,
util.notDeleted(host),
util.notPending(host)
]);
} else {
return policy.ifAllowed({ rules: [['ssh', 'delete_host']] });
}
}
function checkPermission(host) {
return {promise: allowed(host), context: host};
}
function afterCheck(result) {
var outcome = $q.reject(); // Reject the promise by default
if (result.fail.length > 0) {
toast.add('error', getMessage(notAllowedMessage, result.fail));
outcome = $q.reject(result.fail);
}
if (result.pass.length > 0) {
outcome = deleteModal.open(scope, result.pass.map(getEntity), context).then(createResult);
}
return outcome;
}
function createResult(deleteModalResult) {
// To make the result of this action generically useful, reformat the return
// from the deleteModal into a standard form
var actionResult = actionResultService.getActionResult();
deleteModalResult.pass.forEach(function markDeleted(item) {
actionResult.deleted(resourceType, getEntity(item).id);
});
deleteModalResult.fail.forEach(function markFailed(item) {
actionResult.failed(resourceType, getEntity(item).id);
});
return actionResult.result;
}
function labelize(count) {
return {
title: ngettext(
'Confirm Delete Host',
'Confirm Delete Hosts', count),
message: ngettext(
'You have selected "%s". Deleted host is not recoverable.',
'You have selected "%s". Deleted hosts are not recoverable.', count),
submit: ngettext(
'Delete Host',
'Delete Hosts', count),
success: ngettext(
'Deleted Host: %s.',
'Deleted Hosts: %s.', count),
error: ngettext(
'Unable to delete Host: %s.',
'Unable to delete Hosts: %s.', count)
};
}
function deleteHost(host) {
return hostApi.deleteHost(host, true);
}
function getMessage(message, entities) {
return interpolate(message, [entities.map(getName).join(", ")]);
}
function getName(result) {
return getEntity(result).name;
}
function getEntity(result) {
return result.context;
}
}
})();

View File

@ -1,147 +0,0 @@
/**
*
* (c) Copyright 2016 Hewlett Packard Enterprise Development Company LP
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use self 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-host.actions')
.factory('tatudashboard.resources.os-tatu-host.actions.update', action);
action.$inject = [
'$q',
'tatudashboard.resources.os-tatu-host.actions.common-forms',
'tatudashboard.resources.os-tatu-host.api',
'tatudashboard.resources.os-tatu-host.resourceType',
'tatudashboard.resources.util',
'horizon.app.core.openstack-service-api.policy',
'horizon.app.core.openstack-service-api.serviceCatalog',
'horizon.framework.widgets.form.ModalFormService',
'horizon.framework.widgets.toast.service',
'horizon.framework.widgets.modal-wait-spinner.service'
];
/**
* @ngDoc factory
* @name tatudashboard.resources.os-tatu-host.actions.update
*
* @Description
* Brings up the Update Host modal.
*/
function action($q,
forms,
api,
resourceTypeName,
util,
policy,
serviceCatalog,
schemaFormModalService,
toast,
waitSpinner) {
var updateHostPolicy, sshServiceEnabled;
var title = gettext("Update Host");
var message = {
success: gettext('Host %s was successfully updated.')
};
var service = {
initScope: initScope,
allowed: allowed,
perform: perform
};
return service;
/////////////////
function initScope() {
updateHostPolicy = policy.ifAllowed({rules: [['ssh', 'update_host']]});
sshServiceEnabled = serviceCatalog.ifTypeEnabled('ssh');
}
function allowed(host) {
// only supports row action (exactly 1 host)
if (host) {
return $q.all([
updateHostPolicy,
util.notDeleted(host),
util.notPending(host)
]);
} else {
return false;
}
}
function perform(item) {
var formConfig = forms.getUpdateFormConfig();
formConfig.title = title;
formConfig.model = util.getModel(formConfig.form, item);
// Append the id so it can be used on submit
formConfig.model.id = item.id;
// schema form doesn't appear to support populating the masters array directly
// Map the masters objects to address objects
if (item.hasOwnProperty("masters")) {
var masters = item.masters.map(function (item) {
return { "address": item }
})
formConfig.masters = masters;
}
return schemaFormModalService.open(formConfig).then(onSubmit, onCancel);
}
function onSubmit(context) {
var hostModel = angular.copy(context.model);
// schema form doesn't appear to support populating the masters array directly
// Map the masters objects to simple array of addresses
if (context.model.hasOwnProperty("masters")) {
var masters = context.model.masters.map(function (item) {
return item.address;
})
hostModel.masters = masters;
}
waitSpinner.showModalSpinner(gettext('Updating Host'));
return api.update(hostModel.id, hostModel).then(onSuccess, onFailure);
}
function onCancel() {
waitSpinner.hideModalSpinner();
}
function onSuccess(response) {
waitSpinner.hideModalSpinner();
var host = response.data;
toast.add('success', interpolate(message.success, [host.name]));
// To make the result of this action generically useful, reformat the return
// from the deleteModal into a standard form
return {
created: [],
updated: [{type: resourceTypeName, id: host.id}],
deleted: [],
failed: []
};
}
function onFailure() {
waitSpinner.hideModalSpinner();
}
}
})();

View File

@ -1,171 +0,0 @@
/**
* (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-host')
.factory('tatudashboard.resources.os-tatu-host.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 Host APIs.
* @returns {Object} The service
*/
function apiService(apiPassthroughUrl, httpService, toastService) {
var service = {
get: get,
list: list,
deleteHost: deleteHost,
create: create,
update: update
};
return service;
///////////////
/**
* @name list
* @description
* Get a list of hosts.
*
* The listing result is an object with property "items." Each item is
* a host.
*
* @param {Object} params
* Query parameters. Optional.
*
* @returns {Object} The result of the API call
*/
function list(params) {
var config = params ? {'params': params} : {};
var hosts = [{
'instance_id': '00000000-aaaa-bbbb-cccc-111122224444',
'hostname': 'fluffy',
'proj_id': 'aaaaaaaa-aaaa-bbbb-cccc-111122224444',
'proj_name': 'ProjectA',
'cert': 'Bogus ssh cert...',
'pat': '11.11.0.1:1002,11.11.0.2:1002',
'srv_url': '_ssh._tcp.fluffy.aaaaaaaa.tatu.com.',
},{
'instance_id': '11111111-aaaa-bbbb-cccc-111122224444',
'hostname': 'chester',
'proj_id': 'aaaaaaaa-aaaa-bbbb-cccc-111122224444',
'proj_name': 'ProjectA',
'cert': 'Bogus ssh cert...',
'pat': '11.11.0.1:1005,11.11.0.2:1005',
'srv_url': '_ssh._tcp.chester.aaaaaaaa.tatu.com.',
},{
'instance_id': '22222222-aaaa-bbbb-cccc-111122224444',
'hostname': 'snoopy',
'proj_id': 'aaaaaaaa-aaaa-bbbb-cccc-111122224444',
'proj_name': 'ProjectA',
'cert': 'Bogus ssh cert...',
'pat': '11.11.0.1:1009,11.11.0.2:1009',
'srv_url': '_ssh._tcp.snoopy.aaaaaaaa.tatu.com.',
}];
return hosts;
/*
return httpService.get(apiPassthroughUrl + 'hosts/', config)
.error(function () {
toastService.add('error', gettext('Unable to retrieve the host.'));
});*/
}
/**
* @name get
* @description
* Get a single host by ID.
*
* @param {string} id
* Specifies the id of the host to request.
*
* @returns {Object} The result of the API call
*/
function get(id) {
return httpService.get(apiPassthroughUrl + 'hosts/' + id + '/')
.error(function () {
toastService.add('error', gettext('Unable to retrieve the host.'));
});
}
/**
* @name deleteHost
* @description
* Delete a single host by ID
* @param id
* @returns {*}
*/
function deleteHost(id) {
return httpService.delete(apiPassthroughUrl + 'hosts/' + id + '/')
.error(function () {
toastService.add('error', gettext('Unable to delete the host.'));
});
}
/**
* @name create
* @description
* Create a host
*
* @param {Object} data
* Specifies the host information to create
*
* @returns {Object} The created host object
*/
function create(data) {
return httpService.post(apiPassthroughUrl + 'hosts/', data)
.error(function() {
toastService.add('error', gettext('Unable to create the host.'));
})
}
/**
* @name create
* @description
* Update a host
*
* @param {Object} id - host id
* @param {Object} data to pass directly to host update API
* Specifies the host information to update
*
* @returns {Object} The updated host object
*/
function update(id, data) {
// The update API will not accept extra data. Restrict the input to only the allowed
// fields
var apiData = {
email: data.email,
ttl: data.ttl,
description: data.description
};
return httpService.patch(apiPassthroughUrl + 'hosts/' + id + '/', apiData )
.error(function() {
toastService.add('error', gettext('Unable to update the host.'));
})
}
}
}());

View File

@ -1,61 +0,0 @@
/**
* (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';
/**
* @ngdoc overview
* @ngname tatudashboard.resources.os-tatu-host.details
*
* @description
* Provides details features for hosts.
*/
angular.module('tatudashboard.resources.os-tatu-host.details',
['horizon.framework.conf', 'horizon.app.core'])
.run(run);
run.$inject = [
'tatudashboard.resources.os-tatu-host.resourceType',
'tatudashboard.resources.os-tatu-host.api',
'tatudashboard.resources.os-tatu-host.basePath',
'horizon.framework.conf.resource-type-registry.service'
];
function run(
hostResourceType,
hostApi,
basePath,
registry
) {
var resourceType = registry.getResourceType(hostResourceType);
resourceType
.setLoadFunction(loadFunction)
.setSummaryTemplateUrl(basePath + 'details/drawer.html');
resourceType.detailsViews
.prepend({
id: 'hostDetailsOverview',
name: gettext('Overview'),
template: basePath + 'details/overview.html',
}, 0);
function loadFunction(identifier) {
return hostApi.get(identifier);
}
}
})();

View File

@ -1,10 +0,0 @@
<hz-resource-property-list
ng-if="item"
resource-type-name="OS::Tatu::Host"
item="item"
cls="dl-horizontal"
property-groups="[
['description', 'email'],
['id', 'pool_id', 'project_id']
]">
</hz-resource-property-list>

View File

@ -1,55 +0,0 @@
/**
* (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-host')
.controller('tatudashboard.resources.os-tatu-host.detailController', controller);
controller.$inject = [
'tatudashboard.resources.os-tatu-host.resourceType',
'horizon.framework.conf.resource-type-registry.service',
'$scope'
];
function controller(
resourceTypeCode,
registry,
$scope
) {
var ctrl = this;
ctrl.item;
ctrl.resourceType = registry.getResourceType(resourceTypeCode);
$scope.context.loadPromise.then(onGetResponse);
function onGetResponse(response) {
ctrl.item = response.data;
var attr = '';
var keys = Object.keys(response.data.attributes);
for (var i = keys.length - 1; i >= 0; i--) {
attr += keys[i] + ':' + response.data.attributes[keys[i]] + ', ';
}
ctrl.item.attributes = attr;
}
}
})();

View File

@ -1,58 +0,0 @@
<div ng-controller="tatudashboard.resources.os-tatu-host.detailController as ctrl">
<div class="row">
<div class="col-md-6 detail">
<h3 translate>Details</h3>
<hr>
<hz-resource-property-list
ng-if="ctrl.item"
resource-type-name="OS::Tatu::Host"
item="ctrl.item"
cls="dl-horizontal"
property-groups="[
['id', 'description', 'type', 'status', 'action', 'email', 'serial', 'ttl', 'version']
]">
</hz-resource-property-list>
</div>
<div class="col-md-6 detail">
<h3 translate>Attributes</h3>
<hr>
<hz-resource-property-list
ng-if="ctrl.item"
resource-type-name="OS::Tatu::Host"
item="ctrl.item"
cls="dl-horizontal"
property-groups="[
['attributes']
]">
</hz-resource-property-list>
</div>
</div>
<div class="row">
<div class="col-md-6 detail">
<h3 translate>Modification Times</h3>
<hr>
<hz-resource-property-list
ng-if="ctrl.item"
resource-type-name="OS::Tatu::Host"
item="ctrl.item"
cls="dl-horizontal"
property-groups="[
['created_at', 'updated_at', 'transferred_at']
]">
</hz-resource-property-list>
</div>
<div class="col-md-6 detail">
<h3 translate>Associations</h3>
<hr>
<hz-resource-property-list
ng-if="ctrl.item"
resource-type-name="OS::Tatu::Host"
item="ctrl.item"
cls="dl-horizontal"
property-groups="[
['pool_id', 'project_id', 'masters']
]">
</hz-resource-property-list>
</div>
</div>
</div>

View File

@ -1,110 +0,0 @@
/**
* (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';
/**
* @ngdoc overview
* @ngname tatudashboard.resources.os-tatu-host
*
* @description
* Provides all of the services and widgets required
* to support and display SSH (Tatu) host related content.
*/
angular
.module('tatudashboard.resources.os-tatu-host', [
'ngRoute',
])
.constant(
'tatudashboard.resources.os-tatu-host.resourceType', 'OS::Tatu::Host')
.run(run);
run.$inject = [
'horizon.framework.conf.resource-type-registry.service',
'tatudashboard.resources.os-tatu-host.resourceType',
'tatudashboard.resources.util'
];
function run(registry,
resourceTypeString,
util) {
var resourceType = registry.getResourceType(resourceTypeString);
resourceType
.setNames(gettext('SSH Host'), gettext('SSH Hosts'))
.setListFunction(listHosts)
.setProperty('action', {
label: gettext('Action'),
values: util.actionMap()
})
.setProperty('instance_id', {
label: gettext('Instance ID')
})
.setProperty('hostname', {
label: gettext('Hostname'),
})
.setProperty('proj_id', {
label: gettext('Project ID'),
})
.setProperty('proj_name', {
label: gettext('Project Name'),
})
.setProperty('cert', {
label: gettext('Certificate')
})
.setProperty('pat', {
label: gettext('IP:Port for PAT')
})
.setProperty('srv_url', {
label: gettext('SRV Record URL')
})
resourceType
.tableColumns
.append({
id: 'hostname',
priority: 1,
sortDefault: true,
})
.append({
id: 'proj_name',
priority: 2,
})
.append({
id: 'pat',
priority: 2,
})
.append({
id: 'srv_url',
priority: 2
});
resourceType
.filterFacets
.append({
label: gettext('Hostname'),
name: 'hostname',
isServer: false,
singleton: true,
persistent: false
});
function listHosts() {
return [];
}
}
})();

View File

@ -58,13 +58,13 @@
$provide.constant('tatudashboard.basePath', path);
$routeProvider
.when('/tatu/ca/', {
.when('/project/tatu_ca/', {
templateUrl: path + 'ca.html'
})
.when('/tatu/user/', {
.when('/project/tatu_user/', {
templateUrl: path + 'ca.html'
})
.when('/tatu/host/', {
.when('/project/tatu_host/', {
templateUrl: path + 'ca.html'
});
}