'); 52 | o.document.write((response.logs as string[]).join('')); 53 | o.document.write(''); 54 | } 55 | } 56 | } 57 | 58 | //https://stackoverflow.com/questions/8211744/convert-time-interval-given-in-seconds-into-more-human-readable-form 59 | function millisecondToHumanReadable(milliseconds: number): string { 60 | const seconds = milliseconds / 1000; 61 | const levels = [ 62 | [Math.floor(seconds / 31557600), 'years'], 63 | [Math.floor((seconds % 31557600) / 86400), 'days'], 64 | [Math.floor(((seconds % 31557600) % 86400) / 3600), 'hours'], 65 | [Math.floor((((seconds % 31557600) % 86400) % 3600) / 60), 'minutes'] 66 | ]; 67 | const calcSeconds = [ 68 | Math.floor((((seconds % 31536000) % 86400) % 3600) % 60), 69 | 'seconds' 70 | ]; 71 | let returntext = ''; 72 | 73 | for (let i = 0, max = levels.length; i < max; i++) { 74 | if (levels[i][0] === 0) continue; 75 | returntext += 76 | ' ' + 77 | levels[i][0] + 78 | ' ' + 79 | (levels[i][0] === 1 80 | ? (levels[i][1] as string).substr( 81 | 0, 82 | (levels[i][1] as string).length - 1 83 | ) 84 | : levels[i][1]); 85 | } 86 | returntext = returntext.trim(); 87 | if (returntext === '') { 88 | returntext = 89 | calcSeconds[0] + 90 | ' ' + 91 | (calcSeconds[0] === 1 92 | ? (calcSeconds[1] as string).substr( 93 | 0, 94 | (calcSeconds[1] as string).length - 1 95 | ) 96 | : calcSeconds[1]); 97 | } 98 | return returntext + ' ago'; 99 | } 100 | 101 | export const Action: React.FC
118 | {action.statusTime && 119 | millisecondToHumanReadable( 120 | new Date().getTime() - new Date(action.statusTime).getTime() 121 | )} 122 |
123 |Repository: {action.repo}
} 138 | {action.branch &&Branch: {action.branch}
} 139 | {action.details && ( 140 |