Version 0.0.2 - Refresh button; Multiple Pages; Configfile for Repooptions and Tokens
This commit is contained in:
parent
e0998f4aa2
commit
ff29374fe2
@ -4,6 +4,14 @@ All notable changes to the "gitea-vscode" extension will be documented in this f
|
||||
|
||||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
||||
|
||||
## [0.0.2] - 2019-04-10
|
||||
### Added:
|
||||
- Configfile with token and repo properties
|
||||
- Refresh button (Await HTTP Request)
|
||||
- Multiple Pages
|
||||
### Removed:
|
||||
- Interval for updating
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Initial release
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -251,6 +251,11 @@
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"configparser": {
|
||||
"version": "0.2.6",
|
||||
"resolved": "https://registry.npmjs.org/configparser/-/configparser-0.2.6.tgz",
|
||||
"integrity": "sha512-u0k0Xs6CBDUcCfHHX0rMgZ4QoRQm6V3sb9AuNYkKK+4kwTlBophxBQjuVbI61vTQSRTDx4Ds7CWDQTGusf5q0A=="
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
|
25
package.json
25
package.json
@ -3,7 +3,7 @@
|
||||
"displayName": "Gitea-VSCode",
|
||||
"description": "Gitea Issue Tracker for vs-code",
|
||||
"publisher": "IJustDev",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"engines": {
|
||||
"vscode": "^1.32.0"
|
||||
},
|
||||
@ -36,14 +36,26 @@
|
||||
{
|
||||
"command": "giteaIssues.openIssue",
|
||||
"title": "Show"
|
||||
},
|
||||
{
|
||||
"command": "giteaIssues.refreshIssues",
|
||||
"title": "Refresh",
|
||||
"icon": {
|
||||
"dark": "resources/dark/refresh.svg",
|
||||
"light": "resources/light/refresh.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "giteaIssues.initRepo",
|
||||
"title": "Initialize Gitea-Issue Tracker"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"view/item/context": [
|
||||
"view/title": [
|
||||
{
|
||||
"command": "giteaIssues.openIssue",
|
||||
"group": "inline",
|
||||
"when": "view == open-issues && viewItem == issue"
|
||||
"command": "giteaIssues.refreshIssues",
|
||||
"group": "navigation",
|
||||
"when": "view == open-issues"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -64,6 +76,7 @@
|
||||
"vscode": "^1.1.28"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0"
|
||||
"axios": "^0.18.0",
|
||||
"configparser": "^0.2.6"
|
||||
}
|
||||
}
|
1
resources/dark/refresh.svg
Normal file
1
resources/dark/refresh.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#2D2D30"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#C5C5C5"/></svg>
|
After Width: | Height: | Size: 986 B |
1
resources/light/refresh.svg
Normal file
1
resources/light/refresh.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#F6F6F6"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#424242"/></svg>
|
After Width: | Height: | Size: 986 B |
37
src/configurationProvider.ts
Normal file
37
src/configurationProvider.ts
Normal file
@ -0,0 +1,37 @@
|
||||
const ConfigParser = require("configparser");
|
||||
|
||||
// import * as path from "path";
|
||||
const path = require("path");
|
||||
import * as fs from "fs";
|
||||
|
||||
export class RepositoryInformationManager {
|
||||
public token(rootPath: string | undefined) {
|
||||
const config = new ConfigParser();
|
||||
config.read(path.join(rootPath as string, "/.gitea/config.ini"));
|
||||
return config.get("PRIVATE", "token");
|
||||
}
|
||||
public repoApiUrl(rootPath: string | undefined) {
|
||||
const config = new ConfigParser();
|
||||
config.read(rootPath + "/.gitea/config.ini");
|
||||
const domain = config.get("REPO", "domain");
|
||||
const repo_owner = config.get("REPO", "repo_owner");
|
||||
const repo_name = config.get("REPO", "repo_name");
|
||||
return "http://" + domain + "/api/v1/repos/" + repo_owner + "/" + repo_name + "/issues";
|
||||
}
|
||||
public saveRepoInformation(rootPath: string | undefined, repoInformations: any) {
|
||||
const file_path = path.join(rootPath as string, ".gitea/config.ini");
|
||||
try {
|
||||
fs.mkdirSync(path.join(rootPath as string, ".gitea/"));
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
const config = new ConfigParser();
|
||||
config.addSection("PRIVATE");
|
||||
config.addSection("REPO");
|
||||
config.set("PRIVATE", "token", repoInformations.token);
|
||||
config.set("REPO", "domain", repoInformations.domain);
|
||||
config.set("REPO", "repo_owner", repoInformations.repo_owner);
|
||||
config.set("REPO", "repo_name", repoInformations.repo_name);
|
||||
config.write(file_path);
|
||||
}
|
||||
}
|
@ -3,27 +3,65 @@ import { html } from './template.html';
|
||||
// Import the module and reference it with the alias vscode in your code below
|
||||
import * as vscode from 'vscode';
|
||||
import { IssueProvider, Issue } from './issueProvider';
|
||||
import { RepositoryInformationManager } from './configurationProvider';
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
const issueProvider = new IssueProvider();
|
||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||||
// This line of code will only be executed once when your extension is activated
|
||||
vscode.window.registerTreeDataProvider('open-issues', issueProvider);
|
||||
vscode.commands.registerCommand('giteaIssues.openIssue', (issue: Issue) => {
|
||||
const panel = vscode.window.createWebviewPanel('issue', issue.label,
|
||||
vscode.ViewColumn.Active,
|
||||
{});
|
||||
// panel.webview.html = "<h1>Issue #" + issue.issueId + "!</h1>";
|
||||
// panel.webview.html += "<p>Status: " + issue.issueState + "</p>";
|
||||
// panel.webview.html += "<p>Assignees: " + issue.assignee + "</p>";
|
||||
// panel.webview.html += "<p>" + issue.body + "</p>";
|
||||
panel.webview.html = html(issue);
|
||||
});
|
||||
const issueProvider = new IssueProvider();
|
||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||||
// This line of code will only be executed once when your extension is activated
|
||||
|
||||
// The command has been defined in the package.json file
|
||||
// Now provide the implementation of the command with registerCommand
|
||||
// The commandId parameter must match the command field in package.json
|
||||
let disposable = vscode.commands.registerCommand('giteaIssues.initRepo', async () => {
|
||||
if (vscode.workspace.rootPath === undefined) {
|
||||
return vscode.window.showErrorMessage("No project opened!");
|
||||
}
|
||||
let Token, Domain, Owner, Name;
|
||||
await vscode.window.showInputBox({
|
||||
placeHolder: "Enter your gitea token here",
|
||||
}).then(token => {
|
||||
Token = token === undefined ? "" : token;
|
||||
});
|
||||
await vscode.window.showInputBox({
|
||||
placeHolder: "Domain from your gitea server without 'https://'",
|
||||
}).then(domain => {
|
||||
Domain = domain === undefined ? "" : domain;
|
||||
});
|
||||
await vscode.window.showInputBox({
|
||||
placeHolder: "Repository Owner",
|
||||
}).then(owner => {
|
||||
Owner = owner === undefined ? "" : owner;
|
||||
});
|
||||
await vscode.window.showInputBox({
|
||||
placeHolder: "Repository Name",
|
||||
}).then(name => {
|
||||
Name = name === undefined ? "" : name;
|
||||
});
|
||||
const repoInfo = {
|
||||
token: Token,
|
||||
domain: Domain,
|
||||
repo_owner: Owner,
|
||||
repo_name: Name,
|
||||
};
|
||||
const rpim = new RepositoryInformationManager();
|
||||
rpim.saveRepoInformation(vscode.workspace.rootPath, repoInfo);
|
||||
});
|
||||
context.subscriptions.push(disposable);
|
||||
|
||||
vscode.window.registerTreeDataProvider('open-issues', issueProvider);
|
||||
vscode.commands.registerCommand('giteaIssues.openIssue', (issue: Issue) => {
|
||||
const panel = vscode.window.createWebviewPanel('issue', issue.label,
|
||||
vscode.ViewColumn.Active,
|
||||
{});
|
||||
panel.webview.html = html(issue);
|
||||
});
|
||||
|
||||
vscode.commands.registerCommand('giteaIssues.refreshIssues', () => {
|
||||
issueProvider.refresh();
|
||||
});
|
||||
|
||||
// The command has been defined in the package.json file
|
||||
// Now provide the implementation of the command with registerCommand
|
||||
// The commandId parameter must match the command field in package.json
|
||||
}
|
||||
|
||||
// this method is called when your extension is deactivated
|
||||
|
@ -1,47 +1,67 @@
|
||||
import * as vscode from "vscode";
|
||||
import axios from "axios";
|
||||
import { RepositoryInformationManager } from "./configurationProvider";
|
||||
|
||||
export class IssueProvider implements vscode.TreeDataProvider<Issue> {
|
||||
|
||||
private _onDidChangeTreeData: vscode.EventEmitter<Issue | undefined> = new vscode.EventEmitter<Issue | undefined>();
|
||||
readonly onDidChangeTreeData: vscode.Event<Issue | undefined> = this._onDidChangeTreeData.event;
|
||||
|
||||
issueList: any[] = [];
|
||||
issueList: Issue[] = [];
|
||||
|
||||
constructor() {
|
||||
this.getChildrenAsync();
|
||||
const id = setInterval(() => {
|
||||
if (this.issueList.length === 0) {
|
||||
this._onDidChangeTreeData.fire();
|
||||
} else {
|
||||
clearInterval(id);
|
||||
}
|
||||
}, 1 * 10);
|
||||
setInterval(() => {
|
||||
this._onDidChangeTreeData.fire();
|
||||
}, 10 * 1000);
|
||||
async refresh() {
|
||||
await this.getChildrenAsync();
|
||||
this._onDidChangeTreeData.fire();
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
|
||||
getTreeItem(element: Issue): vscode.TreeItem | Thenable<vscode.TreeItem> {
|
||||
return element;
|
||||
}
|
||||
|
||||
async getChildrenAsync() {
|
||||
this.issueList = [];
|
||||
const repoMng = new RepositoryInformationManager();
|
||||
const repoUri = repoMng.repoApiUrl(vscode.workspace.rootPath);
|
||||
console.log(repoUri);
|
||||
const token = repoMng.token(vscode.workspace.rootPath);
|
||||
let stop = false;
|
||||
for (let i = 0; i !== 10; i++) {
|
||||
await axios.get("http://git.mypenink.com/api/v1/repos/MyPenInk/Frontend/issues?page=" + i, { headers: { Authorization: "token baab9fb94100c3a4f22213a0d0d0b8ce03c55bec" } }).then(res => {
|
||||
await axios.get(repoUri + "?page=" + i, { headers: { Authorization: "token " + token } }).then(res => {
|
||||
for (const issue of res.data) {
|
||||
const title = issue["title"];
|
||||
const id = issue["number"];
|
||||
let isAlreadyInList = false;
|
||||
this.issueList.forEach((issueOfList) => {
|
||||
if (id === issueOfList.issueId) {
|
||||
isAlreadyInList = true;
|
||||
}
|
||||
});
|
||||
if (isAlreadyInList) {
|
||||
continue;
|
||||
}
|
||||
const title = issue["title"];
|
||||
const body = issue["body"];
|
||||
const state = issue["state"];
|
||||
const assignee = issue["assignee"] === null ? "None" : issue["assignee"]["username"];
|
||||
const issueForList = new Issue("#" + id + " - " + title, id, body, state, assignee, "Frontend", vscode.TreeItemCollapsibleState.None);
|
||||
const tmpIssue = new Issue("#" + id + " - " + title, id, body, state, assignee, "Frontend", vscode.TreeItemCollapsibleState.None);
|
||||
const issueForList = new Issue(tmpIssue.label, tmpIssue.issueId, tmpIssue.body, tmpIssue.issueState,
|
||||
tmpIssue.assignee, tmpIssue.firstlabel, tmpIssue.collapsibleState, {
|
||||
command: 'giteaIssues.openIssue',
|
||||
title: '',
|
||||
arguments: [tmpIssue],
|
||||
});
|
||||
this.issueList.push(issueForList);
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
stop = true;
|
||||
vscode.window.showErrorMessage("Can't fetch issues; HTTP Error!");
|
||||
return;
|
||||
});
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(this.issueList);
|
||||
|
Loading…
Reference in New Issue
Block a user