Skip to content

Commit

Permalink
Merge pull request #59 from SparkEdUAB/add-stats
Browse files Browse the repository at this point in the history
Added stats
  • Loading branch information
OlivierJM authored Feb 11, 2019
2 parents 8e0539e + c9c5a7b commit 2f26bb8
Show file tree
Hide file tree
Showing 50 changed files with 3,878 additions and 1,736 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ rules:
# overwrite some rules
semi: 'error'
no-unexpected-multiline: 2
object-curly-newline: 0
no-throw-literal: 0
no-underscore-dangle: 0
import/no-named-as-default: 0
Expand Down
8 changes: 6 additions & 2 deletions client/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
#dashtweek {
padding-bottom: 75px;
padding-top: 25px;
background-color: #1e4847;
/* background-color: #1e4847; */
margin-top: 10px;
font-size: 30px;
color: white;
Expand All @@ -215,7 +215,7 @@
top: 23px;
}
.notification-item {
color: #0893d2;
/* color: #0893d2; */
padding: 10px;
}
.notification-date {
Expand Down Expand Up @@ -661,3 +661,7 @@ nav ul a:hover {
background-color: #276a76;
will-change: left, right;
}

.slider .indicators {
display: none;
}
11 changes: 11 additions & 0 deletions client/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Essential for the roles package to initialise and check if the user is in roles for real
import { Roles } from 'meteor/alanning:roles';
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import 'materialize-css/dist/css/materialize.min.css';
import 'materialize-css/dist/js/materialize';
import '../imports/ui/stylesheets/wizard.css';
Expand All @@ -17,6 +19,15 @@ import '../i18n/es.i18n.json';
import '../i18n/fr.i18n.json';
// import { La }

Meteor.startup(() => {
Session.setPersistent({
main: '#005555',
isDark: false,
mainDark: '#212121',
bodyBackground: '',
});
});

FlowRouter.wait();

Tracker.autorun(() => {
Expand Down
11 changes: 10 additions & 1 deletion client/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import EditResources from '../imports/ui/components/Dashboard/EditResources.jsx'
import NotFound from '../imports/ui/components/layouts/NotFound';
import OverView from '../imports/ui/components/Dashboard/Statistics/Overview.jsx';
import UserStatistics from '../imports/ui/components/Dashboard/Statistics/UserStatistics';
import Stats from '../imports/ui/components/Dashboard/Statistics/Stats';
import AllTopics from '../imports/ui/components/Dashboard/AllTopics.jsx';
import Feedback from '../imports/ui/components/Dashboard/Feedback.jsx';
import Additional from '../imports/ui/components/Dashboard/Additional.jsx';
Expand Down Expand Up @@ -53,7 +54,9 @@ const adminRoutes = FlowRouter.group({
() => {
if (!(Meteor.loggingIn() || Meteor.userId())) {
return FlowRouter.go('/login');
} else if (!Roles.userIsInRole(Meteor.userId(), ['content-manager', 'admin'])) {
} else if (
!Roles.userIsInRole(Meteor.userId(), ['content-manager', 'admin'])
) {
return FlowRouter.go('/');
}
},
Expand Down Expand Up @@ -258,6 +261,12 @@ adminRoutes.route('/dashboard/settings', {
mount(WrappedSidenav, { yield: <Institution /> });
},
});
adminRoutes.route('/dashboard/stats', {
name: 'Stats',
action() {
mount(WrappedSidenav, { yield: <Stats /> });
},
});

adminRoutes.route('/dashboard/view_resource/:_id', {
name: 'DisplayResource',
Expand Down
5 changes: 0 additions & 5 deletions imports/api/accounts/account.test.js

This file was deleted.

25 changes: 0 additions & 25 deletions imports/api/accounts/methods.test.js

This file was deleted.

4 changes: 0 additions & 4 deletions imports/api/accounts/sum.js

This file was deleted.

16 changes: 16 additions & 0 deletions imports/api/settings/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,20 @@ Meteor.methods({
},
);
},
// prevent Updating when user is not logged in
setDarkMode(isSet) {
check(isSet, Boolean);
if (this.userId) {
return _Settings.update(
{},
{
$set: {
isDark: isSet,
},
},
// { upsert: true },
);
}
throw new Meteor.Error('Auth', 'You are not authenticated');
},
});
2 changes: 2 additions & 0 deletions imports/startup/server/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { _Settings } from '../../api/settings/settings';
The file contains the initial database of the Institution and the users
*/

// eslint-disable-next-line func-names
Meteor.startup(() => {
// initialize the main color
if (!_Settings.find().count()) {
_Settings.insert({
main: '#006b76',
mainDark: '#0c0c0c',
});
}
});
57 changes: 35 additions & 22 deletions imports/ui/components/Accounts/ManageAccounts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as config from '../../../../config.json';
import { formatText } from '../../utils/utils';
import PasswordEdit from '../Utilities/Modal/PasswordEdit.jsx';
import { checkPassword } from './AccountFunction';
import { ThemeContext } from '../../containers/AppWrapper'

const T = i18n.createComponent();

Expand Down Expand Up @@ -251,37 +252,45 @@ export class ManageAccounts extends React.Component {
} = this.state;

return (
<ThemeContext.Consumer>
{
({ state }) => (
<div>
{/* <Header /> */}

<MainModal
show={isOpen}
onClose={this.close}
subFunc={this.handleSubmit}
title={title}
confirm={confirm}
reject={reject}
>
>
{modalType === 'edit' ? (
<AccountEditModal email={email} fname={fname} />
) : modalType === 'roles' ? (
<div className="input-field">
<UserRoles value={this.state.role} />
<AccountEditModal email={email} fname={fname} color={ state.isDark ? '#F5FAF8' : '#000000' } />
) : modalType === 'roles' ? (
<div className="input-field">
<UserRoles value={this.state.role}
color={ state.isDark ? '#F5FAF8' : '#000000' } />
</div>
) :
modalType === 'pass' ? (
<PasswordEdit password={password}
passwordConfirm={passwordConfirm}
validatePassword={this.validatePassword}
confirmPassword={this.confirmPassword}
error={error}
/>
) :
passwordConfirm={passwordConfirm}
validatePassword={this.validatePassword}
confirmPassword={this.confirmPassword}
error={error}
color={ state.isDark ? '#F5FAF8' : '#000000' }
/>
) :
<span />
}
</MainModal>
<div className='m1' />
<div className="col m9 s11">
<div className="col m9 s11"
style={{
backgroundColor: state.isDark ? state.mainDark : '#FFFFFF',
color: state.isDark ? '#F5FAF8' : '#000000',
}}
>
<div className="row">
<div>
<h4>
Expand All @@ -292,17 +301,18 @@ export class ManageAccounts extends React.Component {
<SearchField
action={'/dashboard/accounts'}
name={'accounts'}
color={ state.isDark ? '#F5FAF8' : '#000000' }
placeholder={'search user by name,email'}
query={'q'}
/>
/>
</div>
</div>
<div className="row">
<div className="col m3 s3">
<button
className="btn red darken-3"
onClick={e => this.openModal('delete', e)}
>
>
{' '}
<T>common.actions.delete</T>
</button>
Expand All @@ -320,7 +330,7 @@ export class ManageAccounts extends React.Component {
<button
className="btn grey darken-3"
onClick={e => this.openModal('suspend', e)}
>
>
{' '}
Suspend
</button>
Expand All @@ -334,7 +344,7 @@ export class ManageAccounts extends React.Component {
<button
className="btn green darken-3"
onClick={e => this.openModal('roles', e)}
>
>
{' '}
<T>common.actions.changeRole</T>
</button>
Expand All @@ -343,7 +353,7 @@ export class ManageAccounts extends React.Component {
<button
className="btn teal "
onClick={e => this.openModal('pass', e)}
>
>
{' '}
<T>Change Password</T>
</button>
Expand Down Expand Up @@ -390,7 +400,7 @@ export class ManageAccounts extends React.Component {
} else if (status === 2) {
statusIcon = 'fa-ban ';
}

return (
<tr key={user._id}>
<td>{count++}</td>
Expand All @@ -408,7 +418,7 @@ export class ManageAccounts extends React.Component {
href=""
onClick={e => this.openModal('edit', user._id, email, user.profile.name, e)}
className="fa fa-pencil"
/>
/>
</td>
<td onClick={handleCheckboxChange.bind(this, user._id)}>
<label htmlFor={user._id}>
Expand All @@ -426,10 +436,13 @@ export class ManageAccounts extends React.Component {
itemPerPage={limit}
query={getQuery(queryParams, true)}
totalResults={this.props.count}
/>{' '}
/>{' '}
</div>
{/* </div> */}
</div>
)
}
</ThemeContext.Consumer>
);
}
}
Expand Down
Loading

0 comments on commit 2f26bb8

Please sign in to comment.