* 恢复合并时误删的/logo router * change terminal * change terminal * Merge main * fix api bug * feature-permission
234 lines
9.1 KiB
Handlebars
234 lines
9.1 KiB
Handlebars
{{template "base/head" .}}
|
||
<div role="main" aria-label="{{.Title}}" class="page-content repository wiki pages">
|
||
{{template "repo/header" .}}
|
||
<div class="ui container">
|
||
{{template "base/alert" .}}
|
||
<!-- 开始:Dev Container 正文 -->
|
||
<div class="issue-content">
|
||
<!-- 开始:Dev Container 正文内容 - 左侧主展示区 -->
|
||
<div class="issue-content-left">
|
||
{{if not .HasValidDevContainerJSON}}
|
||
|
||
<div class="empty-placeholder">
|
||
{{svg "octicon-container" 48}}
|
||
<h2>{{ctx.Locale.Tr "repo.dev_container_empty"}}</h2>
|
||
{{if .isAdmin}}
|
||
<form method="get" action="{{.CreateDevcontainerSettingUrl}}" class="ui edit form">
|
||
<button class="ui primary button" type="submit">Create</button>
|
||
</form>
|
||
{{end}}
|
||
</div>
|
||
|
||
{{else}}
|
||
|
||
<div class="ui container">
|
||
|
||
<form class="ui edit form">
|
||
<div class="repo-editor-header">
|
||
<div class="ui breadcrumb field">
|
||
<a class="section" href="{{$.BranchLink}}">{{.Repository.Name}}</a>
|
||
{{range $i, $v := .TreeNames}}
|
||
<div class="breadcrumb-divider">/</div>
|
||
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>
|
||
{{end}}
|
||
|
||
</div>
|
||
<a href="{{.EditDevcontainerConfigurationUrl}}"><div class="ui primary button" style="margin-left: 10px;width: 4em;height: 1em;">Edit</div></a>
|
||
</div>
|
||
|
||
</form>
|
||
<iframe src="http://localhost:3000/assets/terminal/index.html?{{.TerminalParams}}" width="100%" height="400" frameborder="0">您的浏览器不支持iframe</iframe>
|
||
</div>
|
||
|
||
<!--<div id="repo-devcontainer-view" data-outputLink="{{.Repository.Link}}/dev-container/output"></div>-->
|
||
|
||
{{end}}
|
||
</div>
|
||
<!-- 结束:Dev Container 正文内容 - 左侧主展示区 -->
|
||
|
||
<!-- 开始:Dev Container 正文内容 - 右侧展示区 -->
|
||
<div class="issue-content-right ui segment">
|
||
<strong>Options</strong>
|
||
<div class="ui relaxed list">
|
||
|
||
{{if .HasDevContainer}}
|
||
<div class="item"><a class="delete-button flex-text-inline" data-modal="#delete-repo-devcontainer-of-user-modal" href="#" data-url="{{.Repository.Link}}/dev-container/delete">{{svg "octicon-trash" 14}}{{ctx.Locale.Tr "repo.dev_container_control.delete"}}</a></div>
|
||
{{if .isAdmin}}
|
||
|
||
{{if .Running}}
|
||
<div class="item"><a class="delete-button flex-text-inline" style="color:black;" data-modal-id="updatemodal" href="#">{{svg "octicon-database"}}{{ctx.Locale.Tr "repo.dev_container_control.update"}}</a></div>
|
||
{{end}}
|
||
{{end}}
|
||
{{if .InitializedContainer}}
|
||
{{if not .Restart}}
|
||
{{if not .Stop}}
|
||
<div class="item"><button id="restartButton" class="flex-text-inline" style="color:black;" onclick="handleClick(event, '{{.Repository.Link}}/dev-container/restart', document.getElementById('stopButton'))" >{{svg "octicon-terminal" 14 "tw-mr-2"}} Restart Dev Container</button></div>
|
||
<div class="item"><button id="stopButton" class="flex-text-inline" style="color:black;" onclick="handleClick(event, '{{.Repository.Link}}/dev-container/stop', document.getElementById('restartButton'))" >{{svg "octicon-terminal" 14 "tw-mr-2"}} Stop Dev Container</button></div>
|
||
|
||
<div class="item"><a class="flex-text-inline" style="color:black;" href="{{.WebSSHUrl}}" target="_blank">{{svg "octicon-code" 14}}open with WebTerminal</a></div>
|
||
<div class="item"><a class="flex-text-inline" style="color:black;" onclick="window.location.href = '{{.VSCodeUrl}}'">{{svg "octicon-code" 14}}open with VSCode</a ></div>
|
||
<div class="item"><a class="flex-text-inline" style="color:black;" onclick="window.location.href = '{{.CursorUrl}}'">{{svg "octicon-code" 14}}open with Cursor</a ></div>
|
||
<div class="item"><a class="flex-text-inline" style="color:black;" onclick="window.location.href = '{{.WindsurfUrl}}'">{{svg "octicon-code" 14}}open with Windsurf</a ></div>
|
||
{{end}}
|
||
{{end}}
|
||
{{end}}
|
||
{{else if .HasValidDevContainerJSON}}
|
||
<div class="item">
|
||
{{if not .isCreatingDevcontainer}}
|
||
{{if .canRead}}
|
||
<a class="button flex-text-inline" href="{{.Repository.Link}}/dev-container/create">{{svg "octicon-terminal" 14 "tw-mr-2"}} Create Dev Container</a>
|
||
{{else}}
|
||
<div class="button flex-text-inline" disabled>Permission Denied</div>
|
||
{{end}}
|
||
{{else}}
|
||
<div class="button flex-text-inline" disabled>{{svg "octicon-terminal" 14 "tw-mr-2"}} Running</div>
|
||
{{end}}
|
||
</div>
|
||
{{end}}
|
||
{{if not .HasValidDevContainerJSON}}
|
||
<div class="item">{{svg "octicon-alert" 16 "tw-mr-2"}} {{ctx.Locale.Tr "repo.dev_container_invalid_config_prompt"}} </div>
|
||
{{end}}
|
||
</div>
|
||
</div>
|
||
<!-- 结束:Dev Container 正文内容 - 右侧展示区 -->
|
||
</div>
|
||
|
||
<!-- 结束Dev Container 正文内容 -->
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 确认删除 Dev Container 模态对话框 -->
|
||
<div class="ui g-modal-confirm delete modal" id="delete-repo-devcontainer-of-user-modal">
|
||
<div class="header">
|
||
{{svg "octicon-trash"}}
|
||
{{ctx.Locale.Tr "repo.dev_container_control.delete"}}
|
||
</div>
|
||
<div class="content">
|
||
<p>{{ctx.Locale.Tr "repo.dev_container_control.deletion_desc"}}</p>
|
||
</div>
|
||
{{template "base/modal_actions_confirm" .}}
|
||
</div>
|
||
<!-- 确认 Dev Container 模态对话框 -->
|
||
<div class="ui g-modal-confirm delete modal" style="width: 35%" id="updatemodal">
|
||
<div class="header">
|
||
{{ctx.Locale.Tr "repo.dev_container_control.update"}}
|
||
</div>
|
||
<script>
|
||
function submitForm(event) {
|
||
event.preventDefault(); // 阻止默认的表单提交行为
|
||
const {csrfToken} = window.config;
|
||
const {appSubUrl} = window.config;
|
||
const form = document.getElementById('updateForm');
|
||
const submitButton = document.getElementById('updateSubmitButton');
|
||
const closeButton = document.getElementById('updateCloseButton');
|
||
submitButton.disabled = true;
|
||
const formData = new FormData(form);
|
||
fetch('{{.Repository.Link}}'+'/dev-container/update', {
|
||
method: 'POST',
|
||
headers: {
|
||
'x-csrf-token': csrfToken, // 如果需要认证
|
||
'content-type' : 'application/json',
|
||
},
|
||
body: JSON.stringify({
|
||
RepositoryAddress: formData.get('RepositoryAddress'),
|
||
RepositoryUsername: formData.get('RepositoryUsername'),
|
||
RepositoryPassword: formData.get('RepositoryPassword'),
|
||
SaveMethod: formData.get('SaveMethod'),
|
||
ImageName: formData.get('ImageName'),
|
||
})
|
||
|
||
})
|
||
.then(response => response.json())
|
||
.then(data => {
|
||
submitButton.disabled = false;
|
||
alert(data.message);
|
||
if(data.redirect){
|
||
closeButton.click()
|
||
}
|
||
})
|
||
.catch((error) => {
|
||
alert('提交失败,请重试。');
|
||
});
|
||
}
|
||
</script>
|
||
<div class="content">
|
||
<form class="ui form tw-max-w-2xl tw-m-auto" id="updateForm" onsubmit="submitForm(event)">
|
||
<div class="inline field">
|
||
<div class="ui checkbox">
|
||
{{if not .HasDockerfile}}
|
||
<input type="checkbox" id="SaveMethod" name="SaveMethod" disabled>
|
||
{{else}}
|
||
<input type="checkbox" id="SaveMethod" name="SaveMethod" value="on">
|
||
{{end}}
|
||
<label for="SaveMethod">Build From Dockerfile</label>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="required field ">
|
||
<label for="RepositoryAddress">Registry:</label>
|
||
<input style="border: 1px solid black;" type="text" id="RepositoryAddress" name="RepositoryAddress" value="{{.RepositoryAddress}}">
|
||
</div>
|
||
<div class="required field ">
|
||
<label for="RepositoryUsername">Registry Username:</label>
|
||
<input style="border: 1px solid black;" type="text" id="RepositoryUsername" name="RepositoryUsername" value="{{.RepositoryUsername}}">
|
||
</div>
|
||
<div class="required field ">
|
||
<label for="RepositoryPassword">Registry Password:</label>
|
||
<input style="border: 1px solid black;" type="text" id="RepositoryPassword" name="RepositoryPassword" required>
|
||
</div>
|
||
<div class="required field ">
|
||
<label for="ImageName">Image(name:tag):</label>
|
||
<input style="border: 1px solid black;" type="text" id="ImageName" name="ImageName" value="{{.ImageName}}">
|
||
</div>
|
||
|
||
<div class="actions">
|
||
<button class="ui primary button" type="submit" id="updateSubmitButton" >Submit</button>
|
||
<button class="ui cancel button" id="updateCloseButton">Close</button>
|
||
</div>
|
||
|
||
</form>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<script>
|
||
function handleClick(event, targetLink, other) {
|
||
event.preventDefault();
|
||
const link = event.target;
|
||
link.disabled = true; // 禁用链接
|
||
link.style.cursor = 'auto';
|
||
link.style.color = 'gray';
|
||
if(other){
|
||
other.disabled = true;
|
||
other.style.cursor = 'auto';
|
||
other.style.color = 'gray';
|
||
}
|
||
console.log(targetLink);
|
||
// 发送网络请求
|
||
fetch(targetLink)
|
||
.then(response => response.json())
|
||
.then(data => {
|
||
|
||
//console.log('响应数据:', data);
|
||
// 处理响应数据
|
||
})
|
||
.catch(error => {
|
||
|
||
//console.error('请求错误:', error);
|
||
})
|
||
.finally(() => {
|
||
// 无论请求成功还是失败,都重新启用链接
|
||
link.style.color = 'black';
|
||
if(other){
|
||
other.disabled = false;
|
||
other.style.color = 'black';
|
||
other.style.cursor = 'pointer';
|
||
}
|
||
link.disabled = false;
|
||
link.style.cursor = 'pointer';
|
||
location.reload();
|
||
});
|
||
}
|
||
</script>
|
||
{{template "base/footer" .}}
|