Skip to content

Commit

Permalink
make calendar keys links and add additional messages to FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
colinxy committed Mar 25, 2020
1 parent a491cc6 commit fd9d176
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 2 additions & 0 deletions configs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ header_color: '#3a3a3a'
# The public calendar url will be formatted as follows: "{public_calendar_base_url}/{ical_key}".
# Replace localhost with the hostname of the oncall or iris-relay instance.
public_calendar_base_url: 'http://localhost:8080/api/v0/ical'
# Additional message you want to put here, could be a link to the FAQ
public_calendar_additional_message: 'Link to FAQ'

# Integration with Iris, allowing for escalation from Oncall
iris_plan_integration:
Expand Down
3 changes: 3 additions & 0 deletions src/oncall/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def index(req, resp):
iris_plan_settings=IRIS_PLAN_SETTINGS,
usercontact_ui_readonly=USERCONTACT_UI_READONLY,
public_calendar_base_url=PUBLIC_CALENDAR_BASE_URL,
public_calendar_additional_message=PUBLIC_CALENDAR_ADDITIONAL_MESSAGE,
footer=INDEX_CONTENT_SETTING['footer'],
timezones=SUPPORTED_TIMEZONES
)
Expand Down Expand Up @@ -136,12 +137,14 @@ def init(application, config):
global IRIS_PLAN_SETTINGS
global USERCONTACT_UI_READONLY
global PUBLIC_CALENDAR_BASE_URL
global PUBLIC_CALENDAR_ADDITIONAL_MESSAGE
global LOGIN_REQUIRED
SLACK_INSTANCE = config.get('slack_instance')
HEADER_COLOR = config.get('header_color', '#3a3a3a')
IRIS_PLAN_SETTINGS = config.get('iris_plan_integration')
USERCONTACT_UI_READONLY = config.get('usercontact_ui_readonly', True)
PUBLIC_CALENDAR_BASE_URL = config.get('public_calendar_base_url')
PUBLIC_CALENDAR_ADDITIONAL_MESSAGE = config.get('public_calendar_additional_message')
LOGIN_REQUIRED = config.get('require_auth')

