Add video conference action into addressbook

This commit is contained in:
Hadi Nategh 2020-04-02 17:48:07 +02:00
parent 43c75cad94
commit 724e669e72
3 changed files with 122 additions and 14 deletions

View File

@ -577,23 +577,29 @@ class addressbook_ui extends addressbook_bo
++$group; // integration with other apps: infolog, calendar, filemanager, messenger
// Integrate Messenger app actions for adding new buddy into roster list
if ($GLOBALS['egw_info']['user']['apps']['messenger'])
// Integrate Status Videoconference actions
if ($GLOBALS['egw_info']['user']['apps']['status'])
{
$actions['messenger_app'] = array(
'caption' => 'Messenger',
'icon' => 'messenger/navbar',
$actions['videoconference'] = [
'caption' => 'Video Conference',
'icon' => 'video_call',
'group' => $group,
'children' => array(
'addBuddy' => array(
'caption' => lang('Add contact'),
'icon' => 'add',
'children' => [
'call' => [
'caption' => lang('Call'),
'icon' => 'call',
'allowOnMultiple' => true,
'onExecute' => 'javaScript:app.messenger.addBuddy',
'enabled' => 'javaScript:app.messenger.addBuddyEnabaled'
)
)
);
'onExecute' => 'javaScript:app.addressbook.videoconference_actionCall',
'enabled' => 'javaScript:app.addressbook.videoconference_isUserOnline'
],
'schedule_call' => [
'caption' => lang('Schedule a call'),
'icon' => 'calendar',
'allowOnMultiple' => true,
'onExecute' => 'javaScript:app.addressbook.videoconference_scheduleCall',
]
]
];
}
if ($GLOBALS['egw_info']['user']['apps']['infolog'])

View File

@ -1079,6 +1079,52 @@ var AddressbookApp = /** @class */ (function (_super) {
}
return enabled;
};
/**
* Check if selected user(s) is online then enable action
* @param _action
* @param _selected
*/
AddressbookApp.prototype.videoconference_isUserOnline = function (_action, _selected) {
var _a;
var list = app.status.getEntireList();
for (var sel in _selected) {
var row = egw.dataGetUIDdata(_selected[sel]['id']);
var enabled = false;
for (var entry in list) {
if (((_a = row.data) === null || _a === void 0 ? void 0 : _a.account_id) == list[entry]['account_id']) {
enabled = list[entry]['data']['status']['active'];
}
}
if (!enabled)
return false;
}
return true;
};
/**
* Call action
* @param _action
* @param _selected
*/
AddressbookApp.prototype.videoconference_actionCall = function (_action, _selected) {
var data = [];
for (var sel in _selected) {
var row = egw.dataGetUIDdata(_selected[sel]['id']);
data.push({
id: row.data.account_id,
name: row.data.n_fn,
avatar: "account:" + row.data.account_id
});
}
app.status.makeCall(data);
};
/**
*
* @param _action
* @param _selected
* @todo
*/
AddressbookApp.prototype.videoconference_scheduleCall = function (_action, _selected) {
};
return AddressbookApp;
}(egw_app_1.EgwApp));
app.classes.addressbook = AddressbookApp;

View File

@ -1316,6 +1316,62 @@ class AddressbookApp extends EgwApp
}
return enabled;
}
/**
* Check if selected user(s) is online then enable action
* @param _action
* @param _selected
*/
private videoconference_isUserOnline(_action, _selected)
{
let list = app.status.getEntireList();
for (let sel in _selected)
{
let row = egw.dataGetUIDdata(_selected[sel]['id']);
let enabled = false;
for(let entry in list)
{
if (row.data?.account_id == list[entry]['account_id'])
{
enabled = list[entry]['data']['status']['active'];
}
}
if (!enabled) return false;
}
return true;
}
/**
* Call action
* @param _action
* @param _selected
*/
private videoconference_actionCall(_action, _selected)
{
let data = [];
for (let sel in _selected)
{
let row = egw.dataGetUIDdata(_selected[sel]['id']);
data.push({
id: row.data.account_id,
name: row.data.n_fn,
avatar: "account:"+row.data.account_id
});
}
app.status.makeCall(data);
}
/**
*
* @param _action
* @param _selected
* @todo
*/
private videoconference_scheduleCall(_action, _selected)
{
}
}
app.classes.addressbook = AddressbookApp;