mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-09 00:12:03 +01:00
add have logged in and no items handles.
This commit is contained in:
parent
2011453d4b
commit
6216799942
37
controllers/ng/signin.go
Normal file
37
controllers/ng/signin.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package ng
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/vmware/harbor/dao"
|
||||||
|
"github.com/vmware/harbor/models"
|
||||||
|
"github.com/vmware/harbor/utils/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SignInController struct {
|
||||||
|
BaseController
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sic *SignInController) Get() {
|
||||||
|
sessionUserID := sic.GetSession("userId")
|
||||||
|
var hasLoggedIn bool
|
||||||
|
var username string
|
||||||
|
if sessionUserID != nil {
|
||||||
|
hasLoggedIn = true
|
||||||
|
userID := sessionUserID.(int)
|
||||||
|
u, err := dao.GetUser(models.User{UserID: userID})
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error occurred in GetUser, error: %v", err)
|
||||||
|
sic.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||||||
|
}
|
||||||
|
if u == nil {
|
||||||
|
log.Warningf("User was deleted already, user id: %d, canceling request.", userID)
|
||||||
|
sic.CustomAbort(http.StatusUnauthorized, "")
|
||||||
|
}
|
||||||
|
username = u.Username
|
||||||
|
}
|
||||||
|
sic.Data["Username"] = username
|
||||||
|
sic.Data["HasLoggedIn"] = hasLoggedIn
|
||||||
|
sic.TplName = "ng/sign-in.htm"
|
||||||
|
sic.Render()
|
||||||
|
}
|
@ -6,6 +6,29 @@ body {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.has-logged-in {
|
||||||
|
position: relative;
|
||||||
|
top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-logged-in h4 {
|
||||||
|
float: left;
|
||||||
|
width: 100%;
|
||||||
|
line-height: 2em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-logged-in .last-logged-in-time {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-logged-in .control-button {
|
||||||
|
height: 2em;
|
||||||
|
width: 100%;
|
||||||
|
padding-right: 10%;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
.container-fluid-custom {
|
.container-fluid-custom {
|
||||||
background-color: #EFEFEF;
|
background-color: #EFEFEF;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
|
@ -57,3 +57,8 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-hint {
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
@ -8,7 +8,10 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
|
<div ng-if="vm.repositories.length === 0" class="empty-hint">
|
||||||
|
<h3 style="margin-top: 200px;" class="text-muted">// 'no_repositories' | tr //</h3>
|
||||||
|
</div>
|
||||||
|
<div ng-if="vm.repositories.length > 0" class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
|
||||||
<modal-dialog action="vm.deleteImage()" content-type="text/html" title="//vm.modalTitle//" message="//vm.modalMessage//"></modal-dialog>
|
<modal-dialog action="vm.deleteImage()" content-type="text/html" title="//vm.modalTitle//" message="//vm.modalMessage//"></modal-dialog>
|
||||||
<div class="panel panel-default" ng-repeat="repo in vm.repositories">
|
<div class="panel panel-default" ng-repeat="repo in vm.repositories">
|
||||||
<div class="panel-heading" role="tab" id="heading//$index + 1//">
|
<div class="panel-heading" role="tab" id="heading//$index + 1//">
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
vm.retrieve = retrieve;
|
vm.retrieve = retrieve;
|
||||||
vm.projectId = $routeParams.project_id;
|
vm.projectId = $routeParams.project_id;
|
||||||
vm.tagCount = {};
|
vm.tagCount = {};
|
||||||
|
|
||||||
vm.retrieve();
|
vm.retrieve();
|
||||||
|
|
||||||
$scope.$on('repoName', function(e, val) {
|
$scope.$on('repoName', function(e, val) {
|
||||||
@ -58,7 +57,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getRepositoryComplete(data, status) {
|
function getRepositoryComplete(data, status) {
|
||||||
vm.repositories = data;
|
vm.repositories = data || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRepositoryFailed(response) {
|
function getRepositoryFailed(response) {
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
.module('harbor.sign.in')
|
.module('harbor.sign.in')
|
||||||
.directive('signIn', signIn);
|
.directive('signIn', signIn);
|
||||||
|
|
||||||
SignInController.$inject = ['SignInService', '$window', '$scope'];
|
SignInController.$inject = ['SignInService', 'LogOutService', 'currentUser', 'I18nService', '$window', '$scope'];
|
||||||
function SignInController(SignInService, $window, $scope) {
|
function SignInController(SignInService, LogOutService, currentUser, I18nService, $window, $scope) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
vm.hasError = false;
|
vm.hasError = false;
|
||||||
@ -18,6 +18,9 @@
|
|||||||
vm.doSignUp = doSignUp;
|
vm.doSignUp = doSignUp;
|
||||||
vm.doForgotPassword = doForgotPassword;
|
vm.doForgotPassword = doForgotPassword;
|
||||||
|
|
||||||
|
vm.doContinue = doContinue;
|
||||||
|
vm.doLogOut = doLogOut;
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
vm.hasError = false;
|
vm.hasError = false;
|
||||||
vm.errorMessage = '';
|
vm.errorMessage = '';
|
||||||
@ -50,12 +53,32 @@
|
|||||||
function doForgotPassword() {
|
function doForgotPassword() {
|
||||||
$window.location.href = '/ng/forgot_password';
|
$window.location.href = '/ng/forgot_password';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doContinue() {
|
||||||
|
$window.location.href = '/ng/dashboard';
|
||||||
|
}
|
||||||
|
|
||||||
|
function doLogOut() {
|
||||||
|
LogOutService()
|
||||||
|
.success(logOutSuccess)
|
||||||
|
.error(logOutFailed);
|
||||||
|
}
|
||||||
|
|
||||||
|
function logOutSuccess(data, status) {
|
||||||
|
currentUser.unset();
|
||||||
|
I18nService().unset();
|
||||||
|
$window.location.href= '/ng';
|
||||||
|
}
|
||||||
|
|
||||||
|
function logOutFailed(data, status) {
|
||||||
|
console.log('Failed to log out:' + data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function signIn() {
|
function signIn() {
|
||||||
var directive = {
|
var directive = {
|
||||||
'restrict': 'E',
|
'restrict': 'E',
|
||||||
'templateUrl': '/static/ng/resources/js/components/sign-in/sign-in.directive.html',
|
'templateUrl': '/ng/sign_in',
|
||||||
'scope': true,
|
'scope': true,
|
||||||
'controller': SignInController,
|
'controller': SignInController,
|
||||||
'controllerAs': 'vm',
|
'controllerAs': 'vm',
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function listProjectSuccess(data, status) {
|
function listProjectSuccess(data, status) {
|
||||||
vm.projects = data;
|
vm.projects = data || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function listProjectFailed(e) {
|
function listProjectFailed(e) {
|
||||||
|
@ -117,5 +117,10 @@ var locale_messages = {
|
|||||||
'alert_delete_tag_title': 'Delete tag - $0',
|
'alert_delete_tag_title': 'Delete tag - $0',
|
||||||
'alert_delete_tag': 'Delete this "$0" tag now?',
|
'alert_delete_tag': 'Delete this "$0" tag now?',
|
||||||
'close': 'Close',
|
'close': 'Close',
|
||||||
'ok': 'OK'
|
'ok': 'OK',
|
||||||
|
'welcome': 'Welcome ',
|
||||||
|
'to_harbor': ' to Harbor!',
|
||||||
|
'continue' : 'Continue',
|
||||||
|
'no_projects_add_new_project': 'No projects, add new project now.',
|
||||||
|
'no_repositories': 'No repositories, use "push command" to upload new images.'
|
||||||
};
|
};
|
@ -115,5 +115,10 @@ var locale_messages = {
|
|||||||
'alert_delete_tag_title': '删除镜像标签 - $0',
|
'alert_delete_tag_title': '删除镜像标签 - $0',
|
||||||
'alert_delete_tag': '删除镜像标签 "$0" ?',
|
'alert_delete_tag': '删除镜像标签 "$0" ?',
|
||||||
'close': '关闭',
|
'close': '关闭',
|
||||||
'ok': '确认'
|
'ok': '确认',
|
||||||
|
'welcome': '欢迎 ',
|
||||||
|
'to_harbor': ' 使用Harbor!',
|
||||||
|
'continue' : '继续',
|
||||||
|
'no_projects_add_new_project': '当前没有项目,请新增项目。',
|
||||||
|
'no_repositories': '当前没有镜像仓库,使用"push命令"上传镜像。'
|
||||||
};
|
};
|
@ -25,4 +25,5 @@ func initNgRouters() {
|
|||||||
|
|
||||||
beego.Router("/ng/optional_menu", &ng.OptionalMenuController{})
|
beego.Router("/ng/optional_menu", &ng.OptionalMenuController{})
|
||||||
beego.Router("/ng/navigation_header", &ng.NavigationHeaderController{})
|
beego.Router("/ng/navigation_header", &ng.NavigationHeaderController{})
|
||||||
|
beego.Router("/ng/sign_in", &ng.SignInController{})
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,15 @@
|
|||||||
<div class="page-content">
|
<div class="page-content">
|
||||||
<div style="margin-left: auto; margin-right: auto; width: 100%;">
|
<div style="margin-left: auto; margin-right: auto; width: 100%;">
|
||||||
<div class="thumbnail display-inline-block">
|
<div class="thumbnail display-inline-block">
|
||||||
<img src="static/ng/resources/img/Step1.png" alt="Step 1">
|
<img src="/static/ng/resources/img/Step1.png" alt="Step 1">
|
||||||
<h5 class="step-content">// 'anybody_can_read_public_projects' | tr //</h5>
|
<h5 class="step-content">// 'anybody_can_read_public_projects' | tr //</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="thumbnail display-inline-block">
|
<div class="thumbnail display-inline-block">
|
||||||
<img src="static/ng/resources/img/Step2.png" alt="Step 2">
|
<img src="/static/ng/resources/img/Step2.png" alt="Step 2">
|
||||||
<h5 class="step-content">// 'create_projects_and_connect_repositories' | tr //</h5>
|
<h5 class="step-content">// 'create_projects_and_connect_repositories' | tr //</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="thumbnail display-inline-block">
|
<div class="thumbnail display-inline-block">
|
||||||
<img src="static/ng/resources/img/Step3.png" alt="Step 3">
|
<img src="/static/ng/resources/img/Step3.png" alt="Step 3">
|
||||||
<h5 class="step-content">// 'user_management_and_role_assignment' | tr //</h5>
|
<h5 class="step-content">// 'user_management_and_role_assignment' | tr //</h5>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,13 +30,16 @@
|
|||||||
<th>// 'project_name' | tr //</th><th>// 'repositories' | tr //</th><th>// 'role' | tr //</th><th>// 'creation_time' | tr //</th><th>// 'publicity' | tr //</th>
|
<th>// 'project_name' | tr //</th><th>// 'repositories' | tr //</th><th>// 'role' | tr //</th><th>// 'creation_time' | tr //</th><th>// 'publicity' | tr //</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="p in vm.projects">
|
<tr>
|
||||||
|
<td colspan="5" height="320px" class="empty-hint" ng-if="vm.projects.length === 0"><h3 class="text-muted">// 'no_projects_add_new_project' | tr //</h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr ng-if="vm.projects.length > 0" ng-repeat="p in vm.projects">
|
||||||
<td><a href="/ng/repository#/repositories?project_id=//p.ProjectId//&is_public=//p.Public//">//p.Name//</a></td>
|
<td><a href="/ng/repository#/repositories?project_id=//p.ProjectId//&is_public=//p.Public//">//p.Name//</a></td>
|
||||||
<td>N/A</td>
|
<td>N/A</td>
|
||||||
<td>N/A</td>
|
<td>N/A</td>
|
||||||
<td>//p.CreationTime | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
|
<td>//p.CreationTime | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
|
||||||
<td><publicity-button is-public="p.Public" owned="p.OwnerId == vm.user.UserId" project-id="p.ProjectId"></publicity-button></td>
|
<td><publicity-button is-public="p.Public" owned="p.OwnerId == vm.user.UserId" project-id="p.ProjectId"></publicity-button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<span class="sr-only">Toggle navigation</span>
|
<span class="sr-only">Toggle navigation</span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="#"><img class="img-responsive" src="/static/ng/resources/img/Harbor_Logo_rec.png" alt="Harbor's Logo"/></a>
|
<a class="navbar-brand" href="/ng"><img class="img-responsive" src="/static/ng/resources/img/Harbor_Logo_rec.png" alt="Harbor's Logo"/></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||||
<div class="collapse navbar-collapse" id="bs-harbor-navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="bs-harbor-navbar-collapse-1">
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
{{ if eq .HasLoggedIn true }}
|
||||||
|
<div class="has-logged-in">
|
||||||
|
<h4>// 'welcome' | tr // <strong>{{ .Username }}</strong> // 'to_harbor' | tr //</h4>
|
||||||
|
<!--p class="text-muted last-logged-in-time">Last login time: //vm.lastLoggedInTime//</p-->
|
||||||
|
<p class="control-button"><input type="button" class="btn btn-default pull-right" value="// 'continue' | tr //" ng-click="vm.doContinue()"></p>
|
||||||
|
<p class="control-button"><input type="button" class="btn btn-link pull-right" value="// 'log_out' | tr //" ng-click="vm.doLogOut()"></p>
|
||||||
|
</div>
|
||||||
|
{{ else }}
|
||||||
<form name="form" class="form-horizontal css-form" ng-submit="form.$valid" novalidate>
|
<form name="form" class="form-horizontal css-form" ng-submit="form.$valid" novalidate>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-1 col-sm-10">
|
<div class="col-sm-offset-1 col-sm-10">
|
||||||
@ -36,3 +44,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{{ end }}
|
Loading…
Reference in New Issue
Block a user