<commit_before>{% extends 'environs/env_base.html'%} {% load utils %} {% block breadcrumb-items %}
<ul class="breadcrumb">
    <li><a href="/">Home</a></li>
    <li><a href="/envs">Environments</a></li>
    <li><a href="/env/{{ env.envName }}/{{ env.stageName }}">{{ env.envName }} ({{ env.stageName }})</a></li>
    <li><a href="/env/{{ env.envName }}/{{ env.stageName }}/config">General Config</a></li>
    <li class="active">New Capacity</li>
</ul>
{% endblock %}
{% load static %}
{% block side-panel-actions %}
<script type="text/javascript" src="{% static "js/components/sharedcomponents.js?changedate=2016.12.19.150000"%}"></script>
<div class="panel panel-default" id="side-panel">
    <div class="panel-heading clearfix">
        <h4 class="panel-title pull-left">Capacity</h4>
    </div>
    <div class="row">
        <side-button styleclass="fa fa-gears" text="Basic Settings" href="/env/{{ env.envName }}/{{ env.stageName }}/config/newcapacity"
            title="Basic Settings"></side-button>
    </div>
</div>
{% endblock %}
{% block new-builds-panel %}
{% endblock %}
{% block new-pred-deploys-panel %}
{% endblock %}
{% block main%}
{% include "environs/env_tabs.tmpl" with envTabKind="config/capacity" %}
<script type="text/javascript" src="{% static "js/components/capacitycomponents.js?changedate=2017.07.05.180000"%}"></script>
<script type="text/javascript" src="{% static "js/components/clusterconfigcomponents.js?changedate=2017.07.27.153000"%}"></script>

<div id="mainPanel" class="panel panel-default">

    <panel-heading title="Advanced Settings" target="#envCapacityId" initcollapse="false"></panel-heading>
    <div id="envCapacityId" class="collapse in panel-body" v-on:show.bs.collapse="showcontent" v-on:hide.bs.collapse="hidecontent">
        <div class="container-fluid">
            <form id="clusterConfigFormId" class="form-horizontal" role="form">
                <fieldset id="clusterConfigFieldSetId">
                    <cloudprovider-select v-bind:cloudproviders="providers" v-bind:value="currentProvider"></cloudprovider-select>
                    <cell-select v-bind:cells="cells" v-on:cellchange="cellChange"  v-bind:value="currentCell"></cell-select>
                    <label-input label="Capacity" placeholder="# of instances" v-model="instanceCount"></label-input>
                    <baseimage-select v-bind:imagenames="imagenames" v-bind:baseimages="baseimages" v-bind:imagenamevalue="imageNameValue" v-bind:baseImageValue="baseImageValue"
                        v-on:baseimagechange="baseImageChange" v-on:imagenamechange="imageNameChange" inadvanced="true" v-on:helpclick="baseImageHelpClick">
                    </baseimage-select>
                    <base-image-help v-show="showBaseImageHelp" v-bind:data="baseImageHelpData"></base-image-help>
                    <label-select label="Host Type" title="Compute Capability of the host" v-model="selectedHostTypeValue" v-bind:selectoptions="hostTypeOptions"
                        showhelp="true" v-on:helpclick="hostTypeHelpClick"></label-select>
                    <hostype-help v-show="showHostTypeHelp" v-bind:data="hostTypeHelpData"></hostype-help>
                    <label-select label="Security Zone" title="Security zone to control inbound/outboud traffic" showhelp="true" v-model="selectedSecurityZoneValue"
                        v-bind:selectoptions="securityZones" v-on:helpclick="securityZoneHelpClick"></label-select>
                    <securityzone-help v-show="showSecurityZoneHelp" v-bind:data="securityZoneHelpData"></securityzone-help>
                    <placements-select label="Placements" title="Placements" v-bind:selectoptions="placements" v-bind:assignpublicip="assignPublicIP"
                        showhelp="true" v-on:helpclick="placementsHelpClick" v-on:assignpublicipclick="selectpublicip"></placements-select>
                    <placements-help v-show="showPlacementsHelp" v-bind:data="placementsHelpData"></placements-help>
                    <div>
                        <div class="form-group"></div>
                        <div class="form-group">
                            <label class="deployToolTip control-label col-xs-2" data-toggle="tooltip" title="Customize user data">User data configs:</label>
                            <div class="pull-right">
                                <add-config-button target="#newConfigModalId"></add-config-button>
                                <aws-config-modal id="newConfigModalId" v-bind:options="configOptions" v-on:click="addConfig"></aws-config-modal>
                            </div>
                        </div>
                        <aws-user-data v-bind:alluserdata="allUserData" v-on:deleteconfig="deleteConfig" v-on:change="configChange" inadvanced="inAdvanced"></aws-user-data>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
    <modal v-bind:title="confirmDialogTitle" v-bind:id="confirmDialogId" v-on:input="clickDialog">
        <div slot="body">Are you sure to create the cluster for environment {{env.envName}}({{env.stageName}})?</div>
    </modal>

    <div class="panel-footer clearfix">
        <div class="pull-right">
            <button id="saveEnvCapacityBtnId" class="btn btn-primary" data-target="#createHostGroup" data-toggle="modal" data-loading-text="Creating...">
            <span class="glyphicon glyphicon-floppy-save"></span> Create
        </button>
        </div>
    </div>
