Browse Source

integration of react component preview generator

Skylsmoi 7 years ago
parent
commit
0a5467ad8d

BIN
tracim/tracim/i18n/fr/LC_MESSAGES/tracim.mo View File


+ 12 - 0
tracim/tracim/i18n/fr/LC_MESSAGES/tracim.po View File

@@ -1559,6 +1559,18 @@ msgstr "Voir la dernière version"
1559 1559
 msgid "<b>This file is deprecated</b>"
1560 1560
 msgstr "<b>Ce fichier est obsolète</b>"
1561 1561
 
1562
+#: tracim/templates/file/getone.mak:114
1563
+msgid "Preview"
1564
+msgstr "Prévisualisation"
1565
+
1566
+#: tracim/templates/file/getone.mak:136
1567
+msgid "this page"
1568
+msgstr "cette page"
1569
+
1570
+#: tracim/templates/file/getone.mak:143
1571
+msgid "all pages"
1572
+msgstr "toutes les pages"
1573
+
1562 1574
 #: tracim/templates/file/getone.mak:83 tracim/templates/file/toolbar.mak:23
1563 1575
 msgid "Download the file"
1564 1576
 msgstr "Télécharger le fichier"

+ 7 - 0
tracim/tracim/public/assets/css/dashboard.css View File

@@ -1,4 +1,11 @@
1 1
 /*
2
+ * Bootstrap overrides
3
+ */
4
+.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
5
+  border-top-right-radius: 4px
6
+}
7
+
8
+/*
2 9
  * Base structure
3 10
  */
4 11
 

+ 1 - 1
tracim/tracim/public/assets/js/main.js View File

