~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to views/settings-page.twig

  • Committer: Dan Garner
  • Date: 2015-03-26 14:08:33 UTC
  • Revision ID: git-v1:70d14044444f8dc5d602b99890d59dea46d9470c
Moved web servable files to web folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{#
2
 
/*
3
 
 * Spring Signage Ltd - http://www.springsignage.com
4
 
 * Copyright (C) 2015 Spring Signage Ltd
5
 
 * (${FILE_NAME})
6
 
 */
7
 
 
8
 
#}
9
 
{% extends "authed.twig" %}
10
 
{% import "forms.twig" as forms %}
11
 
 
12
 
{% block actionMenu %}
13
 
    <ul class="nav nav-pills pull-right">
14
 
        {% if settings.SETTING_IMPORT_ENABLED %}
15
 
            <li class="btn btn-success btn-xs"><a id="layoutUploadForm" class="btns" title="{% trans "Import a database" %}" href="#"> <i class="fa fa-cloud-download" aria-hidden="true"></i> {% trans "Import" %}</a></li>
16
 
        {% endif %}
17
 
 
18
 
        <li class="btn btn-info btn-xs" ><a class="XiboFormButton btns" title="{% trans "Export database" %}" href="{{ urlFor("maintenance.export.form") }}"> <i class="fa fa-cloud-upload" aria-hidden="true"></i> {% trans "Export" %}</a></li>
19
 
 
20
 
        {% if settings.SETTING_LIBRARY_TIDY_ENABLED %}
21
 
            <li class="btn btn-danger btn-xs"><a class="XiboFormButton btns" title="{% trans "Run through the library and remove unused and unnecessary files" %}" href="{{ urlFor("maintenance.libraryTidy.form") }}"> <i class="fa fa-trash" aria-hidden="true"></i> {% trans "Tidy Library" %}</a></li>
22
 
        {% endif %}
23
 
    </ul>
24
 
{% endblock %}
25
 
 
26
 
{% block pageContent %}
27
 
    <div class="widget">
28
 
        <div class="widget-title">{% trans "Settings" %}</div>
29
 
        <div class="widget-body">
30
 
            <div class="row">
31
 
                <div class="col-md-12">
32
 
                    <ul class="nav nav-tabs" role="tablist">
33
 
                        {% set first = true %}
34
 
                        {% for category in categories %}
35
 
                            {% set transCatTabName = category.tabName %}
36
 
                            <li {% if first %}class="active"{% endif %}><a href="#{{ category.tabId }}" role="tab" data-toggle="tab"><span>{% trans transCatTabName %}</span></a></li>
37
 
                            {% set first = false %}
38
 
                        {% endfor %}
39
 
                    </ul>
40
 
                    <form id="SettingsForm" class="XiboForm form-horizontal" method="put" action="{{ urlFor("settings.update") }}">
41
 
                        <div class="tab-content">
42
 
                            {% for field in fields %}
43
 
                                {% if currentCat != field.cat %}
44
 
                                    {% if currentCat != "" %}
45
 
                                    </div>
46
 
                                    {% endif %}
47
 
 
48
 
                                    <div class="tab-pane {% if currentCat == "" %}active{% endif %}" id="{{ field.catId }}">
49
 
                                    {% set currentCat = field.cat %}
50
 
                                    {% set transFieldCat = field.cat %}
51
 
                                    <h3 class="section-heading">{% trans transFieldCat %}</h3>
52
 
                                {% endif %}
53
 
                                {# Now we have to output the relevant form field #}
54
 
                                {% if field.enabled != 1 %}
55
 
                                    {{ forms.disabled(field.name, field.title, field.value, field.helpText) }}
56
 
                                {% elseif field.fieldType == "text" %}
57
 
                                    {{ forms.input(field.name, field.title, field.value, field.helpText) }}
58
 
                                {% elseif field.fieldType == "number" %}
59
 
                                    {{ forms.number(field.name, field.title, field.value, field.helpText) }}
60
 
                                {% elseif field.fieldType == "email" %}
61
 
                                    {{ forms.email(field.name, field.title, field.value, field.helpText) }}
62
 
                                {% elseif field.fieldType == "checkbox" %}
63
 
                                    {{ forms.checkbox(field.name, field.title, field.value, field.helpText) }}
64
 
                                {% elseif field.fieldType == "dropdown" %}
65
 
                                    {{ forms.dropdown(field.name, "single", field.title, field.value, field.options, "id", "value", field.helpText) }}
66
 
                                {% elseif field.fieldType == "timezone" %}
67
 
                                    {{ forms.dropdown(field.name, "single", field.title, field.value, field.options, "id", "value", field.helpText) }}
68
 
                                {% elseif field.fieldType == "datetime" %}
69
 
                                    {{ forms.datetime(field.name, field.title, field.value, field.helpText) }}
70
 
                                {% endif %}
71
 
                            {% endfor %}
72
 
                        </div>
73
 
                        <button class="btn btn-save btn-block btn-success" href="#"><span>{% trans "Save" %}</span></button>
74
 
                    </form>
75
 
                </div>
76
 
            </div>
77
 
        </div>
78
 
    </div>
79
 
{% endblock %}
80
 
 
81
 
{% block javaScript %}
82
 
    <script type="text/javascript">
83
 
        $("#layoutUploadForm").click(function() {
84
 
 
85
 
            var template = Handlebars.compile($("#template-backup-upload").html());
86
 
 
87
 
            // Handle bars and open a dialog
88
 
            bootbox.dialog({
89
 
                message: template({
90
 
                    trans: {
91
 
                        addFiles: "{% trans "Add Backup File" %}",
92
 
                        startUpload: "{% trans "Start upload" %}",
93
 
                        cancelUpload: "{% trans "Cancel upload" %}"
94
 
                    },
95
 
                    upload: {
96
 
                        maxSize: {{ libraryUpload.maxSize }},
97
 
                        maxSizeMessage: "{{ libraryUpload.maxSizeMessage  }}",
98
 
                        validExt: "{{ libraryUpload.validExt }}"
99
 
                    }
100
 
                }),
101
 
                title: "{% trans "Upload Backup" %}",
102
 
                buttons: {
103
 
                    main: {
104
 
                        label: "{% trans "Done" %}",
105
 
                        className: "btn-primary",
106
 
                        callback: function() {
107
 
                            XiboDialogClose();
108
 
                        }
109
 
                    }
110
 
                }
111
 
            }).on('shown.bs.modal', function() {
112
 
                // Configure the upload form
113
 
                var url = "{{ urlFor("maintenance.import") }}";
114
 
                var form = $(this).find("form");
115
 
 
116
 
                // Initialize the jQuery File Upload widget:
117
 
                form.fileupload({
118
 
                    url: url,
119
 
                    disableImageResize: true
120
 
                });
121
 
 
122
 
                // Upload server status check for browsers with CORS support:
123
 
                if ($.support.cors) {
124
 
                    $.ajax({
125
 
                        url: url,
126
 
                        type: 'HEAD'
127
 
                    }).fail(function () {
128
 
                        $('<span class="alert alert-error"/>')
129
 
                                .text('Upload server currently unavailable - ' + new Date())
130
 
                                .appendTo(form);
131
 
                    });
132
 
                }
133
 
 
134
 
                // Enable iframe cross-domain access via redirect option:
135
 
                form.fileupload(
136
 
                        'option',
137
 
                        'redirect',
138
 
                        window.location.href.replace(
139
 
                                /\/[^\/]*$/,
140
 
                                '/cors/result.html?%s'
141
 
                        )
142
 
                );
143
 
 
144
 
                form.bind('fileuploadsubmit', function (e, data) {
145
 
                    var inputs = data.context.find(':input');
146
 
                    if (inputs.filter('[required][value=""]').first().focus().length) {
147
 
                        return false;
148
 
                    }
149
 
                    data.formData = inputs.serializeArray().concat(form.serializeArray());
150
 
 
151
 
                    inputs.filter("input").prop("disabled", true);
152
 
                });
153
 
            });
154
 
        });
155
 
    </script>
156
 
{% endblock %}
157
 
 
158
 
{% block javaScriptTemplates %}
159
 
    {{ parent() }}
160
 
 
161
 
    {% raw %}
162
 
 
163
 
    <script type="text/x-handlebars-template" id="template-backup-upload">
164
 
        <form method="post" enctype="multipart/form-data" data-max-file-size="{{ upload.maxSize }}" data-accept-file-types="/(\.|\/)tar.gz/i">
165
 
            <div class="row fileupload-buttonbar">
166
 
                <div class="col-md-7">
167
 
                    <div class="well">
168
 
                        {{ upload.maxSizeMessage }}
169
 
                    </div>
170
 
                    <!-- The fileinput-button span is used to style the file input field as button -->
171
 
                    <span class="btn btn-success fileinput-button">
172
 
                        <i class="glyphicon glyphicon-plus glyphicon glyphicon-white"></i>
173
 
                        <span>{{ trans.addFiles }}</span>
174
 
                        <input type="file" name="files[]">
175
 
                    </span>
176
 
                    <button type="submit" class="btn btn-primary start">
177
 
                        <i class="glyphicon glyphicon-upload glyphicon glyphicon-white"></i>
178
 
                        <span>{{ trans.startUpload }}</span>
179
 
                    </button>
180
 
                    <button type="reset" class="btn btn-warning cancel">
181
 
                        <i class="glyphicon glyphicon-ban-circle glyphicon glyphicon-white"></i>
182
 
                        <span>{{ trans.cancelUpload }}</span>
183
 
                    </button>
184
 
                    <!-- The loading indicator is shown during file processing -->
185
 
                    <span class="fileupload-loading"></span>
186
 
                </div>
187
 
                <!-- The global progress information -->
188
 
                <div class="col-md-4 fileupload-progress fade">
189
 
                    <!-- The global progress bar -->
190
 
                    <div class="progress">
191
 
                        <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width:0%;">
192
 
                            <div class="sr-only"></div>
193
 
                        </div>
194
 
                    </div>
195
 
                    <!-- The extended global progress information -->
196
 
                    <div class="progress-extended">&nbsp;</div>
197
 
                </div>
198
 
            </div>
199
 
            <!-- The table listing the files available for upload/download -->
200
 
            <table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
201
 
        </form>
202
 
    </script>
203
 
 
204
 
    <!-- The template to display files available for upload -->
205
 
    <script id="template-backup-upload" type="text/x-tmpl">
206
 
        {% for (var i=0, file; file=o.files[i]; i++) { %}
207
 
            <tr class="template-upload fade">
208
 
                <td>
209
 
                    <span class="fileupload-preview"></span>
210
 
                </td>
211
 
                <td class="title">
212
 
                    {% if (file.error) { %}
213
 
                        <div><span class="label label-danger">{%=file.error%}</span></div>
214
 
                    {% } %}
215
 
                    {% if (!file.error) { %}
216
 
                    <label for="name[]"><input name="name[]" type="text" id="name" value="" /></label>
217
 
                    {% } %}
218
 
                </td>
219
 
                <td>
220
 
                    <p class="size">{%=o.formatFileSize(file.size)%}</p>
221
 
                    {% if (!o.files.error) { %}
222
 
                        <div class="progress">
223
 
                            <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width:0%;">
224
 
                                <div class="sr-only"></div>
225
 
                            </div>
226
 
                        </div>
227
 
                    </div>
228
 
                    {% } %}
229
 
                </td>
230
 
                <td>
231
 
                    {% if (!o.files.error && !i && !o.options.autoUpload) { %}
232
 
                        <button class="btn btn-primary start">
233
 
                            <i class="glyphicon glyphicon-upload glyphicon glyphicon-white"></i>
234
 
                        </button>
235
 
                    {% } %}
236
 
                    {% if (!i) { %}
237
 
                        <button class="btn btn-warning cancel">
238
 
                            <i class="glyphicon glyphicon-ban-circle glyphicon glyphicon-white"></i>
239
 
                        </button>
240
 
                    {% } %}
241
 
                </td>
242
 
            </tr>
243
 
        {% } %}
244
 
        </script>
245
 
    <!-- The template to display files available for download -->
246
 
    <script id="template-backup-download" type="text/x-tmpl">
247
 
        {% for (var i=0, file; file=o.files[i]; i++) { %}
248
 
            <tr class="template-download fade">
249
 
               <td>
250
 
                    <p class="name" id="{%=file.storedas%}" status="{% if (file.error) { %}error{% } %}">
251
 
                        {%=file.name%}
252
 
                    </p>
253
 
                    {% if (file.error) { %}
254
 
                        <div><span class="label label-danger">{%=file.error%}</span></div>
255
 
                    {% } %}
256
 
                </td>
257
 
                <td>
258
 
                    <span class="size">{%=o.formatFileSize(file.size)%}</span>
259
 
                </td>
260
 
            </tr>
261
 
        {% } %}
262
 
        </script>
263
 
 
264
 
    {% endraw %}
265
 
{% endblock %}
 
 
b'\\ No newline at end of file'