This repository has been archived by the owner on Jun 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notifications page to remove failed
- Loading branch information
Showing
4 changed files
with
104 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
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 @@ | ||
import {Api} from '../services/api'; | ||
import {UniqList} from '../models/core'; | ||
import {Timestamp} from '../models/timestamp'; | ||
|
||
export interface INotificationContact{ | ||
value: string; | ||
type: string; | ||
} | ||
|
||
export interface INotification { | ||
contact: INotificationContact; | ||
throttled: boolean; | ||
send_fail: number; | ||
timestamp: number; | ||
} | ||
|
||
export class Notification { | ||
throttled: boolean; | ||
timestamp: Timestamp; | ||
send_fail: number; | ||
contact: INotificationContact; | ||
|
||
constructor(public json: string){ | ||
var notification = <INotification>JSON.parse(json); | ||
this.timestamp = new Timestamp(notification.timestamp); | ||
this.send_fail = notification.send_fail; | ||
this.throttled = notification.throttled; | ||
this.contact = notification.contact; | ||
} | ||
} | ||
|
||
export interface INotificationsScope extends ng.IScope { | ||
total: number; | ||
list: UniqList<Notification>; | ||
} | ||
|
||
export class NotificationsController { | ||
|
||
static $inject = ['$scope', 'api']; | ||
|
||
constructor(private $scope: INotificationsScope, private api: Api) { | ||
api.config().then((config) => { | ||
return api.notification.list() | ||
.then((data) => { | ||
$scope.total = data.total; | ||
$scope.list = new UniqList<Notification>([]); | ||
angular.forEach(data.list, (json) => { | ||
$scope.list.push(new Notification(json)); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
remove(notification: Notification){ | ||
this.api.notification.remove(notification.json).then((data) => { | ||
if(data.result > 0){ | ||
this.$scope.list.remove(notification); | ||
} | ||
}); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="container"> | ||
<table class="highlight bordered"> | ||
<tbody> | ||
<tr> | ||
<th>Timestamp</th> | ||
<th colspan="2">Contact</th> | ||
<th>Throttled</th> | ||
<th>Fails</th> | ||
<th>Remove</th> | ||
</tr> | ||
<tr ng-repeat="notification in list"> | ||
<td> | ||
<moira-timestamp timestamp="notification.timestamp"></moira-timestamp> | ||
</td> | ||
<td ng-bind="notification.contact.type"></td> | ||
<td ng-bind="notification.contact.value"></td> | ||
<td ng-bind="notification.throttled"></td> | ||
<td ng-bind="notification.send_fail"></td> | ||
<td><i class="clickable material-icons" ng-click="ctrl.remove(notification)">delete</i></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> |