mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
delete & sync ical sources
This commit is contained in:
parent
36eba99808
commit
55d2c88134
@ -813,8 +813,35 @@ Application.Controllers.controller('AdminICalendarController', ['$scope', 'iCale
|
|||||||
* @param calendar
|
* @param calendar
|
||||||
*/
|
*/
|
||||||
$scope.delete = function (calendar) {
|
$scope.delete = function (calendar) {
|
||||||
const idx = $scope.calendars.indexOf(calendar);
|
ICalendar.delete(
|
||||||
$scope.calendars.splice(idx, 1);
|
{ id: calendar.id },
|
||||||
|
function () {
|
||||||
|
// success
|
||||||
|
const idx = $scope.calendars.indexOf(calendar);
|
||||||
|
$scope.calendars.splice(idx, 1);
|
||||||
|
}, function (error) {
|
||||||
|
// failed
|
||||||
|
growl.error(_t('icalendar.delete_failed'));
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronously re-fetches the events from the given calendar
|
||||||
|
* @param calendar
|
||||||
|
*/
|
||||||
|
$scope.sync = function (calendar) {
|
||||||
|
ICalendar.sync(
|
||||||
|
{ id: calendar.id },
|
||||||
|
function () {
|
||||||
|
// success
|
||||||
|
growl.info(_t('icalendar.refresh'));
|
||||||
|
}, function (error) {
|
||||||
|
// failed
|
||||||
|
growl.error(_t('icalendar.sync_failed'));
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
@ -6,6 +6,11 @@ Application.Services.factory('ICalendar', ['$resource', function ($resource) {
|
|||||||
events: {
|
events: {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/i_calendar/events'
|
url: '/api/i_calendar/events'
|
||||||
|
},
|
||||||
|
sync: {
|
||||||
|
method: 'POST',
|
||||||
|
url: '/api/i_calendar/:id/sync',
|
||||||
|
params: { id: '@id' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<th style="width: 35%;" translate>{{ 'icalendar.name' }}</th>
|
<th style="width: 35%;" translate>{{ 'icalendar.name' }}</th>
|
||||||
<th style="width: 35%;" translate>{{ 'icalendar.url' }}</th>
|
<th style="width: 35%;" translate>{{ 'icalendar.url' }}</th>
|
||||||
<th translate>{{ 'icalendar.display' }}</th>
|
<th translate>{{ 'icalendar.display' }}</th>
|
||||||
<th></th>
|
<th style="width: 10%;"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -42,6 +42,7 @@
|
|||||||
<td class="calendar-url"><a href="{{calendar.url}}" target="_blank">{{calendar.url}}</a></td>
|
<td class="calendar-url"><a href="{{calendar.url}}" target="_blank">{{calendar.url}}</a></td>
|
||||||
<td class="calendar-legend-block text-left"><span class="calendar-legend" ng-style="calendarStyle(calendar)" translate> {{ calendar.textHidden ? '' : 'icalendar.example' }}</span>
|
<td class="calendar-legend-block text-left"><span class="calendar-legend" ng-style="calendarStyle(calendar)" translate> {{ calendar.textHidden ? '' : 'icalendar.example' }}</span>
|
||||||
<td class="calendar-actions">
|
<td class="calendar-actions">
|
||||||
|
<button class="btn btn-info" ng-click="sync(calendar)"><i class="fa fa-refresh"></i></button>
|
||||||
<button class="btn btn-danger" ng-click="delete(calendar)"><i class="fa fa-trash"></i></button>
|
<button class="btn btn-danger" ng-click="delete(calendar)"><i class="fa fa-trash"></i></button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -43,6 +43,11 @@ class API::ICalendarController < API::ApiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sync
|
||||||
|
puts '[TODO] run worker'
|
||||||
|
render json: { processing: true }, status: :created
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_i_cal
|
def set_i_cal
|
||||||
|
@ -103,6 +103,9 @@ fr:
|
|||||||
hidden: "Caché"
|
hidden: "Caché"
|
||||||
shown: "Affiché"
|
shown: "Affiché"
|
||||||
create_error: "Impossible de créer l'import iCalendar. Veuillez réessayer ultérieurement"
|
create_error: "Impossible de créer l'import iCalendar. Veuillez réessayer ultérieurement"
|
||||||
|
delete_failed: "Impossible de supprimer l'import iCalendar. Veuillez réessayer ultérieurement"
|
||||||
|
refresh: "Mise à jour en cours..."
|
||||||
|
sync_failed: "Impossible de synchroniser l'URL. Veuillez réessayer ultérieurement"
|
||||||
|
|
||||||
project_elements:
|
project_elements:
|
||||||
# gestion des éléments constituant les projets
|
# gestion des éléments constituant les projets
|
||||||
|
@ -114,6 +114,7 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
resources :i_calendar, only: %i[index create destroy] do
|
resources :i_calendar, only: %i[index create destroy] do
|
||||||
get 'events', on: :collection
|
get 'events', on: :collection
|
||||||
|
post 'sync', on: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
# for admin
|
# for admin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user