hackatime/app/views/users/edit.html.erb
2025-03-11 22:05:10 -04:00

109 lines
No EOL
3.4 KiB
Text

<% content_for :title do %>
<%= @is_own_settings ? "My Settings" : "Settings | #{@user.username}" %>
<% end %>
<h1><%= @is_own_settings ? "My Settings" : "Settings for #{@user.username}" %></h1>
<div>
<h2>Slack status</h2>
<% unless @can_enable_slack_status %>
<%= link_to "Re-authorize with Slack to give permission to update your status", slack_auth_path %>
<% end %>
<%= form_with model: @user,
url: @is_own_settings ? my_settings_path : settings_user_path(@user),
method: :patch do |f| %>
<fieldset>
<label for="switch-1">
<input type="checkbox" id="switch-1" name="switch-1" role="switch" checked="">
<%= f.label "Update my Slack status with my current project" %>
</label>
</fieldset>
<%= f.submit "Save Settings" %>
<% end %>
</div>
<div>
<h2>Slack notifications</h2>
<% if @enabled_sailors_logs.any? %>
<p>
You have notifications enabled for the following channels:
</p>
<ul>
<% @enabled_sailors_logs.each do |sl| %>
<li>
<%= render "shared/slack_channel_mention", channel_id: sl.slack_channel_id %>
</li>
<% end %>
</ul>
<% else %>
<p>
You have no notifications enabled.
</p>
<% end %>
<p>
You can enable notifications for specific channels by running `/sailorslog on` in the Slack channel you want to enable notifications for.
</p>
</div>
<div>
<h2>Config file</h2>
<p>
<% if current_user.most_recent_direct_entry_heartbeat %>
Your last heartbeat was <%= time_ago_in_words current_user.most_recent_direct_entry_heartbeat.created_at %> ago.
<% else %>
You haven't sent any heartbeats yet directly to this platform.
<% end %>
</p>
<%= render "wakatime_config_display" %>
<p>
<br>
<small>
This file is located in <code>~/.wakatime.cfg</code> on your computer.
You can configure it with <a href="https://github.com/wakatime/wakatime-cli/blob/develop/USAGE.md#ini-config-file">other settings</a> as well.
</small>
</p>
</div>
<div>
<h2>Hackatime extension</h2>
<%= form_with model: @user,
url: @is_own_settings ? my_settings_path : settings_user_path(@user),
method: :patch do |f| %>
<div>
<%= f.label "Simple text" %>
<%= f.select :hackatime_extension_text_type, User.hackatime_extension_text_types.keys.map { |type| [type.humanize, type] }, selected: @user.hackatime_extension_text_type %>
</div>
<%= f.submit "Save Settings" %>
<% end %>
</div>
<div>
<h2>Migration assistant</h2>
<p>This will migrate your heartbeats from waka.hackclub.com to this platform.</p>
<%= button_to "Migrate heartbeats", my_settings_migrate_heartbeats_path, method: :post %>
<% if @heartbeats_migration_jobs.any? %>
<ul>
<% @heartbeats_migration_jobs.each do |job| %>
<li>
<% if job.finished_at && !job.error %>
<% elsif job.finished_at && job.error %>
<% else %>
<% end %>
Job started at <%= job.created_at.strftime("%Y-%m-%d %H:%M:%S") %>
<% if job.finished_at %>
(and finished after <%= distance_of_time_in_words(job.finished_at - job.created_at) %>)
<% end %>
<% admin_tool('', 'span') do %>
<%= link_to "View job", GoodJob::Engine.routes.url_helpers.job_path(job.id) %>
<% end %>
</li>
<% end %>
</ul>
<% end %>
</div>