[Rt-commit] rt branch, siemens-gui-first-login, created. rt-5.0.1-425-g655f88b813

Steve Burr steve at bestpractical.com
Tue Jun 1 13:40:08 EDT 2021


The branch, siemens-gui-first-login has been created
        at  655f88b813e34d4d951bf7037f146817aabdb9c2 (commit)

- Log -----------------------------------------------------------------
commit 655f88b813e34d4d951bf7037f146817aabdb9c2
Author: Steven Burr <steve at bestpractical.com>
Date:   Tue Jun 1 13:39:55 2021 -0400

    WIP

diff --git a/share/html/Helpers/InitialPrefs b/share/html/Helpers/InitialPrefs
new file mode 100644
index 0000000000..7d0df2d739
--- /dev/null
+++ b/share/html/Helpers/InitialPrefs
@@ -0,0 +1,118 @@
+<%args>
+$Update => 0,
+$PreferredKey => undef,
+</%args>
+<%init>
+my @results = ();
+my $UserObj = $session{'CurrentUser'}->UserObj;
+my $preferences = $UserObj->Preferences( $RT::System );
+
+my $default_dashboard_id = 8;
+#my $default_dashboard_id = $UserObj->Preferences( DefaultDashboard => 0 );
+#warn "XXX default_dashboard_id: $default_dashboard_id";
+#use Data::Printer;
+#p($UserObj->Preferences);
+
+if (defined($PreferredKey) and (not $UserObj->FirstAttribute('PreferredKey')
+        or $PreferredKey ne $UserObj->FirstAttribute('PreferredKey')->Content)) {
+    my ($code, $msg) = $UserObj->SetAttribute(Name => 'PreferredKey', Content => $PreferredKey);
+    push @results, loc('Preferred Key: [_1]', $msg) unless $code;
+}
+
+if ( $Update ) {
+    $preferences ||= {};
+    $m->comp( '/Widgets/BulkProcess',
+        Meta => { map { $_ => RT->Config->Meta($_) } RT->Config->Options },
+        Store => $preferences,
+        Types => [RT->Config->Options],
+        Default => 1,
+        Arguments => \%ARGS,
+        DefaultValue => { map { $_ => RT->Config->Get($_) } RT->Config->Options },
+    );
+
+    my ($ok, $msg) = $UserObj->SetPreferences( $RT::System, $preferences );
+    push @results, $ok ? loc("Mail preferences saved.") : $msg;
+
+    if ( $ARGS{DefaultDashboard} ) {
+        ( $ok, $msg ) = $UserObj->SetAttribute( Name => 'Pref-DefaultDashboard', Description => 'Default Dashboard', Content => $ARGS{DefaultDashboard} );
+        push @results, $ok ? loc('Homepage preferences saved.') : $msg;
+        #MaybeRedirectForResults( Actions => \@results, Path => "/Admin/Global/MyRT.html" );
+    }
+
+    $m->print( join '\n', @results);
+    $m->abort();
+}
+</%init>
+<script>
+jQuery(document).ready(function() {
+    jQuery('#saveInitialPrefs').click(function(e) {
+        e.preventDefault()
+        jQuery.post( RT.Config.WebHomePath + '/Helpers/InitialPrefs', jQuery('form#initialPrefsForm').serialize(), function(data, status) {
+            if (status == "success") {
+                console.log('Preferences saved. Loading video...')
+                jQuery.get(RT.Config.WebHomePath + "/Helpers/VideoOverlay", function(data) { showModal(data, true) })
+            } else {
+                console.error("Error saving initial preferences", status)
+            }
+        } )
+    })
+})
+</script>
+<div class="modal-dialog modal-dialog-centered" role="document">
+  <div class="modal-content">
+    <div class="modal-header">
+      <h5 class="modal-title"><&|/l&>Welcome to Vurious</&></h5>
+      <!--
+      <a href="javascript:void(0)" class="close" data-dismiss="modal" aria-label="Close">
+        <span aria-hidden="true">×</span>
+      </a>
+      -->
+    </div>
+    <div class="modal-body">
+        <p>Since this appears to be your first time accessing Vurious, please take a moment to help us better customize the experience for you.</p>
+        <form method="post" action="/Helpers/InitialPrefs" name="initialPrefsForm" id="initialPrefsForm">
+            <input type="text" hidden="hidden" name="Update" value="1" />
+            <&|/Widgets/TitleBox, title => loc( 'Preferences' ) &>
+% my $option = 'EmailFrequency';  # 'DashboardEmailLanguage'
+% my $meta = RT->Config->Meta( $option );
+                <& $meta->{'Widget'},
+                    Default      => 1,
+                    %{ $m->comp('/Widgets/FinalizeWidgetArguments', WidgetArguments => $meta->{'WidgetArguments'} ) },
+                    Name         => $option,
+                    DefaultValue => scalar RT->Config->Get( $option ),
+                    CurrentValue => $preferences->{ $option },
+                &>
+% $option = 'NotifyActor';  # 'SavedSearchHomePage'
+% $meta = RT->Config->Meta( $option );
+                <& $meta->{'Widget'},
+                    Default      => 1,
+                    %{ $m->comp('/Widgets/FinalizeWidgetArguments', WidgetArguments => $meta->{'WidgetArguments'} ) },
+                    Name         => $option,
+                    DefaultValue => scalar RT->Config->Get( $option ),
+                    CurrentValue => $preferences->{ $option },
+                &>
+                <div class="widget form-row">
+                    <div class="label col-3">Homepage</div>
+                    <div class="value col-9">
+                        <& /Elements/SelectDashboard, Dashboards => [ GetDashboards() ], Default => $default_dashboard_id, ShowEmpty => 0 &>
+                    </div>
+                </div>
+            </&>
+
+            <div class="form-row">
+                <div class="col-12">
+%#                    <& /Elements/Submit, Name => 'Update', Label => loc('Next') &>
+                    <div class="submit">
+                        <div class="buttons">
+                            <div class="next">
+                                <button id="saveInitialPrefs" type="button"><% loc('Next') %></button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </form>
+    </div>
+  </div>
+</div>
+% $m->abort;
diff --git a/share/html/Helpers/VideoOverlay b/share/html/Helpers/VideoOverlay
new file mode 100644
index 0000000000..ae30733d57
--- /dev/null
+++ b/share/html/Helpers/VideoOverlay
@@ -0,0 +1,49 @@
+<%args>
+$Submit => 0,
+$URL => 'https://www.youtube.com/embed/yQa44O3EwvM'
+</%args>
+<%init>
+if ($Submit) {
+    # TODO: save watched-video attribute for user
+    $m->redirect('/');
+}
+</%init>
+<style>
+.video-container {
+  position: relative;
+  width: 710px;
+  height: 450px;
+  margin: auto auto;
+}
+
+.video {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  border: 0;
+}
+</style>
+<div class="modal-dialog modal-dialog-centered" role="document" style="max-width: 750px;">
+  <div class="modal-content">
+    <div class="modal-header" style="display: block;">
+        <div class="modal-title">
+            <h5>Welcome to Vurious</h5>
+        </div>
+    </div>
+    <div class="modal-body">
+        <p>The following short video will introduce you to the process of tracking and resolving security vulnerabilities using the Vurious system, and will show you how to find additional help along the way.</p>
+        <div class="video-container">
+            <iframe src="<% $URL %>" class="video" width="710" height="450" allowfullscreen frameborder="0"></iframe>
+        </div>
+        <form method="GET" url="/" name="initialVideoForm" id="initialVideoForm">
+            <div class="form-row">
+                <div class="col-12">
+                    <& /Elements/Submit, Name => 'Submit', Label => loc('Done') &>
+                </div>
+            </div>
+        </form>
+    </div>
+</div>
+% $m->abort();
diff --git a/share/static/js/util.js b/share/static/js/util.js
index bd9cc01a5a..7690595f46 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -35,8 +35,8 @@ function toggle_upgrade_history(widget, selector) {
     jQuery(widget).toggleClass("rolled-up");
 }
 
-var showModal = function(html) {
-    var modal = jQuery("<div class='modal'></div>");
+var showModal = function(html, static) {
+    var modal = static ? jQuery("<div class='modal' data-backdrop='static'/>") : jQuery("<div class='modal'/>");
     modal.append(html).appendTo("body");
     modal.bind('modal:close', function(ev) { modal.remove(); })
     modal.on('hide.bs.modal', function(ev) { modal.remove(); })

-----------------------------------------------------------------------


More information about the rt-commit mailing list