1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2026-07-30 08:33:51 +00:00

[Imapsync] Add token status badge for user login flow

This commit is contained in:
FreddleSpl0it
2026-07-21 12:01:35 +02:00
parent 6f81778e5e
commit f4f9f72395
6 changed files with 34 additions and 1 deletions
+14
View File
@@ -454,6 +454,20 @@ function imapsyncAuthDisplay(item) {
return out;
}
// Per-syncjob OAuth token badge for authorization_code sources: the token is issued
// per user (via "connect"), so a job can be pending / issued / failed. Returns '' for
// non-XOAUTH2 or client_credentials jobs (those have no per-user token).
function imapsyncJobTokenBadge(item) {
if (item.source_auth_type !== 'XOAUTH2' || item.source_oauth_flow !== 'authorization_code') return '';
if (item.user_token_error) {
return '<span class="badge bg-danger" title="' + escapeHtml(item.user_token_error) + '">' + lang.syncjobs.token_state_failed + '</span>';
}
if (item.user_token_expires && item.user_token_expires * 1000 > Date.now()) {
return '<span class="badge bg-success" title="' + lang.syncjobs.source_token_status + ': ' + new Date(item.user_token_expires * 1000).toLocaleString() + '">' + lang.syncjobs.token_state_issued + '</span>';
}
return '<span class="badge bg-warning">' + lang.syncjobs.token_state_pending + '</span>';
}
// (Re)build every imapsync-source dropdown from the ACL-filtered API (fresh on modal open)
function populateImapsyncSourceSelects() {
$.get("/api/v1/get/syncjob_source/all", function(sources) {
+2
View File
@@ -2174,6 +2174,8 @@ jQuery(function($){
item.exclude = '<code>' + escapeHtml(item.exclude) + '</code>';
}
item.server_w_port = escapeHtml(item.user1) + '@' + escapeHtml(item.source_name || '?') + ' (' + escapeHtml(item.source_host || '?') + ':' + escapeHtml(item.source_port || '?') + ')';
var tokenBadge = imapsyncJobTokenBadge(item);
if (tokenBadge) item.server_w_port += '<div class="mt-1">' + tokenBadge + '</div>';
item.action = '<div class="btn-group">' +
'<a href="/edit/syncjob/' + item.id + '" class="btn btn-sm btn-xs-lg btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +
'<a href="#" data-action="delete_selected" data-id="single-syncjob" data-api-url="delete/syncjob" data-item="' + item.id + '" class="btn btn-sm btn-xs-lg btn-xs-half btn-danger"><i class="bi bi-trash"></i> ' + lang.remove + '</a>' +
+2
View File
@@ -286,6 +286,8 @@ jQuery(function($){
item.exclude = '<code>' + escapeHtml(item.exclude) + '</code>';
}
item.server_w_port = escapeHtml(item.user1 + '@' + (item.source_name || '?') + ' (' + (item.source_host || '?') + ':' + (item.source_port || '?') + ')');
var tokenBadge = imapsyncJobTokenBadge(item);
if (tokenBadge) item.server_w_port += '<div class="mt-1">' + tokenBadge + '</div>';
if (acl_data.syncjobs === 1) {
item.action = '<div class="btn-group">' +
'<a href="/edit/syncjob/' + item.id + '" class="btn btn-xs btn-xs-half btn-secondary"><i class="bi bi-pencil-fill"></i> ' + lang.edit + '</a>' +