1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Added changelog for publications to dashboard

This commit is contained in:
Adolfo Gómez García 2015-06-17 08:21:47 +02:00
parent 32a04edbf9
commit b77fa7dfd6
8 changed files with 113 additions and 8 deletions

View File

@ -42,7 +42,7 @@ from uds.core.util import permissions
from uds.REST.model import ModelHandler
from uds.REST import RequestError, ResponseError
from uds.core.ui.UserInterface import gui
from .user_services import AssignedService, CachedService, Groups, Transports, Publications
from .user_services import AssignedService, CachedService, Groups, Transports, Publications, Changelog
from .services import Services
import logging
@ -61,6 +61,7 @@ class ServicesPools(ModelHandler):
'groups': Groups,
'transports': Transports,
'publications': Publications,
'changelog': Changelog
}
save_fields = ['name', 'comments', 'service_id', 'osmanager_id', 'image_id', 'initial_srvs', 'cache_l1_srvs', 'cache_l2_srvs', 'max_srvs', 'show_transports']

View File

@ -329,3 +329,25 @@ class Publications(DetailHandler):
'field': 'state',
'prefix': 'row-state-'
}
class Changelog(DetailHandler):
'''
Processes the transports detail requests of a Service Pool
'''
def getItems(self, parent, item):
return [{
'revision': i.revision,
'stamp': i.stamp,
'log': i.log,
} for i in parent.changelog.all()]
def getTitle(self, parent):
return _('Changelog')
def getFields(self, parent):
return [
{'revision': {'title': _('Revision'), 'type': 'numeric', 'width': '6em'}},
{'stamp': {'title': _('Publish date'), 'type': 'datetime'}},
{'log': {'title': _('State')}},
]

View File

@ -209,7 +209,7 @@ class PublicationManager(object):
dsp = None
dsp = servicePool.publications.create(state=State.LAUNCHING, state_date=now, publish_date=now, revision=servicePool.current_pub_revision)
if changeLog:
servicePool.changelog.create(revision=servicePool.current_pub_revision, log=changeLog)
servicePool.changelog.create(revision=servicePool.current_pub_revision, log=changeLog, stamp=now)
DelayedTaskRunner.runner().insert(PublicationLauncher(dsp), 4, PUBTAG + str(dsp.id))
except Exception as e:
logger.debug('Caught exception at publish: {0}'.format(e))

View File

@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.db.models.deletion
import uds.models.Util
class Migration(migrations.Migration):
dependencies = [
('uds', '0015_ticketstore'),
]
operations = [
migrations.CreateModel(
name='DeployedServicePublicationChangelog',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('stamp', models.DateTimeField()),
('revision', models.PositiveIntegerField(default=1)),
('log', models.TextField(default='')),
],
options={
'abstract': False,
'db_table': 'uds__deployed_service_pub_cl',
},
),
migrations.AddField(
model_name='group',
name='created',
field=models.DateTimeField(default=uds.models.Util.getSqlDatetime, blank=True),
),
migrations.AddField(
model_name='user',
name='created',
field=models.DateTimeField(default=uds.models.Util.getSqlDatetime, blank=True),
),
migrations.AlterField(
model_name='deployedservice',
name='image',
field=models.ForeignKey(related_name='deployedServices', on_delete=django.db.models.deletion.SET_NULL, blank=True, to='uds.Image', null=True),
),
migrations.AlterField(
model_name='group',
name='manager',
field=uds.models.Util.UnsavedForeignKey(related_name='groups', to='uds.Authenticator'),
),
migrations.AlterField(
model_name='user',
name='manager',
field=uds.models.Util.UnsavedForeignKey(related_name='users', to='uds.Authenticator'),
),
migrations.AddField(
model_name='deployedservicepublicationchangelog',
name='publication',
field=models.ForeignKey(related_name='changelog', to='uds.DeployedService'),
),
]

View File

