Merge "Fix view messages dialog"
This commit is contained in:
commit
3f306b3f4d
@ -97,8 +97,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMessages(queueName) {
|
function getMessages(queueName) {
|
||||||
|
var msg = gettext('Unable to get messages.');
|
||||||
var url = interpolate(msgPath, [queueName]);
|
var url = interpolate(msgPath, [queueName]);
|
||||||
return apiService.get(url);
|
return apiService.get(url).error(error(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
function postMessages(queueName, msgs) {
|
function postMessages(queueName, msgs) {
|
||||||
|
@ -40,8 +40,10 @@
|
|||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
ctrl.queue = $scope.model.id;
|
ctrl.queue = $scope.model.id;
|
||||||
ctrl.messages = [];
|
ctrl.messages = [];
|
||||||
|
/* TODO: actions will be implemented later.
|
||||||
ctrl.claimMessage = claimMessage;
|
ctrl.claimMessage = claimMessage;
|
||||||
ctrl.deleteMessage = deleteMessage;
|
ctrl.deleteMessage = deleteMessage;
|
||||||
|
*/
|
||||||
|
|
||||||
zaqar.getMessages(ctrl.queue).success(function (response) {
|
zaqar.getMessages(ctrl.queue).success(function (response) {
|
||||||
ctrl.messages = response;
|
ctrl.messages = response;
|
||||||
|
@ -23,13 +23,9 @@
|
|||||||
listMessageService.$inject = [
|
listMessageService.$inject = [
|
||||||
'$q',
|
'$q',
|
||||||
'horizon.dashboard.project.queues.basePath',
|
'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.i18n.gettext',
|
||||||
'horizon.framework.util.q.extensions',
|
'horizon.framework.util.q.extensions',
|
||||||
'horizon.framework.widgets.form.ModalFormService',
|
'horizon.framework.widgets.form.ModalFormService'
|
||||||
'horizon.framework.widgets.toast.service'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,26 +33,22 @@
|
|||||||
* @name horizon.dashboard.project.queues.actions.listMessageService
|
* @name horizon.dashboard.project.queues.actions.listMessageService
|
||||||
* @param {Object} $q
|
* @param {Object} $q
|
||||||
* @param {String} basePath
|
* @param {String} basePath
|
||||||
* @param {Object} policy
|
|
||||||
* @param {Object} zaqar
|
|
||||||
* @param {Object} events
|
|
||||||
* @param {Object} gettext
|
* @param {Object} gettext
|
||||||
* @param {Object} $qExtensions
|
* @param {Object} $qExtensions
|
||||||
* @param {Object} modal
|
* @param {Object} modal
|
||||||
* @param {Object} toast
|
|
||||||
* @returns {Object} list messages service
|
* @returns {Object} list messages service
|
||||||
* @description Brings up the polling messages modal dialog.
|
* @description Brings up the polling messages modal dialog.
|
||||||
* On submit, poll messages from given queues.
|
* On submit, poll messages from given queues.
|
||||||
* On cancel, do nothing.
|
* On cancel, do nothing.
|
||||||
*/
|
*/
|
||||||
function listMessageService(
|
function listMessageService(
|
||||||
$q, basePath, policy, zaqar, events, gettext, $qExtensions, modal, toast
|
$q, basePath, gettext, $qExtensions, modal
|
||||||
) {
|
) {
|
||||||
// schema
|
// schema
|
||||||
var schema = {
|
var schema = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
postMessages: {
|
listMessages: {
|
||||||
title: gettext("List Messages"),
|
title: gettext("List Messages"),
|
||||||
type: "string"
|
type: "string"
|
||||||
}
|
}
|
||||||
@ -86,16 +78,21 @@
|
|||||||
// model
|
// model
|
||||||
var model;
|
var model;
|
||||||
|
|
||||||
var message = {
|
|
||||||
success: gettext('Messages has been posted to queue %s successfully.')
|
|
||||||
};
|
|
||||||
|
|
||||||
var service = {
|
var service = {
|
||||||
initAction: initAction,
|
initAction: initAction,
|
||||||
perform: perform,
|
perform: perform,
|
||||||
allowed: allowed
|
allowed: allowed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// modal config
|
||||||
|
var config = {
|
||||||
|
"title": gettext('List Messages'),
|
||||||
|
"submitText": gettext('List Messages'),
|
||||||
|
"schema": schema,
|
||||||
|
"form": form,
|
||||||
|
"model": model
|
||||||
|
};
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
@ -108,29 +105,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
model = {
|
config.model = {
|
||||||
id: selected.id,
|
id: selected.id,
|
||||||
name: selected.name
|
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);
|
return modal.open(config).then(submit);
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit(context) {
|
function submit(context) {
|
||||||
var id = context.model.id;
|
var id = context.model.id;
|
||||||
var name = context.model.name;
|
var name = context.model.name;
|
||||||
delete context.model.id;
|
config.model = {
|
||||||
delete context.model.name;
|
id: id,
|
||||||
return zaqar.postMessages(id, context.model).then(function() {
|
name: name
|
||||||
toast.add('success', interpolate(message.success, [name]));
|
};
|
||||||
});
|
// display new dialog
|
||||||
|
modal.open(config).then(submit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user