mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-26 04:08:21 +01:00
merge + fix conflicy
This commit is contained in:
commit
e81d6ea0c6
@ -6,6 +6,7 @@ The editor functionality can be extended by its extension mechanism.
|
||||
Extension can be developed/released/isntalled by the editor itself.
|
||||
|
||||
### Change logs
|
||||
- 0.2.2-b: Support horizotal scrolling on horizotal tabbars
|
||||
- 0.2.1-b: Add open file to right, editor actions are only attached to code editor
|
||||
- 0.2.0-b: Support diff mode in editor + fix new Monaco version compatible bug
|
||||
- 0.1.17-b: Fix extension keybinding bug with the new monaco editor
|
||||
|
@ -23,7 +23,7 @@
|
||||
</afx-tab-container>
|
||||
</afx-vbox>
|
||||
<afx-resizer data-width = "3" ></afx-resizer>
|
||||
<afx-vbox>
|
||||
<afx-vbox data-id="editor-main-container">
|
||||
<afx-hbox>
|
||||
<afx-vbox data-id="left-panel">
|
||||
<afx-tab-bar closable="true" data-height="26" data-id = "left-tabbar"></afx-tab-bar>
|
||||
|
@ -1,20 +0,0 @@
|
||||
# Antedit
|
||||
Simple yet powerful text/code editor based on the Monaco editor,
|
||||
the editor that powers VS Code.
|
||||
|
||||
The editor functionality can be extended by its extension mechanism.
|
||||
Extension can be developed/released/isntalled by the editor itself.
|
||||
|
||||
### Change logs
|
||||
- 0.2.1-b: Add open file to right, editor actions are only attached to code editor
|
||||
- 0.2.0-b: Support diff mode in editor + fix new Monaco version compatible bug
|
||||
- 0.1.17-b: Fix extension keybinding bug with the new monaco editor
|
||||
- 0.1.16-b: use the new version of monaco editor
|
||||
- 0.1.14-b: improve output log display
|
||||
- 0.1.13-b: Allow file upload in file view, add menu context in tabbar
|
||||
- 0.1.12-b: fix recent files not adding correctly
|
||||
- 0.1.11-b: fix file type parsing from path
|
||||
- 0.1.10-b: Antedit now has it own extension manager
|
||||
- 0.1.9-a: Allow output text selection
|
||||
- 0.1.8-a: Allow to change language mode
|
||||
- 0.1.7-a: Add keyboard shortcut support to extension actions
|
@ -1,19 +0,0 @@
|
||||
(function() {
|
||||
// import the CodePad application module
|
||||
const App = this.OS.application.Antedit;
|
||||
|
||||
// define the extension
|
||||
App.extensions.{0} = class {0} extends App.EditorBaseExtension {
|
||||
constructor(app) {
|
||||
super("{0}",app);
|
||||
}
|
||||
|
||||
test() {
|
||||
return this.notify("Test action is invoked");
|
||||
}
|
||||
|
||||
cleanup() {}
|
||||
|
||||
};
|
||||
|
||||
}).call(this);
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"javascripts": ["{0}.js"],
|
||||
"copies": [],
|
||||
"meta": {
|
||||
"name": "{0}",
|
||||
"text": "{0}",
|
||||
"version": "0.0.1-a",
|
||||
"actions" : [
|
||||
{
|
||||
"text": "__(Example action)",
|
||||
"name": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "EditorExtensionMaker",
|
||||
"text": "Antedit Extension",
|
||||
"version": "0.0.1-a",
|
||||
"actions" : [
|
||||
{
|
||||
"text": "__(New Extension)",
|
||||
"name": "create"
|
||||
},
|
||||
{
|
||||
"text": "__(Build)",
|
||||
"name": "build"
|
||||
},
|
||||
{
|
||||
"text": "__(Run)",
|
||||
"name": "run"
|
||||
},
|
||||
{
|
||||
"text": "__(Build release)",
|
||||
"name": "release"
|
||||
},
|
||||
{
|
||||
"text": "__(Install from file)",
|
||||
"name": "install"
|
||||
},
|
||||
{
|
||||
"text": "__(Install from URL)",
|
||||
"name": "installFromURL"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,171 +0,0 @@
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container
|
||||
{
|
||||
/*border-top: 1px solid #272822;*/
|
||||
overflow: hidden;
|
||||
overflow-x: auto;
|
||||
font-size: 12px;
|
||||
scrollbar-width: none;
|
||||
/*scrollbar-color: #656565 transparent;*/
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container::-webkit-scrollbar {
|
||||
height: 0;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container::-webkit-scrollbar-thumb {
|
||||
background-color: #656565;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container > ul
|
||||
{
|
||||
width: intrinsic;
|
||||
width: -moz-max-content;
|
||||
width: -webkit-max-content;
|
||||
width: max-content;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view ul afx-list-item:nth-child(even) li.selected,
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container > ul > afx-list-item > li.selected{
|
||||
background-color:#272822;
|
||||
color:white;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view afx-list-view i.closable:before {
|
||||
color:#afafaf;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view ul afx-list-item:nth-child(even) li,
|
||||
afx-app-window[data-id = "antedit"] afx-tab-bar> afx-list-view > div.list-container > ul li{
|
||||
background-color:#333333;
|
||||
color:#afafaf;
|
||||
border-radius: 0;
|
||||
border: 0;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
padding-right: 20px;
|
||||
border-right: 1px solid #272822;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-tab-container[data-id="sidebar-tab-container"] afx-tab-bar> afx-list-view > div.list-container {
|
||||
background-color: #333333;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-tab-container[data-id="sidebar-tab-container"] afx-tab-bar> afx-list-view > div.list-container > ul li{
|
||||
float: none;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] .afx-window-wrapper afx-vbox[data-id = "sidebar"]{
|
||||
background-color:#272822;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] div.afx-window-content {
|
||||
background-color:#333333;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-resizer {
|
||||
background-color:#272822;
|
||||
border-right: 1px solid #656565;
|
||||
border-bottom: 1px solid #656565;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] .bottom-tab-content {
|
||||
background-color:#272822;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] .afx-window-wrapper afx-tree-view{
|
||||
color: white;
|
||||
padding: 0;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] .afx-window-wrapper afx-tree-view afx-tree-view-item ul li{
|
||||
padding-left: 10px;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] .afx-window-wrapper .afx_tree_item_selected ul{
|
||||
background-color: #116cd6;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-file-view afx-tree-view .afx-tree-view-item:before{
|
||||
color: white;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] .afx-window-wrapper div[data-id="statctn"]{
|
||||
color: white;
|
||||
background-color: #007acc;
|
||||
padding-right: 10px;
|
||||
padding-top: 5px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] .afx-window-wrapper div[data-id="statctn"] afx-label {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] div[data-id="output-tab"] {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] div[data-id="output-tab"] pre {
|
||||
margin: 3px;
|
||||
white-space: pre-wrap; /* css-3 */
|
||||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] div[data-id="output-tab"] pre.code-pad-log-error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] div[data-id="output-tab"] pre.code-pad-log-warn {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] div[data-id="output-tab"] pre.code-pad-log-info {
|
||||
color: white;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-button[ data-id="logger-clear" ] button{
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-antedit-ext-list-item {
|
||||
color: white !important;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-antedit-ext-list-item afx-label i.label-text{
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-antedit-ext-list-item p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-left:15px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-antedit-ext-list-item p[data-id="ext-list-item-b-p"] {
|
||||
text-align: right;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "antedit"] afx-antedit-ext-list-item > li {
|
||||
background-color: transparent !important;
|
||||
padding-right: 5px !important;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-antedit-ext-list-item > li.selected {
|
||||
background-color: #116cd6 !important;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] afx-antedit-ext-list-item button {
|
||||
height: 22px;
|
||||
width: 24px;
|
||||
padding: 0 !important;
|
||||
}
|
||||
afx-app-window[data-id = "antedit"] input[data-id="txt_ext_search"] {
|
||||
background-color: transparent;
|
||||
border-radius: 0;
|
||||
border-color: #333;
|
||||
color: white;
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,89 +0,0 @@
|
||||
{
|
||||
"pkgname": "Antedit",
|
||||
"app": "Antedit",
|
||||
"name": "Antos Editor",
|
||||
"description": "Antos text/code editor",
|
||||
"info": {
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.2.1-b",
|
||||
"category": "Development",
|
||||
"iconclass": "bi bi-journal-code",
|
||||
"mimes": [
|
||||
"text/.*",
|
||||
"[^/]*/json.*",
|
||||
"[^/]*/.*ml",
|
||||
"[^/]*/javascript",
|
||||
"dir"
|
||||
],
|
||||
"dependencies": [
|
||||
"MonacoCore@0.33.0-r"
|
||||
],
|
||||
"locale": {
|
||||
"en_GB": {
|
||||
"Output": "Output",
|
||||
"Close tab": "Close tab",
|
||||
"Close without saving ?": "Close without saving ?",
|
||||
"Unable to open: {0}": "Unable to open: {0}",
|
||||
"Unable to save file: {0}": "Unable to save file: {0}",
|
||||
"Save as": "Save as",
|
||||
"New extension at": "New extension at",
|
||||
"Select extension archive": "Select extension archive",
|
||||
"Current folder is not found": "Current folder is not found",
|
||||
"Select build directory": "Select build directory",
|
||||
"Unable to read meta-data": "Unable to read meta-data",
|
||||
"ExtensionName": "ExtensionName",
|
||||
"Files generated in {0}": "Files generated in {0}",
|
||||
"Unable to build extension:{0}": "Unable to build extension:{0}",
|
||||
"Unable to read meta-data:{0}": "Unable to read meta-data:{0}",
|
||||
"Invalid extension meta-data": "Invalid extension meta-data",
|
||||
"Unable to run extension:{0}": "Unable to run extension:{0}",
|
||||
"Archive created at {0}": "Archive created at {0}",
|
||||
"Unable to read meta-data: {0}": "Unable to read meta-data: {0}",
|
||||
"Extension installed": "Extension installed",
|
||||
"Unable to install extension: {0}": "Unable to install extension: {0}",
|
||||
"Enter URI": "Enter URI",
|
||||
"Please enter extension URI:": "Please enter extension URI:",
|
||||
"Unable to create extension directories: {0}": "Unable to create extension directories: {0}",
|
||||
"New file": "New file",
|
||||
"New folder": "New folder",
|
||||
"Rename": "Rename",
|
||||
"Delete": "Delete",
|
||||
"File name": "File name",
|
||||
"Folder name": "Folder name",
|
||||
"Quit": "Quit",
|
||||
"View": "View",
|
||||
"Toggle bottom bar": "Toggle bottom bar",
|
||||
"Toggle split view": "Toggle split view",
|
||||
"Unable to move file/folder": "Unable to move file/folder",
|
||||
"Editor": "Editor",
|
||||
"Change language mode": "Change language mode",
|
||||
"Select language": "Select language",
|
||||
"Unable to disable split view: Please save changes of modified files on the right panel": "Unable to disable split view: Please save changes of modified files on the right panel",
|
||||
"File": "File",
|
||||
"New": "New",
|
||||
"Open Recent": "Open Recent",
|
||||
"Open": "Open",
|
||||
"Open Folder": "Open Folder",
|
||||
"Save": "Save",
|
||||
"Fail to create: {0}": "Fail to create: {0}",
|
||||
"Fail to rename: {0}": "Fail to rename: {0}",
|
||||
"Fail to delete: {0}": "Fail to delete: {0}",
|
||||
"Open file": "Open file",
|
||||
"Open folder": "Open folder",
|
||||
"Cannot load extension meta data": "Cannot load extension meta data",
|
||||
"unable to load extension: {0}": "unable to load extension: {0}",
|
||||
"Unable to find extension: {0}": "Unable to find extension: {0}",
|
||||
"Unable to find action: {0}": "Unable to find action: {0}",
|
||||
"Unable to preload extension": "Unable to preload extension",
|
||||
"Example action": "Example action",
|
||||
"New Extension": "New Extension",
|
||||
"Build": "Build",
|
||||
"Run": "Run",
|
||||
"Build release": "Build release",
|
||||
"Install extension from file": "Install extension from file",
|
||||
"Install extension from URL": "Install extension from URL"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<afx-app-window apptitle="Antos Editor" width="600" height="400" data-id="antedit">
|
||||
<afx-vbox>
|
||||
<afx-hbox data-id="wrapper">
|
||||
<afx-vbox data-width = "200" min-width="200" data-id = "sidebar">
|
||||
<afx-tab-container data-id="sidebar-tab-container" dir="row" tabbarwidth="30">
|
||||
<!--File tab-->
|
||||
<afx-hbox data-height="100%" iconclass="bi bi-files" >
|
||||
<afx-vbox>
|
||||
<div data-height="5"></div>
|
||||
<afx-file-view chdir="false" data-id = "fileview" view="tree" status = "false">
|
||||
</afx-file-view>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
|
||||
<!--extension tab-->
|
||||
<afx-hbox data-height="100%" iconclass="bi bi-puzzle" >
|
||||
<afx-vbox>
|
||||
<input data-id="txt_ext_search" type="text" data-height="23">
|
||||
<afx-list-view data-id="extension-list"></afx-list-view>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
|
||||
</afx-tab-container>
|
||||
</afx-vbox>
|
||||
<afx-resizer data-width = "3" ></afx-resizer>
|
||||
<afx-vbox>
|
||||
<afx-hbox>
|
||||
<afx-vbox data-id="left-panel">
|
||||
<afx-tab-bar closable="true" data-height="26" data-id = "left-tabbar"></afx-tab-bar>
|
||||
<div data-id="left-editorarea"></div>
|
||||
</afx-vbox>
|
||||
<afx-resizer data-width="3"></afx-resizer>
|
||||
<afx-vbox data-id="right-panel">
|
||||
<afx-tab-bar closable="true" data-height="26" data-id = "right-tabbar"></afx-tab-bar>
|
||||
<div data-id="right-editorarea"></div>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<afx-resizer data-height = "3" dir = "ve" attachnext = "true" ></afx-resizer>
|
||||
<afx-tab-container data-id = "bottombar" data-height="150" min-height="150" tabbarheight= "22">
|
||||
<afx-hbox tabname="__(Output)" iconclass = "fa fa-file-text" class = "bottom-tab-content">
|
||||
<afx-button text = "" data-id="logger-clear" iconclass="fa fa-trash" data-width="21"></afx-button>
|
||||
<div data-id="output-tab" iconclass = "fa fa-file-text" >
|
||||
</div>
|
||||
</afx-hbox>
|
||||
</afx-tab-container>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<div data-height="20" data-id="statctn">
|
||||
<afx-label text=" " data-id = "current-file-lbl" style="float:left;"></afx-label>
|
||||
<afx-label data-id="langstat" style="float:right; padding-right: 10px;"></afx-label>
|
||||
<afx-label data-id="editorstat" style="float:right;"></afx-label>
|
||||
</div>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
Binary file not shown.
@ -7,7 +7,7 @@
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.2.1-b",
|
||||
"version": "0.2.2-b",
|
||||
"category": "Development",
|
||||
"iconclass": "bi bi-journal-code",
|
||||
"mimes": [
|
||||
|
@ -191,7 +191,6 @@ namespace OS {
|
||||
return false;
|
||||
}*/
|
||||
if (!this.currfile.dirty) {
|
||||
console.log("dirty", this.currfile.path);
|
||||
this.currfile.dirty = true;
|
||||
this.currfile.text += "*";
|
||||
return this.tabbar.update(undefined);
|
||||
@ -268,7 +267,8 @@ namespace OS {
|
||||
this.currfile.selected = false;
|
||||
file.selected = true;
|
||||
//console.log cnt
|
||||
this.tabbar.push(file);
|
||||
const el = this.tabbar.push(file);
|
||||
this.app.trigger("tab-opened", el);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -471,7 +471,18 @@ namespace OS {
|
||||
this.bindKey("ALT-F", () => this.menuAction("opendir"));
|
||||
this.bindKey("CTRL-S", () => this.menuAction("save"));
|
||||
this.bindKey("ALT-W", () => this.menuAction("saveas"));
|
||||
|
||||
|
||||
const list_container = $(".list-container", this.find("editor-main-container"));
|
||||
list_container.each((i,el) => {
|
||||
$(el).on("wheel", (evt)=>{
|
||||
el.scrollLeft += (evt.originalEvent as WheelEvent).deltaY;
|
||||
});
|
||||
});
|
||||
this.on("tab-opened", (el) => {
|
||||
const container = $(el).closest(".list-container");
|
||||
if(container && container[0])
|
||||
container[0].scrollLeft = container[0].scrollWidth;
|
||||
});
|
||||
this.fileview.ondragndrop = (e) => {
|
||||
if(!e.data.from || !e.data.to)
|
||||
{
|
||||
|
@ -85,18 +85,29 @@ namespace OS {
|
||||
{
|
||||
this.options[k] = option[k];
|
||||
}
|
||||
this.current_y_offset = this.options.y_offset;
|
||||
this.init_graph();
|
||||
if(this.options.target)
|
||||
{
|
||||
$(this.options.target)
|
||||
.addClass("git_grapth_container")
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("display", "block")
|
||||
.css("position", "relative");
|
||||
}
|
||||
}
|
||||
set base_dir(v: VFS.BaseFileHandle)
|
||||
{
|
||||
this._base_dir = v;
|
||||
this.render_next();
|
||||
if(v)
|
||||
{
|
||||
this.init_graph();
|
||||
this.render_next();
|
||||
}
|
||||
|
||||
}
|
||||
private gen_color(x:number): string
|
||||
{
|
||||
let n = x + 11;
|
||||
let n = x + 10;
|
||||
const rgb = [0, 0, 0];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
rgb[i%3] <<= 1;
|
||||
@ -154,11 +165,17 @@ namespace OS {
|
||||
{
|
||||
return this.error(API.throwe("Target element is undefined"));
|
||||
}
|
||||
$(this.options.target)
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("display", "block")
|
||||
.css("position", "relative");
|
||||
this.current_y_offset = this.options.y_offset;
|
||||
this.lines_data = [];
|
||||
this.commits = {};
|
||||
this.oldest_commit_date = undefined;
|
||||
this.svg_element = undefined;
|
||||
this.commits_list_element = undefined;
|
||||
this.load_more_el = undefined;
|
||||
this.commit_detail_el = undefined;
|
||||
this.current_head = undefined;
|
||||
|
||||
$(this.options.target).empty();
|
||||
this.svg_element = this.make_svg_el("svg",{
|
||||
width: this.options.x_offset,
|
||||
height: this.options.y_offset
|
||||
@ -169,7 +186,6 @@ namespace OS {
|
||||
.css("left", "0")
|
||||
//s.css("z-index", 10)
|
||||
.css("top", "0");
|
||||
$(this.options.target).empty();
|
||||
this.options.target.appendChild(this.svg_element);
|
||||
const div = $("<div />")
|
||||
.css("position", "absolute")
|
||||
@ -206,6 +222,10 @@ namespace OS {
|
||||
}
|
||||
private render_next()
|
||||
{
|
||||
if(this._base_dir == undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.load(this.oldest_commit_date)
|
||||
.then((data: CommitData[]) =>
|
||||
{
|
||||
@ -429,14 +449,15 @@ namespace OS {
|
||||
.on("click",e => {
|
||||
if(this._on_open_diff)
|
||||
{
|
||||
const parent_comit = commit.hashes.parents.split(" ")[0];
|
||||
Promise.all([
|
||||
this.get_file(arr[1], `${commit.hashes.commit}^`),
|
||||
this.get_file(arr[1], `${parent_comit}`),
|
||||
this.get_file(arr[1], commit.hashes.commit)
|
||||
])
|
||||
.then((values) => {
|
||||
// create the file
|
||||
const files = values.map((content, index) =>{
|
||||
const file = `mem://${commit.hashes.commit.slice(0,8)}${index==0?"^":""}/${arr[1]}`.asFileHandle();
|
||||
const file = `mem://${(index == 0 ?parent_comit:commit.hashes.commit).slice(0,8)}/${arr[1]}`.asFileHandle();
|
||||
file.cache = content;
|
||||
file.info.mime = "text/plain";
|
||||
return file;
|
21
GitGraph/README.md
Normal file
21
GitGraph/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# LibGitGraph
|
||||
Git grapth visualization API for AntOS application.
|
||||
|
||||
The visualization can be easily integrated to an AntOS application, example:
|
||||
|
||||
```typescript
|
||||
const graph = new API.LibGitGraph({
|
||||
target: this.find("git-graph");
|
||||
});
|
||||
graph.on_open_diff = (files) => {
|
||||
console.log(files);
|
||||
}
|
||||
graph.base_dir = "home://workspace/repo-git".asFileHandle();
|
||||
```
|
||||
|
||||
## Change logs:
|
||||
- v0.1.4-b: Fetch changes on a commit based on current commit and its left most parent commit
|
||||
- v0.1.3-b: Support open Git repo with open with dialog
|
||||
- v0.1.2-b: fix init bug
|
||||
- v0.1.1-b: add class to container element
|
||||
- v0.1.0-b: Initial version
|
@ -4,7 +4,7 @@
|
||||
"clean": {
|
||||
"jobs": [
|
||||
{
|
||||
"name": "vfs-rm",
|
||||
"name": "vfs-rm_no_error",
|
||||
"data": ["build/debug","build/release"]
|
||||
}
|
||||
]
|
21
GitGraph/build/debug/README.md
Normal file
21
GitGraph/build/debug/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# LibGitGraph
|
||||
Git grapth visualization API for AntOS application.
|
||||
|
||||
The visualization can be easily integrated to an AntOS application, example:
|
||||
|
||||
```typescript
|
||||
const graph = new API.LibGitGraph({
|
||||
target: this.find("git-graph");
|
||||
});
|
||||
graph.on_open_diff = (files) => {
|
||||
console.log(files);
|
||||
}
|
||||
graph.base_dir = "home://workspace/repo-git".asFileHandle();
|
||||
```
|
||||
|
||||
## Change logs:
|
||||
- v0.1.4-b: Fetch changes on a commit based on current commit and its left most parent commit
|
||||
- v0.1.3-b: Support open Git repo with open with dialog
|
||||
- v0.1.2-b: fix init bug
|
||||
- v0.1.1-b: add class to container element
|
||||
- v0.1.0-b: Initial version
|
1
GitGraph/build/debug/libgitgraph.js
Normal file
1
GitGraph/build/debug/libgitgraph.js
Normal file
File diff suppressed because one or more lines are too long
@ -1,7 +1,14 @@
|
||||
afx-app-window[data-id="GitGraph"] div[data-id="git-graph"]
|
||||
div.git_grapth_container
|
||||
{
|
||||
overflow-y: auto;
|
||||
background-color: bisque;
|
||||
background-color: #1e1e1e;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="GitGraph"] afx-label[data-id="txt-repo"] i.label-text
|
||||
{
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p.git_graph_commit_message:hover
|
||||
@ -65,7 +72,7 @@ p.git_graph_commit_message i.git_graph_commit_branch::before
|
||||
div.git_grapth_commit_detail
|
||||
{
|
||||
border-radius: 5px;
|
||||
background-color: whitesmoke;
|
||||
background-color: bisque;
|
||||
box-shadow: 0px 3px 6px 0px rgb(0,0,0,0.5);
|
||||
}
|
||||
|
||||
@ -179,7 +186,7 @@ p.git_grapth_load_more
|
||||
{
|
||||
font-weight: normal ;
|
||||
text-align: left;
|
||||
color:#131313;
|
||||
color:bisque;
|
||||
display: inline-block !important;
|
||||
padding-left: 5px !important;
|
||||
padding-right: 5px !important;
|
1
GitGraph/build/debug/main.js
Normal file
1
GitGraph/build/debug/main.js
Normal file
@ -0,0 +1 @@
|
||||
var OS;!function(t){let i,e;i=t.API||(t.API={}),function(t){class e extends t.BaseApplication{constructor(t){super("GitGraph",t),t&&t[0]&&(this.curr_repo=t[0].path.asFileHandle(),"file"===t[0].type&&(this.curr_repo=this.curr_repo.parent()))}main(){this.graph=new i.LibGitGraph({target:this.find("git-graph")}),this.graph.on_open_diff=t=>{this._gui.launch("Antedit",[]).then(i=>{i.observable.one("launched",()=>i.openDiff(t))}).catch(t=>this.error(__("Unable to open diff with Antedit: {0}",t.toString()),t))},this.find("btn-open").onbtclick=t=>{this.openDialog("FileDialog",{title:__("Select a repository"),type:"dir"}).then(t=>{this.setRepo(t.file)})},this.setRepo(this.curr_repo)}setRepo(t){t&&(this.find("txt-repo").text=t.path,this.curr_repo=t,this.graph.base_dir=t)}}t.GitGraph=e,e.dependencies=["pkg://GitGraph/libgitgraph.js"]}(e=t.application||(t.application={}))}(OS||(OS={}));
|
@ -4,13 +4,13 @@
|
||||
"name":"GIT Visualization",
|
||||
"description":"Git Grapth",
|
||||
"info":{
|
||||
"author": "",
|
||||
"email": ""
|
||||
"author": "Dany LE",
|
||||
"email": "contact@iohub.dev"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-adn",
|
||||
"mimes":["none"],
|
||||
"version":"0.1.4-b",
|
||||
"category":"Development",
|
||||
"iconclass":"bi bi-git",
|
||||
"mimes":["dir"],
|
||||
"dependencies":[],
|
||||
"locale": {}
|
||||
}
|
12
GitGraph/build/debug/scheme.html
Normal file
12
GitGraph/build/debug/scheme.html
Normal file
@ -0,0 +1,12 @@
|
||||
<afx-app-window apptitle="LibGitGraph" width="600" height="400" data-id="GitGraph">
|
||||
<afx-vbox>
|
||||
<afx-hbox data-height="25">
|
||||
<afx-button data-width="24" iconclass = "bi bi-folder2-open" data-id="btn-open"></afx-button>
|
||||
<afx-label data-id="txt-repo"></afx-label>
|
||||
</afx-hbox>
|
||||
<afx-hbox >
|
||||
<div data-id="git-graph">
|
||||
</div>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
BIN
GitGraph/build/release/GitGraph.zip
Normal file
BIN
GitGraph/build/release/GitGraph.zip
Normal file
Binary file not shown.
@ -1,7 +1,14 @@
|
||||
afx-app-window[data-id="GitGraph"] div[data-id="git-graph"]
|
||||
div.git_grapth_container
|
||||
{
|
||||
overflow-y: auto;
|
||||
background-color: bisque;
|
||||
background-color: #1e1e1e;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="GitGraph"] afx-label[data-id="txt-repo"] i.label-text
|
||||
{
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p.git_graph_commit_message:hover
|
||||
@ -65,7 +72,7 @@ p.git_graph_commit_message i.git_graph_commit_branch::before
|
||||
div.git_grapth_commit_detail
|
||||
{
|
||||
border-radius: 5px;
|
||||
background-color: whitesmoke;
|
||||
background-color: bisque;
|
||||
box-shadow: 0px 3px 6px 0px rgb(0,0,0,0.5);
|
||||
}
|
||||
|
||||
@ -179,7 +186,7 @@ p.git_grapth_load_more
|
||||
{
|
||||
font-weight: normal ;
|
||||
text-align: left;
|
||||
color:#131313;
|
||||
color:bisque;
|
||||
display: inline-block !important;
|
||||
padding-left: 5px !important;
|
||||
padding-right: 5px !important;
|
67
GitGraph/main.ts
Normal file
67
GitGraph/main.ts
Normal file
@ -0,0 +1,67 @@
|
||||
namespace OS {
|
||||
export namespace API
|
||||
{
|
||||
export declare class LibGitGraph
|
||||
{
|
||||
constructor(options:GenericObject<any>);
|
||||
base_dir: VFS.BaseFileHandle;
|
||||
on_open_diff: (file:VFS.BaseFileHandle[]) => void;
|
||||
list_file: (commit: string) => Promise<string[]>;
|
||||
get_changes: (file:string, commit: string) => Promise<string>;
|
||||
get_file: (file:string, commit: string) => Promise<string>
|
||||
}
|
||||
}
|
||||
export namespace application {
|
||||
/**
|
||||
*
|
||||
* @class GitGraph
|
||||
* @extends {BaseApplication}
|
||||
*/
|
||||
export class GitGraph extends BaseApplication {
|
||||
private graph: API.LibGitGraph;
|
||||
private curr_repo: API.VFS.BaseFileHandle;
|
||||
constructor(args: AppArgumentsType[]) {
|
||||
super("GitGraph", args);
|
||||
if(args && args[0])
|
||||
{
|
||||
this.curr_repo = args[0].path.asFileHandle();
|
||||
if(args[0].type === "file")
|
||||
this.curr_repo = this.curr_repo.parent();
|
||||
}
|
||||
}
|
||||
main(): void {
|
||||
this.graph = new API.LibGitGraph({
|
||||
target: this.find("git-graph")
|
||||
});
|
||||
this.graph.on_open_diff = (files) => {
|
||||
this._gui.launch("Antedit", [])
|
||||
.then((p) =>{
|
||||
p.observable.one("launched",() =>(p as any).openDiff(files));
|
||||
})
|
||||
.catch(e => this.error(__("Unable to open diff with Antedit: {0}", e.toString()),e ));
|
||||
|
||||
}
|
||||
(this.find("btn-open") as GUI.tag.ButtonTag).onbtclick = (e) => {
|
||||
this.openDialog("FileDialog", {
|
||||
title: __("Select a repository"),
|
||||
type: "dir",
|
||||
|
||||
}).then((d) => {
|
||||
this.setRepo(d.file);
|
||||
});
|
||||
};
|
||||
this.setRepo(this.curr_repo);
|
||||
}
|
||||
|
||||
private setRepo(d:API.VFS.BaseFileHandle): void
|
||||
{
|
||||
if(!d) return;
|
||||
(this.find("txt-repo") as GUI.tag.LabelTag).text = d.path;
|
||||
this.curr_repo = d;
|
||||
this.graph.base_dir = d;
|
||||
}
|
||||
}
|
||||
|
||||
GitGraph.dependencies = ["pkg://GitGraph/libgitgraph.js"];
|
||||
}
|
||||
}
|
@ -4,13 +4,13 @@
|
||||
"name":"GIT Visualization",
|
||||
"description":"Git Grapth",
|
||||
"info":{
|
||||
"author": "",
|
||||
"email": ""
|
||||
"author": "Dany LE",
|
||||
"email": "contact@iohub.dev"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-adn",
|
||||
"mimes":["none"],
|
||||
"version":"0.1.4-b",
|
||||
"category":"Development",
|
||||
"iconclass":"bi bi-git",
|
||||
"mimes":["dir"],
|
||||
"dependencies":[],
|
||||
"locale": {}
|
||||
}
|
12
GitGraph/scheme.html
Normal file
12
GitGraph/scheme.html
Normal file
@ -0,0 +1,12 @@
|
||||
<afx-app-window apptitle="LibGitGraph" width="600" height="400" data-id="GitGraph">
|
||||
<afx-vbox>
|
||||
<afx-hbox data-height="25">
|
||||
<afx-button data-width="24" iconclass = "bi bi-folder2-open" data-id="btn-open"></afx-button>
|
||||
<afx-label data-id="txt-repo"></afx-label>
|
||||
</afx-hbox>
|
||||
<afx-hbox >
|
||||
<div data-id="git-graph">
|
||||
</div>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
@ -1,15 +0,0 @@
|
||||
# LibGitGraph
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
Use the Antedit command palette to access to the SDK functionalities:
|
||||
|
||||
1. Create new project
|
||||
2. Init the project from the current folder located in side bar
|
||||
3. Build and run the project
|
||||
4. Release the project in zip package
|
||||
|
||||
## Set up build target
|
||||
|
||||
Open the `build.json` file from the current project tree and add/remove
|
||||
build target entries and jobs. Save the file
|
@ -1,15 +0,0 @@
|
||||
# LibGitGraph
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
Use the Antedit command palette to access to the SDK functionalities:
|
||||
|
||||
1. Create new project
|
||||
2. Init the project from the current folder located in side bar
|
||||
3. Build and run the project
|
||||
4. Release the project in zip package
|
||||
|
||||
## Set up build target
|
||||
|
||||
Open the `build.json` file from the current project tree and add/remove
|
||||
build target entries and jobs. Save the file
|
@ -1,498 +0,0 @@
|
||||
|
||||
var OS;
|
||||
(function (OS) {
|
||||
let API;
|
||||
(function (API) {
|
||||
;
|
||||
class LibGitGraph {
|
||||
constructor(option) {
|
||||
this._base_dir = undefined;
|
||||
this.lines_data = [];
|
||||
this.commits = {};
|
||||
this.oldest_commit_date = undefined;
|
||||
this.svg_element = undefined;
|
||||
this.commits_list_element = undefined;
|
||||
this.load_more_el = undefined;
|
||||
this.commit_detail_el = undefined;
|
||||
this.current_head = undefined;
|
||||
this._on_open_diff = undefined;
|
||||
this.options = {
|
||||
commits_per_page: 100,
|
||||
x_offset: 24,
|
||||
y_offset: 24,
|
||||
target: undefined,
|
||||
popup_height: 250
|
||||
};
|
||||
for (const k in option) {
|
||||
this.options[k] = option[k];
|
||||
}
|
||||
this.current_y_offset = this.options.y_offset;
|
||||
this.init_graph();
|
||||
}
|
||||
set base_dir(v) {
|
||||
this._base_dir = v;
|
||||
this.render_next();
|
||||
}
|
||||
gen_color(x) {
|
||||
let n = x + 11;
|
||||
const rgb = [0, 0, 0];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
rgb[i % 3] <<= 1;
|
||||
rgb[i % 3] |= n & 0x01;
|
||||
n >>= 1;
|
||||
}
|
||||
return '#' + rgb.reduce((a, c) => (c > 0x0f ? c.toString(16) : '0' + c.toString(16)) + a, '');
|
||||
}
|
||||
meta() {
|
||||
return OS.setting.system.packages['GitGraph'];
|
||||
}
|
||||
call(request) {
|
||||
return new Promise(async (ok, reject) => {
|
||||
request.args.base_dir = this._base_dir.path;
|
||||
let cmd = {
|
||||
path: this.meta().path + "/api/api.lua",
|
||||
parameters: request
|
||||
};
|
||||
let data = await API.apigateway(cmd, false);
|
||||
if (!data.error) {
|
||||
ok(data.result);
|
||||
}
|
||||
else {
|
||||
reject(API.throwe(__("LibGitGrapth server call error: {0}", data.error)));
|
||||
}
|
||||
});
|
||||
}
|
||||
load(before) {
|
||||
let request = {
|
||||
action: 'log',
|
||||
args: {
|
||||
n_commits: this.options.commits_per_page.toString(),
|
||||
before: before ? before : null
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
error(e) {
|
||||
OS.announcer.oserror(__("GitGraph error: {0}", e.toString()), e);
|
||||
}
|
||||
set on_open_diff(c) {
|
||||
this._on_open_diff = c;
|
||||
}
|
||||
init_graph() {
|
||||
if (!this.options.target) {
|
||||
return this.error(API.throwe("Target element is undefined"));
|
||||
}
|
||||
$(this.options.target)
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("display", "block")
|
||||
.css("position", "relative");
|
||||
this.svg_element = this.make_svg_el("svg", {
|
||||
width: this.options.x_offset,
|
||||
height: this.options.y_offset
|
||||
});
|
||||
$(this.svg_element)
|
||||
.css("display", "block")
|
||||
.css("position", "absolute")
|
||||
.css("left", "0")
|
||||
//s.css("z-index", 10)
|
||||
.css("top", "0");
|
||||
$(this.options.target).empty();
|
||||
this.options.target.appendChild(this.svg_element);
|
||||
const div = $("<div />")
|
||||
.css("position", "absolute")
|
||||
.css("left", "0")
|
||||
.css("top", "0")
|
||||
.css("width", "100%")
|
||||
.css("padding-top", `${this.options.y_offset / 2}px`);
|
||||
this.commits_list_element = div[0];
|
||||
this.options.target.appendChild(this.commits_list_element);
|
||||
const p = $("<p />")
|
||||
.css("height", `${this.options.y_offset}px`)
|
||||
.css("display", "block")
|
||||
.css("padding", "0")
|
||||
.css("margin", "0")
|
||||
.css("line-height", `${this.options.y_offset}px`)
|
||||
.css("vertical-align", "middle");
|
||||
p.addClass("git_grapth_load_more");
|
||||
p.on("click", (e) => this.render_next());
|
||||
p.text(__("More").__());
|
||||
this.load_more_el = p[0];
|
||||
this.commits_list_element.appendChild(this.load_more_el);
|
||||
const popup = $("<div />")
|
||||
.css("position", "absolute")
|
||||
.css("top", "0")
|
||||
.css("height", this.options.popup_height + "px")
|
||||
.css("display", "none")
|
||||
.css("user-select", "text")
|
||||
.addClass("git_grapth_commit_detail");
|
||||
this.commit_detail_el = popup[0];
|
||||
this.options.target.appendChild(this.commit_detail_el);
|
||||
}
|
||||
render_next() {
|
||||
this.load(this.oldest_commit_date)
|
||||
.then((data) => {
|
||||
if (this.oldest_commit_date) {
|
||||
// remove the first commit as it is already in
|
||||
// the graph
|
||||
data.shift();
|
||||
}
|
||||
this.draw_graph(data);
|
||||
})
|
||||
.catch(e => this.error(e));
|
||||
}
|
||||
make_svg_el(tag, attrs) {
|
||||
const el = document.createElementNS('http://www.w3.org/2000/svg', tag);
|
||||
for (var k in attrs)
|
||||
el.setAttribute(k, attrs[k]);
|
||||
return el;
|
||||
}
|
||||
max_line_off_x() {
|
||||
if (this.lines_data.length == 0)
|
||||
return 0;
|
||||
return Math.max.apply(Math, this.lines_data.map((o) => o.x_offset));
|
||||
}
|
||||
update_line_data(commit, y_offset) {
|
||||
const parent_commits = commit.hashes.parents.split(" ");
|
||||
// get the list of child lines
|
||||
const children = this.lines_data.filter((line) => line.next_commit == commit.hashes.commit);
|
||||
let merge = {
|
||||
src: [],
|
||||
dest: undefined
|
||||
};
|
||||
if (children.length === 0) {
|
||||
// add new line
|
||||
let line = {
|
||||
next_commit: parent_commits[0],
|
||||
x_offset: this.max_line_off_x() + this.options.x_offset,
|
||||
current_commit: commit.hashes.commit,
|
||||
beginning: true,
|
||||
y_offset: y_offset,
|
||||
color: this.gen_color(this.lines_data.length),
|
||||
};
|
||||
this.lines_data.push(line);
|
||||
merge.dest = line;
|
||||
}
|
||||
else {
|
||||
let min_offset_x = Math.min.apply(Math, children.map((o) => o.x_offset));
|
||||
let line = undefined;
|
||||
for (let el of children) {
|
||||
if (el.x_offset == min_offset_x) {
|
||||
line = el;
|
||||
line.next_commit = parent_commits[0];
|
||||
line.current_commit = commit.hashes.commit;
|
||||
line.y_offset = y_offset;
|
||||
}
|
||||
else {
|
||||
this.lines_data.splice(this.lines_data.indexOf(el), 1);
|
||||
merge.src.push(el);
|
||||
}
|
||||
}
|
||||
merge.dest = line;
|
||||
}
|
||||
if (parent_commits.length === 2) {
|
||||
let line = undefined;
|
||||
line = this.lines_data.filter(l => l.next_commit == parent_commits[1])[0];
|
||||
if (!line) {
|
||||
// add new line
|
||||
line = {
|
||||
next_commit: parent_commits[1],
|
||||
x_offset: this.max_line_off_x() + this.options.x_offset,
|
||||
current_commit: commit.hashes.commit,
|
||||
beginning: true,
|
||||
y_offset: y_offset + this.options.y_offset,
|
||||
color: this.gen_color(this.lines_data.length),
|
||||
};
|
||||
this.lines_data.push(line);
|
||||
}
|
||||
else {
|
||||
line.y_offset = y_offset + this.options.y_offset;
|
||||
}
|
||||
merge.src.push(line);
|
||||
}
|
||||
return merge;
|
||||
}
|
||||
draw_line(_x1, _y1, _x2, _y2, color, stroke) {
|
||||
let line_opt = {
|
||||
stroke: color,
|
||||
fill: 'none',
|
||||
"stroke-width": 1.5
|
||||
};
|
||||
if (stroke) {
|
||||
line_opt['stroke-width'] = stroke;
|
||||
}
|
||||
if (_x1 == _x2) {
|
||||
line_opt.d = `M ${_x1},${_y1} L ${_x2},${_y2}`;
|
||||
}
|
||||
else {
|
||||
let x1 = _x1;
|
||||
let y1 = _y1;
|
||||
let x2 = _x2;
|
||||
let y2 = _y2;
|
||||
let dx = Math.abs(x2 - x1);
|
||||
let dy = Math.abs(y2 - y1);
|
||||
if (_y1 < _y2) {
|
||||
x1 = _x2;
|
||||
y1 = _y2;
|
||||
x2 = _x1;
|
||||
y2 = _y1;
|
||||
}
|
||||
line_opt.d = `M ${x1},${y1} C ${x1},${y1 - dy} ${x2},${y2 + dy} ${x2},${y2}`;
|
||||
}
|
||||
const line = this.make_svg_el("path", line_opt);
|
||||
return line;
|
||||
}
|
||||
gen_commit_data_header(name, value) {
|
||||
const p = $("<p />")
|
||||
.css("display", "block");
|
||||
p[0].innerHTML = `<b>${name.__()}</b>: ${value}`;
|
||||
return p[0];
|
||||
}
|
||||
open_popup(commit) {
|
||||
const el = commit.domel;
|
||||
if (!el)
|
||||
return;
|
||||
$(this.commit_detail_el).empty();
|
||||
const position = $(el).position();
|
||||
const bbox = this.svg_element.getBBox();
|
||||
const off_left = bbox.x + bbox.width + this.options.x_offset / 2;
|
||||
const svg = this.make_svg_el("svg", {
|
||||
width: off_left - commit.cx + 5,
|
||||
height: this.options.y_offset
|
||||
});
|
||||
$(svg)
|
||||
.css("display", "block")
|
||||
.css("position", "absolute")
|
||||
.css("left", "0")
|
||||
.css("top", "-2px");
|
||||
svg.appendChild(this.draw_line(0, this.options.y_offset / 2, off_left - commit.cx, this.options.y_offset / 2, commit.color));
|
||||
/*
|
||||
svg.appendChild(
|
||||
this.make_svg_el("circle",{
|
||||
cx: off_left-commit.cx - 1,
|
||||
cy: this.options.y_offset/2,
|
||||
r:4,
|
||||
fill: commit.color,
|
||||
"stroke-width": 0.0
|
||||
})
|
||||
);*/
|
||||
$(this.commit_detail_el)
|
||||
.css("border", "2px solid " + commit.color)
|
||||
.css("color", commit.color)
|
||||
.append($("<div />")
|
||||
.css("position", "absolute")
|
||||
.css("height", this.options.y_offset)
|
||||
.css("left", commit.cx - off_left)
|
||||
.css("padding-left", off_left - commit.cx)
|
||||
.append(svg)
|
||||
.append($("<i/>").text('[X]')
|
||||
.css("cursor", "pointer"))
|
||||
.addClass("git_grapth_commit_detail_ctrl")
|
||||
.on("click", (e) => {
|
||||
$(this.commit_detail_el)
|
||||
.css("display", "none")
|
||||
.empty();
|
||||
}));
|
||||
const left = $("<div />")
|
||||
.css("display", "block")
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("flex", "1")
|
||||
.css("border-right", "1px solid " + commit.color)
|
||||
.addClass("git_grapth_commit_detail_left");
|
||||
const right = $("<div />")
|
||||
.css("display", "block")
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("flex", "1")
|
||||
.addClass("git_grapth_commit_detail_right");
|
||||
// display
|
||||
left.append(this.gen_commit_data_header(__("Commit"), commit.hashes.commit));
|
||||
left.append(this.gen_commit_data_header(__("Parents"), commit.hashes.parents));
|
||||
left.append(this.gen_commit_data_header(__("Author"), `${commit.committer.name} <${commit.committer.email}>`));
|
||||
left.append(this.gen_commit_data_header(__("Date"), (new Date(commit.committer.date).toDateString())));
|
||||
left.append($("<pre />")
|
||||
.css("white-space", "pre-wrap")
|
||||
.text(commit.message));
|
||||
this.commit_detail_el.appendChild(left[0]);
|
||||
this.commit_detail_el.appendChild(right[0]);
|
||||
this.list_file(commit.hashes.commit)
|
||||
.then((files) => {
|
||||
const ul = $('<ul/>');
|
||||
$.each(files, (index, value) => {
|
||||
const arr = value.split("\t");
|
||||
const li = $('<li/>');
|
||||
const a = $('<a/>')
|
||||
.css("cursor", "pointer")
|
||||
.addClass(`git_graph_file_${arr[0].toLowerCase()}`)
|
||||
.on("click", e => {
|
||||
if (this._on_open_diff) {
|
||||
Promise.all([
|
||||
this.get_file(arr[1], `${commit.hashes.commit}^`),
|
||||
this.get_file(arr[1], commit.hashes.commit)
|
||||
])
|
||||
.then((values) => {
|
||||
// create the file
|
||||
const files = values.map((content, index) => {
|
||||
const file = `mem://${commit.hashes.commit.slice(0, 8)}${index == 0 ? "^" : ""}/${arr[1]}`.asFileHandle();
|
||||
file.cache = content;
|
||||
file.info.mime = "text/plain";
|
||||
return file;
|
||||
});
|
||||
this._on_open_diff(files);
|
||||
})
|
||||
.catch((e) => {
|
||||
OS.announcer.oserror(__("Unable to fetch diff of {0}: {1}", commit.hashes.commit, e.toString()), e);
|
||||
});
|
||||
}
|
||||
});
|
||||
a.text(arr[1]);
|
||||
ul.append(li.append(a));
|
||||
});
|
||||
right.append(ul);
|
||||
})
|
||||
.catch((e) => OS.announcer.oserror(__("Unable to get commit changes: {0}", e.toString()), e));
|
||||
// scroll down if necessary
|
||||
$(this.commit_detail_el)
|
||||
.css("top", position.top)
|
||||
.css("left", off_left)
|
||||
.css("display", "flex")
|
||||
.css("width", `calc(100% - ${off_left + this.options.x_offset}px)`)
|
||||
.css("fflex-direction", "row");
|
||||
const delta = this.commit_detail_el.getBoundingClientRect().bottom -
|
||||
this.options.target.getBoundingClientRect().bottom;
|
||||
if (delta > 0) {
|
||||
this.options.target.scrollTop += delta + 10;
|
||||
}
|
||||
}
|
||||
render_commit(commit, color) {
|
||||
let current = false;
|
||||
const p = $("<p />")
|
||||
.css("padding", "0")
|
||||
.css("margin", "0")
|
||||
.css("display", "block")
|
||||
.css("height", `${this.options.y_offset}px`)
|
||||
.css("line-height", `${this.options.y_offset}px`)
|
||||
.css("color", color)
|
||||
.css("vertical-align", "middle")
|
||||
.css("white-space", "nowrap")
|
||||
.css("overflow", "hidden");
|
||||
p.addClass("git_graph_commit_message");
|
||||
let html = `<i class="git_graph_commit_hash">${commit.hashes.commit.slice(0, 8)}</i> `;
|
||||
commit.branches = [];
|
||||
for (const tag of commit.extra.split(",").map(e => e.trim()).filter(e => e != "")) {
|
||||
let found = tag.match(/HEAD -> (.*)/i);
|
||||
if (found && found.length == 2) {
|
||||
html += `<i class = "git_graph_commit_branch">${found[1]}</i> `;
|
||||
p.addClass("git_graph_commit_current_head");
|
||||
current = true;
|
||||
commit.branches.push(found[1]);
|
||||
this.current_head = commit;
|
||||
}
|
||||
else if ((found = tag.match(/tag: (.*)/i))) {
|
||||
html += `<i class = "git_graph_commit_tag">${found[1]}</i> `;
|
||||
}
|
||||
else {
|
||||
html += `<i class = "git_graph_commit_branch">${tag}</i> `;
|
||||
commit.branches.push(tag);
|
||||
}
|
||||
}
|
||||
html += `<i class ="git_graph_commit_text">${commit.message.split("\n")[0]}</i> `;
|
||||
html += `<i class ="git_graph_commit_author">${commit.committer.name}</i> `;
|
||||
html += `<i class ="git_graph_commit_date">${new Date(commit.committer.date).toDateString()}</i>`;
|
||||
p[0].innerHTML = html;
|
||||
p.on("click", (e) => {
|
||||
this.open_popup(commit);
|
||||
});
|
||||
this.commits_list_element.insertBefore(p[0], this.load_more_el);
|
||||
commit.domel = p[0];
|
||||
return current;
|
||||
}
|
||||
draw_graph(data) {
|
||||
for (const commit of data) {
|
||||
this.oldest_commit_date = commit.committer.date;
|
||||
if (commit.extra.includes("refs/stash")) {
|
||||
continue;
|
||||
}
|
||||
this.commits[commit.hashes.commit] = commit;
|
||||
let merge = this.update_line_data(commit, this.current_y_offset);
|
||||
let lines = merge.src;
|
||||
// combine the lines
|
||||
for (const linedata of lines.filter(o => o.x_offset != merge.dest.x_offset)) {
|
||||
this.svg_element.appendChild(this.draw_line(merge.dest.x_offset, merge.dest.y_offset, linedata.x_offset, linedata.y_offset, linedata.color));
|
||||
}
|
||||
this.lines_data.sort((a, b) => a.x_offset - b.x_offset);
|
||||
let x_offset = this.options.x_offset;
|
||||
for (const linedata of this.lines_data) {
|
||||
if (linedata.beginning && linedata.y_offset > this.current_y_offset) {
|
||||
continue;
|
||||
}
|
||||
linedata.y_offset = this.current_y_offset;
|
||||
if (!linedata.beginning) {
|
||||
if (linedata.x_offset > x_offset) {
|
||||
this.svg_element.appendChild(this.draw_line(linedata.x_offset, linedata.y_offset - this.options.y_offset, linedata.x_offset - this.options.x_offset, linedata.y_offset, linedata.color));
|
||||
linedata.x_offset = x_offset;
|
||||
}
|
||||
else {
|
||||
this.svg_element.appendChild(this.draw_line(linedata.x_offset, linedata.y_offset - this.options.y_offset, linedata.x_offset, linedata.y_offset, linedata.color));
|
||||
}
|
||||
}
|
||||
x_offset += this.options.x_offset;
|
||||
linedata.beginning = false;
|
||||
}
|
||||
let options = {
|
||||
cx: merge.dest.x_offset,
|
||||
cy: merge.dest.y_offset,
|
||||
r: 4,
|
||||
fill: merge.dest.color,
|
||||
stroke: 'black',
|
||||
"stroke-width": 0.0
|
||||
};
|
||||
if (this.render_commit(commit, merge.dest.color)) {
|
||||
options.r = options.r * 1.5;
|
||||
}
|
||||
commit.cx = options.cx;
|
||||
commit.color = options.fill;
|
||||
const circle = this.make_svg_el("circle", options);
|
||||
this.svg_element.appendChild(circle);
|
||||
this.current_y_offset += this.options.y_offset;
|
||||
}
|
||||
const bbox = this.svg_element.getBBox();
|
||||
this.svg_element.setAttribute("width", (bbox.x + bbox.width).toString());
|
||||
this.svg_element.setAttribute("height", (bbox.y + bbox.height + this.options.y_offset / 2).toString());
|
||||
//$(this.commits_list_element).css("left", `-${bbox.x + bbox.width}px`);
|
||||
$(".git_graph_commit_message", this.commits_list_element).css("padding-left", `${bbox.x + bbox.width + this.options.x_offset / 2}px`);
|
||||
}
|
||||
list_file(hash) {
|
||||
let request = {
|
||||
action: 'list_file',
|
||||
args: {
|
||||
commit: hash
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
get_changes(file, hash) {
|
||||
let request = {
|
||||
action: 'get_changes',
|
||||
args: {
|
||||
commit: hash,
|
||||
file: file
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
get_file(file, hash) {
|
||||
let request = {
|
||||
action: 'get_file',
|
||||
args: {
|
||||
commit: hash,
|
||||
file: file
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
}
|
||||
API.LibGitGraph = LibGitGraph;
|
||||
})(API = OS.API || (OS.API = {}));
|
||||
})(OS || (OS = {}));
|
@ -1,536 +0,0 @@
|
||||
|
||||
|
||||
var OS;
|
||||
(function (OS) {
|
||||
let API;
|
||||
(function (API) {
|
||||
})(API = OS.API || (OS.API = {}));
|
||||
let application;
|
||||
(function (application) {
|
||||
/**
|
||||
*
|
||||
* @class GitGraph
|
||||
* @extends {BaseApplication}
|
||||
*/
|
||||
class GitGraph extends application.BaseApplication {
|
||||
constructor(args) {
|
||||
super("GitGraph", args);
|
||||
}
|
||||
main() {
|
||||
let graph = new API.LibGitGraph({
|
||||
target: this.find("git-graph")
|
||||
});
|
||||
graph.on_open_diff = (files) => {
|
||||
console.log(files);
|
||||
//(OS.PM.processes.Antedit[0] as any).openDiff(files)
|
||||
this._gui.launch("Antedit", [])
|
||||
.then((p) => {
|
||||
p.observable.one("launched", () => p.openDiff(files));
|
||||
});
|
||||
};
|
||||
graph.base_dir = "home://workspace/antos/".asFileHandle();
|
||||
}
|
||||
}
|
||||
application.GitGraph = GitGraph;
|
||||
//GitGraph.dependencies = ["pkg://GitGraph/libgitgraph.js"];
|
||||
})(application = OS.application || (OS.application = {}));
|
||||
})(OS || (OS = {}));
|
||||
|
||||
|
||||
var OS;
|
||||
(function (OS) {
|
||||
let API;
|
||||
(function (API) {
|
||||
;
|
||||
class LibGitGraph {
|
||||
constructor(option) {
|
||||
this._base_dir = undefined;
|
||||
this.lines_data = [];
|
||||
this.commits = {};
|
||||
this.oldest_commit_date = undefined;
|
||||
this.svg_element = undefined;
|
||||
this.commits_list_element = undefined;
|
||||
this.load_more_el = undefined;
|
||||
this.commit_detail_el = undefined;
|
||||
this.current_head = undefined;
|
||||
this._on_open_diff = undefined;
|
||||
this.options = {
|
||||
commits_per_page: 100,
|
||||
x_offset: 24,
|
||||
y_offset: 24,
|
||||
target: undefined,
|
||||
popup_height: 250
|
||||
};
|
||||
for (const k in option) {
|
||||
this.options[k] = option[k];
|
||||
}
|
||||
this.current_y_offset = this.options.y_offset;
|
||||
this.init_graph();
|
||||
}
|
||||
set base_dir(v) {
|
||||
this._base_dir = v;
|
||||
this.render_next();
|
||||
}
|
||||
gen_color(x) {
|
||||
let n = x + 11;
|
||||
const rgb = [0, 0, 0];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
rgb[i % 3] <<= 1;
|
||||
rgb[i % 3] |= n & 0x01;
|
||||
n >>= 1;
|
||||
}
|
||||
return '#' + rgb.reduce((a, c) => (c > 0x0f ? c.toString(16) : '0' + c.toString(16)) + a, '');
|
||||
}
|
||||
meta() {
|
||||
return OS.setting.system.packages['GitGraph'];
|
||||
}
|
||||
call(request) {
|
||||
return new Promise(async (ok, reject) => {
|
||||
request.args.base_dir = this._base_dir.path;
|
||||
let cmd = {
|
||||
path: this.meta().path + "/api/api.lua",
|
||||
parameters: request
|
||||
};
|
||||
let data = await API.apigateway(cmd, false);
|
||||
if (!data.error) {
|
||||
ok(data.result);
|
||||
}
|
||||
else {
|
||||
reject(API.throwe(__("LibGitGrapth server call error: {0}", data.error)));
|
||||
}
|
||||
});
|
||||
}
|
||||
load(before) {
|
||||
let request = {
|
||||
action: 'log',
|
||||
args: {
|
||||
n_commits: this.options.commits_per_page.toString(),
|
||||
before: before ? before : null
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
error(e) {
|
||||
OS.announcer.oserror(__("GitGraph error: {0}", e.toString()), e);
|
||||
}
|
||||
set on_open_diff(c) {
|
||||
this._on_open_diff = c;
|
||||
}
|
||||
init_graph() {
|
||||
if (!this.options.target) {
|
||||
return this.error(API.throwe("Target element is undefined"));
|
||||
}
|
||||
$(this.options.target)
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("display", "block")
|
||||
.css("position", "relative");
|
||||
this.svg_element = this.make_svg_el("svg", {
|
||||
width: this.options.x_offset,
|
||||
height: this.options.y_offset
|
||||
});
|
||||
$(this.svg_element)
|
||||
.css("display", "block")
|
||||
.css("position", "absolute")
|
||||
.css("left", "0")
|
||||
//s.css("z-index", 10)
|
||||
.css("top", "0");
|
||||
$(this.options.target).empty();
|
||||
this.options.target.appendChild(this.svg_element);
|
||||
const div = $("<div />")
|
||||
.css("position", "absolute")
|
||||
.css("left", "0")
|
||||
.css("top", "0")
|
||||
.css("width", "100%")
|
||||
.css("padding-top", `${this.options.y_offset / 2}px`);
|
||||
this.commits_list_element = div[0];
|
||||
this.options.target.appendChild(this.commits_list_element);
|
||||
const p = $("<p />")
|
||||
.css("height", `${this.options.y_offset}px`)
|
||||
.css("display", "block")
|
||||
.css("padding", "0")
|
||||
.css("margin", "0")
|
||||
.css("line-height", `${this.options.y_offset}px`)
|
||||
.css("vertical-align", "middle");
|
||||
p.addClass("git_grapth_load_more");
|
||||
p.on("click", (e) => this.render_next());
|
||||
p.text(__("More").__());
|
||||
this.load_more_el = p[0];
|
||||
this.commits_list_element.appendChild(this.load_more_el);
|
||||
const popup = $("<div />")
|
||||
.css("position", "absolute")
|
||||
.css("top", "0")
|
||||
.css("height", this.options.popup_height + "px")
|
||||
.css("display", "none")
|
||||
.css("user-select", "text")
|
||||
.addClass("git_grapth_commit_detail");
|
||||
this.commit_detail_el = popup[0];
|
||||
this.options.target.appendChild(this.commit_detail_el);
|
||||
}
|
||||
render_next() {
|
||||
this.load(this.oldest_commit_date)
|
||||
.then((data) => {
|
||||
if (this.oldest_commit_date) {
|
||||
// remove the first commit as it is already in
|
||||
// the graph
|
||||
data.shift();
|
||||
}
|
||||
this.draw_graph(data);
|
||||
})
|
||||
.catch(e => this.error(e));
|
||||
}
|
||||
make_svg_el(tag, attrs) {
|
||||
const el = document.createElementNS('http://www.w3.org/2000/svg', tag);
|
||||
for (var k in attrs)
|
||||
el.setAttribute(k, attrs[k]);
|
||||
return el;
|
||||
}
|
||||
max_line_off_x() {
|
||||
if (this.lines_data.length == 0)
|
||||
return 0;
|
||||
return Math.max.apply(Math, this.lines_data.map((o) => o.x_offset));
|
||||
}
|
||||
update_line_data(commit, y_offset) {
|
||||
const parent_commits = commit.hashes.parents.split(" ");
|
||||
// get the list of child lines
|
||||
const children = this.lines_data.filter((line) => line.next_commit == commit.hashes.commit);
|
||||
let merge = {
|
||||
src: [],
|
||||
dest: undefined
|
||||
};
|
||||
if (children.length === 0) {
|
||||
// add new line
|
||||
let line = {
|
||||
next_commit: parent_commits[0],
|
||||
x_offset: this.max_line_off_x() + this.options.x_offset,
|
||||
current_commit: commit.hashes.commit,
|
||||
beginning: true,
|
||||
y_offset: y_offset,
|
||||
color: this.gen_color(this.lines_data.length),
|
||||
};
|
||||
this.lines_data.push(line);
|
||||
merge.dest = line;
|
||||
}
|
||||
else {
|
||||
let min_offset_x = Math.min.apply(Math, children.map((o) => o.x_offset));
|
||||
let line = undefined;
|
||||
for (let el of children) {
|
||||
if (el.x_offset == min_offset_x) {
|
||||
line = el;
|
||||
line.next_commit = parent_commits[0];
|
||||
line.current_commit = commit.hashes.commit;
|
||||
line.y_offset = y_offset;
|
||||
}
|
||||
else {
|
||||
this.lines_data.splice(this.lines_data.indexOf(el), 1);
|
||||
merge.src.push(el);
|
||||
}
|
||||
}
|
||||
merge.dest = line;
|
||||
}
|
||||
if (parent_commits.length === 2) {
|
||||
let line = undefined;
|
||||
line = this.lines_data.filter(l => l.next_commit == parent_commits[1])[0];
|
||||
if (!line) {
|
||||
// add new line
|
||||
line = {
|
||||
next_commit: parent_commits[1],
|
||||
x_offset: this.max_line_off_x() + this.options.x_offset,
|
||||
current_commit: commit.hashes.commit,
|
||||
beginning: true,
|
||||
y_offset: y_offset + this.options.y_offset,
|
||||
color: this.gen_color(this.lines_data.length),
|
||||
};
|
||||
this.lines_data.push(line);
|
||||
}
|
||||
else {
|
||||
line.y_offset = y_offset + this.options.y_offset;
|
||||
}
|
||||
merge.src.push(line);
|
||||
}
|
||||
return merge;
|
||||
}
|
||||
draw_line(_x1, _y1, _x2, _y2, color, stroke) {
|
||||
let line_opt = {
|
||||
stroke: color,
|
||||
fill: 'none',
|
||||
"stroke-width": 1.5
|
||||
};
|
||||
if (stroke) {
|
||||
line_opt['stroke-width'] = stroke;
|
||||
}
|
||||
if (_x1 == _x2) {
|
||||
line_opt.d = `M ${_x1},${_y1} L ${_x2},${_y2}`;
|
||||
}
|
||||
else {
|
||||
let x1 = _x1;
|
||||
let y1 = _y1;
|
||||
let x2 = _x2;
|
||||
let y2 = _y2;
|
||||
let dx = Math.abs(x2 - x1);
|
||||
let dy = Math.abs(y2 - y1);
|
||||
if (_y1 < _y2) {
|
||||
x1 = _x2;
|
||||
y1 = _y2;
|
||||
x2 = _x1;
|
||||
y2 = _y1;
|
||||
}
|
||||
line_opt.d = `M ${x1},${y1} C ${x1},${y1 - dy} ${x2},${y2 + dy} ${x2},${y2}`;
|
||||
}
|
||||
const line = this.make_svg_el("path", line_opt);
|
||||
return line;
|
||||
}
|
||||
gen_commit_data_header(name, value) {
|
||||
const p = $("<p />")
|
||||
.css("display", "block");
|
||||
p[0].innerHTML = `<b>${name.__()}</b>: ${value}`;
|
||||
return p[0];
|
||||
}
|
||||
open_popup(commit) {
|
||||
const el = commit.domel;
|
||||
if (!el)
|
||||
return;
|
||||
$(this.commit_detail_el).empty();
|
||||
const position = $(el).position();
|
||||
const bbox = this.svg_element.getBBox();
|
||||
const off_left = bbox.x + bbox.width + this.options.x_offset / 2;
|
||||
const svg = this.make_svg_el("svg", {
|
||||
width: off_left - commit.cx + 5,
|
||||
height: this.options.y_offset
|
||||
});
|
||||
$(svg)
|
||||
.css("display", "block")
|
||||
.css("position", "absolute")
|
||||
.css("left", "0")
|
||||
.css("top", "-2px");
|
||||
svg.appendChild(this.draw_line(0, this.options.y_offset / 2, off_left - commit.cx, this.options.y_offset / 2, commit.color));
|
||||
/*
|
||||
svg.appendChild(
|
||||
this.make_svg_el("circle",{
|
||||
cx: off_left-commit.cx - 1,
|
||||
cy: this.options.y_offset/2,
|
||||
r:4,
|
||||
fill: commit.color,
|
||||
"stroke-width": 0.0
|
||||
})
|
||||
);*/
|
||||
$(this.commit_detail_el)
|
||||
.css("border", "2px solid " + commit.color)
|
||||
.css("color", commit.color)
|
||||
.append($("<div />")
|
||||
.css("position", "absolute")
|
||||
.css("height", this.options.y_offset)
|
||||
.css("left", commit.cx - off_left)
|
||||
.css("padding-left", off_left - commit.cx)
|
||||
.append(svg)
|
||||
.append($("<i/>").text('[X]')
|
||||
.css("cursor", "pointer"))
|
||||
.addClass("git_grapth_commit_detail_ctrl")
|
||||
.on("click", (e) => {
|
||||
$(this.commit_detail_el)
|
||||
.css("display", "none")
|
||||
.empty();
|
||||
}));
|
||||
const left = $("<div />")
|
||||
.css("display", "block")
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("flex", "1")
|
||||
.css("border-right", "1px solid " + commit.color)
|
||||
.addClass("git_grapth_commit_detail_left");
|
||||
const right = $("<div />")
|
||||
.css("display", "block")
|
||||
.css("overflow-y", "auto")
|
||||
.css("overflow-x", "hidden")
|
||||
.css("flex", "1")
|
||||
.addClass("git_grapth_commit_detail_right");
|
||||
// display
|
||||
left.append(this.gen_commit_data_header(__("Commit"), commit.hashes.commit));
|
||||
left.append(this.gen_commit_data_header(__("Parents"), commit.hashes.parents));
|
||||
left.append(this.gen_commit_data_header(__("Author"), `${commit.committer.name} <${commit.committer.email}>`));
|
||||
left.append(this.gen_commit_data_header(__("Date"), (new Date(commit.committer.date).toDateString())));
|
||||
left.append($("<pre />")
|
||||
.css("white-space", "pre-wrap")
|
||||
.text(commit.message));
|
||||
this.commit_detail_el.appendChild(left[0]);
|
||||
this.commit_detail_el.appendChild(right[0]);
|
||||
this.list_file(commit.hashes.commit)
|
||||
.then((files) => {
|
||||
const ul = $('<ul/>');
|
||||
$.each(files, (index, value) => {
|
||||
const arr = value.split("\t");
|
||||
const li = $('<li/>');
|
||||
const a = $('<a/>')
|
||||
.css("cursor", "pointer")
|
||||
.addClass(`git_graph_file_${arr[0].toLowerCase()}`)
|
||||
.on("click", e => {
|
||||
if (this._on_open_diff) {
|
||||
Promise.all([
|
||||
this.get_file(arr[1], `${commit.hashes.commit}^`),
|
||||
this.get_file(arr[1], commit.hashes.commit)
|
||||
])
|
||||
.then((values) => {
|
||||
// create the file
|
||||
const files = values.map((content, index) => {
|
||||
const file = `mem://${commit.hashes.commit.slice(0, 8)}${index == 0 ? "^" : ""}/${arr[1]}`.asFileHandle();
|
||||
file.cache = content;
|
||||
file.info.mime = "text/plain";
|
||||
return file;
|
||||
});
|
||||
this._on_open_diff(files);
|
||||
})
|
||||
.catch((e) => {
|
||||
OS.announcer.oserror(__("Unable to fetch diff of {0}: {1}", commit.hashes.commit, e.toString()), e);
|
||||
});
|
||||
}
|
||||
});
|
||||
a.text(arr[1]);
|
||||
ul.append(li.append(a));
|
||||
});
|
||||
right.append(ul);
|
||||
})
|
||||
.catch((e) => OS.announcer.oserror(__("Unable to get commit changes: {0}", e.toString()), e));
|
||||
// scroll down if necessary
|
||||
$(this.commit_detail_el)
|
||||
.css("top", position.top)
|
||||
.css("left", off_left)
|
||||
.css("display", "flex")
|
||||
.css("width", `calc(100% - ${off_left + this.options.x_offset}px)`)
|
||||
.css("fflex-direction", "row");
|
||||
const delta = this.commit_detail_el.getBoundingClientRect().bottom -
|
||||
this.options.target.getBoundingClientRect().bottom;
|
||||
if (delta > 0) {
|
||||
this.options.target.scrollTop += delta + 10;
|
||||
}
|
||||
}
|
||||
render_commit(commit, color) {
|
||||
let current = false;
|
||||
const p = $("<p />")
|
||||
.css("padding", "0")
|
||||
.css("margin", "0")
|
||||
.css("display", "block")
|
||||
.css("height", `${this.options.y_offset}px`)
|
||||
.css("line-height", `${this.options.y_offset}px`)
|
||||
.css("color", color)
|
||||
.css("vertical-align", "middle")
|
||||
.css("white-space", "nowrap")
|
||||
.css("overflow", "hidden");
|
||||
p.addClass("git_graph_commit_message");
|
||||
let html = `<i class="git_graph_commit_hash">${commit.hashes.commit.slice(0, 8)}</i> `;
|
||||
commit.branches = [];
|
||||
for (const tag of commit.extra.split(",").map(e => e.trim()).filter(e => e != "")) {
|
||||
let found = tag.match(/HEAD -> (.*)/i);
|
||||
if (found && found.length == 2) {
|
||||
html += `<i class = "git_graph_commit_branch">${found[1]}</i> `;
|
||||
p.addClass("git_graph_commit_current_head");
|
||||
current = true;
|
||||
commit.branches.push(found[1]);
|
||||
this.current_head = commit;
|
||||
}
|
||||
else if ((found = tag.match(/tag: (.*)/i))) {
|
||||
html += `<i class = "git_graph_commit_tag">${found[1]}</i> `;
|
||||
}
|
||||
else {
|
||||
html += `<i class = "git_graph_commit_branch">${tag}</i> `;
|
||||
commit.branches.push(tag);
|
||||
}
|
||||
}
|
||||
html += `<i class ="git_graph_commit_text">${commit.message.split("\n")[0]}</i> `;
|
||||
html += `<i class ="git_graph_commit_author">${commit.committer.name}</i> `;
|
||||
html += `<i class ="git_graph_commit_date">${new Date(commit.committer.date).toDateString()}</i>`;
|
||||
p[0].innerHTML = html;
|
||||
p.on("click", (e) => {
|
||||
this.open_popup(commit);
|
||||
});
|
||||
this.commits_list_element.insertBefore(p[0], this.load_more_el);
|
||||
commit.domel = p[0];
|
||||
return current;
|
||||
}
|
||||
draw_graph(data) {
|
||||
for (const commit of data) {
|
||||
this.oldest_commit_date = commit.committer.date;
|
||||
if (commit.extra.includes("refs/stash")) {
|
||||
continue;
|
||||
}
|
||||
this.commits[commit.hashes.commit] = commit;
|
||||
let merge = this.update_line_data(commit, this.current_y_offset);
|
||||
let lines = merge.src;
|
||||
// combine the lines
|
||||
for (const linedata of lines.filter(o => o.x_offset != merge.dest.x_offset)) {
|
||||
this.svg_element.appendChild(this.draw_line(merge.dest.x_offset, merge.dest.y_offset, linedata.x_offset, linedata.y_offset, linedata.color));
|
||||
}
|
||||
this.lines_data.sort((a, b) => a.x_offset - b.x_offset);
|
||||
let x_offset = this.options.x_offset;
|
||||
for (const linedata of this.lines_data) {
|
||||
if (linedata.beginning && linedata.y_offset > this.current_y_offset) {
|
||||
continue;
|
||||
}
|
||||
linedata.y_offset = this.current_y_offset;
|
||||
if (!linedata.beginning) {
|
||||
if (linedata.x_offset > x_offset) {
|
||||
this.svg_element.appendChild(this.draw_line(linedata.x_offset, linedata.y_offset - this.options.y_offset, linedata.x_offset - this.options.x_offset, linedata.y_offset, linedata.color));
|
||||
linedata.x_offset = x_offset;
|
||||
}
|
||||
else {
|
||||
this.svg_element.appendChild(this.draw_line(linedata.x_offset, linedata.y_offset - this.options.y_offset, linedata.x_offset, linedata.y_offset, linedata.color));
|
||||
}
|
||||
}
|
||||
x_offset += this.options.x_offset;
|
||||
linedata.beginning = false;
|
||||
}
|
||||
let options = {
|
||||
cx: merge.dest.x_offset,
|
||||
cy: merge.dest.y_offset,
|
||||
r: 4,
|
||||
fill: merge.dest.color,
|
||||
stroke: 'black',
|
||||
"stroke-width": 0.0
|
||||
};
|
||||
if (this.render_commit(commit, merge.dest.color)) {
|
||||
options.r = options.r * 1.5;
|
||||
}
|
||||
commit.cx = options.cx;
|
||||
commit.color = options.fill;
|
||||
const circle = this.make_svg_el("circle", options);
|
||||
this.svg_element.appendChild(circle);
|
||||
this.current_y_offset += this.options.y_offset;
|
||||
}
|
||||
const bbox = this.svg_element.getBBox();
|
||||
this.svg_element.setAttribute("width", (bbox.x + bbox.width).toString());
|
||||
this.svg_element.setAttribute("height", (bbox.y + bbox.height + this.options.y_offset / 2).toString());
|
||||
//$(this.commits_list_element).css("left", `-${bbox.x + bbox.width}px`);
|
||||
$(".git_graph_commit_message", this.commits_list_element).css("padding-left", `${bbox.x + bbox.width + this.options.x_offset / 2}px`);
|
||||
}
|
||||
list_file(hash) {
|
||||
let request = {
|
||||
action: 'list_file',
|
||||
args: {
|
||||
commit: hash
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
get_changes(file, hash) {
|
||||
let request = {
|
||||
action: 'get_changes',
|
||||
args: {
|
||||
commit: hash,
|
||||
file: file
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
get_file(file, hash) {
|
||||
let request = {
|
||||
action: 'get_file',
|
||||
args: {
|
||||
commit: hash,
|
||||
file: file
|
||||
}
|
||||
};
|
||||
return this.call(request);
|
||||
}
|
||||
}
|
||||
API.LibGitGraph = LibGitGraph;
|
||||
})(API = OS.API || (OS.API = {}));
|
||||
})(OS || (OS = {}));
|
@ -1,8 +0,0 @@
|
||||
<afx-app-window apptitle="LibGitGraph" width="600" height="400" data-id="GitGraph">
|
||||
<afx-hbox >
|
||||
<div data-id="git-graph">
|
||||
</div>
|
||||
<!--afx-resizer data-width="3"></afx-resizer>
|
||||
<div data-id="commit-detail"></div-->
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
@ -1,44 +0,0 @@
|
||||
namespace OS {
|
||||
export namespace API
|
||||
{
|
||||
export declare class LibGitGraph
|
||||
{
|
||||
constructor(options:GenericObject<any>);
|
||||
base_dir: VFS.BaseFileHandle;
|
||||
on_open_diff: (file:VFS.BaseFileHandle[]) => void;
|
||||
list_file: (commit: string) => Promise<string[]>;
|
||||
get_changes: (file:string, commit: string) => Promise<string>;
|
||||
get_file: (file:string, commit: string) => Promise<string>
|
||||
}
|
||||
}
|
||||
export namespace application {
|
||||
/**
|
||||
*
|
||||
* @class GitGraph
|
||||
* @extends {BaseApplication}
|
||||
*/
|
||||
export class GitGraph extends BaseApplication {
|
||||
constructor(args: AppArgumentsType[]) {
|
||||
super("GitGraph", args);
|
||||
}
|
||||
main(): void {
|
||||
let graph = new API.LibGitGraph({
|
||||
target: this.find("git-graph")
|
||||
});
|
||||
graph.on_open_diff = (files) => {
|
||||
console.log(files);
|
||||
//(OS.PM.processes.Antedit[0] as any).openDiff(files)
|
||||
|
||||
this._gui.launch("Antedit", [])
|
||||
.then((p) =>{
|
||||
p.observable.one("launched",() =>(p as any).openDiff(files));
|
||||
});
|
||||
|
||||
}
|
||||
graph.base_dir = "home://workspace/antos/".asFileHandle();
|
||||
}
|
||||
}
|
||||
|
||||
//GitGraph.dependencies = ["pkg://GitGraph/libgitgraph.js"];
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<afx-app-window apptitle="LibGitGraph" width="600" height="400" data-id="GitGraph">
|
||||
<afx-hbox >
|
||||
<div data-id="git-graph">
|
||||
</div>
|
||||
<!--afx-resizer data-width="3"></afx-resizer>
|
||||
<div data-id="commit-detail"></div-->
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
@ -2,6 +2,7 @@
|
||||
AntOSDK: development API for AntOS based applications/projects
|
||||
|
||||
## Change logs
|
||||
- 0.0.14: vfs-rm can be configured to be silent when the target does not exist
|
||||
- 0.0.13: allow linux-job handle to set defaut pwd if it is not specified in job description
|
||||
- 0.0.12: TS worker now allows user specific compile options (defined un build file)
|
||||
- 0.0.11: Update AntOS API v1.2.1
|
||||
|
@ -2,6 +2,7 @@
|
||||
AntOSDK: development API for AntOS based applications/projects
|
||||
|
||||
## Change logs
|
||||
- 0.0.14: vfs-rm can be configured to be silent when the target does not exist
|
||||
- 0.0.13: allow linux-job handle to set defaut pwd if it is not specified in job description
|
||||
- 0.0.12: TS worker now allows user specific compile options (defined un build file)
|
||||
- 0.0.11: Update AntOS API v1.2.1
|
||||
|
@ -446,7 +446,12 @@ class VFSJob extends AntOSDKBaseJob {
|
||||
case 'rm':
|
||||
this.delete(this.job.data)
|
||||
.then(d => this.result(d))
|
||||
.catch(e => this.error(e));
|
||||
.catch((e) =>this.error(e));
|
||||
break;
|
||||
case 'rm_no_error':
|
||||
this.delete(this.job.data)
|
||||
.then(d => this.result(d))
|
||||
.catch((e) =>this.result(false));
|
||||
break;
|
||||
case 'mkdir':
|
||||
this.mkdir(this.job.data)
|
||||
@ -473,6 +478,7 @@ API.jobhandle["sdk-import"] = LoadScritpJob;
|
||||
API.jobhandle["sdk-setup"] = SDKSetup;
|
||||
API.jobhandle["vfs-cat"] = VFSJob;
|
||||
API.jobhandle["vfs-rm"] = VFSJob;
|
||||
API.jobhandle["vfs-rm_no_error"] = VFSJob;
|
||||
API.jobhandle["vfs-mkdir"] = VFSJob;
|
||||
API.jobhandle["vfs-cp"] = VFSJob;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.0.13-a",
|
||||
"version": "0.0.14-a",
|
||||
"category": "Development",
|
||||
"iconclass": "fa fa-cog",
|
||||
"mimes": [
|
||||
|
@ -446,7 +446,12 @@ class VFSJob extends AntOSDKBaseJob {
|
||||
case 'rm':
|
||||
this.delete(this.job.data)
|
||||
.then(d => this.result(d))
|
||||
.catch(e => this.error(e));
|
||||
.catch((e) =>this.error(e));
|
||||
break;
|
||||
case 'rm_no_error':
|
||||
this.delete(this.job.data)
|
||||
.then(d => this.result(d))
|
||||
.catch((e) =>this.result(false));
|
||||
break;
|
||||
case 'mkdir':
|
||||
this.mkdir(this.job.data)
|
||||
@ -473,6 +478,7 @@ API.jobhandle["sdk-import"] = LoadScritpJob;
|
||||
API.jobhandle["sdk-setup"] = SDKSetup;
|
||||
API.jobhandle["vfs-cat"] = VFSJob;
|
||||
API.jobhandle["vfs-rm"] = VFSJob;
|
||||
API.jobhandle["vfs-rm_no_error"] = VFSJob;
|
||||
API.jobhandle["vfs-mkdir"] = VFSJob;
|
||||
API.jobhandle["vfs-cp"] = VFSJob;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.0.13-a",
|
||||
"version": "0.0.14-a",
|
||||
"category": "Development",
|
||||
"iconclass": "fa fa-cog",
|
||||
"mimes": [
|
||||
|
@ -45,7 +45,7 @@
|
||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/README.md",
|
||||
"category": "Development",
|
||||
"author": "Xuan Sang LE",
|
||||
"version": "0.2.1-b",
|
||||
"version": "0.2.2-b",
|
||||
"dependencies": ["MonacoCore@0.33.0-r"],
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antedit/build/release/Antedit.zip"
|
||||
},
|
||||
@ -69,16 +69,6 @@
|
||||
"dependencies": ["Antunnel@0.2.0-b"],
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/AntunnelPlugins/build/release/AntunnelPlugins.zip"
|
||||
},
|
||||
{
|
||||
"pkgname": "AntunnelTestClient",
|
||||
"name": "AntunnelTestClient",
|
||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/AntunnelTestClient/README.md",
|
||||
"category": "Development",
|
||||
"author": "Dany LE",
|
||||
"version": "0.1.0-a",
|
||||
"dependencies": ["Antunnel@0.2.1-b"],
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/AntunnelTestClient/build/release/AntunnelTestClient.zip"
|
||||
},
|
||||
{
|
||||
"pkgname": "Archive",
|
||||
"name": "Archive",
|
||||
@ -169,6 +159,16 @@
|
||||
"dependencies": [],
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Dockman/build/release/Dockman.zip"
|
||||
},
|
||||
{
|
||||
"pkgname": "GitGraph",
|
||||
"name": "GIT Visualization",
|
||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/GitGraph/README.md",
|
||||
"category": "Development",
|
||||
"author": "Dany LE",
|
||||
"version": "0.1.4-b",
|
||||
"dependencies": [],
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/GitGraph/build/release/GitGraph.zip"
|
||||
},
|
||||
{
|
||||
"pkgname": "GPClient",
|
||||
"name": "Generic Purpose client",
|
||||
@ -215,7 +215,7 @@
|
||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/README.md",
|
||||
"category": "Development",
|
||||
"author": "Xuan Sang LE",
|
||||
"version": "0.0.13-a",
|
||||
"version": "0.0.14-a",
|
||||
"dependencies": [],
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/build/release/libantosdk.zip"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user