Merge "Fix view messages dialog"

This commit is contained in:
Jenkins 2017-07-27 01:41:09 +00:00 committed by Gerrit Code Review
commit 3f306b3f4d
3 changed files with 23 additions and 30 deletions

View File

@ -97,8 +97,9 @@
}
function getMessages(queueName) {
var msg = gettext('Unable to get messages.');
var url = interpolate(msgPath, [queueName]);
return apiService.get(url);
return apiService.get(url).error(error(msg));
}
function postMessages(queueName, msgs) {

View File

@ -40,8 +40,10 @@
var ctrl = this;
ctrl.queue = $scope.model.id;
ctrl.messages = [];
/* TODO: actions will be implemented later.
ctrl.claimMessage = claimMessage;
ctrl.deleteMessage = deleteMessage;
*/
zaqar.getMessages(ctrl.queue).success(function (response) {
ctrl.messages = response;

View File

@ -23,13 +23,9 @@
listMessageService.$inject = [
'$q',
'horizon.dashboard.project.queues.basePath',
'horizon.app.core.openstack-service-api.policy',
'horizon.app.core.openstack-service-api.zaqar',
'horizon.dashboard.project.queues.events',
'horizon.framework.util.i18n.gettext',
'horizon.framework.util.q.extensions',
'horizon.framework.widgets.form.ModalFormService',
'horizon.framework.widgets.toast.service'
'horizon.framework.widgets.form.ModalFormService'
];
/**
@ -37,26 +33,22 @@
* @name horizon.dashboard.project.queues.actions.listMessageService
* @param {Object} $q
* @param {String} basePath
* @param {Object} policy
* @param {Object} zaqar
* @param {Object} events
* @param {Object} gettext
* @param {Object} $qExtensions
* @param {Object} modal
* @param {Object} toast
* @returns {Object} list messages service
* @description Brings up the polling messages modal dialog.
* On submit, poll messages from given queues.
* On cancel, do nothing.
*/
function listMessageService(
$q, basePath, policy, zaqar, events, gettext, $qExtensions, modal, toast
$q, basePath, gettext, $qExtensions, modal
) {
// schema
var schema = {
type: "object",
properties: {
postMessages: {
listMessages: {
title: gettext("List Messages"),
type: "string"
}
@ -86,16 +78,21 @@
// model
var model;
var message = {
success: gettext('Messages has been posted to queue %s successfully.')
};
var service = {
initAction: initAction,
perform: perform,
allowed: allowed
};
// modal config
var config = {
"title": gettext('List Messages'),
"submitText": gettext('List Messages'),
"schema": schema,
"form": form,
"model": model
};
return service;
//////////////
@ -108,29 +105,22 @@
}
function perform(selected) {
model = {
config.model = {
id: selected.id,
name: selected.name
};
// modal config
var config = {
"title": gettext('List Messages'),
"submitText": gettext('List Messages'),
"schema": schema,
"form": form,
"model": model
};
return modal.open(config).then(submit);
}
function submit(context) {
var id = context.model.id;
var name = context.model.name;
delete context.model.id;
delete context.model.name;
return zaqar.postMessages(id, context.model).then(function() {
toast.add('success', interpolate(message.success, [name]));
});
config.model = {
id: id,
name: name
};
// display new dialog
modal.open(config).then(submit);
}
}
})();