From f8a10fa7af3b23a2bd77c89187dfbc6150f7c73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 6 Feb 2015 08:21:00 +0100 Subject: [PATCH] Updated account and profile pages, very temporary solution, do not like it at all --- pkg/models/account.go | 1 + pkg/models/dashboards.go | 1 + pkg/models/datasource.go | 1 + pkg/models/user.go | 1 + pkg/services/sqlstore/migrations.go | 8 +- src/app/controllers/sidemenuCtrl.js | 13 +- src/app/directives/topnav.js | 12 +- .../features/account/partials/account.html | 184 ++++++++++++++-- .../account/partials/datasources.html | 6 +- src/app/features/admin/adminUsersCtrl.js | 1 - src/app/features/admin/partials/admin.html | 3 +- src/app/features/admin/partials/users.html | 68 +++--- .../features/profile/partials/profile.html | 204 ++++++++---------- src/app/partials/sidemenu.html | 2 +- src/css/less/gfbox.less | 19 ++ src/css/less/navbar.less | 18 +- src/css/less/sidemenu.less | 5 +- 17 files changed, 342 insertions(+), 205 deletions(-) diff --git a/pkg/models/account.go b/pkg/models/account.go index 8a1b80e534a..ad4cdc47e53 100644 --- a/pkg/models/account.go +++ b/pkg/models/account.go @@ -12,6 +12,7 @@ var ( type Account struct { Id int64 + Version int Name string Created time.Time Updated time.Time diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index aec0b6f9fc5..0ebde7aa163 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -17,6 +17,7 @@ type Dashboard struct { Id int64 Slug string AccountId int64 + Version int Created time.Time Updated time.Time diff --git a/pkg/models/datasource.go b/pkg/models/datasource.go index 280d2a4c79d..77e14c04c3b 100644 --- a/pkg/models/datasource.go +++ b/pkg/models/datasource.go @@ -23,6 +23,7 @@ type DsAccess string type DataSource struct { Id int64 + Version int AccountId int64 Name string diff --git a/pkg/models/user.go b/pkg/models/user.go index 822d79187cd..0a3de0c9a4d 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -12,6 +12,7 @@ var ( type User struct { Id int64 + Version int Email string Name string Login string diff --git a/pkg/services/sqlstore/migrations.go b/pkg/services/sqlstore/migrations.go index 1bc4ebccfa2..720aa3bd28f 100644 --- a/pkg/services/sqlstore/migrations.go +++ b/pkg/services/sqlstore/migrations.go @@ -33,11 +33,13 @@ func addUserMigrations(mg *Migrator) { mg.AddMigration("create user table", new(AddTableMigration). Name("user").WithColumns( &Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, + &Column{Name: "version", Type: DB_Int, Nullable: false}, &Column{Name: "login", Type: DB_NVarchar, Length: 255, Nullable: false}, &Column{Name: "email", Type: DB_NVarchar, Length: 255, Nullable: false}, &Column{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true}, &Column{Name: "password", Type: DB_NVarchar, Length: 255, Nullable: true}, &Column{Name: "salt", Type: DB_NVarchar, Length: 50, Nullable: true}, + &Column{Name: "rands", Type: DB_NVarchar, Length: 50, Nullable: true}, &Column{Name: "company", Type: DB_NVarchar, Length: 255, Nullable: true}, &Column{Name: "account_id", Type: DB_BigInt, Nullable: false}, &Column{Name: "is_admin", Type: DB_Bool, Nullable: false}, @@ -50,9 +52,6 @@ func addUserMigrations(mg *Migrator) { Table("user").Columns("login").Unique()) mg.AddMigration("add unique index user.email", new(AddIndexMigration). Table("user").Columns("email").Unique()) - - mg.AddMigration("add column user.rands", new(AddColumnMigration). - Table("user").Column(&Column{Name: "rands", Type: DB_NVarchar, Length: 255, Nullable: true})) } func addStarMigrations(mg *Migrator) { @@ -71,6 +70,7 @@ func addAccountMigrations(mg *Migrator) { mg.AddMigration("create account table", new(AddTableMigration). Name("account").WithColumns( &Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, + &Column{Name: "version", Type: DB_Int, Nullable: false}, &Column{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: false}, &Column{Name: "created", Type: DB_DateTime, Nullable: false}, &Column{Name: "updated", Type: DB_DateTime, Nullable: false}, @@ -98,6 +98,7 @@ func addDashboardMigration(mg *Migrator) { mg.AddMigration("create dashboard table", new(AddTableMigration). Name("dashboard").WithColumns( &Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, + &Column{Name: "version", Type: DB_Int, Nullable: false}, &Column{Name: "slug", Type: DB_NVarchar, Length: 255, Nullable: false}, &Column{Name: "title", Type: DB_NVarchar, Length: 255, Nullable: false}, &Column{Name: "data", Type: DB_Text, Nullable: false}, @@ -129,6 +130,7 @@ func addDataSourceMigration(mg *Migrator) { Name("data_source").WithColumns( &Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, &Column{Name: "account_id", Type: DB_BigInt, Nullable: false}, + &Column{Name: "version", Type: DB_Int, Nullable: false}, &Column{Name: "type", Type: DB_NVarchar, Length: 255, Nullable: false}, &Column{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: false}, &Column{Name: "access", Type: DB_NVarchar, Length: 255, Nullable: false}, diff --git a/src/app/controllers/sidemenuCtrl.js b/src/app/controllers/sidemenuCtrl.js index d503cecab42..c267131ba27 100644 --- a/src/app/controllers/sidemenuCtrl.js +++ b/src/app/controllers/sidemenuCtrl.js @@ -17,10 +17,9 @@ function (angular, _, $, config) { $scope.menu = []; $scope.menu.push({ - text: "Dashbords", + text: "Dashboards", icon: "fa fa-th-large", href: $scope.getUrl("/"), - //startsWith: config.appSubUrl + '/dashboard/', }); if ($scope.grafana.user.accountRole === 'Admin') { @@ -34,16 +33,6 @@ function (angular, _, $, config) { requireRole: "Admin", icon: "fa fa-shield", }); - $scope.menu.push({ - text: "Users", href: $scope.getUrl("/account/users"), - requireRole: "Admin", - icon: "fa fa-users", - }); - $scope.menu.push({ - text: "API Keys", href: $scope.getUrl("/account/apikeys"), - requireRole: "Admin", - icon: "fa fa-key", - }); } if ($scope.grafana.user.isGrafanaAdmin) { diff --git a/src/app/directives/topnav.js b/src/app/directives/topnav.js index 0dd497de047..b27a6be6241 100644 --- a/src/app/directives/topnav.js +++ b/src/app/directives/topnav.js @@ -13,7 +13,6 @@ function (angular) { transclude: true, scope: { title: "@", - section: "@", titleAction: "&", toggle: "&", showMenuBtn: "=", @@ -23,18 +22,13 @@ function (angular) { '
' + '' + ' ' + - '' + + '' + '' + - '' + - '' + + '' + + '' + '' + - '' + - '{{section}}' + - '' + - '' + - '' + '{{title}}' + '' + diff --git a/src/app/features/account/partials/account.html b/src/app/features/account/partials/account.html index 8382552a1bc..da8392aac15 100644 --- a/src/app/features/account/partials/account.html +++ b/src/app/features/account/partials/account.html @@ -1,30 +1,184 @@ - + -
+
+

+ Account Info +

-
-
-
-
-
+
+
+ +
+
+
    +
  • + Account name +
  • +
  • + +
  • +
+
+
+
+
+ +
+ + +
+
+ +

+ Account users +

+ +
+
+
+
+
    -
  • - Account name +
  • + Username or Email
  • - + +
  • +
  • + role +
  • +
  • + +
  • +
  • +
-
-
+ +
+
-
- - + +
+ + + + + + +
{{user.email}} + {{user.role}} + + + + +
+
+ +
+
+ +

+ API Keys +

+ +
+
+
+
+
+
    +
  • + Add a key +
  • +
  • + +
  • +
  • + Role +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+ +
+
+ + + + + + + +
{{t.name}}{{t.role}}{{t.key}} + + + +
+
+
+
+
+ +

Import dashboards

+
+
+
+
+
+
    +
  • + Dashboard source +
  • +
  • + +
  • +
  • + Destination +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+ +
+
+
{{infoText}}
+ +
+ + + + + +
{{dash.name}} + {{dash.info}} +
+
+
diff --git a/src/app/features/account/partials/datasources.html b/src/app/features/account/partials/datasources.html index 65b52e4c3e0..de70d794930 100644 --- a/src/app/features/account/partials/datasources.html +++ b/src/app/features/account/partials/datasources.html @@ -1,11 +1,10 @@ -
+
@@ -117,3 +116,4 @@
+ diff --git a/src/app/features/admin/adminUsersCtrl.js b/src/app/features/admin/adminUsersCtrl.js index ef7a88622de..ce5cc7a3b86 100644 --- a/src/app/features/admin/adminUsersCtrl.js +++ b/src/app/features/admin/adminUsersCtrl.js @@ -27,7 +27,6 @@ function (angular) { backendSrv.delete('/api/admin/users/delete/' + user.id); } }); - }; $scope.init(); diff --git a/src/app/features/admin/partials/admin.html b/src/app/features/admin/partials/admin.html index 968d7ba23b6..6dcf42e25fc 100644 --- a/src/app/features/admin/partials/admin.html +++ b/src/app/features/admin/partials/admin.html @@ -1,7 +1,6 @@ diff --git a/src/app/features/admin/partials/users.html b/src/app/features/admin/partials/users.html index 17f4a20769a..74cac3befae 100644 --- a/src/app/features/admin/partials/users.html +++ b/src/app/features/admin/partials/users.html @@ -1,42 +1,44 @@ -
+
+

Users

+
-
-
-
- - - - - - - - - - - - - - - - - -
IdLoginEmailNameAdmin
{{user.id}}{{user.login}}{{user.email}}{{user.name}}{{user.isAdmin}} - - - Edit - -    - - - -
+
+
+
+ + + + + + + + + + + + + + + + + +
IdLoginEmailNameAdmin
{{user.id}}{{user.login}}{{user.email}}{{user.name}}{{user.isAdmin}} + + + Edit + +    + + + +
+
diff --git a/src/app/features/profile/partials/profile.html b/src/app/features/profile/partials/profile.html index 87d49af0bcf..e39a663584e 100644 --- a/src/app/features/profile/partials/profile.html +++ b/src/app/features/profile/partials/profile.html @@ -1,127 +1,105 @@ +
+

Personal information

-
-
- -
-
-
- - Personal information -
-
- -
-
-
-
-
-
    -
  • - Name -
  • -
  • - -
  • -
-
-
-
-
    -
  • - Email -
  • -
  • - -
  • -
-
-
-
-
    -
  • - Username -
  • -
  • - -
  • -
-
-
+
+
+
+ +
+
+
    +
  • + Name +
  • +
  • + +
  • +
+
+
+
+
    +
  • + Email +
  • +
  • + +
  • +
+
+
+
+
    +
  • + Username +
  • +
  • + +
  • +
+
- -
- - -
-
-
-
- -
- -
-
-
- - Your accounts -
-
-
- - - - - - - -
Name: {{ac.name}}Role: {{ac.role}} - - active now - - - - Select - -
-
-
-
- -
-
-
-
- - Add account -
-
-
-
-
-
    -
  • - Account name -
  • -
  • - -
  • -
  • - -
  • -
-
+ +
+
+ +

Your accounts

+ +
+
+ + + + + + +
Name: {{ac.name}}Role: {{ac.role}} + + Current + + + Select + +
+
+
+ +

Add account

+
+
+
+
+
+
+
    +
  • + Account name +
  • +
  • + +
  • +
  • +
  • +
+
+
+
+
+ +
+
+ +
- diff --git a/src/app/partials/sidemenu.html b/src/app/partials/sidemenu.html index 52770d725ba..ea7416469d7 100644 --- a/src/app/partials/sidemenu.html +++ b/src/app/partials/sidemenu.html @@ -10,7 +10,7 @@
  • - + {{item.text}}
  • diff --git a/src/css/less/gfbox.less b/src/css/less/gfbox.less index 80a915b2ac9..8214cdb84b7 100644 --- a/src/css/less/gfbox.less +++ b/src/css/less/gfbox.less @@ -59,3 +59,22 @@ } } +.admin-page { + max-width: 800px; + margin-left: 10px; + .gf-box { + margin-top: 0; + } + .gf-box-body { + min-height: 0; + } + h2 { + margin-left: 15px; + margin-bottom: 0px; + font-size: @fontSizeLarge; + color: @textColor; + i { + padding-right: 6px; + } + } +} diff --git a/src/css/less/navbar.less b/src/css/less/navbar.less index 2398de3c7f2..0fe60a433bb 100644 --- a/src/css/less/navbar.less +++ b/src/css/less/navbar.less @@ -37,13 +37,13 @@ font-size: 150%; opacity: 0; position: absolute; - transition: opacity .35s ease-in-out; + transition: opacity .20s ease-in-out; } img { width: 30px; position: absolute; opacity: 1; - transition: opacity .35s ease-in-out; + transition: opacity .20s ease-in-out; } &:hover { .fa { @@ -68,7 +68,7 @@ a { display: inline-block; background: @grafanaTargetFuncBackground; - padding: 5px 4px 5px 13px; + padding: 5px 15px 5px 10px; border: 1px solid #000; border-radius: 3px; color: #a2a2a2; @@ -88,16 +88,10 @@ } } -.top-nav-breadcrumb { - display: block; +.top-nav-icon { + line-height: 34px; float: left; - padding: 18px 9px 8px 12px; - font-size: 1.4em; - font-weight: bold; - color: darken(@gray, 10%); - i { - padding-left: 9px; - } + margin: 5px 11px; } .top-nav-section { diff --git a/src/css/less/sidemenu.less b/src/css/less/sidemenu.less index 82a60cb6f0a..98b2d85d0d0 100644 --- a/src/css/less/sidemenu.less +++ b/src/css/less/sidemenu.less @@ -72,7 +72,7 @@ } } -.sidemenu-icon { +.icon-circle { border-radius: 50%; background: #000; box-shadow: 0 0 14px 2px rgba(255,255,255, 0.05); @@ -89,6 +89,9 @@ } } +.sidemenu-icon { +} + .sidemenu-item { color: #f80; line-height: 34px;