fixing column endings, sort
This commit is contained in:
parent
eb8e3f8d79
commit
0702fea1ed
13
src/api.ts
13
src/api.ts
|
|
@ -138,6 +138,19 @@ export async function fetchIssues(
|
|||
})
|
||||
);
|
||||
|
||||
// Apply local sorting as the Forgejo API does not inherently sort via endpoint parameters
|
||||
issues.sort((a, b) => {
|
||||
let diff = 0;
|
||||
if (options.sortField === 'created') {
|
||||
diff = new Date(b.created_at).getTime() - new Date(a.created_at).getTime();
|
||||
} else if (options.sortField === 'updated') {
|
||||
diff = new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime();
|
||||
} else if (options.sortField === 'comments') {
|
||||
diff = b.comments - a.comments;
|
||||
}
|
||||
return options.sortOrder === 'desc' ? diff : -diff;
|
||||
});
|
||||
|
||||
return { issues, totalCount };
|
||||
} catch (error: any) {
|
||||
if (error.response) {
|
||||
|
|
|
|||
|
|
@ -1181,7 +1181,9 @@ export class TuiEngine {
|
|||
const lineIndex = r + this.state.detailScrollOffset;
|
||||
if (lineIndex < contentLines.length) {
|
||||
const line = contentLines[lineIndex];
|
||||
console.log(borderCh + ' ' + line.padEnd(cols - 4) + ' ' + borderCh);
|
||||
const linePlainLen = stripAnsi(line).length;
|
||||
const padding = Math.max(0, cols - 4 - linePlainLen);
|
||||
console.log(borderCh + ' ' + line + ' '.repeat(padding) + ' ' + borderCh);
|
||||
} else {
|
||||
console.log(borderCh + ' '.repeat(cols - 2) + borderCh);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import axios from 'axios';
|
||||
|
||||
const configPath = os.homedir() + '/.config/fjtui/fjtui.json';
|
||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
|
||||
axios.post(config.url + '/api/v1/repos/' + config.repo + '/issues', {
|
||||
title: 'Second issue',
|
||||
body: 'Body'
|
||||
}, {
|
||||
headers: { 'Authorization': 'token ' + config.token }
|
||||
}).then(r => console.log('created')).catch(e => console.error(e.message));
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import axios from 'axios';
|
||||
|
||||
const configPath = os.homedir() + '/.config/fjtui/fjtui.json';
|
||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
|
||||
axios.get(config.url + '/api/v1/repos/' + config.repo + '/issues', {
|
||||
headers: { 'Authorization': 'token ' + config.token },
|
||||
params: { sort: 'oldest' }
|
||||
}).then(r => console.log(r.data.map(i => i.id + ' ' + i.created_at))).catch(e => console.error(e.message));
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import axios from 'axios';
|
||||
|
||||
const configPath = os.homedir() + '/.config/fjtui/fjtui.json';
|
||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
|
||||
axios.get(config.url + '/api/v1/repos/' + config.repo + '/issues?state=all', {
|
||||
headers: { 'Authorization': 'token ' + config.token }
|
||||
}).then(r => console.log('NO SORT: ' + r.data.map(i => i.id).join(', '))).catch(e => console.error(e.message));
|
||||
|
||||
axios.get(config.url + '/api/v1/repos/' + config.repo + '/issues?state=all&sort=oldest', {
|
||||
headers: { 'Authorization': 'token ' + config.token }
|
||||
}).then(r => console.log('OLDEST: ' + r.data.map(i => i.id).join(', '))).catch(e => console.error(e.message));
|
||||
Loading…
Reference in New Issue