Improve UI for offline teams

pull/1/head
yflory 4 years ago
parent 4e5f8fcb99
commit 5c87c57371

@ -39,6 +39,7 @@
"dev": "DEV=1 node server.js", "dev": "DEV=1 node server.js",
"fresh": "FRESH=1 node server.js", "fresh": "FRESH=1 node server.js",
"offline": "FRESH=1 OFFLINE=1 node server.js", "offline": "FRESH=1 OFFLINE=1 node server.js",
"offlinedev": "DEV=1 OFFLINE=1 node server.js",
"package": "PACKAGE=1 node server.js", "package": "PACKAGE=1 node server.js",
"lint": "jshint --config .jshintrc --exclude-path .jshintignore . && ./node_modules/lesshint/bin/lesshint -c ./.lesshintrc ./customize.dist/src/less2/", "lint": "jshint --config .jshintrc --exclude-path .jshintignore . && ./node_modules/lesshint/bin/lesshint -c ./.lesshintrc ./customize.dist/src/less2/",
"lint:js": "jshint --config .jshintrc --exclude-path .jshintignore .", "lint:js": "jshint --config .jshintrc --exclude-path .jshintignore .",

@ -1041,6 +1041,7 @@ define([
if (!teamId) { return void cb({error: 'EINVAL'}); } if (!teamId) { return void cb({error: 'EINVAL'}); }
var team = ctx.teams[teamId]; var team = ctx.teams[teamId];
if (!team) { return void cb ({error: 'ENOENT'}); } if (!team) { return void cb ({error: 'ENOENT'}); }
if (team.offline) { return void cb({error: 'OFFLINE'}); }
if (!team.roster) { return void cb({error: 'NO_ROSTER'}); } if (!team.roster) { return void cb({error: 'NO_ROSTER'}); }
team.roster.metadata(data.metadata, function (err) { team.roster.metadata(data.metadata, function (err) {
if (err) { return void cb({error: err}); } if (err) { return void cb({error: err}); }

@ -24,6 +24,21 @@
.export_main(); .export_main();
&:not(.cp-app-team-offline) {
.cp-offline {
display: none !important;
}
}
&.cp-app-team-offline {
.cp-online {
display: none !important;
}
.cp-online-alt {
cursor: not-allowed;
opacity: 0.5;
}
}
#cp-sidebarlayout-container { #cp-sidebarlayout-container {
@media screen and (max-width: 900px) { @media screen and (max-width: 900px) {
.cp-app-drive-toolbar-leftside { .cp-app-drive-toolbar-leftside {

@ -171,12 +171,15 @@ define([
'cp-team-drive' 'cp-team-drive'
], ],
'members': [ 'members': [
'cp-team-offline',
'cp-team-roster' 'cp-team-roster'
], ],
'chat': [ 'chat': [
'cp-team-offline',
'cp-team-chat' 'cp-team-chat'
], ],
'admin': [ 'admin': [
'cp-team-offline',
'cp-team-edpublic', 'cp-team-edpublic',
'cp-team-name', 'cp-team-name',
'cp-team-avatar', 'cp-team-avatar',
@ -285,10 +288,12 @@ define([
var buildUI = APP.buildUI = function (common, team, teamAdmin) { var buildUI = APP.buildUI = function (common, team, teamAdmin) {
var $rightside = APP.$rightside; var $rightside = APP.$rightside;
$rightside.empty(); $rightside.empty();
var added = [];
var addItem = function (cssClass) { var addItem = function (cssClass) {
var item = cssClass.slice(8); var item = cssClass.slice(8);
if (typeof (create[item]) === "function") { if (typeof (create[item]) === "function" && added.indexOf(item) < 0) {
$rightside.append(create[item](common)); $rightside.append(create[item](common));
added.push(item);
} }
}; };
var categories = team ? teamCategories : mainCategories; var categories = team ? teamCategories : mainCategories;
@ -393,6 +398,14 @@ define([
var t = Messages._getKey('team_title', [Util.fixHTML(team.metadata.name)]); var t = Messages._getKey('team_title', [Util.fixHTML(team.metadata.name)]);
sframeChan.query('Q_SET_TEAM', id, function (err) { sframeChan.query('Q_SET_TEAM', id, function (err) {
if (err) { return void console.error(err); } if (err) { return void console.error(err); }
// Set editable
var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
if (team.offline) {
APP.$body.addClass('cp-app-team-offline');
} else if (!privateData.offline) {
APP.$body.removeClass('cp-app-team-offline');
}
// Change title // Change title
$('.cp-toolbar-title-value').text(t); $('.cp-toolbar-title-value').text(t);
sframeChan.event('EV_SET_TAB_TITLE', t); sframeChan.event('EV_SET_TAB_TITLE', t);
@ -534,9 +547,10 @@ define([
name: name name: name
}, function (obj) { }, function (obj) {
if (obj && obj.error) { if (obj && obj.error) {
if (obj.error === "OFFLINE") { return UI.alert(Messages.driveOfflineError); }
console.error(obj.error);
$spinner.hide(); $spinner.hide();
state = false;
if (obj.error === "OFFLINE") { return UI.alert(Messages.disconnected); } // XXX
console.error(obj.error);
return void UI.warn(Messages.error); return void UI.warn(Messages.error);
} }
// Redraw the create block // Redraw the create block
@ -700,7 +714,7 @@ define([
// Status // Status
var status = h('span.cp-team-member-status'+(data.online ? '.online' : '')); var status = h('span.cp-team-member-status'+(data.online ? '.online' : ''));
// Actions // Actions
var actions = h('span.cp-team-member-actions'); var actions = h('span.cp-online.cp-team-member-actions');
var $actions = $(actions); var $actions = $(actions);
var isMe = me && me.curvePublic === data.curvePublic; var isMe = me && me.curvePublic === data.curvePublic;
var myRole = me ? (ROLES.indexOf(me.role) || 1) : -1; var myRole = me ? (ROLES.indexOf(me.role) || 1) : -1;
@ -866,7 +880,7 @@ define([
// If you're an admin or an owner, you can invite your friends to the team // If you're an admin or an owner, you can invite your friends to the team
// TODO and acquaintances later? // TODO and acquaintances later?
if (me && (me.role === 'ADMIN' || me.role === 'OWNER')) { if (me && (me.role === 'ADMIN' || me.role === 'OWNER')) {
var invite = h('button.btn.btn-primary', Messages.team_inviteButton); var invite = h('button.cp-online.btn.btn-primary', Messages.team_inviteButton);
var inviteFriends = common.getFriends(); var inviteFriends = common.getFriends();
Object.keys(inviteFriends).forEach(function (curve) { Object.keys(inviteFriends).forEach(function (curve) {
// Keep only friends that are not already in the team and that you can contact // Keep only friends that are not already in the team and that you can contact
@ -888,7 +902,7 @@ define([
} }
if (me && (me.role !== 'OWNER')) { if (me && (me.role !== 'OWNER')) {
var leave = h('button.btn.btn-danger', Messages.team_leaveButton); var leave = h('button.cp-online.btn.btn-danger', Messages.team_leaveButton);
$(leave).click(function () { $(leave).click(function () {
UI.confirm(Messages.team_leaveConfirm, function (yes) { UI.confirm(Messages.team_leaveConfirm, function (yes) {
if (!yes) { return; } if (!yes) { return; }
@ -937,6 +951,11 @@ define([
cb(content); cb(content);
}); });
makeBlock('offline', function (common, cb, $div) {
$div.addClass('cp-offline');
cb(h('div.alert.alert-danger', Messages.disconnected));
});
makeBlock('chat', function (common, cb) { makeBlock('chat', function (common, cb) {
var container = h('div#cp-app-contacts-container.cp-app-contacts-inapp'); var container = h('div#cp-app-contacts-container.cp-app-contacts-inapp');
var content = [container]; var content = [container];
@ -985,7 +1004,7 @@ define([
'type': 'text', 'type': 'text',
'id': 'cp-settings-displayname', 'id': 'cp-settings-displayname',
'placeholder': Messages.anonymous}).appendTo($inputBlock); 'placeholder': Messages.anonymous}).appendTo($inputBlock);
var $save = $('<button>', {'class': 'btn btn-primary'}).text(Messages.settings_save).appendTo($inputBlock); var $save = $('<button>', {'class': 'cp-online-alt btn btn-primary'}).text(Messages.settings_save).appendTo($inputBlock);
var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved}).hide(); var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved}).hide();
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}).hide(); var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}).hide();
@ -998,12 +1017,20 @@ define([
teamId: APP.team teamId: APP.team
}, function (obj) { }, function (obj) {
if (obj && obj.error) { return void UI.warn(Messages.error); } if (obj && obj.error) { return void UI.warn(Messages.error); }
var oldName = obj.name;
obj.name = newName; obj.name = newName;
APP.module.execCommand('SET_TEAM_METADATA', { APP.module.execCommand('SET_TEAM_METADATA', {
teamId: APP.team, teamId: APP.team,
metadata: obj metadata: obj
}, function () { }, function (res) {
$spinner.hide(); $spinner.hide();
if (res && res.error) {
$input.val(oldName);
if (res.error === 'OFFLINE') {
return void UI.warn(Messages.disconnected);
}
return void UI.warn(Messages.error);
}
$ok.show(); $ok.show();
}); });
}); });
@ -1051,6 +1078,7 @@ define([
}); });
}); });
var $upButton = common.createButton('upload', false, data); var $upButton = common.createButton('upload', false, data);
$upButton.addClass('cp-online');
$upButton.removeProp('title'); $upButton.removeProp('title');
$upButton.text(Messages.profile_upload); $upButton.text(Messages.profile_upload);
$upButton.prepend($('<span>', {'class': 'fa fa-upload'})); $upButton.prepend($('<span>', {'class': 'fa fa-upload'}));
@ -1126,7 +1154,8 @@ define([
cb(button); cb(button);
}, true); }, true);
makeBlock('delete', function (common, cb) { makeBlock('delete', function (common, cb, $div) {
$div.addClass('cp-online');
var deleteTeam = h('button.btn.btn-danger', Messages.team_deleteButton); var deleteTeam = h('button.btn.btn-danger', Messages.team_deleteButton);
var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved}).hide(); var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved}).hide();
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}).hide(); var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}).hide();
@ -1463,7 +1492,7 @@ define([
delete mainCategories.create; delete mainCategories.create;
} }
$('body').css('display', ''); var $body = APP.$body = $('body').css('display', '');
loadMain(common); loadMain(common);
metadataMgr.onChange(function () { metadataMgr.onChange(function () {
@ -1490,6 +1519,7 @@ define([
var onDisconnect = function (teamId) { var onDisconnect = function (teamId) {
if (APP.team && teamId && APP.team !== teamId) { return; } if (APP.team && teamId && APP.team !== teamId) { return; }
setEditable(false); setEditable(false);
$body.addClass('cp-app-team-offline');
if (APP.team && driveAPP.refresh) { driveAPP.refresh(); } if (APP.team && driveAPP.refresh) { driveAPP.refresh(); }
toolbar.failed(); toolbar.failed();
UIElements.disconnectAlert(); UIElements.disconnectAlert();
@ -1497,6 +1527,7 @@ define([
var onReconnect = function (teamId) { var onReconnect = function (teamId) {
if (APP.team && teamId && APP.team !== teamId) { return; } if (APP.team && teamId && APP.team !== teamId) { return; }
setEditable(true); setEditable(true);
$body.removeClass('cp-app-team-offline');
if (APP.team && driveAPP.refresh) { driveAPP.refresh(); } if (APP.team && driveAPP.refresh) { driveAPP.refresh(); }
toolbar.reconnecting(); toolbar.reconnecting();
UIElements.reconnectAlert(); UIElements.reconnectAlert();

Loading…
Cancel
Save