mirror of
https://github.com/goharbor/harbor
synced 2025-04-28 08:13:16 +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
|
package ng
|
||||||
|
|
||||||
|
// AccountSettingController handles request to /ng/account_setting
|
||||||
type AccountSettingController struct {
|
type AccountSettingController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders the account settings page
|
||||||
func (asc *AccountSettingController) Get() {
|
func (asc *AccountSettingController) Get() {
|
||||||
asc.Forward("Account Settings", "account-settings.htm")
|
asc.Forward("Account Settings", "account-settings.htm")
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ng
|
package ng
|
||||||
|
|
||||||
|
// AdminOptionController handles requests to /ng/admin_option
|
||||||
type AdminOptionController struct {
|
type AdminOptionController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders the admin options page
|
||||||
func (aoc *AdminOptionController) Get() {
|
func (aoc *AdminOptionController) Get() {
|
||||||
aoc.Forward("Admin Options", "admin-options.htm")
|
aoc.Forward("Admin Options", "admin-options.htm")
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/vmware/harbor/utils/log"
|
"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 {
|
type BaseController struct {
|
||||||
beego.Controller
|
beego.Controller
|
||||||
i18n.Locale
|
i18n.Locale
|
||||||
@ -84,32 +85,37 @@ func (b *BaseController) Prepare() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bc *BaseController) Forward(title, templateName string) {
|
// Forward to setup layout and template for content for a page.
|
||||||
bc.Layout = filepath.Join(prefixNg, "layout.htm")
|
func (b *BaseController) Forward(title, templateName string) {
|
||||||
bc.TplName = filepath.Join(prefixNg, templateName)
|
b.Layout = filepath.Join(prefixNg, "layout.htm")
|
||||||
bc.Data["Title"] = title
|
b.TplName = filepath.Join(prefixNg, templateName)
|
||||||
bc.LayoutSections = make(map[string]string)
|
b.Data["Title"] = title
|
||||||
bc.LayoutSections["HeaderInclude"] = filepath.Join(prefixNg, viewPath, "header-include.htm")
|
b.LayoutSections = make(map[string]string)
|
||||||
bc.LayoutSections["FooterInclude"] = filepath.Join(prefixNg, viewPath, "footer-include.htm")
|
b.LayoutSections["HeaderInclude"] = filepath.Join(prefixNg, viewPath, "header-include.htm")
|
||||||
bc.LayoutSections["HeaderContent"] = filepath.Join(prefixNg, viewPath, "header-content.htm")
|
b.LayoutSections["FooterInclude"] = filepath.Join(prefixNg, viewPath, "footer-include.htm")
|
||||||
bc.LayoutSections["FooterContent"] = filepath.Join(prefixNg, viewPath, "footer-content.htm")
|
b.LayoutSections["HeaderContent"] = filepath.Join(prefixNg, viewPath, "header-content.htm")
|
||||||
|
b.LayoutSections["FooterContent"] = filepath.Join(prefixNg, viewPath, "footer-content.htm")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var langTypes []*langType
|
var langTypes []*langType
|
||||||
|
|
||||||
|
// CommonController handles request from UI that doesn't expect a page, such as /SwitchLanguage /logout ...
|
||||||
type CommonController struct {
|
type CommonController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render returns nil.
|
||||||
func (cc *CommonController) Render() error {
|
func (cc *CommonController) Render() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LogOut Habor UI
|
||||||
func (cc *CommonController) LogOut() {
|
func (cc *CommonController) LogOut() {
|
||||||
cc.DestroySession()
|
cc.DestroySession()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SwitchLanguage User can swith to prefered language
|
||||||
func (cc *CommonController) SwitchLanguage() {
|
func (cc *CommonController) SwitchLanguage() {
|
||||||
lang := cc.GetString("lang")
|
lang := cc.GetString("lang")
|
||||||
if _, exist := supportLanguages[lang]; exist {
|
if _, exist := supportLanguages[lang]; exist {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ng
|
package ng
|
||||||
|
|
||||||
|
// DashboardController handles requests to /ng/dashboard
|
||||||
type DashboardController struct {
|
type DashboardController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders the dashboard page
|
||||||
func (dc *DashboardController) Get() {
|
func (dc *DashboardController) Get() {
|
||||||
dc.Forward("Dashboard", "dashboard.htm")
|
dc.Forward("Dashboard", "dashboard.htm")
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ng
|
package ng
|
||||||
|
|
||||||
|
// IndexController handles request to /ng
|
||||||
type IndexController struct {
|
type IndexController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders the index page
|
||||||
func (ic *IndexController) Get() {
|
func (ic *IndexController) Get() {
|
||||||
ic.Forward("Index", "index.htm")
|
ic.Forward("Index", "index.htm")
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,12 @@ import (
|
|||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NavigationHeaderController handles requests to /ng/navigation_header
|
||||||
type NavigationHeaderController struct {
|
type NavigationHeaderController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders user's navigation header
|
||||||
func (nhc *NavigationHeaderController) Get() {
|
func (nhc *NavigationHeaderController) Get() {
|
||||||
sessionUserID := nhc.GetSession("userId")
|
sessionUserID := nhc.GetSession("userId")
|
||||||
var hasLoggedIn bool
|
var hasLoggedIn bool
|
||||||
|
@ -8,10 +8,12 @@ import (
|
|||||||
"github.com/vmware/harbor/utils/log"
|
"github.com/vmware/harbor/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// OptionalMenuController handles request to /ng/optional_menu
|
||||||
type OptionalMenuController struct {
|
type OptionalMenuController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders optional menu, Admin user has "Add User" menu
|
||||||
func (omc *OptionalMenuController) Get() {
|
func (omc *OptionalMenuController) Get() {
|
||||||
sessionUserID := omc.GetSession("userId")
|
sessionUserID := omc.GetSession("userId")
|
||||||
|
|
||||||
|
@ -95,10 +95,12 @@ func (cc *CommonController) SendEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ForgotPasswordController handles requests to /ng/forgot_password
|
||||||
type ForgotPasswordController struct {
|
type ForgotPasswordController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders forgot password page
|
||||||
func (fpc *ForgotPasswordController) Get() {
|
func (fpc *ForgotPasswordController) Get() {
|
||||||
fpc.Forward("Forgot Password", "forgot-password.htm")
|
fpc.Forward("Forgot Password", "forgot-password.htm")
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ng
|
package ng
|
||||||
|
|
||||||
|
// ProjectController handles requests to /ng/projec
|
||||||
type ProjectController struct {
|
type ProjectController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders project page
|
||||||
func (pc *ProjectController) Get() {
|
func (pc *ProjectController) Get() {
|
||||||
pc.Forward("My Projects", "project.htm")
|
pc.Forward("My Projects", "project.htm")
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@ package ng
|
|||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
|
// RepositoryController handles request to /ng/repository
|
||||||
type RepositoryController struct {
|
type RepositoryController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders repository page
|
||||||
func (rc *RepositoryController) Get() {
|
func (rc *RepositoryController) Get() {
|
||||||
rc.Data["HarborRegUrl"] = os.Getenv("HARBOR_REG_URL")
|
rc.Data["HarborRegUrl"] = os.Getenv("HARBOR_REG_URL")
|
||||||
rc.Forward("Repository", "repository.htm")
|
rc.Forward("Repository", "repository.htm")
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ng
|
package ng
|
||||||
|
|
||||||
|
// SearchController handles request to ng/search
|
||||||
type SearchController struct {
|
type SearchController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get rendlers search bar
|
||||||
func (sc *SearchController) Get() {
|
func (sc *SearchController) Get() {
|
||||||
sc.Forward("Search", "search.htm")
|
sc.Forward("Search", "search.htm")
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ng
|
package ng
|
||||||
|
|
||||||
|
// SignUpController handles requests to /ng/sign_up
|
||||||
type SignUpController struct {
|
type SignUpController struct {
|
||||||
BaseController
|
BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get renders sign up page
|
||||||
func (suc *SignUpController) Get() {
|
func (suc *SignUpController) Get() {
|
||||||
suc.Forward("Sign Up", "sign-up.htm")
|
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