@@ -1,7 +1,7 @@
1 1
 $(document).ready(function () {
2 2
 
3 3
   // toggle sidebar-left width to fixed or auto
4
-  $('#toggle-left-sidebar-width').click( function() {
4
+  $('#toggle-left-sidebar-width').click(function() {
5 5
     const sidebar = $('#sidebar-left')
6 6
     const buttonIcon = $('> i', this)
7 7
 

File diff suppressed because it is too large
+ 22 - 0
tracim/tracim/public/assets/js/previewGenerator.app.entry.js


File diff suppressed because it is too large
+ 2587 - 0
tracim/tracim/public/assets/js/previewGenerator.vendor.bundle.js


+ 29 - 110
tracim/tracim/templates/file/getone.mak View File

@@ -101,117 +101,36 @@
101 101
 
102 102
     <div class="content__detail file">
103 103
         <% download_url = tg.url('/workspaces/{}/folders/{}/files/{}/download?revision_id={}'.format(result.file.workspace.id, result.file.parent.id,result.file.id,result.file.selected_revision)) %>
104
-        <div class="t-half-spacer-above download-file-button">
105
-            <a style="" class="btn btn-default" tittle="${_('Download the file')}"
106
-                href="${download_url}" >
107
-                ${ICON.FA_FW('fa fa-download fa-2x')}
108
-            </a>
109
-        </div>
110
-
111 104
         <div class="t-half-spacer-above">
112
-            <table class="table table-hover table-condensed table-striped table-bordered">
113
-                <tr>
114
-                    <td class="tracim-title">${_('Preview')}</td>
115
-                    <td>
116
-                        <table>
117
-                            <tr>
118
-                                <td>
119
-                                    <button type="button" id="pg_previous_page" onclick="previous_page()">
120
-                                        <span class="pull-left">
121
-                                            ${ICON.FA_FW('fa fa-chevron-left')}
122
-                                        </span>
123
-                                    </button>
124
-                                </td>
125
-                                <td>
126
-                                    <div id="pg_link"><img id='preview_generator' alt="Preview"></div>
127
-                                </td>
128
-                                <td>
129
-                                    <button type="button" id="pg_next_page" onclick="next_page()">
130
-                                        <span>
131
-                                            ${ICON.FA_FW('fa fa-chevron-right')}
132
-                                        </span>
133
-                                    </button>
134
-                                </td>
135
-                                <td>
136
-                                    <a type="button" id="dl_one_pdf">${_('this page')}
137
-                                        <span class="pull-left">
138
-                                            ${ICON.FA_FW('fa fa-download')}
139
-                                        </span>
140
-                                    </a>
141
-                                </td>
142
-                                <td>
143
-                                    <a type="button" id="dl_full_pdf">${_('all pages')}
144
-                                        <span class="pull-left">
145
-                                            ${ICON.FA_FW('fa fa-download')}
146
-                                        </span>
147
-                                    </a>
148
-                                </td>
149
-                            </tr>
150
-                        </table>
151
-
152
-                        <script type="text/javascript">
153
-                            var nb_page = parseInt(${nb_page})
154
-                            var page = 0
155
-                            var urls = [
156
-                                % for one_url in url:
157
-                                    '${one_url}',
158
-                                % endfor
159
-                            ]
160
-
161
-                            document.getElementById('preview_generator').src = urls[page]
162
-                            refresh_button()
163
-
164
-                            function next_page () {
165
-                                page = page + 1
166
-                                document.getElementById('preview_generator').src = urls[page]
167
-                                refresh_button()
168
-                            }
169
-
170
-                            function previous_page () {
171
-                                page = page - 1
172
-                                document.getElementById('preview_generator').src = urls[page]
173
-                                refresh_button()
174
-                            }
175
-
176
-                            function refresh_button () {
177
-                                document.getElementById('pg_previous_page').disabled = false
178
-                                document.getElementById('pg_next_page').disabled = false
179
-                                document.getElementById('dl_one_pdf').href = '/previews/${result.file.id}/pages/' + page + '/download_pdf_one?revision_id=${result.file.selected_revision}'
180
-                                document.getElementById('dl_full_pdf').href = '/previews/${result.file.id}/pages/' + page + '/download_pdf_full?revision_id=${result.file.selected_revision}'
181
-                                document.getElementById('pg_link').href = '/previews/${result.file.id}/pages/' + page + '/high_quality?revision_id=${result.file.selected_revision}'
182
-
183
-                                if (page >= nb_page - 1) {
184
-                                    document.getElementById('pg_next_page').disabled = true
185
-                                }
186
-                                if (page <= 0) {
187
-                                    document.getElementById('pg_previous_page').disabled = true
188
-                                }
189
-                            }
190
-                        </script>
191
-                    </td>
192
-                </tr>
193
-                <tr>
194
-                    <td class="tracim-title">${_('File')}</td>
195
-                    <td>
196
-                        <a href="${download_url}" tittle="${_('Download the file (last revision)')}">
197
-                            ${result.file.file.name}
198
-                            <span class="pull-right">
199
-                                ${ICON.FA_FW('fa fa-download')}
200
-                            </span>
201
-
202
-                        </a>
203
-                    </td>
204
-                </tr>
205
-                <tr>
206
-                    <td class="tracim-title">${_('Size')}</td>
207
-                    <td>${h.user_friendly_file_size(result.file.file.size)}</td>
208
-                </tr>
209
-                <tr>
210
-                    <td class="tracim-title">${_('Modified')}</td>
211
-                    <% created_localized = h.get_with_timezone(result.file.created) %>
212
-                    <td>${h.format_short(created_localized)|n} ${_('by {}').format(result.file.owner.name)}</td>
213
-                </tr>
214
-            </table>
105
+            <div id='previewGenerator'></div>
106
+            <script src="${tg.url('/assets/js/previewGenerator.vendor.bundle.js')}" type="text/javascript"></script>
107
+            <script src="${tg.url('/assets/js/previewGenerator.app.entry.js')}" type="text/javascript"></script>
108
+            <script type="text/javascript">
109
+              <% created_localized = h.get_with_timezone(result.file.created) %>
110
+              (function initialisePreviewGenerator() {
111
+                previewGenerator(
112
+                  document.getElementById('previewGenerator'),
113
+                  [
114
+                    % for one_url in url:
115
+                      '${one_url}',
116
+                    % endfor
117
+                  ],
118
+                  '${nb_page}',
119
+                  '/previews/__FILE_ID__/pages/__CURRENT_PAGE__/__DOWNLOAD_TYPE__?revision_id=__REVISION_ID__',
120
+                  {
121
+                    id: '${result.file.id}',
122
+                    name: '${result.file.file.name}',
123
+                    selectedRevision: '${result.file.selected_revision}',
124
+                    weight: '${h.user_friendly_file_size(result.file.file.size)}',
125
+                    height: '300',
126
+                    modifiedAt: '${h.format_short(created_localized)|n}',
127
+                    owner: '${result.file.owner.name}',
128
+                    sourceLink: '${download_url}',
129
+                    pdfAvailable: false // Côme - 2017/07/24 - backend should return this information
130
+                  }
131
+                )
132
+              })()
133
+            </script>
215 134
         </div>
216 135
 
217 136
         <div class="t-half-spacer-above">