Skip to content

Commit

Permalink
UI-377: Added restart feature to SmartPBX
Browse files Browse the repository at this point in the history
  • Loading branch information
JRMaitre committed Jul 6, 2015
1 parent f528cca commit 03da3ca
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
8 changes: 8 additions & 0 deletions i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@
"ignoreCompletedElsewhere": {
"label": "Ignore Completed Elsewhere",
"help": "When checked supporting phones will show a call missed if it was part of a ring group answered elsewhere."
},
"__comment": "UI-377: Adding Restart device feature",
"__version": "3.21",
"restart": {
"label": "Send a Restart request",
"button": "Restart",
"help": "This sends a request to restart the device. This action is only available if the device is currently registered to the platform.",
"success": "You successfully sent a Restart request to this device!"
}
},
"restrictions": {
Expand Down
8 changes: 8 additions & 0 deletions i18n/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@
"ignoreCompletedElsewhere": {
"label": "Afficher les appels manqués des groupes d'Appels",
"help": "Si cette case est cochée, les téléphones ayant accès à cette fonctionnalité afficheront les appels manqués même s'ils viennent d'un Groupe d'Appel et que l'appel a été pris par un collègue"
},
"__comment": "UI-377: Adding Restart device feature",
"__version": "3.21",
"restart": {
"label": "Envoyer une requête de redémarrage",
"button": "Redémarrer",
"help": "Ce bouton envoie une requête de redémarrage. Cette action n'est disponible que pour les appareils qui sont actuellement connectés à la plateforme.",
"success": "Vous avez envoyé une requête de redémarrage avec succès!"
}
},
"restrictions": {
Expand Down
5 changes: 5 additions & 0 deletions submodules/devices/devices.css
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,8 @@
margin-left: 35px;
padding-top: 3px;
}

/* Restart Button */
.edit-device #restart_device {
margin-left: 10px;
}
37 changes: 32 additions & 5 deletions submodules/devices/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ define(function(require){
template.find('.settings').on('click', function() {
var $this = $(this),
dataDevice = {
id: $this.parents('.grid-row').data('id')
id: $this.parents('.grid-row').data('id'),
isRegistered: $this.parents('.grid-row').data('registered') === 'true'
};


self.devicesRenderEdit({ data: dataDevice, callbackSave: function(dataDevice) {
self.devicesRender({ deviceId: dataDevice.id });
}});
Expand Down Expand Up @@ -365,6 +365,14 @@ define(function(require){
templateDevice.find('#rtp_method').toggle();
});

templateDevice.find('#restart_device').on('click', function() {
if(!$(this).hasClass('disabled')) {
self.devicesRestart(data.id, function() {
toastr.success(self.i18n.active().devices.popupSettings.miscellaneous.restart.success);
});
}
});

templateDevice.find('.actions .save').on('click', function() {
if(monster.ui.valid(deviceForm)) {
templateDevice.find('.feature-key-value:not(.active)').remove();
Expand Down Expand Up @@ -498,6 +506,21 @@ define(function(require){
});
},

devicesRestart: function(deviceId, callback) {
var self = this;

self.callApi({
resource: 'device.restart',
data: {
accountId: self.accountId,
deviceId: deviceId
},
success: function(data) {
callback && callback(data.data);
}
});
},

devicesMergeData: function(originalData, template, audioCodecs, videoCodecs) {
var self = this,
hasCodecs = $.inArray(originalData.device_type, ['sip_device', 'landline', 'fax', 'ata', 'softphone', 'smartphone', 'mobile', 'sip_uri']) > -1,
Expand Down Expand Up @@ -612,7 +635,7 @@ define(function(require){
return mergedData;
},

devicesFormatData: function(data) {
devicesFormatData: function(data, dataList) {
var self = this,
defaults = {
extra: {
Expand Down Expand Up @@ -763,6 +786,8 @@ define(function(require){
formattedData.media.video.codecs = data.device.media.video.codecs;
}

formattedData.extra.isRegistered = dataList.isRegistered;

return formattedData;
},

Expand Down Expand Up @@ -807,7 +832,8 @@ define(function(require){
type: device.device_type,
friendlyType: self.i18n.active().devices.types[device.device_type],
registered: false,
classStatus: device.enabled ? 'unregistered' : 'disabled' /* Display a device in black if it's disabled, otherwise, until we know whether it's registered or not, we set the color to red */
classStatus: device.enabled ? 'unregistered' : 'disabled' /* Display a device in black if it's disabled, otherwise, until we know whether it's registered or not, we set the color to red */,
isRegistered: false
}
});

Expand All @@ -820,6 +846,7 @@ define(function(require){
/* Now that we know if it's registered, we set the color to green */
if(device.enabled) {
device.classStatus = 'registered';
device.isRegistered = true;
}
}
});
Expand Down Expand Up @@ -972,7 +999,7 @@ define(function(require){
}
},
function(error, results) {
var formattedData = self.devicesFormatData(results);
var formattedData = self.devicesFormatData(results, dataDevice);

callback && callback(formattedData);
}
Expand Down
2 changes: 1 addition & 1 deletion views/devices-row.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="grid-row" data-id="{{id}}" data-search="{{userName}} {{friendlyType}} {{type}} {{name}} {{macAddress}}" data-assigned="{{isAssigned}}">
<div class="grid-row" data-id="{{id}}" data-search="{{userName}} {{friendlyType}} {{type}} {{name}} {{macAddress}}" data-assigned="{{isAssigned}}" data-registered="{{isRegistered}}">
<div class="devices-cells">
<div class="type grid-cell centered {{classStatus}}">
<div class="first-line">
Expand Down
12 changes: 11 additions & 1 deletion views/devices-sip_device.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
</label>
</div>

<div class="rtp-line">
<div class="rtp-line clearfix">
<div class="control-group">
<label class="control-label checkbox">
{{#monsterCheckbox i18n.devices.popupSettings.miscellaneous.rtp.enable }}
Expand All @@ -227,6 +227,16 @@
</select>
</div>
</div>

{{#if provision}}
<div class="control-group">
<label class="control-label checkbox">{{ i18n.devices.popupSettings.miscellaneous.restart.label }}</label>
<div class="controls">
<button id="restart_device" type="button" class="monster-button monster-button-primary{{#unless extra.isRegistered}} disabled{{/unless}}">{{ i18n.devices.popupSettings.miscellaneous.restart.button }}</button>
<i class="help-popover fa fa-question-circle" data-original-title="{{ i18n.devices.popupSettings.miscellaneous.restart.help }}" data-placement="top" data-toggle="tooltip"></i>
</div>
</div>
{{/if}}
</div>

{{#if provision.feature_keys}}
Expand Down

0 comments on commit 03da3ca

Please sign in to comment.