Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voicemails in portal user #2589

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions web/portal/user/src/entities/Voicemail/Form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
EntityFormProps,
FieldsetGroups,
Form as DefaultEntityForm,
} from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
import _ from '@irontec/ivoz-ui/services/translations/translate';

const Form = (props: EntityFormProps): JSX.Element => {
const groups: Array<FieldsetGroups> = [
{
legend: _('Basic Configuration'),
fields: ['enabled', 'name'],
},
{
legend: _('Notification configuration'),
fields: ['sendMail', 'email', 'attachSound'],
},
{
legend: _('Customization'),
fields: ['locution'],
},
];

return <DefaultEntityForm {...props} groups={groups} />;
};

export default Form;
75 changes: 65 additions & 10 deletions web/portal/user/src/entities/Voicemail/Voicemail.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,80 @@
import { EntityValues } from '@irontec/ivoz-ui';
import defaultEntityBehavior from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
import EntityInterface from '@irontec/ivoz-ui/entities/EntityInterface';
import _ from '@irontec/ivoz-ui/services/translations/translate';
import AccountTreeIcon from '@mui/icons-material/AccountTree';
import MailIcon from '@mui/icons-material/Mail';

const VoiceMail: EntityInterface = {
import {
VoicemailProperties,
VoicemailPropertyList,
} from './VoicemailProperties';

const properties: VoicemailProperties = {
enabled: {
label: _('Enabled'),
enum: {
'0': _('No'),
'1': _('Yes'),
},
default: '1',
},
name: {
label: _('Name'),
required: true,
},
sendMail: {
label: _('Voicemail send mail'),
enum: {
'0': _('No'),
'1': _('Yes'),
},
default: '1',
visualToggle: {
'0': {
show: [],
hide: ['attachSound', 'email'],
},
'1': {
show: ['attachSound', 'email'],
hide: [],
},
},
},
email: {
label: _('Email'),
required: true,
},
attachSound: {
label: _('Voicemail attach sound'),
enum: {
'0': _('No'),
'1': _('Yes'),
},
default: '1',
},
};

const columns = ['enabled', 'name', 'email'];

const voicemail: EntityInterface = {
...defaultEntityBehavior,
icon: AccountTreeIcon,
icon: MailIcon,
iden: 'Voicemail',
title: _('Voicemail', { count: 2 }),
path: '/my/company_voicemails',
path: '/my/voicemails',

acl: {
...defaultEntityBehavior.acl,
iden: 'Voicemail',
iden: 'Voicemails',
},
selectOptions: async () => {
const module = await import('./SelectOptions');
toStr: (row: VoicemailPropertyList<string>) => `${row.name as string}`,
properties,
columns,
defaultOrderBy: '',
Form: async () => {
const module = await import('./Form');

return module.default;
},
toStr: (row: EntityValues) => row.name as string,
};

export default VoiceMail;
export default voicemail;
21 changes: 21 additions & 0 deletions web/portal/user/src/entities/Voicemail/VoicemailProperties.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { PropertySpec } from '@irontec/ivoz-ui/services/api/ParsedApiSpecInterface';
import {
EntityValue,
EntityValues,
} from '@irontec/ivoz-ui/services/entity/EntityService';

export type VoicemailPropertyList<T> = {
id?: T;
enabled?: T;
user?: T;
name?: T;
email?: T;
sendMail?: T;
attachSound?: T;
voicemail?: T;
};

export type VoicemailProperties = VoicemailPropertyList<Partial<PropertySpec>>;
export type VoicemailPropertiesList = Array<
VoicemailPropertyList<EntityValue | EntityValues>
>;
37 changes: 37 additions & 0 deletions web/portal/user/src/entities/VoicemailMessage/Field/Status.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import withCustomComponentWrapper, {
PropertyCustomFunctionComponent,
PropertyCustomFunctionComponentProps,
} from '@irontec/ivoz-ui/services/form/Field/CustomComponentWrapper';
import DraftsIcon from '@mui/icons-material/Drafts';
import EmailIcon from '@mui/icons-material/Email';
import { Tooltip } from '@mui/material';

import { VoicemailMessagePropertyList } from '../VoicemailMessageProperties';

type VoicemailMessageValues = VoicemailMessagePropertyList<
string | number | boolean
>;
type TargetGhostType = PropertyCustomFunctionComponent<
PropertyCustomFunctionComponentProps<VoicemailMessageValues>
>;

const Status: TargetGhostType = (props): JSX.Element => {
const { values } = props;
const { folder } = values;

if (folder === 'INBOX') {
return (
<Tooltip title={folder}>
<EmailIcon />
</Tooltip>
);
}

return (
<Tooltip title={folder as string}>
<DraftsIcon />
</Tooltip>
);
};

export default withCustomComponentWrapper<VoicemailMessageValues>(Status);
23 changes: 23 additions & 0 deletions web/portal/user/src/entities/VoicemailMessage/View.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
FieldsetGroups,
View as DefaultEntityView,
} from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
import { ViewProps } from '@irontec/ivoz-ui/entities/EntityInterface';
import _ from '@irontec/ivoz-ui/services/translations/translate';

const View = (props: ViewProps): JSX.Element | null => {
const groups: Array<FieldsetGroups | false> = [
{
legend: _('Basic Information'),
fields: ['calldate', 'caller', 'duration'],
},
{
legend: _('Recording', { count: 1 }),
fields: ['recordingFile'],
},
];

return <DefaultEntityView {...props} groups={groups} />;
};

export default View;
57 changes: 57 additions & 0 deletions web/portal/user/src/entities/VoicemailMessage/VoicemailMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import defaultEntityBehavior from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
import EntityInterface, {
OrderDirection,
} from '@irontec/ivoz-ui/entities/EntityInterface';
import _ from '@irontec/ivoz-ui/services/translations/translate';
import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted';

import Status from '../VoicemailMessage/Field/Status';
import { VoicemailMessageProperties } from './VoicemailMessageProperties';

const properties: VoicemailMessageProperties = {
status: {
label: _('Status'),
component: Status,
},
folder: {
label: _('Folder'),
},
calldate: {
label: _('Date'),
},
caller: {
label: _('Caller'),
},
duration: {
label: _('Duration'),
},
recordingFile: {
label: _('Recording', { count: 1 }),
type: 'file',
},
};

const columns = ['status', 'calldate', 'caller', 'duration'];

const voicemailMessage: EntityInterface = {
...defaultEntityBehavior,
icon: FormatListBulletedIcon,
iden: 'VoicemailMessage',
title: _('Voicemail Message', { count: 1 }),
path: '/voicemail_messages',
properties,
columns,
acl: {
...defaultEntityBehavior.acl,
iden: 'VoicemailMessages',
},
defaultOrderBy: 'calldate',
defaultOrderDirection: OrderDirection.desc,
View: async () => {
const module = await import('./View');

return module.default;
},
};

export default voicemailMessage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PropertySpec } from '@irontec/ivoz-ui/services/api/ParsedApiSpecInterface';
import {
EntityValue,
EntityValues,
} from '@irontec/ivoz-ui/services/entity/EntityService';

