Commit d9dc99d3 authored by Gabriel Engel's avatar Gabriel Engel Committed by GitHub

Merge pull request #5230 from RocketChat/livechat-improve-triggers-page

Improve livechat triggers page
parents ddfe65a7 ca646248
<template name="requiresPermission">
{{#if hasPermission this}}
{{> Template.contentBlock}}
{{else}}
{{#if Template.elseBlock}}
{{> Template.elseBlock}}
{{else}}
{{_ "Not_found_or_not_allowed"}}
{{/if}}
{{/if}}
</template>
......@@ -31,6 +31,7 @@ Package.onUse(function(api) {
api.addFiles('client/startup.coffee', ['client']);
api.addFiles('client/hasPermission.coffee', ['client']);
api.addFiles('client/hasRole.coffee', ['client']);
api.addFiles('client/requiresPermission.html', ['client']);
api.addFiles('client/route.coffee', ['client']);
......
......@@ -372,6 +372,7 @@
"Edit": "Edit",
"Edit_Custom_Field": "Edit Custom Field",
"Edit_Department": "Edit Department",
"Edit_Trigger": "Edit Trigger",
"edited": "edited",
"Editing_room": "Editing room",
"Editing_user": "Editing user",
......@@ -908,6 +909,7 @@
"New_role": "New role",
"New_Room_Notification": "New Room Notification",
"New_videocall_request": "New videocall request",
"New_Trigger": "New Trigger",
"No_available_agents_to_transfer": "No available agents to transfer",
"No_channel_with_name_%s_was_found": "No channel with name <strong>\"%s\"</strong> was found!",
"No_channels_yet": "You aren't part of any channel yet.",
......
......@@ -349,6 +349,7 @@
"Edit": "Editar",
"Edit_Custom_Field": "Editar Campo Personalizado",
"Edit_Department": "Editar Departamento",
"Edit_Trigger": "Editar Gatilho",
"edited": "editado",
"Editing_room": "Edição de sala",
"Editing_user": "Edição de usuário",
......@@ -793,6 +794,7 @@
"New_role": "Novo papel",
"New_Room_Notification": "Notificação de nova sala",
"New_videocall_request": "Nova requisição de chamada de vídeo",
"New_Trigger": "Novo Gatilho",
"No_available_agents_to_transfer": "Nenhum agente disponível para transferir",
"No_channel_with_name_%s_was_found": "Nenhum canal com nome <strong>\"%s\"</strong> foi encontrado!",
"No_channels_yet": "Você não faz parte de nenhum canal ainda.",
......
......@@ -129,7 +129,7 @@ class ModelsBaseDb {
try {
return this.ensureIndex(...arguments);
} catch (e) {
console.log(e);
console.error('Error creating index:', this.name, '->', ...arguments, e);
}
}
......@@ -137,7 +137,7 @@ class ModelsBaseDb {
try {
return this.dropIndex(...arguments);
} catch (e) {
console.log(e);
console.error('Error dropping index:', this.name, '->', ...arguments, e);
}
}
......
......@@ -59,6 +59,22 @@ AccountBox.addRoute({
pageTemplate: 'livechatTriggers'
}, livechatManagerRoutes);
AccountBox.addRoute({
name: 'livechat-trigger-edit',
path: '/triggers/:_id/edit',
sideNav: 'livechatFlex',
i18nPageTitle: 'Edit_Trigger',
pageTemplate: 'livechatTriggersForm'
}, livechatManagerRoutes);
AccountBox.addRoute({
name: 'livechat-trigger-new',
path: '/triggers/new',
sideNav: 'livechatFlex',
i18nPageTitle: 'New_Trigger',
pageTemplate: 'livechatTriggersForm'
}, livechatManagerRoutes);
AccountBox.addRoute({
name: 'livechat-installation',
path: '/installation',
......
<template name="livechatCurrentChats">
<fieldset>
<form class="form-inline" method="post">
<div class="form-group">
<label for="name">{{_ "Name"}}</label>
<input type="text" name="name">
</div>
<div class="form-group">
<label for="agent">{{_ "Served_By"}}</label>
<select name="agent">
<option value=""></option>
{{#each agents}}
<option value="{{_id}}">{{username}}</option>
{{/each}}
</select>
</div>
<div class="form-group">
<label for="status">{{_ "Status"}}</label>
<select name="status">
<option value=""></option>
<option value="opened">{{_ "Opened"}}</option>
<option value="closed">{{_ "Closed"}}</option>
</select>
</div>
<!--Added by Deepankar-->
<div class="input-group input-daterange" data-date-autoclose="true" data-date-todayHighlight="true" data-provide="datepicker" >
<span class="input-group-addon">From</span>
<input type="text" class="form-control" id="from" name="from" >
<span class="input-group-addon">to</span>
<input type="text" class="form-control" id="to" name="to">
{{#requiresPermission 'view-livechat-manager'}}
<fieldset>
<form class="form-inline" method="post">
<div class="form-group">
<label for="name">{{_ "Name"}}</label>
<input type="text" name="name">
</div>
<button class="button">{{_ "Filter"}}</button>
<div class="form-group">
<label for="agent">{{_ "Served_By"}}</label>
<select name="agent">
<option value=""></option>
{{#each agents}}
<option value="{{_id}}">{{username}}</option>
{{/each}}
</select>
</div>
<!--Added by Deepankar-->
</form>
</fieldset>
<div class="list">
<table>
<thead>
<tr>
<th width="25%">{{_ "Name"}}</th>
<th width="25%">{{_ "Served_By"}}</th>
<th width="15%">{{_ "Started_At"}}</th>
<th width="15%">{{_ "Last_Message_At"}}</th>
<th width="10%">{{_ "Status"}}</th>
</tr>
</thead>
<tbody>
{{#each livechatRoom}}
<tr class="row-link">
<td>{{label}}</td>
<td>{{servedBy}}</td>
<td>{{startedAt}}</td>
<td>{{lastMessage}}</td>
<td>{{status}}</td>
<div class="form-group">
<label for="status">{{_ "Status"}}</label>
<select name="status">
<option value=""></option>
<option value="opened">{{_ "Opened"}}</option>
<option value="closed">{{_ "Closed"}}</option>
</select>
</div>
<!--Added by Deepankar-->
<div class="input-group input-daterange" data-date-autoclose="true" data-date-todayHighlight="true" data-provide="datepicker" >
<span class="input-group-addon">From</span>
<input type="text" class="form-control" id="from" name="from" >
<span class="input-group-addon">to</span>
<input type="text" class="form-control" id="to" name="to">
<button class="button">{{_ "Filter"}}</button>
</div>
<!--Added by Deepankar-->
</form>
</fieldset>
<div class="list">
<table>
<thead>
<tr>
<th width="25%">{{_ "Name"}}</th>
<th width="25%">{{_ "Served_By"}}</th>
<th width="15%">{{_ "Started_At"}}</th>
<th width="15%">{{_ "Last_Message_At"}}</th>
<th width="10%">{{_ "Status"}}</th>
</tr>
{{/each}}
</tbody>
</table>
</div>
<div class="text-center">
<button class="button load-more">{{_ "Load_more"}}</button>
</div>
</thead>
<tbody>
{{#each livechatRoom}}
<tr class="row-link">
<td>{{label}}</td>
<td>{{servedBy}}</td>
<td>{{startedAt}}</td>
<td>{{lastMessage}}</td>
<td>{{status}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
<div class="text-center">
<button class="button load-more">{{_ "Load_more"}}</button>
</div>
{{/requiresPermission}}
</template>
<template name="livechatCustomFieldForm">
<form id="customField-form" data-id="{{customField._id}}">
<div class="rocket-form">
{{#if Template.subscriptionsReady}}
<fieldset>
<div class="input-line">
<label>{{_ "Field"}}</label>
<div>
<input type="text" name="field" value="{{customField._id}}" readonly="{{$exists customField._id}}" placeholder="{{_ "Field"}}" />
{{#requiresPermission 'view-livechat-manager'}}
<form id="customField-form" data-id="{{customField._id}}">
<div class="rocket-form">
{{#if Template.subscriptionsReady}}
<fieldset>
<div class="input-line">
<label>{{_ "Field"}}</label>
<div>
<input type="text" name="field" value="{{customField._id}}" readonly="{{$exists customField._id}}" placeholder="{{_ "Field"}}" />
</div>
</div>
</div>
<div class="input-line">
<label>{{_ "Label"}}</label>
<div>
<input type="text" name="label" value="{{customField.label}}" placeholder="{{_ "Label"}}" />
<div class="input-line">
<label>{{_ "Label"}}</label>
<div>
<input type="text" name="label" value="{{customField.label}}" placeholder="{{_ "Label"}}" />
</div>
</div>
</div>
<div class="input-line">
<label>{{_ "Scope"}}</label>
<div>
<select name="scope">
<option value="visitor" selected="{{$eq customField.scope 'visitor'}}">{{_ "Visitor"}}</option>
<option value="room" selected="{{$eq customField.scope 'room'}}">{{_ "Room"}}</option>
</select>
<div class="input-line">
<label>{{_ "Scope"}}</label>
<div>
<select name="scope">
<option value="visitor" selected="{{$eq customField.scope 'visitor'}}">{{_ "Visitor"}}</option>
<option value="room" selected="{{$eq customField.scope 'room'}}">{{_ "Room"}}</option>
</select>
</div>
</div>
</div>
<div class="input-line">
<label>{{_ "Visibility"}}</label>
<div>
<select name="visibility">
<option value="visible" selected="{{$eq customField.visibility 'visible'}}">{{_ "Visible"}}</option>
<option value="hidden" selected="{{$eq customField.visibility 'hidden'}}">{{_ "Hidden"}}</option>
</select>
<div class="input-line">
<label>{{_ "Visibility"}}</label>
<div>
<select name="visibility">
<option value="visible" selected="{{$eq customField.visibility 'visible'}}">{{_ "Visible"}}</option>
<option value="hidden" selected="{{$eq customField.visibility 'hidden'}}">{{_ "Hidden"}}</option>
</select>
</div>
</div>
</fieldset>
<div class="submit">
<button class="button back" type="button"><i class="icon-left-big"></i><span>{{_ "Back"}}</span></button>
<button class="button primary save"><i class="icon-floppy"></i><span>{{_ "Save"}}</span></button>
</div>
</fieldset>
<div class="submit">
<button class="button back" type="button"><i class="icon-left-big"></i><span>{{_ "Back"}}</span></button>
<button class="button primary save"><i class="icon-floppy"></i><span>{{_ "Save"}}</span></button>
</div>
{{else}}
{{> loading}}
{{/if}}
</div>
</form>
{{else}}
{{> loading}}
{{/if}}
</div>
</form>
{{/requiresPermission}}
</template>
<template name="livechatCustomFields">
<div class="list">
<table>
<thead>
<tr>
<th width="25%">{{_ "Field"}}</th>
<th width="25%">{{_ "Label"}}</th>
<th width="25%">{{_ "Scope"}}</th>
<th width="25%">{{_ "Visibility"}}</th>
<th>{{_ "Delete"}}</th>
</tr>
</thead>
<tbody>
{{#each customFields}}
<tr class="custom-field-info row-link" data-id="{{_id}}">
<td>{{_id}}</td>
<td>{{label}}</td>
<td>{{scope}}</td>
<td>{{visibility}}</td>
<td><a href="#remove" class="remove-custom-field"><i class="icon-trash"></i></a></td>
{{#requiresPermission 'view-livechat-manager'}}
<div class="list">
<table>
<thead>
<tr>
<th width="25%">{{_ "Field"}}</th>
<th width="25%">{{_ "Label"}}</th>
<th width="25%">{{_ "Scope"}}</th>
<th width="25%">{{_ "Visibility"}}</th>
<th>{{_ "Delete"}}</th>
</tr>
{{/each}}
</tbody>
</table>
</div>
<a href="{{pathFor 'livechat-customfield-new'}}" class="button primary">{{_ "New_Custom_Field"}}</a>
</thead>
<tbody>
{{#each customFields}}
<tr class="custom-field-info row-link" data-id="{{_id}}">
<td>{{_id}}</td>
<td>{{label}}</td>
<td>{{scope}}</td>
<td>{{visibility}}</td>
<td><a href="#remove" class="remove-custom-field"><i class="icon-trash"></i></a></td>
</tr>
{{/each}}
</tbody>
</table>
</div>
<a href="{{pathFor 'livechat-customfield-new'}}" class="button primary">{{_ "New_Custom_Field"}}</a>
{{/requiresPermission}}
</template>
<template name="livechatDashboard">
<h1>Dashboard</h1>
{{#requiresPermission 'view-livechat-manager'}}
<h1>Dashboard</h1>
{{/requiresPermission}}
</template>
<template name="livechatDepartmentForm">
<form id="department-form" data-id="{{department._id}}">
<div class="rocket-form">
{{#if Template.subscriptionsReady}}
<fieldset>
<div class="input-line">
<label>{{_ "Enabled"}}</label>
<div>
<label><input type="radio" name="enabled" value="1" checked="{{$eq department.enabled true}}" /> {{_ "Yes"}}</label>
<label><input type="radio" name="enabled" value="0" checked="{{$eq department.enabled false}}" /> {{_ "No"}}</label>
{{#requiresPermission 'view-livechat-manager'}}
<form id="department-form" data-id="{{department._id}}">
<div class="rocket-form">
{{#if Template.subscriptionsReady}}
<fieldset>
<div class="input-line">
<label>{{_ "Enabled"}}</label>
<div>
<label><input type="radio" name="enabled" value="1" checked="{{$eq department.enabled true}}" /> {{_ "Yes"}}</label>
<label><input type="radio" name="enabled" value="0" checked="{{$eq department.enabled false}}" /> {{_ "No"}}</label>
</div>
</div>
</div>
<div class="input-line">
<label>{{_ "Name"}}</label>
<div>
<input type="text" name="name" value="{{department.name}}" placeholder="{{_ "Name"}}" />
<div class="input-line">
<label>{{_ "Name"}}</label>
<div>
<input type="text" name="name" value="{{department.name}}" placeholder="{{_ "Name"}}" />
</div>
</div>
</div>
<div class="input-line">
<label>{{_ "Description"}}</label>
<div>
<textarea name="description" rows="6">{{department.description}}</textarea>
<div class="input-line">
<label>{{_ "Description"}}</label>
<div>
<textarea name="description" rows="6">{{department.description}}</textarea>
</div>
</div>
</div>
<div class="input-line">
<label>{{_ "Show_on_registration_page"}}</label>
<div>
<label><input type="radio" name="showOnRegistration" value="1" checked="{{showOnRegistration true}}" /> {{_ "Yes"}}</label>
<label><input type="radio" name="showOnRegistration" value="0" checked="{{showOnRegistration false}}" /> {{_ "No"}}</label>
<div class="input-line">
<label>{{_ "Show_on_registration_page"}}</label>
<div>
<label><input type="radio" name="showOnRegistration" value="1" checked="{{showOnRegistration true}}" /> {{_ "Yes"}}</label>
<label><input type="radio" name="showOnRegistration" value="0" checked="{{showOnRegistration false}}" /> {{_ "No"}}</label>
</div>
</div>
</div>
<hr />
<h2>{{_ "Agents"}}</h2>
<hr />
<h2>{{_ "Agents"}}</h2>
<fieldset>
<legend>{{_ "Available_agents"}}</legend>
<fieldset>
<legend>{{_ "Available_agents"}}</legend>
<ul class="department-agents available-agents">
{{#each availableAgents}}
<li><i class="icon-plus-circled"></i>{{username}}</li>
{{/each}}
</ul>
</fieldset>
<ul class="department-agents available-agents">
{{#each availableAgents}}
<li><i class="icon-plus-circled"></i>{{username}}</li>
{{/each}}
</ul>
</fieldset>
<fieldset>
<legend>{{_ "Selected_agents"}}</legend>
<fieldset>
<legend>{{_ "Selected_agents"}}</legend>
<div class="list">
<table>
<thead>
<tr>
<th width="25%">{{_ "Username"}}</th>
<th>{{_ "Count"}}</th>
<th>{{_ "Order"}}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{{#if selectedAgents}}
{{#each selectedAgents}}
<tr class="agent-info">
<td>{{username}}</td>
<td><input type="text" class="count-{{agentId}}" name="count" value="{{count}}" size="3"></td>
<td><input type="text" class="order-{{agentId}}" name="order" value="{{order}}" size="3"></td>
<td><a href="#remove" class="remove-agent"><i class="icon-trash"></i></a></td>
</tr>
{{/each}}
{{else}}
<div class="list">
<table>
<thead>
<tr>
<td colspan="4">{{_ "There_are_no_agents_added_to_this_department_yet"}}</td>
<th width="25%">{{_ "Username"}}</th>
<th>{{_ "Count"}}</th>
<th>{{_ "Order"}}</th>
<th>&nbsp;</th>
</tr>
{{/if}}
</tbody>
</table>
</div>
</thead>
<tbody>
{{#if selectedAgents}}
{{#each selectedAgents}}
<tr class="agent-info">
<td>{{username}}</td>
<td><input type="text" class="count-{{agentId}}" name="count" value="{{count}}" size="3"></td>
<td><input type="text" class="order-{{agentId}}" name="order" value="{{order}}" size="3"></td>
<td><a href="#remove" class="remove-agent"><i class="icon-trash"></i></a></td>
</tr>
{{/each}}
{{else}}
<tr>
<td colspan="4">{{_ "There_are_no_agents_added_to_this_department_yet"}}</td>
</tr>
{{/if}}
</tbody>
</table>
</div>
</fieldset>
</fieldset>
</fieldset>
<div class="submit">
<button class="button back" type="button"><i class="icon-left-big"></i><span>{{_ "Back"}}</span></button>
<button class="button primary save"><i class="icon-floppy"></i><span>{{_ "Save"}}</span></button>
</div>
{{else}}
{{> loading}}
{{/if}}
</div>
</form>
</fieldset>
<div class="submit">
<button class="button back" type="button"><i class="icon-left-big"></i><span>{{_ "Back"}}</span></button>
<button class="button primary save"><i class="icon-floppy"></i><span>{{_ "Save"}}</span></button>
</div>
{{else}}
{{> loading}}
{{/if}}
</div>
</form>
{{/requiresPermission}}
</template>
<template name="livechatDepartments">
<div class="list">
<table>
<thead>
<tr>
<th width="20%">{{_ "Name"}}</th>
<th width="30%">{{_ "Description"}}</th>
<th width="10%">{{_ "Num_Agents"}}</th>
<th width="20%">{{_ "Enabled"}}</th>
<th width="20%">{{_ "Show_on_registration_page"}}</th>
<th>{{_ "Delete"}}</th>
</tr>
</thead>
<tbody>
{{#each departments}}
<tr class="department-info row-link" data-id="{{_id}}">
<td>{{name}}</td>
<td>{{description}}</td>
<td>{{numAgents}}</td>
<td>{{#if enabled}}{{_ "Yes"}}{{else}}{{_ "No"}}{{/if}}</td>
<td>{{#if showOnRegistration}}{{_ "Yes"}}{{else}}{{_ "No"}}{{/if}}</td>
<td><a href="#remove" class="remove-department"><i class="icon-trash"></i></a></td>
{{#requiresPermission 'view-livechat-manager'}}
<div class="list">
<table>
<thead>
<tr>
<th width="20%">{{_ "Name"}}</th>
<th width="30%">{{_ "Description"}}</th>
<th width="10%">{{_ "Num_Agents"}}</th>
<th width="20%">{{_ "Enabled"}}</th>
<th width="20%">{{_ "Show_on_registration_page"}}</th>
<th>{{_ "Delete"}}</th>
</tr>
{{/each}}
</tbody>
</table>
</div>
</thead>
<tbody>
{{#each departments}}
<tr class="department-info row-link" data-id="{{_id}}">
<td>{{name}}</td>
<td>{{description}}</td>
<td>{{numAgents}}</td>
<td>{{#if enabled}}{{_ "Yes"}}{{else}}{{_ "No"}}{{/if}}</td>
<td>{{#if showOnRegistration}}{{_ "Yes"}}{{else}}{{_ "No"}}{{/if}}</td>
<td><a href="#remove" class="remove-department"><i class="icon-trash"></i></a></td>
</tr>
{{/each}}
</tbody>
</table>
</div>
<a href="{{pathFor 'livechat-department-new'}}" class="button primary">{{_ "New_Department"}}</a>
<a href="{{pathFor 'livechat-department-new'}}" class="button primary">{{_ "New_Department"}}</a>
{{/requiresPermission}}
</template>
<template name="livechatInstallation">
<p>{{{_ "To_install_RocketChat_Livechat_in_your_website_copy_paste_this_code_above_the_last_body_tag_on_your_site"}}}</p>
{{#requiresPermission 'view-livechat-manager'}}
<p>{{{_ "To_install_RocketChat_Livechat_in_your_website_copy_paste_this_code_above_the_last_body_tag_on_your_site"}}}</p>
<div class="livechat-code">
<textarea class="clipboard" data-clipboard-target=".livechat-code textarea">{{script}}</textarea>
<button class="button clipboard" data-clipboard-target=".livechat-code textarea"><i class="icon-docs"></i>{{_ "Copy_to_clipboard"}}</button>
</div>
<div class="livechat-code">
<textarea class="clipboard" data-clipboard-target=".livechat-code textarea">{{script}}</textarea>
<button class="button clipboard" data-clipboard-target=".livechat-code textarea"><i class="icon-docs"></i>{{_ "Copy_to_clipboard"}}</button>
</div>
{{/requiresPermission}}
</template>
<template name="livechatIntegrations">
<div class="rocket-form">
<h2>{{_ "Webhooks"}}</h2>
<p>
{{_ "You_can_use_webhooks_to_easily_integrate_livechat_with_your_CRM"}}
<a href="https://rocket.chat/docs/administrator-guides/livechat/#integrations">{{_ "Click_here"}}</a> {{_ "to_see_more_details_on_how_to_integrate"}}
</p>
{{#requiresPermission 'view-livechat-manager'}}
<div class="rocket-form">
<h2>{{_ "Webhooks"}}</h2>
<p>
{{_ "You_can_use_webhooks_to_easily_integrate_livechat_with_your_CRM"}}
<a href="https://rocket.chat/docs/administrator-guides/livechat/#integrations">{{_ "Click_here"}}</a> {{_ "to_see_more_details_on_how_to_integrate"}}
</p>
<form id="integration-form">
<div class="input-line">
<label for="webhookUrl">{{_ "Webhook_URL"}}</label>
<div>
<input type="url" name="webhookUrl" id="webhookUrl" value="{{webhookUrl}}" placeholder="https://yourdomain.com/webhook/entrypoint">
<form id="integration-form">
<div class="input-line">
<label for="webhookUrl">{{_ "Webhook_URL"}}</label>
<div>
<input type="url" name="webhookUrl" id="webhookUrl" value="{{webhookUrl}}" placeholder="https://yourdomain.com/webhook/entrypoint">
</div>
</div>
</div>
<div class="input-line">
<label for="secretToken">{{_ "Secret_token"}}</label>
<div>
<input type="text" name="secretToken" id="secretToken" value="{{secretToken}}">
<div class="input-line">
<label for="secretToken">{{_ "Secret_token"}}</label>
<div>
<input type="text" name="secretToken" id="secretToken" value="{{secretToken}}">
</div>
</div>
</div>
<div class="input-line">
<label for="sendOnClose">
<input type="checkbox" name="sendOnClose" id="sendOnClose" value="1" checked="{{sendOnCloseChecked}}">
{{_ "Send_request_on_chat_close"}}
</label>
</div>
<div class="input-line">
<label for="sendOnOffline">
<input type="checkbox" name="sendOnOffline" id="sendOnOffline" value="1" checked="{{sendOnOfflineChecked}}">
{{_ "Send_request_on_offline_messages"}}
</label>
</div>
<div class="submit">
<button class="button danger reset-settings" type="button"><i class="icon-ccw"></i>{{_ "Reset"}}</button>
<button class="button secondary test" type="button" disabled="{{disableTest}}">{{_ "Send_Test"}}</button>