mirror of
https://github.com/goharbor/harbor
synced 2025-04-26 17:03:17 +00:00
Merge pull request #250 from xiahaoshawn/new-version-of-ui
set up jshint task
This commit is contained in:
commit
c661b5dbe4
@ -1,9 +1,11 @@
|
||||
package ng
|
||||
|
||||
// AccountSettingController handles request to /ng/account_setting
|
||||
type AccountSettingController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders the account settings page
|
||||
func (asc *AccountSettingController) Get() {
|
||||
asc.Forward("Account Settings", "account-settings.htm")
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ng
|
||||
|
||||
// AdminOptionController handles requests to /ng/admin_option
|
||||
type AdminOptionController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders the admin options page
|
||||
func (aoc *AdminOptionController) Get() {
|
||||
aoc.Forward("Admin Options", "admin-options.htm")
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/vmware/harbor/utils/log"
|
||||
)
|
||||
|
||||
// BaseController wraps common methods such as i18n support, forward, which can be leveraged by other UI render controllers.
|
||||
type BaseController struct {
|
||||
beego.Controller
|
||||
i18n.Locale
|
||||
@ -84,32 +85,37 @@ func (b *BaseController) Prepare() {
|
||||
|
||||
}
|
||||
|
||||
func (bc *BaseController) Forward(title, templateName string) {
|
||||
bc.Layout = filepath.Join(prefixNg, "layout.htm")
|
||||
bc.TplName = filepath.Join(prefixNg, templateName)
|
||||
bc.Data["Title"] = title
|
||||
bc.LayoutSections = make(map[string]string)
|
||||
bc.LayoutSections["HeaderInclude"] = filepath.Join(prefixNg, viewPath, "header-include.htm")
|
||||
bc.LayoutSections["FooterInclude"] = filepath.Join(prefixNg, viewPath, "footer-include.htm")
|
||||
bc.LayoutSections["HeaderContent"] = filepath.Join(prefixNg, viewPath, "header-content.htm")
|
||||
bc.LayoutSections["FooterContent"] = filepath.Join(prefixNg, viewPath, "footer-content.htm")
|
||||
// Forward to setup layout and template for content for a page.
|
||||
func (b *BaseController) Forward(title, templateName string) {
|
||||
b.Layout = filepath.Join(prefixNg, "layout.htm")
|
||||
b.TplName = filepath.Join(prefixNg, templateName)
|
||||
b.Data["Title"] = title
|
||||
b.LayoutSections = make(map[string]string)
|
||||
b.LayoutSections["HeaderInclude"] = filepath.Join(prefixNg, viewPath, "header-include.htm")
|
||||
b.LayoutSections["FooterInclude"] = filepath.Join(prefixNg, viewPath, "footer-include.htm")
|
||||
b.LayoutSections["HeaderContent"] = filepath.Join(prefixNg, viewPath, "header-content.htm")
|
||||
b.LayoutSections["FooterContent"] = filepath.Join(prefixNg, viewPath, "footer-content.htm")
|
||||
|
||||
}
|
||||
|
||||
var langTypes []*langType
|
||||
|
||||
// CommonController handles request from UI that doesn't expect a page, such as /SwitchLanguage /logout ...
|
||||
type CommonController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Render returns nil.
|
||||
func (cc *CommonController) Render() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// LogOut Habor UI
|
||||
func (cc *CommonController) LogOut() {
|
||||
cc.DestroySession()
|
||||
}
|
||||
|
||||
// SwitchLanguage User can swith to prefered language
|
||||
func (cc *CommonController) SwitchLanguage() {
|
||||
lang := cc.GetString("lang")
|
||||
if _, exist := supportLanguages[lang]; exist {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ng
|
||||
|
||||
// DashboardController handles requests to /ng/dashboard
|
||||
type DashboardController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders the dashboard page
|
||||
func (dc *DashboardController) Get() {
|
||||
dc.Forward("Dashboard", "dashboard.htm")
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ng
|
||||
|
||||
// IndexController handles request to /ng
|
||||
type IndexController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders the index page
|
||||
func (ic *IndexController) Get() {
|
||||
ic.Forward("Index", "index.htm")
|
||||
}
|
||||
|
@ -8,10 +8,12 @@ import (
|
||||
"github.com/vmware/harbor/utils/log"
|
||||
)
|
||||
|
||||
// NavigationHeaderController handles requests to /ng/navigation_header
|
||||
type NavigationHeaderController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders user's navigation header
|
||||
func (nhc *NavigationHeaderController) Get() {
|
||||
sessionUserID := nhc.GetSession("userId")
|
||||
var hasLoggedIn bool
|
||||
|
@ -8,10 +8,12 @@ import (
|
||||
"github.com/vmware/harbor/utils/log"
|
||||
)
|
||||
|
||||
// OptionalMenuController handles request to /ng/optional_menu
|
||||
type OptionalMenuController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders optional menu, Admin user has "Add User" menu
|
||||
func (omc *OptionalMenuController) Get() {
|
||||
sessionUserID := omc.GetSession("userId")
|
||||
|
||||
|
@ -95,10 +95,12 @@ func (cc *CommonController) SendEmail() {
|
||||
|
||||
}
|
||||
|
||||
// ForgotPasswordController handles requests to /ng/forgot_password
|
||||
type ForgotPasswordController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders forgot password page
|
||||
func (fpc *ForgotPasswordController) Get() {
|
||||
fpc.Forward("Forgot Password", "forgot-password.htm")
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ng
|
||||
|
||||
// ProjectController handles requests to /ng/projec
|
||||
type ProjectController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders project page
|
||||
func (pc *ProjectController) Get() {
|
||||
pc.Forward("My Projects", "project.htm")
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package ng
|
||||
|
||||
import "os"
|
||||
|
||||
// RepositoryController handles request to /ng/repository
|
||||
type RepositoryController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders repository page
|
||||
func (rc *RepositoryController) Get() {
|
||||
rc.Data["HarborRegUrl"] = os.Getenv("HARBOR_REG_URL")
|
||||
rc.Forward("Repository", "repository.htm")
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ng
|
||||
|
||||
// SearchController handles request to ng/search
|
||||
type SearchController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get rendlers search bar
|
||||
func (sc *SearchController) Get() {
|
||||
sc.Forward("Search", "search.htm")
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ng
|
||||
|
||||
// SignUpController handles requests to /ng/sign_up
|
||||
type SignUpController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// Get renders sign up page
|
||||
func (suc *SignUpController) Get() {
|
||||
suc.Forward("Sign Up", "sign-up.htm")
|
||||
}
|
||||
|
59
static/ng/Gruntfile.js
Normal file
59
static/ng/Gruntfile.js
Normal file
@ -0,0 +1,59 @@
|
||||
/*global module:false*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
'use strict';
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
// Task configuration.
|
||||
jshint: {
|
||||
options: {
|
||||
browser: true,
|
||||
curly: true,
|
||||
freeze: true,
|
||||
bitwise: true,
|
||||
eqeqeq: true,
|
||||
strict: true,
|
||||
immed: true,
|
||||
latedef: false,
|
||||
newcap: false,
|
||||
smarttabs: true,
|
||||
noarg: true,
|
||||
devel: true,
|
||||
sub: true,
|
||||
undef: true,
|
||||
unused: false,
|
||||
boss: true,
|
||||
eqnull: true,
|
||||
globals: {
|
||||
jQuery: true,
|
||||
angular: true,
|
||||
$: true,
|
||||
}
|
||||
},
|
||||
gruntfile: {
|
||||
src: 'Gruntfile.js'
|
||||
},
|
||||
scripts: {
|
||||
src: ['resources/**/**/*.js']
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
gruntfile: {
|
||||
files: '<%= jshint.gruntfile.src %>',
|
||||
tasks: ['jshint:gruntfile']
|
||||
},
|
||||
scripts: {
|
||||
files: '<%= jshint.scripts.src %>',
|
||||
tasks: ['jshint:scripts']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// These plugins provide necessary tasks.
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
|
||||
// Default task.
|
||||
grunt.registerTask('default', ['jshint']);
|
||||
|
||||
};
|
10
static/ng/package.json
Normal file
10
static/ng/package.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-contrib-jshint": "~0.10.0",
|
||||
"grunt-contrib-watch": "~0.6.1"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user