export type VoicemailMessagePropertyList<T> = {
status?: T;
calldate?: T;
folder?: T;
caller?: T;
duration?: T;
recordingFile?: T;
voicemail?: T;
};

export type VoicemailMessageProperties = VoicemailMessagePropertyList<
Partial<PropertySpec>
>;
export type VoicemailMessagePropertiesList = Array<
VoicemailMessagePropertyList<EntityValue | EntityValues>
>;
11 changes: 10 additions & 1 deletion web/portal/user/src/router/EntityMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ const getEntityMap = (): RouteMap => {
{
entity: entities.CallForwardSetting,
},
{
entity: entities.Voicemail,
children: [
{
entity: entities.VoicemailMessage,
filterBy: 'voicemail',
},
],
divider: true,
},
{
entity: {
...entities.UsersCdr,
Expand All @@ -26,7 +36,6 @@ const getEntityMap = (): RouteMap => {
detail: false,
},
},
divider: true,
},
];

Expand Down
18 changes: 17 additions & 1 deletion web/portal/user/src/translations/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Active call_one": "Trucada activa",
"Active call_other": "Trucades actives",
"Answered": "Contestada",
"Basic Information": "Informació bàsica",
"Basic Configuration": "Configuració bàsica",
"Boss / Assistant": "Assistent vinculat",
"Both": "Ambdós",
"Busy": "Ocupat",
Expand All @@ -21,6 +23,7 @@
"Country_many": "Països",
"Country_one": "País",
"Country_other": "Països",
"Customization": "Personalitzat",
"Date": "Data",
"Direction": "Direcció",
"Disposition": "Disposició",
Expand All @@ -35,6 +38,7 @@
"Extension_one": "Extensió",
"Extension_other": "Extensions",
"External": "Externa",
"Folder": "Directorio",
"Get started": "Començar",
"Go to Call Forward Setting": "Aneu a la configuració de les trucades",
"Go to Calls": "Anar a trucades",
Expand All @@ -54,8 +58,10 @@
"My Account": "El meu compte",
"My Preferences": "Els meus ajustaments",
"Name": "Nom",
"No": "No",
"No answer": "No resposta",
"No answer timeout": "Sense temps d'espera de resposta",
"Notification configuration": "Configuració de la notificació",
"Number": "Número",
"Number country": "País",
"Number value": "Valor",
Expand All @@ -71,8 +77,12 @@
"Profile_many": "Perfiles",
"Profile_one": "Perfil",
"Profile_other": "Perfiles",
"Recording_many": "Enregistraments",
"Recording_one": "Gravació",
"Recording_other": "Enregistraments",
"Repeat password": "Repeteix contrasenya",
"Start Time": "Hora inicio",
"Status": "Estat",
"Target type": "Tipus d'objectiu",
"Terminal": "Terminal",
"Terminal Status": "Estat del terminal",
Expand All @@ -84,8 +94,14 @@
"User": "Usuari",
"User information": "Informació dels usuaris",
"User not registered": "Usuari no registrat",
"Voicemail Message_many": "Missatges de bústia de veu",
"Voicemail Message_one": "Missatge de bústia de veu",
"Voicemail Message_other": "Missatges de bústia de veu",
"Voicemail attach sound": "Adjunta àudio bústia de veu",
"Voicemail send mail": "Envia notificació per correu de la bústia de veu",
"Voicemail_many": "Bústies de veu",
"Voicemail_one": "Bústia de veu",
"Voicemail_other": "Bústies de veu",
"Welcome to <br />Ivoz Provider vPBX user portal": "Benvingut a <br /> Portal d'usuari del proveïdor d'Ivoz VPBX"
"Welcome to <br />Ivoz Provider vPBX user portal": "Benvingut a <br /> Portal d'usuari del proveïdor d'Ivoz VPBX",
"Yes": "Sí"
}
Loading