update project info changes on the fly

This commit is contained in:
oleg 2015-09-26 23:49:03 +03:00
parent 2958e5ff84
commit ed2e9cea4f
4 changed files with 43 additions and 4 deletions

View File

@ -38,7 +38,7 @@ Ui fixes
* speed up build points animation at ff
* current successfully streak icons at project page
* don't appear build from other project on project page
* update project info changes (avg duration, etc) on the fly - project page
* ~~update project info changes (avg duration, etc) on the fly - project page~~
* long commit comment breakes build card makeup
* ~~comment start/duration should be on same place during all steps~~

View File

@ -88,6 +88,13 @@ exports.init = function(app, callback) {
createBuildDataResource(build.id);
}
// notify about build's project change, coz building affects project
// related stat (last build date, avg build time, etc)
if (changes.completed) {
var projectsResource = app.dataio.resource('projects');
projectsResource.clientEmitSyncChange({name: build.project.name});
}
buildsResource.clientEmitSync('change', {
buildId: build.id, changes: changes
});

View File

@ -22,11 +22,11 @@ module.exports = function(app) {
res.send(app.projects);
});
resource.use('read', function(req, res) {
var getProject = function(params, callback) {
var project;
Steppy(
function() {
project = _(app.projects).findWhere(req.data);
project = _(app.projects).findWhere(params.condition);
getAvgProjectBuildDuration(project.name, this.slot());
@ -69,6 +69,37 @@ module.exports = function(app) {
project.avgBuildDuration = avgProjectBuildDuration;
project.doneBuildsStreak = doneBuildsStreak;
this.pass(project);
},
callback
);
};
// resource custom method which finds project by condition
// and emits event about it change to clients
resource.clientEmitSyncChange = function(condition) {
Steppy(
function() {
getProject({condition: condition}, this.slot());
},
function(err, project) {
resource.clientEmitSync('change', project);
},
function(err) {
console.error(
'Error during sync project change occurred:',
err.stack || err
);
}
);
};
resource.use('read', function(req, res) {
Steppy(
function() {
getProject({condition: req.data}, this.slot());
},
function(err, project) {
res.send(project);
}
);

View File

@ -10,7 +10,8 @@ define([
listenables: ProjectActions,
project: null,
onChange: function(data, action) {
onChange: function(project, action) {
this.trigger(project);
},
init: function() {