Skip to content

Commit

Permalink
refactor sync status and last sync date notice
Browse files Browse the repository at this point in the history
  • Loading branch information
irahopkinson committed Dec 28, 2016
1 parent 3580381 commit 3d90a66
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ angular.module('lexicon.services')

// UI strings corresponding to SRState in the LfMerge state file.
// SRStates with an "LF_" prefix are languageforge overrides
this.syncNotice = function syncNotice(projectSettings) {
this.syncStateNotice = function syncStateNotice() {
if (angular.isUndefined(status)) return;

switch (status.SRState) {
Expand All @@ -204,18 +204,38 @@ angular.module('lexicon.services')
return 'Pending';
case 'IDLE':
case 'SYNCED':
return 'Synced';
case 'LF_UNSYNCED':
return 'Un-synced';
case 'HOLD':
return 'On hold';

// Undefined initial state
default:
return '';
}
};

this.lastSyncNotice = function lastSyncNotice() {
if (angular.isUndefined(status)) return;

switch (status.SRState) {
case 'SYNCING':
case 'PENDING':
case 'IDLE':
case 'SYNCED':
case 'LF_UNSYNCED':
case 'HOLD':
if (angular.isDefined(projectSettings) &&
angular.isDefined(projectSettings.lastSyncedDate)
) {
return 'Last sync: ' + $filter('relativetime')(projectSettings.lastSyncedDate);
return 'Last sync was ' + $filter('relativetime')(projectSettings.lastSyncedDate);
} else {
return 'Synced';
return '';
}

case 'LF_UNSYNCED':
return 'Un-synced';
case 'HOLD':
return 'On hold';
case 'CLONING':
case 'LF_CLONING':

// Undefined initial state
default:
Expand Down Expand Up @@ -318,7 +338,7 @@ angular.module('lexicon.services')
};

// For now, we generate the same S/R string based on the SRState
this.cloneNotice = this.syncNotice;
this.cloneNotice = this.syncStateNotice;

this.cancelAllStatusTimers = function cancelAllStatusTimers() {
this.cancelSyncStatusTimer();
Expand Down
3 changes: 2 additions & 1 deletion src/angular-app/languageforge/lexicon/views/sync.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
data-ng-disabled="disableSyncButton()"
data-ng-click="syncProject()">
<i class="fa fa-cloud-upload fa-lg text-info"></i>{{'Send/Receive' | translate}}</button>
<div class="muted" style="margin-right: 10px">{{syncNotice(projectSettings)}}</div>
<div class="muted" style="margin-right: 10px">{{syncStateNotice()}}</div>
<div class="muted" style="margin-right: 10px">{{lastSyncNotice()}}</div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions src/angular-app/languageforge/lexicon/views/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ angular.module('lexicon.sync', ['ui.bootstrap', 'bellows.services', 'palaso.ui.n
rights, sendReceiveApi, sendReceive) {
lexProjectService.setBreadcrumbs('sync', 'Synchronize');

$scope.syncNotice = sendReceive.syncNotice;
$scope.projectSettings = sessionService.session.projectSettings;
$scope.syncStateNotice = sendReceive.syncStateNotice;
$scope.lastSyncNotice = sendReceive.lastSyncNotice;

$scope.showSyncButton = function showSyncButton() {
return !sessionService.session.project.isArchived && rights.canEditUsers() &&
Expand Down

0 comments on commit 3d90a66

Please sign in to comment.