<!-- Modal sysinfo -->
<div class="modal fade" id="sysinfoModal" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">{{ 'network.configureIp.title' | tr }}</h4>
      </div>
      <div class="modal-body">
        <form name="sysinfoForm" role="form" novalidate ng-submit="sysinfo.submit()" autocomplete="off">
          <fieldset>
            <div class="form-group">
              <label class="control-label">{{ 'network.ip.provider' | tr }} <sup><a ng-href="https://docs.cloudron.io/networking/#ip-configuration" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></label>
              <select class="form-control" ng-model="sysinfo.newProvider" ng-options="a.value as a.name for a in sysinfoProvider"></select>
            </div>

            <div ng-show="sysinfo.newProvider === 'generic'">
              {{ 'network.configureIp.providerGenericDescription' | tr }} <sup><a ng-href="https://api.cloudron.io/api/v1/helper/public_ip" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup>
            </div>

            <!-- Fixed -->
            <div class="form-group" ng-show="sysinfo.newProvider === 'fixed'" ng-class="{ 'has-error': (!sysinfoForm.ip.$dirty && sysinfo.error.ip) }">
              <label class="control-label">{{ 'network.ip.address' | tr }}</label>
              <input type="text" class="form-control" ng-model="sysinfo.newIp" name="ip" ng-disabled="sysinfo.busy" ng-required="sysinfo.newProvider === 'fixed'">
              <p class="has-error" ng-show="sysinfo.error.ip">{{ sysinfo.error.ip }}</p>
            </div>

            <!-- Network Interface -->
            <div class="form-group" ng-show="sysinfo.newProvider === 'network-interface'" ng-class="{ 'has-error': (!sysinfoForm.ifname.$dirty && sysinfo.error.ifname) }">
              <label class="control-label">{{ 'network.ip.interface' | tr }}</label>
              <p>{{ 'network.ip.interfaceDescription' | tr }} <code>ip -f inet -br addr</code></p>
              <input type="text" class="form-control" ng-model="sysinfo.newIfname" name="ifname" ng-disabled="sysinfo.busy" ng-required="sysinfo.newProvider === 'network-interface'">
              <p class="has-error" ng-show="sysinfo.error.ifname">{{ sysinfo.error.ifname }}</p>
            </div>

            <input class="ng-hide" type="submit" ng-disabled="sysinfoForm.$invalid || sysinfo.busy"/>
          </fieldset>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">{{ 'main.dialog.cancel' | tr }}</button>
        <button type="button" class="btn btn-success" ng-click="sysinfo.submit()" ng-disabled="sysinfoForm.$invalid || sysinfo.busy"><i class="fa fa-circle-notch fa-spin" ng-show="sysinfo.busy"></i> {{ 'main.dialog.save' | tr }}</button>
      </div>
    </div>
  </div>
</div>

<!-- Modal block list -->
<div class="modal fade" id="blocklistModal" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">{{ 'network.firewall.configure.title' | tr }}</h4>
      </div>
      <div class="modal-body">
        <form name="blocklistChangeForm" role="form" novalidate ng-submit="blocklist.submit()" autocomplete="off">
          <div class="form-group">
            <label class="control-label">{{ 'network.firewall.blockedIpRanges' | tr }}</label>
            <p class="small">{{ 'network.firewall.configure.description' | tr }}</p>
            <div class="has-error" ng-show="blocklist.error.blocklist">{{ blocklist.error.blocklist }}</div>
            <textarea ng-model="blocklist.blocklist" placeholder="{{ 'network.firewall.configure.blocklistPlaceholder' | tr }}" name="blocklist" class="form-control" ng-class="{ 'has-error': !blocklistChangeForm.blocklist.$dirty && blocklist.error.blocklist }" rows="4"></textarea>
          </div>
          <input class="ng-hide" type="submit"/>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">{{ 'main.dialog.cancel' | tr }}</button>
        <button type="button" class="btn btn-success" ng-click="blocklist.submit()"><i class="fa fa-circle-notch fa-spin" ng-show="blocklist.busy"></i> {{ 'main.dialog.save' | tr }}</button>
      </div>
    </div>
  </div>
