Skip to content

Commit

Permalink
Admin theme split repo
Browse files Browse the repository at this point in the history
  • Loading branch information
cabloo committed May 21, 2016
0 parents commit b0c5891
Show file tree
Hide file tree
Showing 234 changed files with 22,614 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/bower_components
/node_modules
/.sass-cache
/public
11 changes: 11 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Synergy Default Theme
===

## Gulp
Gulp is used for running common tasks such as:
- Less -> CSS compilation
- JS compilation
- Preparation for licensing
- And more.

To run the default gulp task, make sure `gulp` is installed globally and then run `gulp` from the root directory of this theme. For front-end developers, use `gulp watch` to automatically update JS and CSS files on change.
12 changes: 12 additions & 0 deletions app/app.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function () {
'use strict';

angular
.module('app', [
'app.core',
'app.auth',
'app.dashboard',
'app.layout',
'app.user'
]);
})();
51 changes: 51 additions & 0 deletions app/auth/api-key.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(function () {
'use strict';

angular
.module('app.auth')
.service('ApiKey', ApiKey);

/**
* ApiKey Service
*
* @ngInject
*/
function ApiKey ($localStorage) {
var apiKey = this;
var _apiKey = getApiKeyFromStorage();

apiKey.get = getApiKey;
apiKey.set = setApiKey;
apiKey.id = getApiKeyId;
apiKey.delete = deleteApiKey;

function getApiKey() {
return _apiKey ? _apiKey.key : null;
}

function getApiKeyId() {
return _apiKey ? _apiKey.id : null;
}

function setApiKey(key, remember) {
_apiKey = {
id: key.id,
key: key.key
};

$localStorage.apiKey = _apiKey;
}

function getApiKeyFromStorage() {
return $localStorage.apiKey || null;
}

/**
* Delete this API Key from local storage.
*/
function deleteApiKey() {
_apiKey = null;
delete $localStorage.apiKey;
}
}
})();
8 changes: 8 additions & 0 deletions app/auth/auth.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(function () {
'use strict';

angular
.module('app.auth', [
'restangular'
]);
})();
76 changes: 76 additions & 0 deletions app/auth/auth.provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
(function() {
'use strict';

angular
.module('app.auth')
.provider('Auth', AuthProvider)
;

function AuthProvider() {
var authProvider = this;
var internalApi = {
$get: getService
};

return internalApi;

/**
* @ngInject
*/
function getService(Api, ApiKey, $state) {
return new Auth(Api, ApiKey, $state);
}

/**
* Auth Service
*/
function Auth(Api, ApiKey, $state) {
var auth = this;
var keys = Api.all('key');

auth.logout = logout;
auth.login = login;

/////////////

/**
* Revoke this API Key,
* so that all of the user's browser instances
* are logged out of the application.
*
* @return {promise}
*/
function logout() {
return keys.one(""+ApiKey.id()).remove()
.then(ApiKey.delete, ApiKey.delete)
.then(transferToLogin, transferToLogin)
;
}

/**
* @param object credentials
* @param boolean remember
*/
function login(credentials, remember) {
return keys
.post(credentials)
.then(handleResponse.bind(null, remember))
.then(transferToApp)
;
}

function handleResponse(remember, response) {
ApiKey.set(response, remember);
}

function transferToApp() {
// TODO: attempted URL
$state.go('app.dashboard');
}

function transferToLogin() {
$state.go('auth.login');
}
}
}
}());
38 changes: 38 additions & 0 deletions app/auth/auth.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(function () {
angular
.module('app.auth')
.config(routeConfig);

/**
* @ngInject
*/
function routeConfig($stateProvider, RouteHelpersProvider) {
var helper = RouteHelpersProvider;
$stateProvider
.state('auth', {
url: '/auth',
abstract: true,
templateUrl: helper.basepath('auth/page.html'),
resolveFor: helper.resolveFor([
'icons'
])
})
.state('auth.login', {
url: '/login',
title: 'Login',
templateUrl: helper.basepath('auth/login.html')
})
.state('auth.logout', {
url: '/logout',
title: 'Logout',
template: '',
controller: 'LogoutCtrl'
})
.state('auth.recover', {
url: '/recover',
title: 'Recover',
templateUrl: helper.basepath('auth/recover.html')
})
;
}
})();
68 changes: 68 additions & 0 deletions app/auth/login.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**=========================================================
* Module: access-login.js
* Demo for login api
=========================================================*/

