PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/static/scripts/mvc/library/library-foldertoolbar-view.js

https://bitbucket.org/hbc/galaxy-central-hbc/
JavaScript | 666 lines | 534 code | 78 blank | 54 comment | 50 complexity | 51143712d3bf5218bc50400283e86957 MD5 | raw file
Possible License(s): CC-BY-3.0
  1. define([
  2. "galaxy.masthead",
  3. "utils/utils",
  4. "libs/toastr",
  5. "mvc/library/library-model"],
  6. function(mod_masthead,
  7. mod_utils,
  8. mod_toastr,
  9. mod_library_model) {
  10. var FolderToolbarView = Backbone.View.extend({
  11. el: '#center',
  12. events: {
  13. 'click #toolbtn_create_folder' : 'createFolderFromModal',
  14. 'click #toolbtn_bulk_import' : 'modalBulkImport',
  15. 'click .toolbtn_add_files' : 'addFilesToFolderModal',
  16. 'click #include_deleted_datasets_chk' : 'checkIncludeDeleted',
  17. 'click #toolbtn_bulk_delete' : 'deleteSelectedDatasets'
  18. },
  19. defaults: {
  20. 'can_add_library_item' : false,
  21. 'contains_file' : false,
  22. 'chain_call_control' : {
  23. 'total_number' : 0,
  24. 'failed_number' : 0
  25. }
  26. },
  27. modal : null,
  28. // user's histories
  29. histories : null,
  30. initialize: function(options){
  31. this.options = _.defaults(options || {}, this.defaults);
  32. this.render();
  33. },
  34. render: function(options){
  35. this.options = _.extend(this.options, options);
  36. var is_admin = false;
  37. var is_anonym = true;
  38. if (Galaxy.currUser){
  39. is_admin = Galaxy.currUser.isAdmin();
  40. is_anonym = Galaxy.currUser.isAnonymous();
  41. }
  42. var toolbar_template = this.templateToolBar();
  43. this.$el.html(toolbar_template({id: this.options.id, admin_user: is_admin, anonym: is_anonym}));
  44. },
  45. configureElements: function(options){
  46. this.options = _.extend(this.options, options);
  47. if (this.options.can_add_library_item === true){
  48. $('.add-library-items').show();
  49. } else{
  50. $('.add-library-items').hide();
  51. }
  52. if (this.options.contains_file === true){
  53. if (Galaxy.currUser){
  54. if (!Galaxy.currUser.isAnonymous()){
  55. $('.logged-dataset-manipulation').show();
  56. $('.dataset-manipulation').show();
  57. } else {
  58. $('.dataset-manipulation').show();
  59. $('.logged-dataset-manipulation').hide();
  60. }
  61. } else {
  62. $('.logged-dataset-manipulation').hide();
  63. $('.dataset-manipulation').hide();
  64. }
  65. } else {
  66. $('.logged-dataset-manipulation').hide();
  67. $('.dataset-manipulation').hide();
  68. }
  69. this.$el.find('[data-toggle]').tooltip();
  70. },
  71. // shows modal for creating folder
  72. createFolderFromModal: function(){
  73. event.preventDefault();
  74. event.stopPropagation();
  75. // create modal
  76. var self = this;
  77. var template = this.templateNewFolderInModal();
  78. this.modal = Galaxy.modal;
  79. this.modal.show({
  80. closing_events : true,
  81. title : 'Create New Folder',
  82. body : template(),
  83. buttons : {
  84. 'Create' : function() {self.create_new_folder_event();},
  85. 'Close' : function() {Galaxy.modal.hide();}
  86. }
  87. });
  88. },
  89. // create the new folder from modal
  90. create_new_folder_event: function(){
  91. var folderDetails = this.serialize_new_folder();
  92. if (this.validate_new_folder(folderDetails)){
  93. var folder = new mod_library_model.FolderAsModel();
  94. url_items = Backbone.history.fragment.split('/');
  95. current_folder_id = url_items[url_items.length-1];
  96. folder.url = folder.urlRoot + '/' + current_folder_id ;
  97. folder.save(folderDetails, {
  98. success: function (folder) {
  99. Galaxy.modal.hide();
  100. mod_toastr.success('Folder created');
  101. folder.set({'type' : 'folder'});
  102. Galaxy.libraries.folderListView.collection.add(folder);
  103. },
  104. error: function(model, response){
  105. Galaxy.modal.hide();
  106. if (typeof response.responseJSON !== "undefined"){
  107. mod_toastr.error(response.responseJSON.err_msg);
  108. } else {
  109. mod_toastr.error('An error ocurred :(');
  110. }
  111. }
  112. });
  113. } else {
  114. mod_toastr.error('Folder\'s name is missing');
  115. }
  116. return false;
  117. },
  118. // serialize data from the modal
  119. serialize_new_folder : function(){
  120. return {
  121. name: $("input[name='Name']").val(),
  122. description: $("input[name='Description']").val()
  123. };
  124. },
  125. // validate new folder info
  126. validate_new_folder: function(folderDetails){
  127. return folderDetails.name !== '';
  128. },
  129. // show bulk import modal
  130. modalBulkImport : function(){
  131. var checkedValues = $('#folder_table').find(':checked');
  132. if(checkedValues.length === 0){
  133. mod_toastr.info('You have to select some datasets first');
  134. } else {
  135. this.refreshUserHistoriesList(function(self){
  136. var template = self.templateBulkImportInModal();
  137. self.modal = Galaxy.modal;
  138. self.modal.show({
  139. closing_events : true,
  140. title : 'Import into History',
  141. body : template({histories : self.histories.models}),
  142. buttons : {
  143. 'Import' : function() {self.importAllIntoHistory();},
  144. 'Close' : function() {Galaxy.modal.hide();}
  145. }
  146. });
  147. });
  148. }
  149. },
  150. refreshUserHistoriesList: function(callback){
  151. var self = this;
  152. this.histories = new mod_library_model.GalaxyHistories();
  153. this.histories.fetch({
  154. success: function (){
  155. callback(self);
  156. },
  157. error: function(model, response){
  158. if (typeof response.responseJSON !== "undefined"){
  159. mod_toastr.error(response.responseJSON.err_msg);
  160. } else {
  161. mod_toastr.error('An error ocurred :(');
  162. }
  163. }
  164. });
  165. },
  166. /**
  167. * import all selected datasets into history
  168. */
  169. importAllIntoHistory : function (){
  170. // disable the button to prevent multiple submission
  171. this.modal.disableButton('Import');
  172. // init the control counters
  173. this.options.chain_call_control.total_number = 0;
  174. this.options.chain_call_control.failed_number = 0;
  175. var history_id = $("select[name=dataset_import_bulk] option:selected").val();
  176. // we can save last used history to pre-select it next time
  177. this.options.last_used_history_id = history_id;
  178. var history_name = $("select[name=dataset_import_bulk] option:selected").text();
  179. var dataset_ids = [];
  180. $('#folder_table').find(':checked').each(function(){
  181. if (this.parentElement.parentElement.id !== '') {
  182. dataset_ids.push(this.parentElement.parentElement.id);
  183. }
  184. });
  185. var progress_bar_tmpl = this.templateImportIntoHistoryProgressBar();
  186. this.modal.$el.find('.modal-body').html(progress_bar_tmpl({ history_name : history_name }));
  187. // init the progress bar
  188. var progressStep = 100 / dataset_ids.length;
  189. this.initProgress(progressStep);
  190. // prepare the dataset objects to be imported
  191. var datasets_to_import = [];
  192. for (var i = dataset_ids.length - 1; i >= 0; i--) {
  193. var library_dataset_id = dataset_ids[i];
  194. var historyItem = new mod_library_model.HistoryItem();
  195. historyItem.url = historyItem.urlRoot + history_id + '/contents';
  196. historyItem.content = library_dataset_id;
  197. historyItem.source = 'library';
  198. datasets_to_import.push(historyItem);
  199. }
  200. this.options.chain_call_control.total_number = datasets_to_import.length;
  201. // set the used history as current so user will see the last one
  202. // that he imported into in the history panel on the 'analysis' page
  203. var set_current_url = '/api/histories/' + history_id + '/set_as_current';
  204. $.ajax({
  205. url: set_current_url,
  206. type: 'PUT'
  207. });
  208. // call the recursive function to call ajax one after each other (request FIFO queue)
  209. this.chainCall(datasets_to_import, history_name);
  210. },
  211. chainCall: function(history_item_set, history_name){
  212. var self = this;
  213. var popped_item = history_item_set.pop();
  214. if (typeof popped_item === "undefined") {
  215. if (this.options.chain_call_control.failed_number === 0){
  216. mod_toastr.success('Selected datasets imported into history. Click this to start analysing it.', '', {onclick: function() {window.location='/'}});
  217. } else if (this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number){
  218. mod_toastr.error('There was an error and no datasets were imported into history.');
  219. } else if (this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number){
  220. mod_toastr.warning('Some of the datasets could not be imported into history. Click this to see what was imported.', '', {onclick: function() {window.location='/'}});
  221. }
  222. Galaxy.modal.hide();
  223. return;
  224. }
  225. var promise = $.when(popped_item.save({content: popped_item.content, source: popped_item.source}));
  226. promise.done(function(){
  227. // we are fine
  228. self.updateProgress();
  229. self.chainCall(history_item_set, history_name);
  230. })
  231. .fail(function(){
  232. // we have a problem
  233. self.options.chain_call_control.failed_number += 1;
  234. self.updateProgress();
  235. self.chainCall(history_item_set, history_name);
  236. });
  237. },
  238. initProgress: function(progressStep){
  239. this.progress = 0;
  240. this.progressStep = progressStep;
  241. },
  242. updateProgress: function(){
  243. this.progress += this.progressStep;
  244. $('.progress-bar-import').width(Math.round(this.progress) + '%');
  245. txt_representation = Math.round(this.progress) + '% Complete';
  246. $('.completion_span').text(txt_representation);
  247. },
  248. // download selected datasets
  249. download : function(folder_id, format){
  250. var dataset_ids = [];
  251. $('#folder_table').find(':checked').each(function(){
  252. if (this.parentElement.parentElement.id !== '') {
  253. dataset_ids.push(this.parentElement.parentElement.id);
  254. }
  255. });
  256. var url = '/api/libraries/datasets/download/' + format;
  257. var data = {'ldda_ids' : dataset_ids};
  258. this.processDownload(url, data, 'get');
  259. },
  260. // create hidden form and submit through POST to initialize download
  261. processDownload: function(url, data, method){
  262. //url and data options required
  263. if( url && data ){
  264. //data can be string of parameters or array/object
  265. data = typeof data === 'string' ? data : $.param(data);
  266. //split params into form inputs
  267. var inputs = '';
  268. $.each(data.split('&'), function(){
  269. var pair = this.split('=');
  270. inputs+='<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />';
  271. });
  272. //send request
  273. $('<form action="'+ url +'" method="'+ (method||'post') +'">'+inputs+'</form>')
  274. .appendTo('body').submit().remove();
  275. mod_toastr.info('Your download will begin soon');
  276. }
  277. },
  278. addFilesToFolderModal: function(){
  279. this.refreshUserHistoriesList(function(self){
  280. self.modal = Galaxy.modal;
  281. var template_modal = self.templateAddFilesInModal();
  282. self.modal.show({
  283. closing_events : true,
  284. title : 'Add datasets from history to ' + self.options.folder_name,
  285. body : template_modal({histories: self.histories.models}),
  286. buttons : {
  287. 'Add' : function() {self.addAllDatasetsFromHistory();},
  288. 'Close' : function() {Galaxy.modal.hide();}
  289. }
  290. });
  291. // user should always have a history, even anonymous user
  292. if (self.histories.models.length > 0){
  293. self.fetchAndDisplayHistoryContents(self.histories.models[0].id);
  294. $( "#dataset_add_bulk" ).change(function(event) {
  295. self.fetchAndDisplayHistoryContents(event.target.value);
  296. });
  297. } else {
  298. mod_toastr.error('An error ocurred :(');
  299. }
  300. });
  301. },
  302. fetchAndDisplayHistoryContents: function(history_id){
  303. var history_contents = new mod_library_model.HistoryContents({id:history_id});
  304. var self = this;
  305. history_contents.fetch({
  306. success: function(history_contents){
  307. var history_contents_template = self.templateHistoryContents();
  308. self.histories.get(history_id).set({'contents' : history_contents});
  309. self.modal.$el.find('#selected_history_content').html(history_contents_template({history_contents: history_contents.models.reverse()}));
  310. },
  311. error: function(){
  312. mod_toastr.error('An error ocurred :(');
  313. }
  314. });
  315. },
  316. // add all selected datasets from history into current folder
  317. addAllDatasetsFromHistory : function (){
  318. // disable the button to prevent multiple submission
  319. this.modal.disableButton('Add');
  320. // init the control counters
  321. this.options.chain_call_control.total_number = 0;
  322. this.options.chain_call_control.failed_number = 0;
  323. var history_dataset_ids = [];
  324. this.modal.$el.find('#selected_history_content').find(':checked').each(function(){
  325. var hid = $(this.parentElement).data('id');
  326. if (hid) {
  327. history_dataset_ids.push(hid);
  328. }
  329. });
  330. var folder_name = this.options.folder_name;
  331. var progress_bar_tmpl = this.templateAddingDatasetsProgressBar();
  332. this.modal.$el.find('.modal-body').html(progress_bar_tmpl({ folder_name : folder_name }));
  333. // init the progress bar
  334. this.progressStep = 100 / history_dataset_ids.length;
  335. this.progress = 0;
  336. // prepare the dataset items to be added
  337. var hdas_to_add = [];
  338. for (var i = history_dataset_ids.length - 1; i >= 0; i--) {
  339. history_dataset_id = history_dataset_ids[i];
  340. var folder_item = new mod_library_model.Item();
  341. folder_item.url = '/api/folders/' + this.options.id + '/contents';
  342. folder_item.set({'from_hda_id':history_dataset_id});
  343. hdas_to_add.push(folder_item);
  344. }
  345. this.options.chain_call_control.total_number = hdas_to_add.length;
  346. // call the recursive function to call ajax one after each other (request FIFO queue)
  347. this.chainCallAddingHdas(hdas_to_add);
  348. },
  349. chainCallAddingHdas: function(hdas_set){
  350. var self = this;
  351. this.added_hdas = new mod_library_model.Folder();
  352. var popped_item = hdas_set.pop();
  353. if (typeof popped_item === "undefined") {
  354. if (this.options.chain_call_control.failed_number === 0){
  355. mod_toastr.success('Selected datasets from history added to the folder');
  356. } else if (this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number){
  357. mod_toastr.error('There was an error and no datasets were added to the folder.');
  358. } else if (this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number){
  359. mod_toastr.warning('Some of the datasets could not be added to the folder');
  360. }
  361. Galaxy.modal.hide();
  362. return this.added_hdas;
  363. }
  364. var promise = $.when(popped_item.save({from_hda_id: popped_item.get('from_hda_id')}));
  365. promise.done(function(model){
  366. // we are fine
  367. Galaxy.libraries.folderListView.collection.add(model);
  368. self.updateProgress();
  369. self.chainCallAddingHdas(hdas_set);
  370. })
  371. .fail(function(){
  372. // we have a problem
  373. self.options.chain_call_control.failed_number += 1;
  374. self.updateProgress();
  375. self.chainCallAddingHdas(hdas_set);
  376. });
  377. },
  378. /**
  379. * Handles the click on 'show deleted' checkbox
  380. */
  381. checkIncludeDeleted: function(event){
  382. if (event.target.checked){
  383. Galaxy.libraries.folderListView.fetchFolder({include_deleted: true});
  384. } else{
  385. Galaxy.libraries.folderListView.fetchFolder({include_deleted: false});
  386. }
  387. },
  388. /**
  389. * Deletes the selected datasets. Atomic. One by one.
  390. */
  391. deleteSelectedDatasets: function(){
  392. var checkedValues = $('#folder_table').find(':checked');
  393. if(checkedValues.length === 0){
  394. mod_toastr.info('You have to select some datasets first');
  395. } else {
  396. var template = this.templateDeletingDatasetsProgressBar();
  397. this.modal = Galaxy.modal;
  398. this.modal.show({
  399. closing_events : true,
  400. title : 'Deleting selected datasets',
  401. body : template({}),
  402. buttons : {
  403. 'Close' : function() {Galaxy.modal.hide();}
  404. }
  405. });
  406. // init the control counters
  407. this.options.chain_call_control.total_number = 0;
  408. this.options.chain_call_control.failed_number = 0;
  409. var dataset_ids = [];
  410. checkedValues.each(function(){
  411. if (this.parentElement.parentElement.id !== '') {
  412. dataset_ids.push(this.parentElement.parentElement.id);
  413. }
  414. });
  415. // init the progress bar
  416. this.progressStep = 100 / dataset_ids.length;
  417. this.progress = 0;
  418. // prepare the dataset items to be added
  419. var lddas_to_delete = [];
  420. for (var i = dataset_ids.length - 1; i >= 0; i--) {
  421. var dataset = new mod_library_model.Item({id:dataset_ids[i]});
  422. lddas_to_delete.push(dataset);
  423. }
  424. this.options.chain_call_control.total_number = dataset_ids.length;
  425. // call the recursive function to call ajax one after each other (request FIFO queue)
  426. this.chainCallDeletingHdas(lddas_to_delete);
  427. }
  428. },
  429. chainCallDeletingHdas: function(lddas_set){
  430. var self = this;
  431. this.deleted_lddas = new mod_library_model.Folder();
  432. var popped_item = lddas_set.pop();
  433. if (typeof popped_item === "undefined") {
  434. if (this.options.chain_call_control.failed_number === 0){
  435. mod_toastr.success('Selected datasets deleted');
  436. } else if (this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number){
  437. mod_toastr.error('There was an error and no datasets were deleted.');
  438. } else if (this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number){
  439. mod_toastr.warning('Some of the datasets could not be deleted');
  440. }
  441. Galaxy.modal.hide();
  442. return this.deleted_lddas;
  443. }
  444. var promise = $.when(popped_item.destroy());
  445. promise.done(function(dataset){
  446. // we are fine
  447. // self.$el.find('#' + popped_item.id).remove();
  448. Galaxy.libraries.folderListView.collection.remove(popped_item.id);
  449. self.updateProgress();
  450. // add the deleted dataset to collection, triggers rendering
  451. if (Galaxy.libraries.folderListView.options.include_deleted){
  452. var updated_dataset = new mod_library_model.Item(dataset);
  453. Galaxy.libraries.folderListView.collection.add(updated_dataset);
  454. }
  455. // execute next request
  456. self.chainCallDeletingHdas(lddas_set);
  457. })
  458. .fail(function(){
  459. // we have a problem
  460. self.options.chain_call_control.failed_number += 1;
  461. self.updateProgress();
  462. // execute next request
  463. self.chainCallDeletingHdas(lddas_set);
  464. });
  465. },
  466. templateToolBar: function(){
  467. tmpl_array = [];
  468. // CONTAINER
  469. tmpl_array.push('<div class="library_style_container">');
  470. // TOOLBAR
  471. tmpl_array.push('<div id="library_toolbar">');
  472. tmpl_array.push('<span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"><input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted</input></span>');
  473. tmpl_array.push('<div class="btn-group add-library-items" style="display:none;">');
  474. tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button" type="button"><span class="fa fa-plus"></span> <span class="fa fa-folder"></span></button>');
  475. tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button" type="button"><span class="fa fa-plus"></span> <span class="fa fa-file"></span></span></button>');
  476. tmpl_array.push('</div>');
  477. tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');
  478. tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');
  479. tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');
  480. tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');
  481. tmpl_array.push(' </button>');
  482. tmpl_array.push(' <ul class="dropdown-menu" role="menu">');
  483. tmpl_array.push(' <li id="download_archive"><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');
  484. tmpl_array.push(' <li id="download_archive"><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');
  485. tmpl_array.push(' <li id="download_archive"><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');
  486. tmpl_array.push(' </ul>');
  487. tmpl_array.push(' </div>');
  488. tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');
  489. tmpl_array.push(' </div>');
  490. tmpl_array.push(' <div id="folder_items_element">');
  491. // library items will append here
  492. tmpl_array.push(' </div>');
  493. tmpl_array.push('</div>');
  494. return _.template(tmpl_array.join(''));
  495. },
  496. templateNewFolderInModal: function(){
  497. tmpl_array = [];
  498. tmpl_array.push('<div id="new_folder_modal">');
  499. tmpl_array.push('<form>');
  500. tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');
  501. tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');
  502. tmpl_array.push('</form>');
  503. tmpl_array.push('</div>');
  504. return _.template(tmpl_array.join(''));
  505. },
  506. templateBulkImportInModal : function(){
  507. var tmpl_array = [];
  508. tmpl_array.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');
  509. tmpl_array.push('Select history: ');
  510. tmpl_array.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');
  511. tmpl_array.push(' <% _.each(histories, function(history) { %>'); //history select box
  512. tmpl_array.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');
  513. tmpl_array.push(' <% }); %>');
  514. tmpl_array.push('</select>');
  515. tmpl_array.push('</span>');
  516. return _.template(tmpl_array.join(''));
  517. },
  518. templateImportIntoHistoryProgressBar : function (){
  519. var tmpl_array = [];
  520. tmpl_array.push('<div class="import_text">');
  521. tmpl_array.push('Importing selected datasets to history <b><%= _.escape(history_name) %></b>');
  522. tmpl_array.push('</div>');
  523. tmpl_array.push('<div class="progress">');
  524. tmpl_array.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');
  525. tmpl_array.push(' <span class="completion_span">0% Complete</span>');
  526. tmpl_array.push(' </div>');
  527. tmpl_array.push('</div>');
  528. tmpl_array.push('');
  529. return _.template(tmpl_array.join(''));
  530. },
  531. templateAddingDatasetsProgressBar : function (){
  532. var tmpl_array = [];
  533. tmpl_array.push('<div class="import_text">');
  534. tmpl_array.push('Adding selected datasets from history to library folder <b><%= _.escape(folder_name) %></b>');
  535. tmpl_array.push('</div>');
  536. tmpl_array.push('<div class="progress">');
  537. tmpl_array.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');
  538. tmpl_array.push(' <span class="completion_span">0% Complete</span>');
  539. tmpl_array.push(' </div>');
  540. tmpl_array.push('</div>');
  541. tmpl_array.push('');
  542. return _.template(tmpl_array.join(''));
  543. },
  544. templateDeletingDatasetsProgressBar : function (){
  545. var tmpl_array = [];
  546. tmpl_array.push('<div class="import_text">');
  547. tmpl_array.push('</div>');
  548. tmpl_array.push('<div class="progress">');
  549. tmpl_array.push(' <div class="progress-bar progress-bar-delete" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');
  550. tmpl_array.push(' <span class="completion_span">0% Complete</span>');
  551. tmpl_array.push(' </div>');
  552. tmpl_array.push('</div>');
  553. tmpl_array.push('');
  554. return _.template(tmpl_array.join(''));
  555. },
  556. templateAddFilesInModal : function (){
  557. var tmpl_array = [];
  558. tmpl_array.push('<div id="add_files_modal">');
  559. tmpl_array.push('<div id="history_modal_combo_bulk">');
  560. tmpl_array.push('Select history: ');
  561. tmpl_array.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');
  562. tmpl_array.push(' <% _.each(histories, function(history) { %>'); //history select box
  563. tmpl_array.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');
  564. tmpl_array.push(' <% }); %>');
  565. tmpl_array.push('</select>');
  566. tmpl_array.push('</div>');
  567. tmpl_array.push('<div id="selected_history_content">');
  568. tmpl_array.push('</div>');
  569. tmpl_array.push('</div>');
  570. return _.template(tmpl_array.join(''));
  571. },
  572. templateHistoryContents : function (){
  573. var tmpl_array = [];
  574. tmpl_array.push('Choose the datasets to import:');
  575. tmpl_array.push('<ul>');
  576. tmpl_array.push(' <% _.each(history_contents, function(history_item) { %>');
  577. tmpl_array.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');
  578. tmpl_array.push(' <input style="margin: 0;" type="checkbox"> <%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');
  579. tmpl_array.push(' </li>');
  580. tmpl_array.push(' <% }); %>');
  581. tmpl_array.push('</ul>');
  582. return _.template(tmpl_array.join(''));
  583. }
  584. });
  585. return {
  586. FolderToolbarView: FolderToolbarView
  587. };
  588. });