-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: OB-5034
- Loading branch information
Showing
12 changed files
with
331 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
...ules/dbaas-logs/src/logs/detail/streams/subscriptions/streams-subscriptions.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import datagridToIcebergFilter from '../../logs-iceberg.utils'; | ||
|
||
export default class LogsStreamsSubscriptionsCtrl { | ||
/* @ngInject */ | ||
constructor( | ||
$stateParams, | ||
$translate, | ||
ouiDatagridService, | ||
CucCloudMessage, | ||
CucControllerHelper, | ||
LogsStreamsService, | ||
LogsStreamsSubscriptionsService, | ||
) { | ||
this.$stateParams = $stateParams; | ||
this.$translate = $translate; | ||
this.ouiDatagridService = ouiDatagridService; | ||
this.CucCloudMessage = CucCloudMessage; | ||
this.CucControllerHelper = CucControllerHelper; | ||
this.LogsStreamsService = LogsStreamsService; | ||
this.LogsStreamsSubscriptionsService = LogsStreamsSubscriptionsService; | ||
|
||
this.serviceName = this.$stateParams.serviceName; | ||
this.streamId = this.$stateParams.streamId; | ||
this.initLoaders(); | ||
} | ||
|
||
$onInit() { | ||
this.stream.load(); | ||
} | ||
|
||
/** | ||
* Load the current stream | ||
*/ | ||
initLoaders() { | ||
this.stream = this.CucControllerHelper.request.getHashLoader({ | ||
loaderFunction: () => | ||
this.LogsStreamsService.getStream(this.serviceName, this.streamId), | ||
}); | ||
} | ||
|
||
/** | ||
* Retrieve subscription list, according to pagination/sort/filter | ||
* | ||
* @param offset int element offset to retrieve results from | ||
* @param pageSize int Number of results to retrieve | ||
* @param sort Object Sort object from ovh-ui datagrid | ||
* @param criteria Object Criteria object from ovh-ui datagrid | ||
* @return {*|Promise<any>} | ||
*/ | ||
loadSubscriptions({ offset, pageSize = 1, sort, criteria }) { | ||
const filters = criteria.map((c) => { | ||
const name = c.property || 'resource.name'; | ||
return datagridToIcebergFilter(name, c.operator, c.value); | ||
}); | ||
const pageOffset = Math.ceil(offset / pageSize); | ||
return this.LogsStreamsSubscriptionsService.getPaginatedStreamSubscriptions( | ||
this.serviceName, | ||
this.streamId, | ||
pageOffset, | ||
pageSize, | ||
{ name: sort.property, dir: sort.dir === -1 ? 'DESC' : 'ASC' }, | ||
filters, | ||
); | ||
} | ||
|
||
/** | ||
* Display a modal to confirm subscription deletion | ||
* | ||
* @param subscription Object Subscription object from API | ||
* @return {*|Promise<any>} | ||
*/ | ||
showSubscriptionDeleteConfirm(subscription) { | ||
this.CucCloudMessage.flushChildMessage(); | ||
return this.CucControllerHelper.modal | ||
.showDeleteModal({ | ||
titleText: this.$translate.instant( | ||
'streams_subscriptions_delete_modal_title', | ||
), | ||
textHtml: this.$translate.instant( | ||
'streams_subscriptions_delete_modal_content', | ||
{ | ||
resourceName: `<strong>${subscription.resource.name}</strong>`, | ||
}, | ||
), | ||
}) | ||
.then(() => this.removeSubscription(subscription)); | ||
} | ||
|
||
/** | ||
* Delete a subscription on API | ||
* Update datagrid accordingly | ||
* | ||
* @param subscription Object Subscription object from API | ||
*/ | ||
removeSubscription(subscription) { | ||
this.CucCloudMessage.flushChildMessage(); | ||
this.deleteSubscriptionLoading = true; | ||
this.LogsStreamsSubscriptionsService.deleteSubscription( | ||
this.serviceName, | ||
this.streamId, | ||
subscription, | ||
) | ||
.then((operation) => | ||
this.LogsHelperService.handleOperation( | ||
this.serviceName, | ||
operation.data || operation, | ||
'streams_subscriptions_delete_success', | ||
{ resourceName: subscription.resource.name }, | ||
), | ||
) | ||
.catch((err) => { | ||
this.LogsHelperService.handleError( | ||
'streams_subscriptions_delete_error', | ||
err, | ||
{ resourceName: subscription.resource.name }, | ||
); | ||
}) | ||
.finally(() => { | ||
this.deleteSubscriptionLoading = false; | ||
this.ouiDatagridService.refresh('subscriptions-datagrid', true); | ||
this.CucControllerHelper.scrollPageToTop(); | ||
}); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...nager/modules/dbaas-logs/src/logs/detail/streams/subscriptions/streams-subscriptions.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<div class="subscriptions-home"> | ||
<oui-back-button | ||
><span data-translate="logs_streams_subscriptions"></span | ||
></oui-back-button> | ||
|
||
<h6> | ||
{{'streams_subscriptions_current_title' | translate:{ name: | ||
ctrl.stream.data.title } }} | ||
</h6> | ||
<p data-translate="streams_subscriptions_intro_text"></p> | ||
|
||
<oui-datagrid | ||
id="subscriptions-datagrid" | ||
rows-loader="ctrl.loadSubscriptions($config)" | ||
> | ||
<oui-datagrid-topbar> | ||
<oui-spinner | ||
size="s" | ||
data-ng-if="ctrl.deleteSubscriptionLoading" | ||
></oui-spinner> | ||
</oui-datagrid-topbar> | ||
|
||
<oui-datagrid-column | ||
data-title="::'streams_subscriptions_resource_name_label' | translate" | ||
data-property="resource.name" | ||
data-type="string" | ||
data-sortable | ||
data-searchable | ||
data-filterable | ||
></oui-datagrid-column> | ||
<oui-datagrid-column | ||
data-title="::'streams_subscriptions_resource_type_label' | translate" | ||
data-property="resource.type" | ||
data-type="string" | ||
data-sortable="asc" | ||
data-searchable | ||
data-filterable | ||
> | ||
<span> | ||
{{ ::'streams_subscriptions_resource_products_' + | ||
$row.resource.type | translate }} | ||
</span> | ||
</oui-datagrid-column> | ||
<oui-datagrid-column | ||
data-title="::'logs_home_start_date' | translate" | ||
data-property="createdAt" | ||
data-sortable | ||
data-type="date" | ||
> | ||
{{ $row.createdAt | cucMomentFormat:'L'}} | ||
</oui-datagrid-column> | ||
|
||
<oui-action-menu compact data-placement="end"> | ||
<oui-action-menu-item | ||
data-on-click="ctrl.showSubscriptionDeleteConfirm($row)" | ||
> | ||
<span data-translate="logs_delete"></span> | ||
</oui-action-menu-item> | ||
</oui-action-menu> | ||
</oui-datagrid> | ||
</div> |
60 changes: 60 additions & 0 deletions
60
...modules/dbaas-logs/src/logs/detail/streams/subscriptions/streams-subscriptions.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
export default class LogsStreamsSubscriptionsService { | ||
/* @ngInject */ | ||
constructor($http, iceberg) { | ||
this.$http = $http; | ||
this.iceberg = iceberg; | ||
} | ||
|
||
/** | ||
* Retrieve list of stream's subscription with pagination, sorts, filters etc. | ||
* @param serviceName string LDP service name | ||
* @param streamId string LDP stream UUID | ||
* @param offset int Offset to start from | ||
* @param pageSize int Number of results to retrieve from API | ||
* @param sort string Name of field to sort from | ||
* @param filters Array List of Iceberg filters to apply | ||
* @return {Object} | ||
*/ | ||
getPaginatedStreamSubscriptions( | ||
serviceName, | ||
streamId, | ||
offset = 0, | ||
pageSize = 25, | ||
sort = { name: 'nbArchive', dir: 'desc' }, | ||
filters = null, | ||
) { | ||
let res = this.iceberg( | ||
`/dbaas/logs/${serviceName}/output/graylog/stream/${streamId}/subscription`, | ||
) | ||
.query() | ||
.expand('CachedObjectList-Pages') | ||
.limit(pageSize) | ||
.offset(offset) | ||
.sort(sort.name, sort.dir); | ||
if (filters !== null) { | ||
filters.forEach((filter) => { | ||
res = res.addFilter(filter.name, filter.operator, filter.value); | ||
}); | ||
} | ||
return res.execute().$promise.then((response) => ({ | ||
data: response.data, | ||
meta: { | ||
totalCount: | ||
parseInt(response.headers['x-pagination-elements'], 10) || 0, | ||
}, | ||
})); | ||
} | ||
|
||
/** | ||
* Delete a subscription on the API side | ||
* @param serviceName string LDP service name | ||
* @param streamId string LDP stream UUID | ||
* @param subscription Object Subscription object to delete | ||
* @return {Promise<any>} | ||
*/ | ||
deleteSubscription(serviceName, streamId, subscription) { | ||
return this.$http.delete( | ||
`/dbaas/logs/${serviceName}/output/graylog/stream/${streamId}/subscription/${subscription.subscriptionId}`, | ||
); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...nager/modules/dbaas-logs/src/logs/detail/streams/subscriptions/subscriptions.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import controller from './streams-subscriptions.controller'; | ||
import template from './streams-subscriptions.html'; | ||
|
||
export default { | ||
controller, | ||
controllerAs: 'ctrl', | ||
template, | ||
}; |
30 changes: 30 additions & 0 deletions
30
.../manager/modules/dbaas-logs/src/logs/detail/streams/subscriptions/subscriptions.module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import angular from 'angular'; | ||
|
||
import '@ovh-ux/manager-core'; | ||
import '@ovh-ux/ng-ovh-cloud-universe-components'; | ||
import '@uirouter/angularjs'; | ||
import 'angular-translate'; | ||
import 'ovh-api-services'; | ||
import '@ovh-ux/ui-kit'; | ||
|
||
import component from './subscriptions.component'; | ||
import routing from './subscriptions.routing'; | ||
import service from './streams-subscriptions.service'; | ||
|
||
const moduleName = 'ovhManagerDbaasLogsDetailStreamsSubscriptions'; | ||
|
||
angular | ||
.module(moduleName, [ | ||
'ngOvhCloudUniverseComponents', | ||
'oui', | ||
'ovhManagerCore', | ||
'ovh-api-services', | ||
'pascalprecht.translate', | ||
'ui.router', | ||
]) | ||
.config(routing) | ||
.service('LogsStreamsSubscriptionsService', service) | ||
.component('dbaasLogsDetailStreamsSubscriptions', component) | ||
.run(/* @ngTranslationsInject:json ./translations */); | ||
|
||
export default moduleName; |
10 changes: 10 additions & 0 deletions
10
...manager/modules/dbaas-logs/src/logs/detail/streams/subscriptions/subscriptions.routing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default /* @ngInject */ ($stateProvider) => { | ||
$stateProvider.state('dbaas-logs.detail.streams.stream.subscriptions', { | ||
url: '/subscriptions', | ||
component: 'dbaasLogsDetailStreamsSubscriptions', | ||
resolve: { | ||
breadcrumb: /* @ngInject */ ($translate) => | ||
$translate.instant('dbaas_logs_streams_subscriptions'), | ||
}, | ||
}); | ||
}; |
3 changes: 3 additions & 0 deletions
3
...modules/dbaas-logs/src/logs/detail/streams/subscriptions/translations/Messages_fr_FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dbaas_logs_streams_subscriptions": "Abonnements" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters