Skip to content

Commit

Permalink
Fixed #1, #2 and #3, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
labibramadhan committed Jan 15, 2017
1 parent c2dee56 commit 34a9be5
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 39 deletions.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Created using [AngularJS Seed](https://github.com/angular/angular-seed).

This is the open source version of my original project called Ujian Berbasis Komputer - Teka-teki Silang (Computer Based Test - Crossword). So this closed source project does exist since 13 September 2016. The open source version initialized on 12 January 2017. Every suspicious commercials activity of this project happened before 12 January 2017 are marked as illegal.

The differences from closed source version are:
The differences from the closed source version are:

1. Variable names translated from Indonesian to English
1. Model & code adjustments either on API Server & Mobile Application packages
1. Using ES6 & ES7 javascript language
Expand Down Expand Up @@ -157,4 +158,24 @@ Then, you can start serving your production ready package by using this command:

After that, you can visit http://localhost:2796 on your browser to start using this application on production mode.

Note that you can change the configured production server port (2796) from [package.json](package.json) file.
Note that you can change the configured production server port (2796) from [package.json](package.json) file.

### Default Accounts

```
Admin
email: [email protected]
pass: asdqwe123
```

```
Guru
email: [email protected]
pass: asdqwe123
```

```
Participant
email: [email protected]
pass: asdqwe123
```
30 changes: 15 additions & 15 deletions app/app-acl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ angular.module('app')
'$location',
'AclService',
'Authentication',
async(
(
$rootScope,
$state,
$location,
Expand Down Expand Up @@ -67,27 +67,27 @@ angular.module('app')
};

AclService.setAbilities(aclData);

AclService.attachRole('guest');

$rootScope.$on('$stateChangeStart', function (e, to) {
if (!AclService.can(to.name)) {
e.preventDefault();
$state.go('app');
}
$rootScope.stateTransition = to;
});

$rootScope.$on('$stateChangeSuccess', function (e, to) {
if (!to.name || to.name === 'app') {
if (AclService.hasRole('$authenticated')) {
if ($state.current.name !== 'app.dashboard') $state.go('app.dashboard');
} else {
if ($state.current.name !== 'app.login') $state.go('app.login');
}
}
$rootScope.$on('$stateChangeSuccess', function () {
delete $rootScope.stateTransition;
});

await Authentication.authenticationCheck();
Authentication.authenticationCheck().then(() => {
$rootScope.$on('$stateChangeStart', function (e, to) {
if (to.name && !AclService.can(to.name)) {
e.preventDefault();
$state.go('app');
}
});
$rootScope.$on('$stateChangeSuccess', () => {
Authentication.redirector();
});
});

$rootScope.acl = AclService;
},
Expand Down
4 changes: 3 additions & 1 deletion app/app-formly.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ angular.module('app')
$translate,
formlyValidationMessages
) => {
formlyValidationMessages.addStringMessage('required', $translate.instant('error.validation.required'));
$translate('error.validation.required').then((message) => {
formlyValidationMessages.addStringMessage('required', message);
});
}
]);
40 changes: 32 additions & 8 deletions app/app-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,28 @@ angular.module('app')
'$mdToast',
'$translate',
'$window',
'$timeout',
'Utils',
'AclService',
'Menu',
async(
(
$rootScope,
$state,
$mdToast,
$translate,
$window,
$timeout,
Utils,
AclService,
Menu
) => {
$rootScope.config = {
menuTitle: await $translate('menu.main'),
menuTitle: '',
pageTitle: '',
};
$translate('menu.main').then((message) => {
$rootScope.config.menuTitle = message;
});

$rootScope.excludeMenu = ['app.login', 'app.test.start'];
$rootScope.excludeHeader = ['app.login'];
Expand Down Expand Up @@ -96,14 +101,33 @@ angular.module('app')
});

