<commit_before>(function(cloudStack, $, testData) {
  var actionFilters = {
    ipAddress: function(args) {
      var allowedActions = args.context.actions;
      var disallowedActions = [];
      var item = args.context.item;
      var status = item.state;

      if (status == 'Released') {
        return [];
      }

      if (status == 'Destroyed' ||
          status == 'Releasing' ||
          status == 'Released' ||
          status == 'Creating' ||
          status == 'Allocating' ||
          item.account == 'system') {
        disallowedActions = allowedActions;
      }

      if (item.isstaticnat) {
        disallowedActions.push('enableStaticNAT');
      } else {
        disallowedActions.push('disableStaticNAT');
      }

      if (item.vpnenabled) {
        disallowedActions.push('enableVPN');
      } else {
        disallowedActions.push('disableVPN');
      }

      if (item.issourcenat){
        disallowedActions.push('enableStaticNAT');
        disallowedActions.push('disableStaticNAT');
        disallowedActions.push('destroy');
      } else {
        disallowedActions.push('enableVPN');
        disallowedActions.push('disableVPN');
      }

      allowedActions = $.grep(allowedActions, function(item) {
        return $.inArray(item, disallowedActions) == -1;
      });

      return allowedActions;
    }
  };

  cloudStack.sections.network = {
    title: 'Network',
    id: 'network',
    sectionSelect: {
      preFilter: function(args) {
        if (g_directAttachSecurityGroupsEnabled == "true") {
          return args.context.sections;
        }
        else {
          return ['networks', 'ipAddresses'];
        }
      },
      label: 'Select view'
    },
    sections: {
      networks: {
        type: 'select',
        title: 'Networks',
        listView: {
          filters: {
            all: { label: 'All' },
            mine: { label: 'My network' }
          },
          fields: {
            name: { label: 'Name' },
            traffictype: { label: 'Traffic Type' },
            gateway: { label: 'Gateway' },
            vlan: { label: 'VLAN' }
          },
          dataProvider: function(args) {
            $.ajax({
              url: createURL('listNetworks'),
              data: {
                trafficType: 'Guest'
              },
              dataType: 'json',
              async: true,
              success: function(data) {
                args.response.success({
                  data: data.listnetworksresponse.network
                });
              }
            });
          },

          detailView: {
            name: 'Network details',
            viewAll: { path: 'network.ipAddresses', label: 'IP Addresses' },
            tabs: {
              details: {
                title: 'Details',
                fields: [
                  {
                    name: { label: 'Name' }
                  },
                  {
                    name: { label: 'Short name' },
                    displaytext: { label: 'Description' },
                    traffictype: { label: 'Traffic Type' },
                    gateway: { label: 'Gateway' },
                    vlan: { label: 'VLAN' }
                  },
                  {
                    startip: { label: 'Start IP' },
                    endip: { label: 'End IP' }
                  }
                ],
                dataProvider: function(args) {
                  args.response.success({ data: args.context.networks[0] });
                }
              }
            }
          }
        }<commit_msg>bug 12288: Add more fields to network list view/detail view<commit_after>(function(cloudStack, $, testData) {
  var actionFilters = {
    ipAddress: function(args) {
      var allowedActions = args.context.actions;
      var disallowedActions = [];
      var item = args.context.item;
      var status = item.state;

      if (status == 'Released') {
        return [];
      }

      if (status == 'Destroyed' ||
          status == 'Releasing' ||
          status == 'Released' ||
          status == 'Creating' ||
          status == 'Allocating' ||
          item.account == 'system') {
        disallowedActions = allowedActions;
      }

      if (item.isstaticnat) {
        disallowedActions.push('enableStaticNAT');
      } else {
        disallowedActions.push('disableStaticNAT');
      }

      if (item.vpnenabled) {
        disallowedActions.push('enableVPN');
      } else {
        disallowedActions.push('disableVPN');
      }

      if (item.issourcenat){
        disallowedActions.push('enableStaticNAT');
        disallowedActions.push('disableStaticNAT');
        disallowedActions.push('destroy');
      } else {
        disallowedActions.push('enableVPN');
        disallowedActions.push('disableVPN');
      }

      allowedActions = $.grep(allowedActions, function(item) {
        return $.inArray(item, disallowedActions) == -1;
      });

      return allowedActions;
    }
  };

  cloudStack.sections.network = {
    title: 'Network',
    id: 'network',
    sectionSelect: {
      preFilter: function(args) {
        if (g_directAttachSecurityGroupsEnabled == "true") {
          return args.context.sections;
        }
        else {
          return ['networks', 'ipAddresses'];
        }
      },
      label: 'Select view'
    },
    sections: {
      networks: {
        type: 'select',
        title: 'Networks',
        listView: {
          filters: {
            all: { label: 'All' },
            mine: { label: 'My network' }
          },
          fields: {
            name: { label: 'Name' },
            type: { label: 'Type' },
            traffictype: { label: 'Traffic Type' },
            gateway: { label: 'Gateway' },
            broadcasturi: {
              label: 'VLAN',
              converter: function(value) {
                if (value)
                  return value.split('vlan://')[1];

                return 'Untagged';
              }
            },
            state: { label: 'State', indicator: { 'Setup': 'on' } }
          },
          dataProvider: function(args) {
            $.ajax({
              url: createURL('listNetworks'),
              data: {
                trafficType: 'Guest'
              },
              dataType: 'json',
              async: true,
              success: function(data) {
                args.response.success({
                  data: data.listnetworksresponse.network
                });
              }
            });
          },

          detailView: {
            name: 'Network details',
            viewAll: { path: 'network.ipAddresses', label: 'IP Addresses' },
            tabs: {
              details: {
                title: 'Details',
                fields: [
                  {
                    name: { label: 'Name' }
                  },
                  {
                    type: { label: 'Type' },
                    displaytext: { label: 'Description' },
                    traffictype: { label: 'Traffic Type' },
                    gateway: { label: 'Gateway' },
                    vlan: { label: 'VLAN' }
                  },
                  {
                    startip: { label: 'Start IP' },
                    endip: { label: 'End IP' }
                  }
                ],
                dataProvider: function(args) {
                  args.response.success({ data: args.context.networks[0] });
                }
              }
            }
          }
        }
{'fraction_non_alphanumeric': 0.12625250501002003, 'fraction_numerical': 0.0013360053440213762, 'mean_word_length': 1.3212403100775194, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '77703', 'n_tokens_mistral': 2017, 'n_tokens_neox': 1936, 'n_words': 379}