<rd-header>
  <rd-header-title title-text="Network details"></rd-header-title>
  <rd-header-content>
    <a ui-sref="docker.networks">Networks</a> &gt; <a ui-sref="docker.networks.network({id: network.Id})">{{ network.Name }}</a>
  </rd-header-content>
</rd-header>

<div class="row">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="fa-sitemap" title-text="Network details"></rd-widget-header>
      <rd-widget-body classes="no-padding">
        <table class="table">
          <tbody>
            <tr>
              <td>Name</td>
              <td>{{ network.Name }}</td>
            </tr>
            <tr>
              <td>ID</td>
              <td>
                {{ network.Id }}
                <button authorization="DockerNetworkDelete" ng-if="allowRemove()" class="btn btn-xs btn-danger" ng-click="removeNetwork(network.Id)"
                  ><i class="fa fa-trash-alt space-right" aria-hidden="true"></i>Delete this network</button
                >
              </td>
            </tr>
            <tr>
              <td>Driver</td>
              <td>{{ network.Driver }}</td>
            </tr>
            <tr>
              <td>Scope</td>
              <td>{{ network.Scope }}</td>
            </tr>
            <tr>
              <td>Attachable</td>
              <td>{{ network.Attachable }}</td>
            </tr>
            <tr>
              <td>Internal</td>
              <td>{{ network.Internal }}</td>
            </tr>
            <tr ng-if="network.IPAM.IPV4Configs.length > 0" ng-repeat-start="config in network.IPAM.IPV4Configs">
              <td>IPV4 Subnet - {{ config.Subnet }}</td>
              <td>IPV4 Gateway - {{ config.Gateway }}</td>
            </tr>
            <tr ng-if="network.IPAM.IPV4Configs.length > 0" ng-repeat-end>
              <td>IPV4 IP range - {{ config.IPRange }}</td>
              <td
                >IPV4 Excluded Ips<span ng-repeat="auxAddress in config.AuxiliaryAddresses"> - {{ auxAddress }}</span></td
              >
            </tr>
            <tr ng-if="network.IPAM.IPV6Configs.length > 0" ng-repeat-start="config in network.IPAM.IPV6Configs">
              <td>IPV6 Subnet - {{ config.Subnet }}</td>
              <td>IPV6 Gateway - {{ config.Gateway }}</td>
            </tr>
            <tr ng-if="network.IPAM.IPV6Configs.length > 0" ng-repeat-end>
              <td>IPV6 IP range - {{ config.IPRange }}</td>
              <td
                >IPV6 Excluded Ips<span ng-repeat="auxAddress in config.AuxiliaryAddresses"> - {{ auxAddress }}</span></td
              >
            </tr>
          </tbody>
        </table>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<!-- access-control-panel -->
<por-access-control-panel
  ng-if="network"
  resource-id="network.Id"
  resource-control="network.ResourceControl"
  resource-type="'network'"
  disable-ownership-change="isSystemNetwork()"
>
</por-access-control-panel>
<!-- !access-control-panel -->

<div class="row" ng-if="!(network.Options | emptyobject)">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="fa-cogs" title-text="Network options"></rd-widget-header>
      <rd-widget-body classes="no-padding">
        <table class="table">
          <tbody>
            <tr ng-repeat="(key, value) in network.Options">
              <td>{{ key }}</td>
              <td>{{ value }}</td>
            </tr>
          </tbody>
        </table>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<div class="row" ng-if="containersInNetwork.length > 0">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="fa-server" title-text="Containers in network"></rd-widget-header>
      <rd-widget-body classes="no-padding">
        <table class="table">
          <thead>
            <th>Container Name</th>
            <th>IPv4 Address</th>
            <th>IPv6 Address</th>
            <th>MacAddress</th>
            <th authorization="DockerNetworkDisconnect">Actions</th>
          </thead>
          <tbody>
            <tr ng-repeat="container in containersInNetwork">
              <td
                ><a ui-sref="docker.containers.container({ id: container.Id, nodeName: nodeName })">{{ container.Name }}</a></td
              >
              <td>{{ container.IPv4Address || '-' }}</td>
              <td>{{ container.IPv6Address || '-' }}</td>
              <td>{{ container.MacAddress || '-' }}</td>
              <td authorization="DockerNetworkDisconnect">
                <button type="button" class="btn btn-xs btn-danger" ng-click="containerLeaveNetwork(network, container)"
                  ><i class="fa fa-trash-alt space-right" aria-hidden="true"></i>Leave Network</button
                >
              </td>
            </tr>
          </tbody>
        </table>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>
