Add a maintenance notification kind and make it of the level warning.
This commit is contained in:
parent
b47742b011
commit
4e5e8a08de
5 changed files with 69 additions and 9 deletions
|
@ -0,0 +1,33 @@
|
||||||
|
"""Add the maintenance notification type.
|
||||||
|
|
||||||
|
Revision ID: 4b7ef0c7bdb2
|
||||||
|
Revises: bcdde200a1b
|
||||||
|
Create Date: 2014-06-27 19:09:56.387534
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '4b7ef0c7bdb2'
|
||||||
|
down_revision = 'bcdde200a1b'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
from data.model.sqlalchemybridge import gen_sqlalchemy_metadata
|
||||||
|
from data.database import all_models
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
schema = gen_sqlalchemy_metadata(all_models)
|
||||||
|
op.bulk_insert(schema.tables['notificationkind'],
|
||||||
|
[
|
||||||
|
{'id':4, 'name':'maintenance'},
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
notificationkind = schema.tables['notificationkind']
|
||||||
|
op.execute(
|
||||||
|
(notificationkind.delete()
|
||||||
|
.where(notificationkind.c.name == op.inline_literal('maintenance')))
|
||||||
|
|
||||||
|
)
|
13
initdb.py
13
initdb.py
|
@ -2,8 +2,10 @@ import logging
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import random
|
import random
|
||||||
|
import calendar
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from email.utils import formatdate
|
||||||
from peewee import (SqliteDatabase, create_model_tables, drop_model_tables,
|
from peewee import (SqliteDatabase, create_model_tables, drop_model_tables,
|
||||||
savepoint_sqlite)
|
savepoint_sqlite)
|
||||||
|
|
||||||
|
@ -232,6 +234,7 @@ def initialize_database():
|
||||||
NotificationKind.create(name='password_required')
|
NotificationKind.create(name='password_required')
|
||||||
NotificationKind.create(name='over_private_usage')
|
NotificationKind.create(name='over_private_usage')
|
||||||
NotificationKind.create(name='expiring_license')
|
NotificationKind.create(name='expiring_license')
|
||||||
|
NotificationKind.create(name='maintenance')
|
||||||
|
|
||||||
NotificationKind.create(name='test_notification')
|
NotificationKind.create(name='test_notification')
|
||||||
|
|
||||||
|
@ -289,6 +292,16 @@ def populate_database():
|
||||||
|
|
||||||
model.create_notification('test_notification', new_user_1, metadata={'some': 'value'})
|
model.create_notification('test_notification', new_user_1, metadata={'some': 'value'})
|
||||||
|
|
||||||
|
from_date = datetime.utcnow()
|
||||||
|
to_date = from_date + timedelta(hours=1)
|
||||||
|
notification_metadata = {
|
||||||
|
'from_date': formatdate(calendar.timegm(from_date.utctimetuple())),
|
||||||
|
'to_date': formatdate(calendar.timegm(to_date.utctimetuple())),
|
||||||
|
'reason': 'database migration'
|
||||||
|
}
|
||||||
|
model.create_notification('maintenance', new_user_1, metadata=notification_metadata)
|
||||||
|
|
||||||
|
|
||||||
__generate_repository(new_user_4, 'randomrepo', 'Random repo repository.', False,
|
__generate_repository(new_user_4, 'randomrepo', 'Random repo repository.', False,
|
||||||
[], (4, [], ['latest', 'prod']))
|
[], (4, [], ['latest', 'prod']))
|
||||||
|
|
||||||
|
|
|
@ -582,7 +582,7 @@ i.toggle-icon:hover {
|
||||||
|
|
||||||
.notification-warning {
|
.notification-warning {
|
||||||
color: #8a6d3b;
|
color: #8a6d3b;
|
||||||
background: #fcf8e3;
|
background: #ffde2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification-error {
|
.notification-error {
|
||||||
|
|
|
@ -919,6 +919,12 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
'message': 'Your license will expire at: {expires_at} ' +
|
'message': 'Your license will expire at: {expires_at} ' +
|
||||||
'<br><br>Please contact Quay.io support to purchase a new license.',
|
'<br><br>Please contact Quay.io support to purchase a new license.',
|
||||||
'page': '/contact/'
|
'page': '/contact/'
|
||||||
|
},
|
||||||
|
'maintenance': {
|
||||||
|
'level': 'warning',
|
||||||
|
'message': 'We will be down for schedule maintenance from {from_date} to {to_date} ' +
|
||||||
|
'for {reason}. We are sorry about any inconvenience.',
|
||||||
|
'page': 'http://status.quay.io/'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4335,7 +4341,11 @@ quayApp.directive('notificationView', function () {
|
||||||
'notification': '=notification',
|
'notification': '=notification',
|
||||||
'parent': '=parent'
|
'parent': '=parent'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, $location, UserService, NotificationService) {
|
controller: function($scope, $element, $window, $location, UserService, NotificationService) {
|
||||||
|
var stringStartsWith = function (str, prefix) {
|
||||||
|
return str.slice(0, prefix.length) == prefix;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.getMessage = function(notification) {
|
$scope.getMessage = function(notification) {
|
||||||
return NotificationService.getMessage(notification);
|
return NotificationService.getMessage(notification);
|
||||||
};
|
};
|
||||||
|
@ -4352,14 +4362,18 @@ quayApp.directive('notificationView', function () {
|
||||||
$scope.showNotification = function() {
|
$scope.showNotification = function() {
|
||||||
var url = NotificationService.getPage($scope.notification);
|
var url = NotificationService.getPage($scope.notification);
|
||||||
if (url) {
|
if (url) {
|
||||||
var parts = url.split('?')
|
if (stringStartsWith(url, 'http://') || stringStartsWith(url, 'https://')) {
|
||||||
$location.path(parts[0]);
|
$window.location.href = url;
|
||||||
|
} else {
|
||||||
if (parts.length > 1) {
|
var parts = url.split('?')
|
||||||
$location.search(parts[1]);
|
$location.path(parts[0]);
|
||||||
}
|
|
||||||
|
if (parts.length > 1) {
|
||||||
|
$location.search(parts[1]);
|
||||||
|
}
|
||||||
|
|
||||||
$scope.parent.$hide();
|
$scope.parent.$hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Binary file not shown.
Reference in a new issue