</div>
<script>
var capacityView = new Vue({
    el:"#side-panel"
 }
)

var info = {{capacity_creation_info|safe}}
var environment = info.environment;
var accepted = info.baseImages.filter(function (e) {
        return e.acceptance == 'ACCEPTED';
    });
var sorted = accepted.sort(function(item1,item2){
        return item2.publish_date - item1.publish_date;
});
var placements = getDefaultPlacement(info);
var capacitySetting = new Vue({
    el: "#mainPanel",
    data: {
        allUserData: Object.keys(info.defaultCMPConfigs).map(
            function (key) {
                return {
                    name: key,
                    value: info.defaultCMPConfigs[key]
                }
            }).filter(function(item){return item.name!='cmp_group'}),
        assignPublicIP: false,
        baseImageHelpData: [],
        baseimages: info.baseImages.map(
            function (o) {
                var acceptance = o.acceptance ? ' [' + o.acceptance + ']' : '';
                return {
                    value: o.id,
                    text: o.provider_name + acceptance,
                    isSelected: o.id === sorted[0].id
                }
            }),
        baseImageValue: sorted[0].id,
        configOptions: Object.keys(info.configList).map(
            function (key) {
                return {
                    name: key,
                    text: key,
                    default: info.configList[key]
                }
            }),
        confirmDialogTitle: "Confirm New Capacity Creation",
        confirmDialogId: "createHostGroup",
        currentProvider: info.defaultProvider,
        currentCell: info.defaultCell,
        hostTypeHelpData:[],
        hostTypeOptions: info.hostTypes.map(
            function (item, idx) {
                return {
                    value: item.abstract_name,
                    text: item.abstract_name + " (" + item.core + " cores, " + item.mem + " GB, " + item.storage + ")",
                    isSelected: item.abstract_name === info.defaultHostType
                }
            }),
        cellValue: info.defaultCell,
        imageNameValue: info.defaultBaseImage,
        imagenames: info.baseImageNames.map(
            function (o) {
                return {
                    value: o,
                    text: o, isSelected: o === info.defaultBaseImage
                }
            }),
        instanceCount: "",
        placements: placements.allPrivate.map(
            function (item) {
                return {
                    value: item.id,
                    text: item.provider_name,
                    isSelected: placements.inDefault(item)
                }
            }),
        placementsHelpData: [],
        providers: info.providerList.map(
            function (o) {
                return {
                    value: o, text: o
                }
            }),
        cells: info.cells.map(
            function (item) {
                return {
                    value: item.provider_name,
                    text: item.provider_name,
                    isSelected: info.defaultCell
                }
            }),
        securityZoneHelpData: [],
        securityZones: info.securityZones.map(
            function (item) {
                return {
                    value: item.abstract_name,
                    text: item.abstract_name,
                    isSelected: item.id === info.securityZones[0].id
                }
            }),
        selectedHostTypeValue: info.defaultHostType,
        selectedSecurityZoneValue: info.securityZones[0].abstract_name,
        selectedPlacements: [],
        showBaseImageHelp: false,
        showHostTypeHelp: false,
        showSecurityZoneHelp: false,
        showPlacementsHelp: false,
    },
    methods: {
        addConfig: function (config) {
            var filter = this.allUserData.filter(function (data) { return data.name === config.name })
            if (filter.length == 0) {
                this.allUserData.push(config)
            }
            else {<commit_msg>fix bug on cells combox (#473)<commit_after>{% extends 'environs/env_base.html'%} {% load utils %} {% block breadcrumb-items %}
<ul class="breadcrumb">
    <li><a href="/">Home</a></li>
    <li><a href="/envs">Environments</a></li>
    <li><a href="/env/{{ env.envName }}/{{ env.stageName }}">{{ env.envName }} ({{ env.stageName }})</a></li>
    <li><a href="/env/{{ env.envName }}/{{ env.stageName }}/config">General Config</a></li>
    <li class="active">New Capacity</li>
</ul>
{% endblock %}
{% load static %}
{% block side-panel-actions %}
<script type="text/javascript" src="{% static "js/components/sharedcomponents.js?changedate=2016.12.19.150000"%}"></script>
<div class="panel panel-default" id="side-panel">
    <div class="panel-heading clearfix">
        <h4 class="panel-title pull-left">Capacity</h4>
    </div>
    <div class="row">
        <side-button styleclass="fa fa-gears" text="Basic Settings" href="/env/{{ env.envName }}/{{ env.stageName }}/config/newcapacity"
            title="Basic Settings"></side-button>
    </div>
</div>
{% endblock %}
{% block new-builds-panel %}
{% endblock %}
{% block new-pred-deploys-panel %}
{% endblock %}
{% block main%}
{% include "environs/env_tabs.tmpl" with envTabKind="config/capacity" %}
<script type="text/javascript" src="{% static "js/components/capacitycomponents.js?changedate=2017.07.05.180000"%}"></script>
<script type="text/javascript" src="{% static "js/components/clusterconfigcomponents.js?changedate=2017.07.27.153000"%}"></script>

<div id="mainPanel" class="panel panel-default">

    <panel-heading title="Advanced Settings" target="#envCapacityId" initcollapse="false"></panel-heading>
    <div id="envCapacityId" class="collapse in panel-body" v-on:show.bs.collapse="showcontent" v-on:hide.bs.collapse="hidecontent">
        <div class="container-fluid">
            <form id="clusterConfigFormId" class="form-horizontal" role="form">
                <fieldset id="clusterConfigFieldSetId">
                    <cloudprovider-select v-bind:cloudproviders="providers" v-bind:value="currentProvider"></cloudprovider-select>
                    <cell-select v-bind:cells="cells" v-on:cellchange="cellChange"  v-bind:value="currentCell"></cell-select>
                    <label-input label="Capacity" placeholder="# of instances" v-model="instanceCount"></label-input>
                    <baseimage-select v-bind:imagenames="imagenames" v-bind:baseimages="baseimages" v-bind:imagenamevalue="imageNameValue" v-bind:baseImageValue="baseImageValue"
                        v-on:baseimagechange="baseImageChange" v-on:imagenamechange="imageNameChange" inadvanced="true" v-on:helpclick="baseImageHelpClick">
                    </baseimage-select>
                    <base-image-help v-show="showBaseImageHelp" v-bind:data="baseImageHelpData"></base-image-help>
                    <label-select label="Host Type" title="Compute Capability of the host" v-model="selectedHostTypeValue" v-bind:selectoptions="hostTypeOptions"
                        showhelp="true" v-on:helpclick="hostTypeHelpClick"></label-select>
                    <hostype-help v-show="showHostTypeHelp" v-bind:data="hostTypeHelpData"></hostype-help>
                    <label-select label="Security Zone" title="Security zone to control inbound/outboud traffic" showhelp="true" v-model="selectedSecurityZoneValue"
                        v-bind:selectoptions="securityZones" v-on:helpclick="securityZoneHelpClick"></label-select>
                    <securityzone-help v-show="showSecurityZoneHelp" v-bind:data="securityZoneHelpData"></securityzone-help>
                    <placements-select label="Placements" title="Placements" v-bind:selectoptions="placements" v-bind:assignpublicip="assignPublicIP"
                        showhelp="true" v-on:helpclick="placementsHelpClick" v-on:assignpublicipclick="selectpublicip"></placements-select>
                    <placements-help v-show="showPlacementsHelp" v-bind:data="placementsHelpData"></placements-help>
                    <div>
                        <div class="form-group"></div>
                        <div class="form-group">
                            <label class="deployToolTip control-label col-xs-2" data-toggle="tooltip" title="Customize user data">User data configs:</label>
                            <div class="pull-right">
                                <add-config-button target="#newConfigModalId"></add-config-button>
                                <aws-config-modal id="newConfigModalId" v-bind:options="configOptions" v-on:click="addConfig"></aws-config-modal>
                            </div>
                        </div>
                        <aws-user-data v-bind:alluserdata="allUserData" v-on:deleteconfig="deleteConfig" v-on:change="configChange" inadvanced="inAdvanced"></aws-user-data>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
    <modal v-bind:title="confirmDialogTitle" v-bind:id="confirmDialogId" v-on:input="clickDialog">
        <div slot="body">Are you sure to create the cluster for environment {{env.envName}}({{env.stageName}})?</div>
    </modal>

    <div class="panel-footer clearfix">
        <div class="pull-right">
            <button id="saveEnvCapacityBtnId" class="btn btn-primary" data-target="#createHostGroup" data-toggle="modal" data-loading-text="Creating...">
            <span class="glyphicon glyphicon-floppy-save"></span> Create
        </button>
        </div>
    </div>
</div>
<script>
var capacityView = new Vue({
    el:"#side-panel"
 }
)

var info = {{capacity_creation_info|safe}}
var environment = info.environment;
var accepted = info.baseImages.filter(function (e) {
        return e.acceptance == 'ACCEPTED';
    });
var sorted = accepted.sort(function(item1,item2){
        return item2.publish_date - item1.publish_date;
});
var placements = getDefaultPlacement(info);
var capacitySetting = new Vue({
    el: "#mainPanel",
    data: {
        allUserData: Object.keys(info.defaultCMPConfigs).map(
            function (key) {
                return {
                    name: key,
                    value: info.defaultCMPConfigs[key]
                }
            }).filter(function(item){return item.name!='cmp_group'}),
        assignPublicIP: false,
        baseImageHelpData: [],
        baseimages: info.baseImages.map(
            function (o) {
                var acceptance = o.acceptance ? ' [' + o.acceptance + ']' : '';
                return {
                    value: o.id,
                    text: o.provider_name + acceptance,
                    isSelected: o.id === sorted[0].id
                }
            }),
        baseImageValue: sorted[0].id,
        configOptions: Object.keys(info.configList).map(
            function (key) {
                return {
                    name: key,
                    text: key,
                    default: info.configList[key]
                }
            }),
        confirmDialogTitle: "Confirm New Capacity Creation",
        confirmDialogId: "createHostGroup",
        currentProvider: info.defaultProvider,
        currentCell: info.defaultCell,
        hostTypeHelpData:[],
        hostTypeOptions: info.hostTypes.map(
            function (item, idx) {
                return {
                    value: item.abstract_name,
                    text: item.abstract_name + " (" + item.core + " cores, " + item.mem + " GB, " + item.storage + ")",
                    isSelected: item.abstract_name === info.defaultHostType
                }
            }),
        cellValue: info.defaultCell,
        imageNameValue: info.defaultBaseImage,
        imagenames: info.baseImageNames.map(
            function (o) {
                return {
                    value: o,
                    text: o, isSelected: o === info.defaultBaseImage
                }
            }),
        instanceCount: "",
        placements: placements.allPrivate.map(
            function (item) {
                return {
                    value: item.id,
                    text: item.provider_name,
                    isSelected: placements.inDefault(item)
                }
            }),
        placementsHelpData: [],
        providers: info.providerList.map(
            function (o) {
                return {
                    value: o, text: o
                }
            }),
        cells: info.cells.map(
            function (item) {
                return {
                    value: item.name,
                    text: item.name,
                    isSelected: info.defaultCell
                }
            }),
        securityZoneHelpData: [],
        securityZones: info.securityZones.map(
            function (item) {
                return {
                    value: item.abstract_name,
                    text: item.abstract_name,
                    isSelected: item.id === info.securityZones[0].id
                }
            }),
        selectedHostTypeValue: info.defaultHostType,
        selectedSecurityZoneValue: info.securityZones[0].abstract_name,
        selectedPlacements: [],
        showBaseImageHelp: false,
        showHostTypeHelp: false,
        showSecurityZoneHelp: false,
        showPlacementsHelp: false,
    },
    methods: {
        addConfig: function (config) {
            var filter = this.allUserData.filter(function (data) { return data.name === config.name })
            if (filter.length == 0) {
                this.allUserData.push(config)
            }
            else {
{'fraction_non_alphanumeric': 0.1381169205003402, 'fraction_numerical': 0.005809389229078348, 'mean_word_length': 2.140696909927679, 'pattern_counts': {'":': 0, '<': 201, '<?xml version=': 0, '>': 201, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '138224', 'n_tokens_mistral': 5458, 'n_tokens_neox': 5171, 'n_words': 909}