From 3766d9b9e5ccca452279b6822f8057952a34656d Mon Sep 17 00:00:00 2001 From: sukhbir-singh Date: Wed, 10 Jul 2019 01:43:53 +0530 Subject: [PATCH 1/4] fix confirmation page crash, removed routes for non-existing methods --- app/controllers/disk_service_controller.rb | 5 +++-- app/views/disk_wizard/progress.html.slim | 10 +++++++--- config/routes.rb | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controllers/disk_service_controller.rb b/app/controllers/disk_service_controller.rb index e61a06e..9071f42 100644 --- a/app/controllers/disk_service_controller.rb +++ b/app/controllers/disk_service_controller.rb @@ -51,8 +51,9 @@ def operations_progress # Expected key:values in @params: # :debug => Integer value(1) if debug mode has selected in fourth step(confirmation), else nil def progress - debug_mode = params[:debug] - self.user_selections = {debug: debug_mode} + @debug_mode = params[:debug] + #self.user_selections = {debug: debug_mode} + render 'disk_wizard/progress' end end diff --git a/app/views/disk_wizard/progress.html.slim b/app/views/disk_wizard/progress.html.slim index 891e449..f42d351 100644 --- a/app/views/disk_wizard/progress.html.slim +++ b/app/views/disk_wizard/progress.html.slim @@ -1,12 +1,15 @@ - javascript_include_tag "progress" +- user_selections = {debug: @debug_mode} javascript: $(document).ready(function () { start_processing(); - setInterval(ajaxd, 2000); + setInterval(ajaxd, 2000); }); function ajaxd() { + console.log("ajaxd called"); + $.ajax({ type: "GET", dataType: "json", @@ -26,6 +29,7 @@ javascript: } function start_processing() { + console.log("start processing called"); $.ajax({ type: "POST", dataType: "json", @@ -37,13 +41,13 @@ javascript: - "***************#{user_selections}" .row .col-md-5.col-md-offset-3.well - - image_tag("disk_wizard/loading_2.GIF") + / - image_tag("disk_wizard/loading_2.GIF") .progress.progress-striped.active .progress-bar.progress-bar-success aria-valuemax="100" aria-valuemin="0" aria-valuenow="100" role="progressbar" style=("width: 100%") span.sr-only | 100% p.text-primary - = image_tag "disk_wizard/progress.gif" + / = image_tag "disk_wizard/progress.gif" /* 'disk_wizard#manage_disk',via: [:get,:post] match 'confirmation' => 'disk_wizard#confirmation',via: [:get,:post] get 'complete' => 'disk_wizard#done' - get 'get_progress' => 'disk_wizard#operations_progress' + # get 'get_progress' => 'disk_wizard#operations_progress' get 'error' => 'disk_wizard#error' - get 'debug_info' => 'disk_wizard#debug_info' - post 'process' => 'disk_wizard#progress' + # get 'debug_info' => 'disk_wizard#debug_info' + # post 'process' => 'disk_wizard#progress' post 'ajax_process' => 'disk_wizard#process_disk' From 8cd15766c72f9fb105f6359b2c96dbb7a1ec0438 Mon Sep 17 00:00:00 2001 From: sukhbir-singh Date: Thu, 25 Jul 2019 02:09:41 +0530 Subject: [PATCH 2/4] ui improvements --- app/assets/stylesheets/disk_wizards.css | 48 ++++++---- app/views/disk_wizard/confirmation.html.slim | 93 ++++++++++---------- app/views/disk_wizard/manage_disk.html.slim | 10 +-- app/views/disk_wizard/select_fs.html.slim | 14 +-- 4 files changed, 88 insertions(+), 77 deletions(-) diff --git a/app/assets/stylesheets/disk_wizards.css b/app/assets/stylesheets/disk_wizards.css index 8711161..164a806 100755 --- a/app/assets/stylesheets/disk_wizards.css +++ b/app/assets/stylesheets/disk_wizards.css @@ -1,15 +1,15 @@ .panel.panel-default{ - overflow: hidden; - background: white; + overflow: hidden; + background: white; } @media(max-width: 768px){ - #loading_animation{ - margin-left: 10px; - margin-right: 10px; - } + #loading_animation{ + margin-left: 10px; + margin-right: 10px; + } } #loading_animation{ - margin-top: 20px; + margin-top: 20px; } #progress_message{ margin-top: 10px; @@ -17,7 +17,7 @@ display: inline-block; } .well{ - width: 75%; + width: 75%; } .panel .nav li.nav-item a.nav-link{ color: #565656; @@ -31,23 +31,23 @@ padding-bottom: 10px; } .panel .nav li.nav-item.active a.nav-link{ - color: white; + color: white; } .panel .nav li.nav-item.active{ - background: #63b6ea; - color: white; + background: #63b6ea; + color: white; } #devices_data form{ - width: 100%; - margin-left: 30px; - margin-right: 30px; + width: 100%; + margin-left: 30px; + margin-right: 30px; } #next_button{ - margin-right: 15px; + margin-right: 15px; } #refresh_devices_button{ - margin-left: 15px; - padding: 8px; + margin-left: 15px; + padding: 8px; } .panel-title{ font-size: 1.4rem; @@ -58,3 +58,17 @@ margin-right: 15px; margin-left: 15px; } +.back-button-wizard{ + display: inline-block; + margin-left: 32px; + margin-bottom: 12px; + background: lightgrey; + color: black; +} +.right-button-wizard{ + height: fit-content; + margin-left: 10px; +} +#fs_selector{ + margin: 0 auto; +} \ No newline at end of file diff --git a/app/views/disk_wizard/confirmation.html.slim b/app/views/disk_wizard/confirmation.html.slim index 052b326..1aa5e47 100644 --- a/app/views/disk_wizard/confirmation.html.slim +++ b/app/views/disk_wizard/confirmation.html.slim @@ -6,57 +6,54 @@ javascript: .panel-body = form_tag(defined?(disk_wizards_engine) ? disk_wizards_engine.process_path : process_path, {method: "POST", id: "confirmation"}) = hidden_field_tag 'device', user_selections['path'] - .row + .row.mt-2.mb-2 - "*****************#{user_selections} \n ******** #{@selected_disk}>" - .row - .col-md-4 - = pie_chart({"Size: #{number_to_human_size @selected_disk.size}" => (@selected_disk.size)}, \ - library: {legend: {position: 'bottom'}, \ - is3D: true, \ - pieSliceText: 'percentage', \ - tooltip: {text: 'percentage'}, \ - chartArea: {width: '100%', height: '78%'}, \ - slices: [{color: '#A44585'}, {color: '#00B5F0'}] \ - }) - .col-md-6.col-md-offset-1 - br/ - br/ - ul.list-group - li.list-group-item.list-group-item-info.text-center - = @selected_disk.kind_of?(Device) ? @selected_disk.model : @selected_disk.device.model - - if user_selections['format'] + .col-md-4 style="margin: 0 auto;" + = pie_chart({"Size: #{number_to_human_size @selected_disk.size}" => (@selected_disk.size)}, \ + library: {legend: {position: 'bottom'}, \ + is3D: true, \ + pieSliceText: 'percentage', \ + tooltip: {text: 'percentage'}, \ + chartArea: {width: '100%', height: '78%'}, \ + slices: [{color: '#A44585'}, {color: '#00B5F0'}] \ + }) + .col-md-6.col-md-offset-1 style="margin: 0 auto;padding-top: 26px;" + ul.list-group + li.list-group-item.list-group-item-info.text-center + = @selected_disk.kind_of?(Device) ? @selected_disk.model : @selected_disk.device.model + - if user_selections['format'] + li.list-group-item.text-left + span.badge.alert-danger style="font-size:100%;margin-right:5px;" + span.glyphicon.glyphicon-ok + | Format + li.list-group-item.text-left + span.badge.alert-info style="font-size:100%;margin-right:5px;" = Partition.FilesystemType.key(user_selections['fs_type'].to_i) + | New filesystem Type + - user_selections['option'].try(:each) do |option| + - if option == '1' li.list-group-item.text-left - span.badge.alert-danger - span.glyphicon.glyphicon-ok - | Format + span.badge.alert-info style="font-size:100%;margin-right:5px;" + | \/var/hda/files/drives/#{user_selections['label'] || @selected_disk.kname} + | Mount + | Location + - else li.list-group-item.text-left - span.badge.alert-info = Partition.FilesystemType.key(user_selections['fs_type'].to_i) - | New filesystem Type - - user_selections['option'].try(:each) do |option| - - if option == '1' - li.list-group-item.text-left - span.badge.alert-info - | \/var/hda/files/drives/#{user_selections['label'] || @selected_disk.kname} - | Mount - | Location - - else - li.list-group-item.text-left - span.badge.alert-warning [Experimental] - | Add it to shared stroage pool - li.list-group-item.text-left - span.badge.alert-info - = @selected_disk.path - | System name - li.list-group-item.text-right - a.btn.btn-default style=("float: left") href="#{defined?(disk_wizards_engine) ? disk_wizards_engine.manage_path : manage_path}" - span.glyphicon.glyphicon-arrow-left - | Back + span.badge.alert-warning style="font-size:100%;margin-right:5px;" [Experimental] + | Add it to shared stroage pool + li.list-group-item.text-left + span.badge.alert-info style="font-size:100%;margin-right:5px;" + = @selected_disk.path + |  System name + li.list-group-item.text-right + a.btn.btn-default style=("float: left;background: lightgrey;color: black;") href="#{defined?(disk_wizards_engine) ? disk_wizards_engine.manage_path : manage_path}" + span.glyphicon.glyphicon-arrow-left + | ← Back - label#debug.text-warning data-placement="left" data-toggle="tooltip" style=("cursor: pointer") title=("No executions takeplace,only list the commands which get executed.") - = check_box_tag(:debug, 1, false, class: 'format') + label#debug.text-warning data-placement="left" data-toggle="tooltip" style=("cursor: pointer;position: relative;top: 5px;") title=("No executions takeplace,only list the commands which get executed.") + = check_box_tag(:debug, 1, false, class: 'format') + span style="position: relative;top: -3px;margin-right: 15px;margin-left: 2px;" | Debug - = button_tag(type: "submit", class: "btn btn-success") do - | Apply - span.glyphicon.glyphicon-ok - \ No newline at end of file + = button_tag(type: "submit", class: "btn btn-success") do + | Apply + span.glyphicon.glyphicon-ok diff --git a/app/views/disk_wizard/manage_disk.html.slim b/app/views/disk_wizard/manage_disk.html.slim index 41c3b02..32960d5 100644 --- a/app/views/disk_wizard/manage_disk.html.slim +++ b/app/views/disk_wizard/manage_disk.html.slim @@ -18,10 +18,10 @@ javascript: = hidden_field_tag 'device', user_selections['path'] .row - "*#{user_selections}" - .col-md-5.col-md-offset-3.well + div style="margin: 10px auto;" ul.list-group li.list-group-item.list-group-item-success - h5 + h6 | What would you like to do? li.list-group-item .checkbox @@ -33,9 +33,9 @@ javascript: span.input-group-addon | Enter a label input#label.form-control name="label" placeholder="Label" style=("margin: auto;") type="text" value=("#{user_selections['label'] || nil}") / - .row.text-left - = link_to(disk_wizards_engine.file_system_path , class: "btn btn-default") do + .row.mt-2 + = link_to(disk_wizards_engine.file_system_path , class: "btn btn-default back-button-wizard") do | ← Back - = link_to '#', :onclick => "$('#options').submit()", style: "float: right;", class: "btn btn-success" do + = link_to '#', :onclick => "$('#options').submit()", style: "float: right;", class: "btn btn-success right-button-wizard" do | Next → \ No newline at end of file diff --git a/app/views/disk_wizard/select_fs.html.slim b/app/views/disk_wizard/select_fs.html.slim index 97118d8..381096d 100644 --- a/app/views/disk_wizard/select_fs.html.slim +++ b/app/views/disk_wizard/select_fs.html.slim @@ -136,7 +136,7 @@ javascript: = hidden_field_tag 'model', @selected_disk.model = hidden_field_tag 'partition', nil - .row.col-md-10.col-md-offset-1 + .row.mt-2.mb-2 #contextMenu ul.dropdown-menu role="menu" li @@ -183,7 +183,7 @@ javascript: border-radius: 5px; } - table.settings.table-bordered.table.table-hover + table.settings.table-bordered.table style="border: 0px;" thead tr - device = @selected_disk @@ -218,7 +218,7 @@ javascript: label = check_box_tag(:format, 1, !!(user_selections['format'] && (user_selections['path'] == partition.path) rescue false), class: 'format') - tr style=("position: relative;cursor: pointer;") path="#{device.path}" class="#{ !!(user_selections['format'] && (user_selections['partition'] == device.path) rescue false) ? 'danger' : 'warning' }" + tr style=("position: relative; cursor: pointer; margin: 0;") path="#{device.path}" class="#{ !!(user_selections['format'] && (user_selections['partition'] == device.path) rescue false) ? 'danger' : 'warning' }" td colspan="4" | Format entire disk td style=("width: 1%;") @@ -227,15 +227,15 @@ javascript: .row #fs_selector.col-md-5.col-md-offset-4 style=("display: none;") - .well + div ul.list-group li.list-group-item.list-group-item-success | Please select a file system type = select_tag :fs_type, options_for_select([["Ext4", 0], ["Ext3", 1], ["NTFS", 2], ["FAT32", 3]], 0), class: "form-control" - .row.text-left - = link_to(defined?(disk_wizards_engine) ? disk_wizards_engine.select_path : select_path, class: "btn btn-default") do + .row.mt-2 + = link_to(defined?(disk_wizards_engine) ? disk_wizards_engine.select_path : select_path, class: "btn btn-default back-button-wizard") do | ← Back - = link_to '#', :onclick => "$('#select_fs').submit()", style: "float: right;", class: "btn btn-success" do + = link_to '#', :onclick => "$('#select_fs').submit()", style: "float: right;", class: "btn btn-success right-button-wizard" do span#proceed Skip | → From a2da8d43befe760c73125b2ddf81355ad61e2da4 Mon Sep 17 00:00:00 2001 From: sukhbir-singh Date: Sun, 4 Aug 2019 04:15:58 +0530 Subject: [PATCH 3/4] fixed confirmation and done page crash --- app/controllers/disk_wizard_controller.rb | 5 +++++ app/views/disk_wizard/manage_disk.html.slim | 10 ++++----- app/views/disk_wizard/progress.html.slim | 24 +++++++-------------- config/routes.rb | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/app/controllers/disk_wizard_controller.rb b/app/controllers/disk_wizard_controller.rb index 2b99a12..edebc9e 100644 --- a/app/controllers/disk_wizard_controller.rb +++ b/app/controllers/disk_wizard_controller.rb @@ -148,4 +148,9 @@ def clear_mode CommandExecutor.debug_mode = nil end + def progress + debug_mode = params[:debug] + self.user_selections = {debug: debug_mode} + end + end diff --git a/app/views/disk_wizard/manage_disk.html.slim b/app/views/disk_wizard/manage_disk.html.slim index 32960d5..4b4898c 100644 --- a/app/views/disk_wizard/manage_disk.html.slim +++ b/app/views/disk_wizard/manage_disk.html.slim @@ -23,14 +23,14 @@ javascript: li.list-group-item.list-group-item-success h6 | What would you like to do? - li.list-group-item + li.list-group-item style="min-width: 320px;" .checkbox - = check_box_tag('option[]', 1, !!((user_selections['option'].include? '1') rescue false), class: 'mount_check') .alert.alert-info - label for="option_" + = check_box_tag('option[]', 1, !!((user_selections['option'].include? '1') rescue false), class: 'mount_check') + label for="option_" style="position: relative;top: -3px;" | Mount this drive automatically. - #label_input.input-group.input-group-sm style=("#{!!((user_selections['option'].include? '1') rescue false) ? nil : 'display: none'}") - span.input-group-addon + #label_input.input-group.input-group-sm.mt-2 style=("#{!!((user_selections['option'].include? '1') rescue false) ? nil : 'display: none'}") + span.input-group-addon.mr-2 style="position: relative;top: 3px;" | Enter a label input#label.form-control name="label" placeholder="Label" style=("margin: auto;") type="text" value=("#{user_selections['label'] || nil}") / .row.mt-2 diff --git a/app/views/disk_wizard/progress.html.slim b/app/views/disk_wizard/progress.html.slim index f42d351..5294897 100644 --- a/app/views/disk_wizard/progress.html.slim +++ b/app/views/disk_wizard/progress.html.slim @@ -1,10 +1,9 @@ - javascript_include_tag "progress" -- user_selections = {debug: @debug_mode} javascript: $(document).ready(function () { - start_processing(); - setInterval(ajaxd, 2000); + // start_processing(); + // setInterval(ajaxd, 2000); }); function ajaxd() { @@ -38,16 +37,9 @@ javascript: } .panel-body - - "***************#{user_selections}" - .row - .col-md-5.col-md-offset-3.well - / - image_tag("disk_wizard/loading_2.GIF") - .progress.progress-striped.active - .progress-bar.progress-bar-success aria-valuemax="100" aria-valuemin="0" aria-valuenow="100" role="progressbar" style=("width: 100%") - span.sr-only - | 100% - p.text-primary - / = image_tag "disk_wizard/progress.gif" - /* 'disk_service#get_all_devices' get "check_label" => 'disk_service#check_label' get 'debug_info' => 'disk_service#debug_info' - post 'process' => 'disk_service#progress' + post 'process' => 'disk_wizard#progress' get 'get_progress' => 'disk_service#operations_progress' match 'select' => 'disk_wizard#select_device',via: [:get,:post] From e859a049db553992db59ccd5e74d554358cdf730 Mon Sep 17 00:00:00 2001 From: sukhbir-singh Date: Sun, 4 Aug 2019 14:45:58 +0530 Subject: [PATCH 4/4] fixed error and done page --- app/views/disk_wizard/done.html.slim | 18 +++++----- app/views/disk_wizard/error.html.slim | 46 ++++++++++++++---------- app/views/disk_wizard/progress.html.slim | 25 ++++++++----- 3 files changed, 53 insertions(+), 36 deletions(-) diff --git a/app/views/disk_wizard/done.html.slim b/app/views/disk_wizard/done.html.slim index 37630cc..3a1dbad 100644 --- a/app/views/disk_wizard/done.html.slim +++ b/app/views/disk_wizard/done.html.slim @@ -32,15 +32,14 @@ css: font-size: large; } -.row - br/ +.row.p-2.d-inline-block - if user_selections['debug'] - .col-md-10.col-md-offset-1 + div .panel.panel-warning - .panel-heading + .h4.mt-3 | Debug Information span.glyphicon.glyphicon-info-sign - .panel-body.text-left + .panel-body.text-left style="font-size: 14px;" p.text-muted | Note: p.text-muted @@ -49,15 +48,16 @@ css: | 2. Pipeline character(|) has encoded as exclamation character(!). p.text-muted | 3. Order(#) of the commands does matter if you try to execute them manually. + table.table.table-bordered.table-hover thead tr.active th.text-center.text-primary style=("width: 5%;") - | # + | # th.text-center.text-primary style=("width: 20%;") - | Command name + | Command name th.text-center.text-primary - | Parameters + | Parameters tbody - count = 0 @@ -108,7 +108,7 @@ css: | Get Debug infomation #fpaste_loading.col-md-8.col-md-offset-2 - = image_tag "disk_wizard/progress.gif" + / = image_tag "disk_wizard/progress.gif" p.text-primary span.glyphicon.glyphicon-time | Please wait.Generating fpaste URL....... diff --git a/app/views/disk_wizard/error.html.slim b/app/views/disk_wizard/error.html.slim index afc4cbb..df9808f 100644 --- a/app/views/disk_wizard/error.html.slim +++ b/app/views/disk_wizard/error.html.slim @@ -9,6 +9,7 @@ javascript: $('#debug_info').slideDown(); }); } + $(function () { $('#fpaste_url').tooltip(); var $loading = $('#fpaste_loading').hide(); @@ -19,6 +20,10 @@ javascript: }); }); + function sendReport(){ + // + } + css: /* Fix for conflicts with platform CSS */ @@ -55,44 +60,49 @@ css: bottom: 0px; } -.alert.alert-danger.fade.in - button.close aria-hidden="true" data-dismiss="alert" type="button" - | × - h4 Oh snap! You got an error! - .well - p.text-primary.text-center - = @exception - | \. + #fpaste_loading{ + display: inline-block; + margin: 0 auto; + margin-top: 20px; + font-size: 13px; + } - .row.text-center +div style="background: #f5cece;padding: 15px;" + h4 style="color: #f56b6b;" Oh snap! You got an error! + p style="font-size: 13px;" + = @exception + | \. + + .row.text-center.d-inline-block button#get_debug_info.btn.btn-warning onclick="getDebugURL();" | Get Debug infomation - button#send_crash_report.btn.btn-default onclick="sendReport();" + button#send_crash_report.btn.btn-default.ml-4.mr-4 onclick="sendReport();" span.glyphicon.glyphicon-send | Send Report to Amahi - a.btn.btn-default href="/tab/disks/disk_wizards" type="button" + a.btn.btn-default href="/tab/disks/disk_wizard" type="button" | Or try again .row #fpaste_loading.col-md-8.col-md-offset-2 - = image_tag "disk_wizard/progress.gif" + / = image_tag "disk_wizard/progress.gif" p.text-primary span.glyphicon.glyphicon-time | Please wait.Generating fpaste URL....... - #debug_info.col-md-10.col-md-offset-1 style=("display: none;") - .panel.panel-default + + #debug_info.col-md-10.col-md-offset-1.mx-auto style=("display: none;") + .panel.panel-default.p-2.mt-3 form.form-inline.text-center role="form" - .form-group.has-success.has-feedback + .form-group.has-success.has-feedback.pl-2 label.control-label for="fpaste_url" | URL: span.glyphicon.glyphicon-globe - input#fpaste_url.form-control autocomplete="off" data-placement="top" data-toggle="tooltip" onclick="$(this).select();" placeholder=("Generating URL..") style=("width: 500px;") title=("Press Ctrl+c to coppy URL to clipboard") type="text" / + input#fpaste_url.form-control autocomplete="off" data-placement="top" data-toggle="tooltip" onclick="$(this).select();" placeholder=("Generating URL..") style=("width: 500px;font-size:14px;") title=("Press Ctrl+C to copy URL to clipboard") type="text" / span.glyphicon.glyphicon-ok.form-control-feedback .panel-body.text-left - p.text-primary + p.text-primary.mt-2 | After generating your paste, copy the generated url above. p.text-primary | Head over to the Amahi IRC channel, and share your link with one of the helpful folks there. - p.text-info + span.text-info | Good Luck! Thanks for choosing Amahi. \ No newline at end of file diff --git a/app/views/disk_wizard/progress.html.slim b/app/views/disk_wizard/progress.html.slim index 5294897..e45daf7 100644 --- a/app/views/disk_wizard/progress.html.slim +++ b/app/views/disk_wizard/progress.html.slim @@ -2,8 +2,8 @@ javascript: $(document).ready(function () { - // start_processing(); - // setInterval(ajaxd, 2000); + start_processing(); + setInterval(ajaxd, 2000); }); function ajaxd() { @@ -13,16 +13,23 @@ javascript: type: "GET", dataType: "json", url: "get_progress", - // data : "user=success", + data : "user=success", success: function (progress) { - // alert(progress.message + progress.percentage); + console.log("progress is "); + console.log(progress); + $("#progress_message").html(progress.message); - if (progress.percentage < 0) { - window.location.href = "error"; + + if(progress.percentage < 0 || progress.percentage > 100){ + window.location.href = "error"; } - if (progress.percentage == 100) - window.location.href = "complete"; + if(progress.percentage == 100){ + window.location.href = "complete"; + }else if(progress.percentage >= 0){ + $("#disk-wizard-progress")[0].style.width = progress.percentage + "%"; + $("#disk-wizard-progress")[0].innerHTML = progress.percentage + "%"; + } } }); } @@ -39,7 +46,7 @@ javascript: .panel-body .row.mt-4.mb-2 style="display: inline-block;" .progress.active style="width: 500px; display: inline-block;" - .progress-bar.progress-bar-striped.bg-info.progress-bar-animated aria-valuemax="100" aria-valuemin="0" aria-valuenow="100" role="progressbar" style=("width: 100%") + #disk-wizard-progress.progress-bar.progress-bar-striped.bg-info.progress-bar-animated aria-valuemax="100" aria-valuemin="0" aria-valuenow="100" role="progressbar" style=("width: 0%") | 0% p.text-primary span#progress_message Please wait...