Skip to content

Commit 6729b31

Browse files
committed
comments
1 parent de419b1 commit 6729b31

File tree

7 files changed

+25
-11
lines changed

7 files changed

+25
-11
lines changed

app/controllers/api/SnapshotController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static void createSnapshot () {
7474
try {
7575
// create a dummy snapshot from which to get values
7676
Snapshot original = Base.mapper.readValue(params.get("body"), Snapshot.class);
77-
Snapshot s = VersionedDataStore.takeSnapshot(original.agencyId, original.name);
77+
Snapshot s = VersionedDataStore.takeSnapshot(original.agencyId, original.name, original.comment);
7878
s.validFrom = original.validFrom;
7979
s.validTo = original.validTo;
8080
gtx = VersionedDataStore.getGlobalTx();

app/datastore/VersionedDataStore.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static DB getRawAgencyTx (String agencyId) {
7878
}
7979

8080
/** Take a snapshot of an agency database. The snapshot will be saved in the global database. */
81-
public static Snapshot takeSnapshot (String agencyId, String name) {
81+
public static Snapshot takeSnapshot (String agencyId, String name, String comment) {
8282
AgencyTx tx = getAgencyTx(agencyId);
8383
GlobalTx gtx = getGlobalTx();
8484
int version = -1;
@@ -97,6 +97,7 @@ public static Snapshot takeSnapshot (String agencyId, String name) {
9797

9898
ret.snapshotTime = System.currentTimeMillis();
9999
ret.name = name;
100+
ret.comment = comment;
100101
ret.current = true;
101102

102103
snapshot = getSnapshotDb(agencyId, version, false);

app/models/Snapshot.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ public class Snapshot implements Cloneable, Serializable {
2424

2525
/** The name of this snapshot */
2626
public String name;
27-
27+
28+
/** The comment of this snapshot */
29+
public String comment;
30+
2831
/** ID: agency ID, version */
2932
@JsonSerialize(using=JacksonSerializers.Tuple2IntSerializer.class)
3033
@JsonDeserialize(using=JacksonSerializers.Tuple2IntDeserializer.class)

app/views/Application/snapshots.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ <h2>&{'snapshot.for'} {{ agencyName }}</h2>
2929
</p>
3030
<table class="table table-striped">
3131
<thead>
32-
<th>&{'snapshot.name'}</th><th>&{'snapshot.version'}</th><th>&{'snapshot.valid-from'}</th><th>&{'snapshot.valid-to'}</th><th>&{'snapshot.date'}</th><th>&{'snapshot.current'}<th>&{'snapshot.restore'}</th>
32+
<th>&{'snapshot.name'}</th><th>&{'snapshot.comment'}</th><th>&{'snapshot.version'}</th><th>&{'snapshot.valid-from'}</th><th>&{'snapshot.valid-to'}</th><th>&{'snapshot.date'}</th><th>&{'snapshot.current'}<th>&{'snapshot.restore'}</th>
3333
</thead>
3434
<tbody>
3535
{{#snapshots}}
3636
<tr>
3737
<td>{{name}}</td>
38+
<td>{{comment}}</td>
3839
<td>{{version}}</td>
3940
<td>{{validFrom}} <button class="btn btn-link edit-from" data-snapshot="{{id}}"><i class="icon-pencil"></i><span class="sr-only">&{'shared.button.edit'}</span></button></td>
4041
<td>{{validTo}} <button class="btn btn-link edit-to" data-snapshot="{{id}}"><i class="icon-pencil"></i><span class="sr-only">&{'shared.button.edit'}</span></button></td>
@@ -43,6 +44,7 @@ <h2>&{'snapshot.for'} {{ agencyName }}</h2>
4344
<td><button class="btn btn-link restore-snapshot" data-snapshot="{{id}}"><i class="icon-refresh"></i>&nbsp;&{'snapshot.restore'}</button></td>
4445
<td><a class="btn btn-link export-snapshot" href="api/snapshot/{{id}}.zip"><i class="icon-download"></i>&nbsp;&{'snapshot.download'}</button></td>
4546
</tr>
47+
4648
{{/snapshots}}
4749
</tbody>
4850
</table>
@@ -64,6 +66,9 @@ <h3>&{'snapshot.take-snapshot'}</h3>
6466
<label for="snapshot-name">&{'snapshot.name'}</label>
6567
<input type="text" id="snapshot-name" />
6668

69+
<label for="snapshot-name">&{'snapshot.comment'}</label>
70+
<textarea type="text" id="snapshot-comment"></textarea>
71+
6772
<label for="valid-from">&{'snapshot.valid-from'}</label>
6873
<div class="input-append date" id="valid-from">
6974
<input size="96" type="text" />

conf/messages.en

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ snapshot.for=Snapshots for
157157
snapshot.new=Take snapshot
158158
snapshot.restore=Restore snapshot
159159
snapshot.name=Name
160+
snapshot.comment=Comment
160161
snapshot.date=Snapshot date
161162
snapshot.snapshots=Snapshots
162163
snapshot.take-before-restore=You must create a snapshot of the current state of the database before you can restore a previous version.

public/javascripts/models.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ G.Trip = Backbone.Model.extend({
600600
G.Snapshot = Backbone.Model.extend({
601601
defaults: {
602602
name: null,
603+
comment: null,
603604
id: null,
604605
agencyId: null,
605606
snapshotTime: null,

public/javascripts/pages/snapshots.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,26 @@ var GtfsEditor = GtfsEditor || {};
9494
takeSnapshot: function () {
9595
var instance = this;
9696
var name = this.$('#snapshot-name').val();
97+
var comment = this.$('#snapshot-comment').val();
9798
var dfrom = this.toIso(this.$('#valid-from').data('datepicker').getDate());
9899
var dto = this.toIso(this.$('#valid-to').data('datepicker').getDate());
99100

100101
this.$('#modal-container button.snapshot').prop('disabled', true).text('Saving . . .');
101102

102103
this.collection.create({
103104
name: name,
105+
comment: comment,
104106
validFrom: dfrom,
105107
validTo: dto,
106108
agencyId: G.session.agencyId
107109
}, {
108110
wait: true,
109-
110-
111-
success: function () {
112-
this.$('#modal-container > .modal').modal('hide').remove();
113-
instance.collection.fetch({reset: true, data: {agencyId: G.session.agencyId}});
114-
}});
111+
success: function () {
112+
this.$('#modal-container > .modal').modal('hide').remove();
113+
instance.collection.fetch({reset: true, data: {agencyId: G.session.agencyId}});
114+
}
115+
}
116+
);
115117
},
116118

117119
/** convert a local date to an iso date */
@@ -134,8 +136,9 @@ var GtfsEditor = GtfsEditor || {};
134136
takeSnapshotAndRestore: function (e) {
135137
var instance = this;
136138
var name = this.$('#snapshot-name').val();
139+
var comment = this.$('#snapshot-comment').val();
137140
this.$('#modal-container button.snapshot').prop('disabled', true).text('Saving . . .');
138-
this.collection.create({name: name, agencyId: G.session.agencyId},
141+
this.collection.create({name: name, comment: comment, agencyId: G.session.agencyId},
139142
{wait: true, success: function () {
140143
var id = $(e.target).attr('data-snapshot');
141144
instance.$('.restore-snapshot').prop('disabled', true);

0 commit comments

Comments
 (0)