</div>

<div class="content">
  <div class="text-left">
    <h1>{{ 'network.title' | tr }}</h1>
  </div>

  <div class="text-left">
    <h3>{{ 'network.ip.title' | tr }}</h3>
  </div>

  <div class="card">
    <div class="row">
      <div class="col-xs-12">
        {{ 'network.ip.description' | tr }}
      </div>
    </div>

    <br/>
    <div class="row">
      <div class="col-xs-6">
        <span class="text-muted">{{ 'network.ip.provider' | tr }}</span>
      </div>
      <div class="col-xs-6 text-right">
        <span>{{ prettySysinfoProviderName(sysinfo.provider) }}</span>
      </div>
    </div>

    <div class="row">
      <div class="col-xs-6">
        <span class="text-muted">{{ 'network.ip.address' | tr }}</span>
      </div>
      <div class="col-xs-6 text-right">
        <span ng-show="sysinfo.ip">{{ sysinfo.ip }}</span>
        <span ng-show="!sysinfo.ip">{{ sysinfo.serverIp }} ({{ 'network.ip.detected' | tr }})</span>
      </div>
    </div>

    <div class="row" ng-show="sysinfo.ifname">
      <div class="col-xs-6">
        <span class="text-muted">{{ 'network.ip.interface' | tr }}</span>
      </div>
      <div class="col-xs-6 text-right">
        <span>{{ sysinfo.ifname }}</span>
      </div>
    </div>

    <br/>

    <div class="row">
      <div class="col-md-6 col-md-offset-6 text-right">
        <button class="btn btn-outline btn-primary pull-right" ng-click="sysinfo.show()">{{ 'network.ip.configure' | tr }}</button>
      </div>
    </div>
  </div>

  <div class="text-left" ng-show="user.role === 'owner'">
    <h3>{{ 'network.firewall.title' | tr }}</h3>
  </div>

  <div class="card" ng-show="user.role === 'owner'">
    <div class="row">
      <div class="col-xs-6">
        <span class="text-muted">{{ 'network.firewall.blockedIpRanges' | tr }}</span>
      </div>
      <div class="col-xs-6 text-right">
        <span>{{ 'network.firewall.blocklist' | tr:{ blockCount: blocklist.currentBlocklistLength } }} <a href="" ng-click="blocklist.show()"><i class="fa fa-edit text-small"></i></a></span>
      </div>
    </div>
  </div>

  <div class="text-left">
    <h3>{{ 'network.dyndns.title' | tr }}</h3>
  </div>

  <div class="card">
    <div class="row">
      <div class="col-md-12">
        <p>{{ 'network.dyndns.description' | tr }}</p>
        <p class="text-danger" ng-show="dyndnsConfigure.error"><br/>{{ dyndnsConfigure.error }}</p>
        <div class="checkbox">
          <label>
            <input type="checkbox" ng-model="dyndnsConfigure.enabled" name="dynamicDns" ng-disabled="dyndnsConfigure.busy"/>&nbsp; {{ 'network.dyndns.useLabel' | tr }}
          </label>
        </div>
      </div>
    </div>

    <div class="row">
      <div class="col-md-6">
        <span class="text-success text-bold" ng-show="dyndnsConfigure.success">{{ 'network.dyndns.saved' | tr }}</span>
      </div>

      <div class="col-md-6 text-right">
        <button class="btn btn-outline btn-primary pull-right" ng-click="dyndnsConfigure.submit()" ng-disabled="dyndnsConfigure.currentState === dyndnsConfigure.enabled"><i class="fa fa-circle-notch fa-spin" ng-show="dyndnsConfigure.busy"></i>  {{ 'main.dialog.save' | tr }}</button>
      </div>
    </div>
  </div>
</div>