@ -47,7 +47,7 @@ from uds.models.UUIDModel import UUIDModel
import logging
__updated__ = '2015-06-15'
__updated__ = '2015-06-17'
logger = logging.getLogger(__name__)
@ -56,6 +56,7 @@ logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class DeployedServicePublicationChangelog(models.Model):
publication = models.ForeignKey(DeployedService, on_delete=models.CASCADE, related_name='changelog')
stamp = models.DateTimeField()
revision = models.PositiveIntegerField(default=1)
log = models.TextField(default='')

View File

@ -98,6 +98,7 @@ gui.servicesPools.link = (event) ->
groups: "groups-placeholder"
transports: "transports-placeholder"
publications: "publications-placeholder"
changelog: "changelog-placeholder"
logs: "logs-placeholder"
)
gui.setLinksEvents()
@ -378,6 +379,8 @@ gui.servicesPools.link = (event) ->
# * Publications part
#
publications = null
changelog = null
clTable = null
if info.needs_publication
$("#publications-placeholder_tab").removeClass "hidden"
pubApi = api.servicesPools.detail(servPool.id, "publications")
@ -437,20 +440,34 @@ gui.servicesPools.link = (event) ->
)
gui.tools.applyCustoms modalId
$(modalId + " .button-accept").click ->
changelog = encodeURIComponent($('#id_publish_log').val())
chlog = encodeURIComponent($('#id_publish_log').val())
$(modalId).modal "hide"
pubApi.invoke "publish", (->
refreshFnc()
changelog.refresh()
# Also changelog
return
),
gui.failRequestModalFnc(gettext("Failed creating publication")),
{ params: 'changelog=' + changelog }
{ params: 'changelog=' + chlog }
return
return
)
prevTables.push publicationsTable
# changelog
clApi = api.servicesPools.detail(servPool.id, "changelog")
changelog = new GuiElement(clApi, "changelog", { permission: servPool.permission })
clTable = changelog.table(
icon: 'publications'
container: "changelog-placeholder"
rowSelect: "single"
)
clTables.push clTable
else
$("#publications-placeholder_tab").addClass "hidden"

View File

@ -198,7 +198,7 @@
# What execute on refresh button push
onRefresh = tblParams.onRefresh or ->
refreshFnc = ->
self.refresh = refreshFnc = ->
# Refreshes table content
tbl = $("#" + tableId).dataTable()

View File

@ -31,7 +31,7 @@
<li id="{{ cache }}_tab"><a href="#{{ cache }}" data-toggle="tab">{% endverbatim %}{% trans 'Cache' %}{% verbatim %}</a></li>
<li id="{{ groups }}_tab"><a href="#{{ groups }}" data-toggle="tab">{% endverbatim %}{% trans 'Groups' %}{% verbatim %}</a></li>
<li><a href="#{{ transports }}" data-toggle="tab">{% endverbatim %}{% trans 'Transports' %}{% verbatim %}</a></li>
<li id="{{ publications }}_tab"><a href="#{{ publications }}" data-toggle="tab">{% endverbatim %}{% trans 'Publications' %}{% verbatim %}</a></li>
<li id="{{ publications }}_tab"><a href="#{{ publications }}_pane" data-toggle="tab">{% endverbatim %}{% trans 'Publications' %}{% verbatim %}</a></li>
<li><a href="#{{ logs }}" data-toggle="tab">{% endverbatim %}{% trans 'Logs' %}{% verbatim %}</a></li>
</ul>
<div class="tab-content">
@ -57,7 +57,12 @@
</div>
<div class="tab-pane fade" id="{{ groups }}">...</div>
<div class="tab-pane fade" id="{{ transports }}">...</div>
<div class="tab-pane fade" id="{{ publications }}">...</div>
<div class="tab-pane fade" id="{{ publications }}_pane">
<div id="{{ publications }}">
</div>
<div id="{{ changelog }}">
</div>
</div>
<div class="tab-pane fade" id="{{ logs }}">...</div>
</div>
</div>