export default class ListMediaServerController {
  constructor($scope, mediaServers, $log, $window, toolbar) {
    this.mediaServers = mediaServers;
    this.$scope = $scope;
    this.$log = $log;
    this.$window = $window;
    this.toolbar = toolbar;

    this.$scope.list = [];
    this.$scope.headers = [
      'name',
      'display_name',
      'voip_ip'
    ];
    this.$scope.actions = [
      'edit',
      'delete'
    ];
    this.$scope.path = '/xivo/configuration/index.php/manage/mediaserver/';
    this.$scope.delete = (id) => {
      this.mediaServers.deleteMediaServer(id).then(() => {
        this.$window.location.href = '?act=list';
      }, (error) => {
        $log.error(error);
      });
    };

    mediaServers.listMediaServers()
      .then((response) => {
        this.$scope.list = response.data;
      }, (error) => {
        $log.error(error);
      });
  }
}
