-
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.
feat(dedicated.occ): add notifications on occ dashboard
ref: MANAGER-15325 Signed-off-by: Quentin Pavy <[email protected]>
- Loading branch information
Quentin Pavy
committed
Oct 10, 2024
1 parent
77defa1
commit b30537a
Showing
11 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
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
10 changes: 10 additions & 0 deletions
10
packages/manager/modules/cloud-connect/src/details/components/notifications/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,10 @@ | ||
import template from './template.html'; | ||
import controller from './controller'; | ||
|
||
export default { | ||
template, | ||
controller, | ||
bindings: { | ||
notifications: '<', | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/manager/modules/cloud-connect/src/details/components/notifications/constants.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 @@ | ||
export const NOTIFICATION_TYPE = { | ||
INCIDENT: 'incident', | ||
MAINTENANCE: 'maintenance', | ||
}; | ||
|
||
export default { | ||
NOTIFICATION_TYPE, | ||
}; |
67 changes: 67 additions & 0 deletions
67
packages/manager/modules/cloud-connect/src/details/components/notifications/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,67 @@ | ||
import { NOTIFICATION_TYPE } from './constants'; | ||
|
||
export default class NotificationsController { | ||
/* @ngInject */ | ||
constructor(coreConfig) { | ||
this.incident = undefined; | ||
this.maintenances = []; | ||
|
||
this.dateTimeFormat = new Intl.DateTimeFormat( | ||
coreConfig.getUserLocale().replace('_', '-'), | ||
{ | ||
day: 'numeric', | ||
month: 'numeric', | ||
year: 'numeric', | ||
hour: 'numeric', | ||
minute: 'numeric', | ||
second: 'numeric', | ||
timeZoneName: 'short', | ||
}, | ||
); | ||
} | ||
|
||
$onInit() { | ||
// If there is incident, display the incident with the earlier date time | ||
this.incident = this.notifications | ||
.filter( | ||
(notification) => notification.type === NOTIFICATION_TYPE.INCIDENT, | ||
) | ||
.reduce((earliestIncident, currentIncident) => { | ||
const currentIncidentFormatted = { | ||
...currentIncident, | ||
startDateFormatted: this.dateTimeFormat.format( | ||
new Date(currentIncident.startDate), | ||
), | ||
}; | ||
|
||
if (!earliestIncident) { | ||
return currentIncidentFormatted; | ||
} | ||
|
||
if (currentIncident.startDate < earliestIncident.startDate) { | ||
return currentIncidentFormatted; | ||
} | ||
|
||
return earliestIncident; | ||
}, null); | ||
|
||
// Sort all maintenances with the earlier start date time first | ||
this.maintenances = this.notifications | ||
.filter( | ||
(notification) => notification.type === NOTIFICATION_TYPE.MAINTENANCE, | ||
) | ||
.sort( | ||
(maintenanceA, maintenanceB) => | ||
new Date(maintenanceA.startDate) - new Date(maintenanceB.startDate), | ||
) | ||
.map((maintenance) => ({ | ||
...maintenance, | ||
startDateFormatted: this.dateTimeFormat.format( | ||
new Date(maintenance.startDate), | ||
), | ||
endDateFormatted: this.dateTimeFormat.format( | ||
new Date(maintenance.endDate), | ||
), | ||
})); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/manager/modules/cloud-connect/src/details/components/notifications/index.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,13 @@ | ||
import angular from 'angular'; | ||
import 'angular-translate'; | ||
|
||
import component from './component'; | ||
|
||
const moduleName = 'ovhCloudConnectDetailsNotificationsModule'; | ||
|
||
angular | ||
.module(moduleName, ['pascalprecht.translate']) | ||
.component('ovhCloudConnectNotifications', component) | ||
.run(/* @ngTranslationsInject:json ./translations */); | ||
|
||
export default moduleName; |
20 changes: 20 additions & 0 deletions
20
packages/manager/modules/cloud-connect/src/details/components/notifications/template.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,20 @@ | ||
<div id="ovh-cloud-connect-notifications"> | ||
<oui-message data-type="warning" data-ng-if="$ctrl.incident" class="mb-2"> | ||
<span | ||
data-translate="cloud_connect_notifications_incident" | ||
data-translate-values="{startDate: $ctrl.incident.startDateFormatted}" | ||
></span> | ||
</oui-message> | ||
|
||
<oui-message | ||
data-type="info" | ||
data-ng-if="$ctrl.maintenances.length !== 0" | ||
data-ng-repeat="maintenance in $ctrl.maintenances" | ||
class="mb-2" | ||
> | ||
<span | ||
data-translate="cloud_connect_notifications_maintenance" | ||
data-translate-values="{startDate: maintenance.startDateFormatted, endDate: maintenance.endDateFormatted}" | ||
></span> | ||
</oui-message> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
...dules/cloud-connect/src/details/components/notifications/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,4 @@ | ||
{ | ||
"cloud_connect_notifications_incident": "Un incident pouvant impacter votre service a été déclaré le {{startDate}}", | ||
"cloud_connect_notifications_maintenance": "Une opération de maintenance est prévue du {{startDate}} au {{endDate}}" | ||
} |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ export default { | |
cloudConnect: '<', | ||
guideUrl: '<', | ||
clearCache: '<', | ||
notifications: '<', | ||
}, | ||
template, | ||
}; |
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