$rootScope.timeLabel = {
hour: await $translate('time.hour'),
minute: await $translate('time.minute'),
second: await $translate('time.second'),
hour: '',
minute: '',
second: '',
};
$translate('time.hour').then((message) => {
$rootScope.timeLabel.hour = message;
});
$translate('time.minute').then((message) => {
$rootScope.timeLabel.minute = message;
});
$translate('time.second').then((message) => {
$rootScope.timeLabel.second = message;
});

$rootScope.paginationLabel = {
page: await $translate('pagination.page'),
rowsPerPage: await $translate('pagination.rowsPerPage'),
of: await $translate('pagination.of'),
page: '',
rowsPerPage: '',
of: '',
};
$translate('pagination.page').then((message) => {
$rootScope.paginationLabel.page = message;
});
$translate('pagination.rowsPerPage').then((message) => {
$rootScope.paginationLabel.rowsPerPage = message;
});
$translate('pagination.of').then((message) => {
$rootScope.paginationLabel.of = message;
});
},
]);
19 changes: 10 additions & 9 deletions app/components/controllers/package/schedule/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,18 @@ angular.module('app')
vmDialog.submit = async() => {
let schedule = angular.copy(vmDialog.schedule);

let startTime = moment(vmDialog.schedule.startTime, 'HH:mm');
vmDialog.schedule.start =
moment(new Date(vmDialog.schedule.start))
let startTime = moment(schedule.startTime, 'HH:mm');
schedule.start = moment(new Date(schedule.start))
.hour(startTime.hour())
.minute(startTime.minute());
.minute(startTime.minute()).toISOString();

let endTime = moment(vmDialog.schedule.endTime, 'HH:mm');
vmDialog.schedule.end =
moment(new Date(vmDialog.schedule.end))
let endTime = moment(schedule.endTime, 'HH:mm');
schedule.end = moment(new Date(schedule.end))
.hour(endTime.hour())
.minute(endTime.minute());
.minute(endTime.minute()).toISOString();

delete schedule.startTime;
delete schedule.endTime;

if (!vmDialog.isEdit) {
await PackageSchedule.create(_.extend(schedule, {
Expand All @@ -241,7 +242,7 @@ angular.module('app')
} else {
await PackageSchedule.update({
where: {
id: vmDialog.schedule.id,
id: schedule.id,
},
}, schedule).$promise;
}
Expand Down
25 changes: 22 additions & 3 deletions app/components/services/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@ angular.module('app')
.factory('Authentication', [
'$rootScope',
'$state',
'$http',
'$location',
'AclService',
'Menu',
'Person',
(
$rootScope,
$state,
$http,
$location,
AclService,
Menu,
Person
) => {
const service = {};

service.redirector = () => {
if ($location.path() === '/') {
if (AclService.hasRole('$authenticated')) {
$state.go('app.dashboard');
} else {
$state.go('app.login');
}
} else if (_.has($rootScope, 'stateTransition.name') && !AclService.can($rootScope.stateTransition.name)) {
$state.go('app');
}
}

service.authorize = (state) => {
if (state.name && !AclService.can(state.name)) {
$state.go('app');
}
}

service.authenticationCheck = async() => {
if (!localStorage.getItem('$LoopBack$accessTokenId')) {
return false;
Expand All @@ -28,7 +46,7 @@ angular.module('app')
AclService.attachRole(role);
}
$rootScope.menus = Menu.menus();
$state.go('app.dashboard');
service.redirector();
} catch (e) {
await service.logout();
return false;
Expand All @@ -39,6 +57,7 @@ angular.module('app')
if ((model.email || model.username) && model.password) {
await Person.login(model).$promise;
await service.authenticationCheck();
$state.go('app');
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cbt-crossword-web",
"version": "1.0.0-alpha1",
"version": "1.0.0-alpha2",
"repository": {
"type": "git",
"url": "https://github.com/labibramadhan/cbt-crossword-web.git"
Expand Down

0 comments on commit 34a9be5

Please sign in to comment.