Skip to content

Commit

Permalink
Create include_multinodes_checkboxes.html for code reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
my8100 committed Jul 31, 2019
1 parent ce0d47d commit 79ee83f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 71 deletions.
38 changes: 4 additions & 34 deletions scrapydweb/templates/scrapydweb/deploy.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
.folders-content div:hover {
background-color: #f5f7fa;
}

#multinodes .link {margin-left: 140px;}
#multinodes .key {width: 128px;}
</style>

{% if SCRAPYD_SERVERS_AMOUNT > 1 %}
Expand Down Expand Up @@ -210,40 +213,7 @@ <h3>No projects found in '{{ SCRAPY_PROJECTS_DIR }}' of the ScrapydWeb host, che

<form method="post" action="{{ url_deploy_upload }}" enctype="multipart/form-data">
{% if SCRAPYD_SERVERS_AMOUNT > 1 %}
<a class="link" style="margin-left: 140px;" href="{{ url_servers }}" target="_blank">To select nodes in the Servers page &raquo;</a>
<div class="line-container">
<div class="key" style="padding-left: 10px;"><span>*</span>multinodes</div>
<input type="text" name="checked_amount" value="1" hidden />
<div class="multiselect">
<div class="selectBox" onclick="showCheckboxes();">
<div class="value">
<span id="selected_nodes_statement">{{ SCRAPYD_SERVERS[node-1] }}</span>
<svg class="icon anchor" aria-hidden="true">
<use xlink:href="#icon-down"></use>
</svg>
</div>
<div class="overSelect"></div>
</div>
<div id="checkboxes" style="display: none;">
<label for="checkCurrent"><input type="checkbox" id="checkCurrent" />Check current node only</label>
<label for="syncFromServersPage"><input type="checkbox" id="syncFromServersPage" />Sync from Servers page</label>
<label for="checkAll"><input type="checkbox" id="checkAll" />CheckAll / UncheckAll</label>
<div id="nodes_checkboxes">
{% for SCRAPYD_SERVER in SCRAPYD_SERVERS %}
{% if SCRAPYD_SERVERS_GROUPS[loop.index-1] and loop.changed(SCRAPYD_SERVERS_GROUPS[loop.index-1]) %}
<span> --- {{ SCRAPYD_SERVERS_GROUPS[loop.index-1] }} --- </span>
{% endif %}

<label id="label_{{ loop.index }}" for="checkbox_{{ loop.index }}" {% if loop.index == node %}style="color: #409EFF; font-weight: 700;"{% endif %}>
<input type="checkbox" id="checkbox_{{ loop.index }}" name="{{ loop.index }}"
{% if loop.index in selected_nodes %}checked{% endif %} />{{ SCRAPYD_SERVER }}
</label>
{% endfor %}
</div>
</div>
<div class="form-item-error">Select at least one node</div>
</div>
</div>
{% include 'scrapydweb/include_multinodes_checkboxes.html' %}
{% endif %}
</form>

Expand Down
36 changes: 36 additions & 0 deletions scrapydweb/templates/scrapydweb/include_multinodes_checkboxes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div id="multinodes">
<a class="link" href="{{ url_servers }}" target="_blank">To select nodes in the Servers page &raquo;</a>
<div class="line-container">
<div class="key"><span>*</span>multinodes</div>
<input type="text" name="checked_amount" value="1" hidden />
<div class="multiselect">
<div class="selectBox" onclick="showCheckboxes();">
<div class="value">
<span id="selected_nodes_statement">{{ SCRAPYD_SERVERS[node-1] }}</span>
<svg class="icon anchor" aria-hidden="true">
<use xlink:href="#icon-down"></use>
</svg>
</div>
<div class="overSelect"></div>
</div>
<div id="checkboxes" style="display: none;">
<label for="checkCurrent"><input type="checkbox" id="checkCurrent" />Check current node only</label>
<label for="syncFromServersPage"><input type="checkbox" id="syncFromServersPage" />Sync from Servers page</label>
<label for="checkAll"><input type="checkbox" id="checkAll" />CheckAll / UncheckAll</label>
<div id="nodes_checkboxes">
{% for SCRAPYD_SERVER in SCRAPYD_SERVERS %}
{% if SCRAPYD_SERVERS_GROUPS[loop.index-1] and loop.changed(SCRAPYD_SERVERS_GROUPS[loop.index-1]) %}
<span> --- {{ SCRAPYD_SERVERS_GROUPS[loop.index-1] }} --- </span>
{% endif %}

