show differences
Some checks failed
backend / cross (aarch64) (push) Waiting to run
backend / cross (arm) (push) Waiting to run
backend / cross (armhf) (push) Waiting to run
backend / cross (i686) (push) Waiting to run
backend / cross (mips) (push) Waiting to run
backend / cross (mips64) (push) Waiting to run
backend / cross (mips64el) (push) Waiting to run
backend / cross (mipsel) (push) Waiting to run
backend / cross (s390x) (push) Waiting to run
backend / cross (win32) (push) Waiting to run
backend / cross (x86_64) (push) Waiting to run
frontend / build (push) Waiting to run
docker / build (push) Has been cancelled

This commit is contained in:
2025-10-18 16:35:39 +08:00
parent 6dbe2f6e20
commit fd338d2dad
6 changed files with 24752 additions and 27571 deletions

View File

@@ -16,7 +16,22 @@ interface State {
export class Terminal extends Component<Props, State> {
private container: HTMLElement;
private xterm: Xterm;
private intervalID: NodeJS.Timeout;
private currentDevcontainer = {
title: 'Devcontainer Info',
detail: 'No Devcontainer Created yet',
port: '',
ip:'',
steps: [
// {
// summary: '',
// duration: '',
// status: '',
// logs:{
// },
// }
],
};
constructor(props: Props) {
super();
this.xterm = new Xterm(props, this.showModal);
@@ -24,8 +39,42 @@ export class Terminal extends Component<Props, State> {
async componentDidMount() {
await this.xterm.refreshToken();
this.xterm.open(this.container);
this.xterm.connect();
const options = new URLSearchParams(decodeURIComponent(window.location.search));
const params = new URLSearchParams({
repo: options.get('repoid') as string,
user: options.get('userid') as string,
});
fetch('http://' +
options.get('domain') +
':'+
options.get('port') +
'/' +
options.get('user') +
'/' +
options.get('repo') +
'/devcontainer/status?' +
params
)
.then(response => response.json())
.then(data => {
if (data.status !== '-1') {
if (options.get('type') === 'docker') {
this.xterm.open(this.container);
this.xterm.connect();
} else {
this.intervalID = setInterval(this.loadOutput, 3000);
this.xterm.open(this.container);
this.xterm.changeUrl(this.currentDevcontainer.ip, this.currentDevcontainer.port)
this.xterm.changeStatus(true);
this.xterm.connect();
}
}
})
.catch(error => {
console.error('Error:', error);
});
}
componentWillUnmount() {
@@ -56,4 +105,48 @@ export class Terminal extends Component<Props, State> {
const files = (event.target as HTMLInputElement).files;
if (files) this.xterm.sendFile(files);
}
@bind
private loadOutput() {
const options = new URLSearchParams(decodeURIComponent(window.location.search));
const params = new URLSearchParams({
repo: options.get('repoid') as string,
user: options.get('userid') as string,
});
fetch(
'http://' + options.get('domain') + ':'+ options.get('port') +'/' +
options.get('user') +
'/' +
options.get('repo') +
'/devcontainer/output?' +
params
)
.then(response => response.json())
.then(job => {
if (!job) {
clearInterval(this.intervalID);
this.intervalID = null as any;
return;
}
if(this.currentDevcontainer.steps.length < job.currentDevcontainer.steps.length){
for(let i = this.currentDevcontainer.steps.length; i < job.currentDevcontainer.steps.length; i++) {
this.xterm.writeData(job.currentDevcontainer.steps[i].summary);
this.xterm.writeData('\r\n');
for(let j = 0; j < job.currentDevcontainer.steps[i].logs.length; j++) {
this.xterm.writeData(job.currentDevcontainer.steps[i].logs[j].message.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n'));
this.xterm.writeData('\r\n');
}
}
}
this.currentDevcontainer = job.currentDevcontainer;
if (this.currentDevcontainer.detail === '4' && this.intervalID) {
clearInterval(this.intervalID);
this.intervalID = null as any;
}
})
.catch(error => {
console.error('Error:', error);
});
}
}