a b/qiita_pet/templates/study_base.html
1
{% extends sitebase.html %}
2
{% block head %}
3
{% set study_title = study_info['study_title'] %}
4
{% set study_title_msg = study_title.replace('"', '\\"') %}
5
<script type="text/javascript">
6
  function validate_delete_study_text() {
7
    if ($("#study-alias").val() == "{% raw study_title_msg %}") {
8
      $('#delete-study-button').prop('disabled', false);
9
    } else {
10
      $('#delete-study-button').prop('disabled', true);
11
    }
12
  }
13
14
  function delete_study() {
15
    if($("#study-alias").val() != "{% raw study_title_msg %}") {
16
      alert("The entered study alias doesn't match the study");
17
      return false;
18
    }
19
    else if(confirm("Are you sure you want to delete {% raw study_title_msg %}?")) {
20
      $.post('{% raw qiita_config.portal_dir %}/study/delete/', { study_id: {{study_info['study_id']}} })
21
        .done(function ( data ) {
22
          location.reload();
23
        });
24
    }
25
  }
26
27
  /**
28
   *
29
   * Function to populate the main div of the screen
30
   *
31
   * @param url string with the URL to perform the AJAX get call
32
   * @param parameters the parameters for the AJAX call
33
   *
34
   * This function executes an AJAX get against the URL provided with the given
35
   * parameters, and inserts the returned data as HTML in the study-main div
36
   *
37
   */
38
  function populate_main_div(url, parameters) {
39
    show_loading("study-main");
40
    $.get(url, parameters)
41
      .done(function(data) {
42
          $("#study-main").html(data);
43
      });
44
  }
45
46
  /**
47
   *
48
   * Function to populate the data-types-menu div
49
   *
50
   * This function executes an AJAX get against the URL
51
   * "/study/description/data_type_menu/" and inserts the returned data as
52
   * HTML in the data-types-menu div
53
   *
54
   */
55
  function populate_data_type_menu_div() {
56
    show_loading("data-types-menu");
57
    $.get("{% raw qiita_config.portal_dir %}/study/description/data_type_menu/", {study_id: {{study_info['study_id']}} })
58
      .done(function(data) {
59
        $("#data-types-menu").html(data);
60
      });
61
  }
62
63
  $(document).ready(function() {
64
    // Populate the different sections of the page
65
    populate_data_type_menu_div();
66
    // The initial page to be shown is the base information of the study
67
    {% if 'prep_id' in study_info %}
68
        populate_main_div("{% raw qiita_config.portal_dir %}/study/description/prep_template/", { prep_id: {{study_info['prep_id']}}, study_id: {{study_info['study_id']}}});
69
    {% else %}
70
        populate_main_div("{% raw qiita_config.portal_dir %}/study/description/baseinfo/", { study_id: {{study_info['study_id']}}});
71
    {% end %}
72
73
    {% if study_info['num_samples'] > 0 %}
74
      $("#sample-summary-btn").show();
75
      $("#add-new-preparation-btn").show();
76
    {% else %}
77
      $("#sample-summary-btn").hide();
78
      $("#add-new-preparation-btn").hide();
79
    {% end %}
80
    {% if study_info['message'] != '' %}
81
      bootstrapAlert("{{study_info['message']}}", "{{study_info['level']}}");
82
    {% end %}
83
  });
84
</script>
85
<style>
86
.graph {
87
  width:100%;
88
  height:300px;
89
  border: 1px solid #ccc;
90
}
91
</style>
92
{% end %}
93
{% block content %}
94
<div class="row">
95
  {% if study_info['level'] != 'info' %}
96
    <div class="col-md-3">
97
      <button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/baseinfo/', { study_id: {{study_info['study_id']}} })"><span class="glyphicon glyphicon-info-sign"></span> Study Information</button>
98
      <button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/sample_template/', { study_id: {{study_info['study_id']}} })"><span class="glyphicon glyphicon-info-sign"></span> Sample Information</button>
99
      {% if editable %}
100
        <a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/study/upload/{{study_info['study_id']}}"><span class="glyphicon glyphicon-upload"></span> Upload Files</a>
101
        <button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/new_prep_template/', { study_id: {{study_info['study_id']}} })" id="add-new-preparation-btn"><span class="glyphicon glyphicon-plus-sign"></span> Add New Preparation</button>
102
        <button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/analyses/', { study_id: {{study_info['study_id']}} })" id="analyses-btn"><span class="glyphicon glyphicon-info-sign"></span> Derived Analyses </button>
103
      {% end %}
104
      {% if study_info['show_biom_download_button'] %}
105
        <a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/download_study_bioms/{{study_info['study_id']}}"><span class="glyphicon glyphicon-download-alt"></span> All QIIME maps and BIOMs</a>
106
      {% end %}
107
      {% if study_info['has_access_to_raw_data'] and study_info['show_raw_download_button'] %}
108
        <a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/download_raw_data/{{study_info['study_id']}}"><span class="glyphicon glyphicon-download-alt"></span> All raw data</a>
109
      {% end %}
110
      <div style="text-align: center;"><small><a href="{% raw qiita_config.portal_dir %}/static/doc/html/faq.html#how-to-solve-download-or-unzip-errors">Issues with downloads or opening the downloaded zip?</a></small></div>
111
112
      <div id="data-types-menu"></div>
113
    </div>
114
  {% end %}
115
116
  <div class="col-md-9">
117
    <!-- Study ID and study alias always on top -->
118
    <div class="row">
119
      <div class="col-md-12" id="study-base-info">
120
        <h2>{% raw study_title %} - ID {{study_info['study_id']}}</h2>
121
        <h3>{{study_info['study_alias']}}</h3>
122
        <h6>Do you want to submit to <a target="_blank" href="https://www.ebi.ac.uk/ena">EBI-ENA</a>? Review the <a target="_blank" href="{% raw qiita_config.portal_dir %}/static/doc/html/checklist-for-ebi-ena-submission.html">submission checklist</a></h6>
123
      </div>
124
    </div>
125
    <!-- Dynamic div that changes based on what information is shown -->
126
    <div class="row"><div class="col-md-12" id="study-main"></div></div>
127
  </div>
128
</div>
129
130
<!-- Modal used to delete the study -->
131
<div class="modal fade delete-study" tabindex="-1" role="dialog" id="delete-study">
132
  <div class="modal-dialog modal-md">
133
    <div class="modal-content">
134
      <div class="modal-header">
135
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
136
        <h3>Deleting:<br/></h3><h4>{% raw study_title %}</h4>
137
      </div>
138
      <div class="modal-body">
139
        You will only be able to delete a sandboxed study. This will delete all data associated with the study, including analyses using this data.<br/>
140
        To continue you need to write the title of the study:<br/>
141
        <input type="text" name="study-alias" id="study-alias" onkeyup="validate_delete_study_text();" size="{{ len(study_title) }}">
142
        <button class="btn btn-danger glyphicon glyphicon-trash" onclick="delete_study();" id="delete-study-button" disabled></button>
143
      </div>
144
      <div class="modal-footer">
145
      </div>
146
    </div>
147
  </div>
148
</div>
149
{% end %}