<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
  
<div class="clearfix">
  <ol class="breadcrumb pull-left">
    <li><a href="#/groups">Groups</a></li>
    <li class="active">{{group.group_name}}</li>
  </ol>
  <div class="pull-right top-margin-4">
    <div ng-switch="group.ldap_group">
      <button ng-switch-when="true" class="btn disabled deletegroup-btn deleteuser-btn" tooltip="Cannot Delete Group">Delete Group</button>
      <button ng-switch-when="false" class="btn btn-danger deletegroup-btn" ng-click="deleteGroup(group)">Delete Group</button>
    </div>
      
  </div>
</div>
<hr>
<form class="form-horizontal group-edit" role="form" novalidate name="form" >
  <div class="form-group">
    <label for="" class="col-sm-2 control-label">Type</label>
    <div class="col-sm-10">
      <label for="" class="control-label">{{group.ldap_group ? 'LDAP' : 'Local'}}</label>
    </div>
  </div>
  <div class="form-group">
    <label for="members" class="col-sm-2 control-label">{{group.ldap_group ? 'LDAP Members' : 'Local Members'}}</label>
    <div class="col-sm-10">
      <editable-list items-source="group.editingUsers" resource-type="User" editable="!group.ldap_group"></editable-list>
    </div>
  </div>

  <div class="form-group">
      <label for="" class="col-sm-2 control-label">Privileges</label>
      <div class="col-sm-10">
        <table class="table">
          <thead>
            <tr>
              <th>Resource</th>
              <th>Permissions</th>
            </tr>
          </thead>
          <tbody>
            <tr ng-repeat="(name, privilege) in privileges.clusters">
              <td>
                <span class="glyphicon glyphicon-cloud"></span> 
                <a href="#/clusters/{{name}}/manageAccess">{{name}}</a>
              </td>
              <td>
                <span tooltip="{{item}}" ng-repeat="item in privilege">{{item | translate}}{{$last ? '' : ', '}}</span>
              </td>
            </tr>
            <tr ng-repeat="(name, privilege) in privileges.views">
              <td>
                <span class="glyphicon glyphicon-th"></span> 
                <a href="#/views/{{privilege.view_name}}/versions/{{privilege.version}}/instances/{{name}}/edit">{{name}}</a>
              </td>
              <td>
                <span tooltip="{{item}}" ng-repeat="item in privilege.privileges">{{item | translate}}{{$last ? '' : ', '}}</span>
              </td>
            </tr>
          </tbody>
        </table>
        <div class="alert alert-info hide-soft" ng-class="{'visible' : !privileges}">This group does not have any privileges.</div>
      </div>
    </div>
</form>