<label id="label_{{ loop.index }}" for="checkbox_{{ loop.index }}" {% if loop.index == node %}style="color: #409EFF; font-weight: 700;"{% endif %}>
<input type="checkbox" id="checkbox_{{ loop.index }}" name="{{ loop.index }}"
{% if loop.index in selected_nodes %}checked{% endif %} />{{ SCRAPYD_SERVER }}
</label>
{% endfor %}
</div>
</div>
<div class="form-item-error">Select at least one node</div>
</div>
</div>
</div>
41 changes: 4 additions & 37 deletions scrapydweb/templates/scrapydweb/schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
border: 1px solid #e3e3e3;
}

.line-container .key {
width: 188px;
}
#settings_arguments .el-form-item__label {color: #409EFF;}
#time_task .el-form-item__label {color: #feb324;}
#time_task .main_settings .el-form-item__label {color: #67c23a;}

#multinodes .link {margin-left: 200px;}
#multinodes .key {width: 188px;}
</style>


Expand Down Expand Up @@ -348,40 +348,7 @@ <h4>HELP</h4>
<form id="form_run_spider" method="post" action="{{ url_schedule_run }}" enctype="multipart/form-data">
<input type="text" name="filename" hidden />
{% if SCRAPYD_SERVERS_AMOUNT > 1 %}
<a class="link" style="margin-left: 200px;" href="{{ url_servers }}" target="_blank">To select nodes in the Servers page &raquo;</a>
<div class="line-container">
<div class="key"><span>*</span>multinodes</div>
<input type="text" name="checked_amount" value="1" hidden />
<div class="multiselect">
<div class="selectBox" onclick="showCheckboxes();">
<div class="value">
<span id="selected_nodes_statement">{{ SCRAPYD_SERVERS[node-1] }}</span>
<svg class="icon anchor" aria-hidden="true">
<use xlink:href="#icon-down"></use>
</svg>
</div>
<div class="overSelect"></div>
</div>
<div id="checkboxes" style="display: none;">
<label for="checkCurrent"><input type="checkbox" id="checkCurrent" />Check current node only</label>
<label for="syncFromServersPage"><input type="checkbox" id="syncFromServersPage" />Sync from Servers page</label>
<label for="checkAll"><input type="checkbox" id="checkAll" />CheckAll / UncheckAll</label>
<div id="nodes_checkboxes">
{% for SCRAPYD_SERVER in SCRAPYD_SERVERS %}
{% if SCRAPYD_SERVERS_GROUPS[loop.index-1] and loop.changed(SCRAPYD_SERVERS_GROUPS[loop.index-1]) %}
<span> --- {{ SCRAPYD_SERVERS_GROUPS[loop.index-1] }} --- </span>
{% endif %}

<label id="label_{{ loop.index }}" for="checkbox_{{ loop.index }}" {% if loop.index == node %}style="color: #409EFF; font-weight: 700;"{% endif %}>
<input type="checkbox" id="checkbox_{{ loop.index }}" name="{{ loop.index }}"
{% if loop.index in selected_nodes %}checked{% endif %} />{{ SCRAPYD_SERVER }}
</label>
{% endfor %}
</div>
</div>
<div class="form-item-error">Select at least one node</div>
</div>
</div>
{% include 'scrapydweb/include_multinodes_checkboxes.html' %}
{% endif %}
</form>

Expand Down

0 comments on commit 79ee83f

Please sign in to comment.