application.add_sink(index, '/')
Expand Down
20 changes: 8 additions & 12 deletions src/oncall/ui/static/js/oncall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2847,7 +2847,7 @@ var oncall = {
moduleIcalKeyTemplate: $('#module-ical-key-template').html(),
subheaderWrapper: '.subheader-wrapper',
icalKeyRow: '.ical-key-row',
requestIcalKey: '#request-ical-key'
createIcalKey: '#create-ical-key'
},
init: function(){
Handlebars.registerHelper('capitalize', function(str){
Expand All @@ -2856,20 +2856,19 @@ var oncall = {
Handlebars.registerPartial('settings-subheader', this.data.settingsSubheaderTemplate);
Handlebars.registerPartial('ical-key', this.data.moduleIcalKeyTemplate);
this.getData();
oncall.getModes();
},
events: function(){
router.updatePageLinks();
this.data.$page.on('click', this.data.requestIcalKey, this.requestIcalKey.bind(this));
this.data.$page.on('click', this.data.createIcalKey, this.createIcalKey.bind(this));
},
getData: function(){
var self = this;

if (oncall.data.user) {
$.when(
$.get(this.data.icalKeyUrl + 'requester/' + oncall.data.user),
oncall.data.modesPromise
).done(function(icalKeys){
$.get(this.data.url + oncall.data.user + '/teams')
).done(function(icalKeys, teamsData){
icalKeys = icalKeys[0];

var userKeys = [],
Expand All @@ -2885,6 +2884,7 @@ var oncall = {
icalKeys.userKeys = userKeys;
icalKeys.teamKeys = teamKeys;
icalKeys.name = oncall.data.user;
icalKeys.teams = teamsData[0];

self.renderPage.call(self, icalKeys);
}).fail(function(){
Expand All @@ -2900,16 +2900,14 @@ var oncall = {
this.data.$page.html(template(data));
this.events();
},
requestIcalKey: function(e, data){
createIcalKey: function(e, data){
console.log(e, data);
},
updateIcalKey: function($modal, $caller){
var self = this,
$cta = $modal.find('.modal-cta'),
ical_key = $caller.attr('data-ical-key'),
ical_type = $caller.attr('data-ical-type'),
ical_name = $caller.attr('data-ical-name'),
$icalKeyRow = this.data.$page.find(this.data.icalKeyRow + '[data-id="' + ical_key + '"]')
url = this.data.icalKeyUrl + ical_type + '/' + ical_name;

if ((ical_type === 'user' || ical_type === 'team') && ical_name) {
Expand All @@ -2921,8 +2919,7 @@ var oncall = {
dataType: 'html'
}).done(function(data){
$modal.modal('hide');
$icalKeyRow.find('span.ical-key').text(data.trim());
$icalKeyRow.find('span.ical-key-time-created').text(moment().format('YYYY/MM/DD HH:mm'));
self.getData();
}).fail(function(data){
var error = oncall.isJson(data.responseText) ? JSON.parse(data.responseText).description : data.responseText || 'Delete failed.';
oncall.alerts.createAlert(error, 'danger');
Expand All @@ -2937,7 +2934,6 @@ var oncall = {
var self = this,
$cta = $modal.find('.modal-cta'),
key = $caller.attr('data-ical-key'),
$icalKeyRow = this.data.$page.find(this.data.icalKeyRow + '[data-id="' + key + '"]')
url = this.data.icalKeyUrl + 'key/' + key;

if (key) {
Expand All @@ -2949,7 +2945,7 @@ var oncall = {
dataType: 'html'
}).done(function(){
$modal.modal('hide');
$icalKeyRow.remove();
self.getData();
}).fail(function(data){
var error = oncall.isJson(data.responseText) ? JSON.parse(data.responseText).description : data.responseText || 'Delete failed.';
oncall.alerts.createAlert(error, 'danger');
Expand Down
17 changes: 11 additions & 6 deletions src/oncall/ui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1710,30 +1710,31 @@ <h4>
<h4 class="module-heading">How to subscribe to your calendars</h4>
<div>
<p>
From your personal calendar application, subscribe to the following URL, followed by slash, and followed by one of the calendar key above.
From your personal calendar application, subscribe to the following URL, followed by slash, and followed by a calendar key above. Or copy the link address of a key above.
{% endraw %} <pre>{{public_calendar_base_url}}</pre> {% raw %}
</p>
<p>
For example, if the key is abc-123, then your calendar subscription URL will be:
{% endraw %} <pre>{{public_calendar_base_url}}/abc-123</pre> {% raw %}
</p>
{% endraw %} <p>{{public_calendar_additional_message}}</p> {% raw %}
</div>
</div>
</script>

<!-- // ical key view partial -->
<script id="module-ical-key-template" type="text/x-handlebars-template">
<h3 class="module-heading"> {{capitalize key_type}} Calendar Keys <button id="request-ical-key" class="btn btn-primary pull-right">+ {{capitalize key_type}} Ical Key</button></h3>
<h3 class="module-heading"> {{capitalize key_type}} Calendar Keys <button id="create-ical-key" class="btn btn-primary pull-right">+ {{capitalize key_type}} Ical Key</button></h3>
<div class="module">
<table width="100%" class="table table-striped">
<thead><th>{{capitalize key_type}} Name</th><th>Key</th><th>Time Created</th></thead>
<tbody>
{{#each keys}}
<tr class="ical-key-row" data-id="{{this.key}}">
<tr>
<td><span>{{this.name}}</span></td>
<td><span class="ical-key">{{this.key}}</span></td>
<td><span class="ical-key-time-created">{{this.time_created}}</span></td>
<td><button id="update-ical-key" class="btn btn-warning btn-sm pull-right" type="button" data-toggle="modal" data-target="#confirm-action-modal" data-modal-action="oncall.settings.ical_key.updateIcalKey" data-modal-title="Regenerate Ical Key for {{this.type}} {{this.name}}" data-modal-content="Regenerate an ical key will invalidate the existing key." data-ical-key="{{this.key}}" data-ical-type="{{this.type}}" data-ical-name="{{this.name}}">Regenerate</button></td>
<td><span><a href="{% endraw %}{{public_calendar_base_url}}{% raw %}/{{this.key}}">{{this.key}}</a></span></td>
<td><span>{{this.time_created}}</span></td>
<td><button id="update-ical-key" class="btn btn-warning btn-sm pull-right" type="button" data-toggle="modal" data-target="#confirm-action-modal" data-modal-action="oncall.settings.ical_key.updateIcalKey" data-modal-title="Regenerate Ical Key for {{this.type}} {{this.name}}" data-modal-content="Regenerate an ical key will invalidate the existing key." data-ical-type="{{this.type}}" data-ical-name="{{this.name}}">Regenerate</button></td>
<td><button id="delete-ical-key" class="btn btn-danger btn-sm pull-right" type="button" data-toggle="modal" data-target="#confirm-action-modal" data-modal-action="oncall.settings.ical_key.deleteIcalKey" data-modal-content="Invalidate key {{this.key}}?" data-modal-title="Delete Ical Key for {{this.type}} {{this.name}}" data-ical-key="{{this.key}}">Delete</button></td>
</tr>
{{/each}}
Expand All @@ -1742,6 +1743,10 @@ <h3 class="module-heading"> {{capitalize key_type}} Calendar Keys <button id="re
</div>
</script>

<!-- // ical key view partial -->
<script id="module-ical-key-create-template" type="text/x-handlebars-template">
</script>

<!--// **********************
Errors Page
*********************** //-->
Expand Down

0 comments on commit fd9d176

Please sign in to comment.