(function () {
'use strict';

angular
.module('app.auth')
.controller('AuthLoginController', AuthLoginController);

/**
* @ngInject
*/
function AuthLoginController(Auth, $state) {
var vm = this;

vm.type = 'admin';

activate();

////////////////

function activate() {
// Bound form data
vm.account = {
username: "",
password: ""
};
vm.loginForm = null;

// Error message
vm.authMsg = '';

vm.login = handleLoginForm;
}

function handleLoginForm() {
vm.authMsg = '';

if (!vm.loginForm.$valid) {
// set as dirty if the user click directly to login,
// so we show the validation messages.
vm.loginForm.username.$dirty = vm.loginForm.password.$dirty = true;

return;
}

var remember = false; // TODO

Auth.login(credentials(), remember)
.catch(handleError);
}

function credentials() {
return {
type: vm.type,
username: vm.account.username,
password: vm.account.password
};
}

function handleError(error) {
console.error(error);
}
}
})();
70 changes: 70 additions & 0 deletions app/auth/login.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
doctype html
.block-center.mt-xl.wd-xl(ng-controller="AuthLoginController as login")
// START panel
.panel.panel-inverse.panel-flat
.panel-heading.text-center
.logo
| {{ 'app.title' | translate }}
.panel-body
p.text-center.pv
| {{ 'auth.login.SIGNIN' | translate }}
form.form-validate.mb-lg(
role='form'
ng-submit="login.login()"
name='login.loginForm'
novalidate=''
)
.form-group.has-feedback
input.form-control(
type="text"
name="username"
placeholder="{{ 'auth.login.input.username.PLACEHOLDER' | translate }}"
autocomplete="off"
ng-model="login.account.username"
required
)
span.fa.fa-envelope.form-control-feedback.text-muted
span.text-danger(
ng-show="login.loginForm.username.$dirty && login.loginForm.username.$error.required"
) This field is required
span.text-danger(
ng-show="login.loginForm.username.$dirty && login.loginForm.username.$error.email"
) This field must be a valid email address
.form-group.has-feedback
input.form-control(
type='password'
name="password"
placeholder="{{ 'auth.login.input.password.PLACEHOLDER' | translate }}"
ng-model="login.account.password"
required=''
)
span.fa.fa-lock.form-control-feedback.text-muted
span.text-danger(
ng-show="login.loginForm.password.$dirty && login.loginForm.password.$error.required"
) This field is required
.clearfix
.checkbox.c-checkbox.pull-left.mt0
label
input(
type='checkbox'
value=''
name="account_remember"
ng-model="login.account.remember"
)
| {{ 'auth.login.REMEMBER' | translate }}
.pull-right
a.text-muted(ui-sref="auth.recover")
| {{ 'auth.login.FORGOT' | translate }}

button.btn.btn-block.btn-primary.mt-lg(type='submit')
| {{ 'auth.login.LOGIN' | translate }}

.alert.alert-danger.text-center(ng-show='login.authMsg') {{login.authMsg}}
// END panel
.p-lg.text-center
span ©
span(ng-bind="app.year")
span -
span(ng-bind="app.name")
br
span(ng-bind="app.description")
25 changes: 25 additions & 0 deletions app/auth/logout.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function () {
'use strict';

angular
.module('app.auth')
.controller('LogoutCtrl', LogoutCtrl)
;

/**
* Logout Controller
*
* @ngInject
*/
function LogoutCtrl(Auth) {
var vm = this;

activate();

//////////

function activate() {
Auth.logout();
}
}
})();
1 change: 1 addition & 0 deletions app/auth/page.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.auth-page.ng-zoomBackDown.ng-fluid(ui-view='', autoscroll='false')
Loading

0 comments on commit b0c5891

Please sign in to comment.