Skip to content

Commit 2f26bb8

Browse files
authored
Merge pull request #59 from SparkEdUAB/add-stats
Added stats
2 parents 8e0539e + c9c5a7b commit 2f26bb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3878
-1736
lines changed

.eslintrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ rules:
3434
# overwrite some rules
3535
semi: 'error'
3636
no-unexpected-multiline: 2
37+
object-curly-newline: 0
3738
no-throw-literal: 0
3839
no-underscore-dangle: 0
3940
import/no-named-as-default: 0

client/main.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
#dashtweek {
200200
padding-bottom: 75px;
201201
padding-top: 25px;
202-
background-color: #1e4847;
202+
/* background-color: #1e4847; */
203203
margin-top: 10px;
204204
font-size: 30px;
205205
color: white;
@@ -215,7 +215,7 @@
215215
top: 23px;
216216
}
217217
.notification-item {
218-
color: #0893d2;
218+
/* color: #0893d2; */
219219
padding: 10px;
220220
}
221221
.notification-date {
@@ -661,3 +661,7 @@ nav ul a:hover {
661661
background-color: #276a76;
662662
will-change: left, right;
663663
}
664+
665+
.slider .indicators {
666+
display: none;
667+
}

client/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Essential for the roles package to initialise and check if the user is in roles for real
22
import { Roles } from 'meteor/alanning:roles';
3+
import { Meteor } from 'meteor/meteor';
4+
import { Session } from 'meteor/session';
35
import 'materialize-css/dist/css/materialize.min.css';
46
import 'materialize-css/dist/js/materialize';
57
import '../imports/ui/stylesheets/wizard.css';
@@ -17,6 +19,15 @@ import '../i18n/es.i18n.json';
1719
import '../i18n/fr.i18n.json';
1820
// import { La }
1921

22+
Meteor.startup(() => {
23+
Session.setPersistent({
24+
main: '#005555',
25+
isDark: false,
26+
mainDark: '#212121',
27+
bodyBackground: '',
28+
});
29+
});
30+
2031
FlowRouter.wait();
2132

2233
Tracker.autorun(() => {

client/routes.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import EditResources from '../imports/ui/components/Dashboard/EditResources.jsx'
1717
import NotFound from '../imports/ui/components/layouts/NotFound';
1818
import OverView from '../imports/ui/components/Dashboard/Statistics/Overview.jsx';
1919
import UserStatistics from '../imports/ui/components/Dashboard/Statistics/UserStatistics';
20+
import Stats from '../imports/ui/components/Dashboard/Statistics/Stats';
2021
import AllTopics from '../imports/ui/components/Dashboard/AllTopics.jsx';
2122
import Feedback from '../imports/ui/components/Dashboard/Feedback.jsx';
2223
import Additional from '../imports/ui/components/Dashboard/Additional.jsx';
@@ -53,7 +54,9 @@ const adminRoutes = FlowRouter.group({
5354
() => {
5455
if (!(Meteor.loggingIn() || Meteor.userId())) {
5556
return FlowRouter.go('/login');
56-
} else if (!Roles.userIsInRole(Meteor.userId(), ['content-manager', 'admin'])) {
57+
} else if (
58+
!Roles.userIsInRole(Meteor.userId(), ['content-manager', 'admin'])
59+
) {
5760
return FlowRouter.go('/');
5861
}
5962
},
@@ -258,6 +261,12 @@ adminRoutes.route('/dashboard/settings', {
258261
mount(WrappedSidenav, { yield: <Institution /> });
259262
},
260263
});
264+
adminRoutes.route('/dashboard/stats', {
265+
name: 'Stats',
266+
action() {
267+
mount(WrappedSidenav, { yield: <Stats /> });
268+
},
269+
});
261270

262271
adminRoutes.route('/dashboard/view_resource/:_id', {
263272
name: 'DisplayResource',

imports/api/accounts/account.test.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

imports/api/accounts/methods.test.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

imports/api/accounts/sum.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

imports/api/settings/methods.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,20 @@ Meteor.methods({
119119
},
120120
);
121121
},
122+
// prevent Updating when user is not logged in
123+
setDarkMode(isSet) {
124+
check(isSet, Boolean);
125+
if (this.userId) {
126+
return _Settings.update(
127+
{},
128+
{
129+
$set: {
130+
isDark: isSet,
131+
},
132+
},
133+
// { upsert: true },
134+
);
135+
}
136+
throw new Meteor.Error('Auth', 'You are not authenticated');
137+
},
122138
});

imports/startup/server/init.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { _Settings } from '../../api/settings/settings';
55
The file contains the initial database of the Institution and the users
66
*/
77

8+
// eslint-disable-next-line func-names
89
Meteor.startup(() => {
910
// initialize the main color
1011
if (!_Settings.find().count()) {
1112
_Settings.insert({
1213
main: '#006b76',
14+
mainDark: '#0c0c0c',
1315
});
1416
}
1517
});

imports/ui/components/Accounts/ManageAccounts.jsx

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import * as config from '../../../../config.json';
2121
import { formatText } from '../../utils/utils';
2222
import PasswordEdit from '../Utilities/Modal/PasswordEdit.jsx';
2323
import { checkPassword } from './AccountFunction';
24+
import { ThemeContext } from '../../containers/AppWrapper'
2425

2526
const T = i18n.createComponent();
2627

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

253254
return (
255+
<ThemeContext.Consumer>
256+
{
257+
({ state }) => (
254258
<div>
255-
{/* <Header /> */}
256-
257259
<MainModal
258260
show={isOpen}
259261
onClose={this.close}
260262
subFunc={this.handleSubmit}
261263
title={title}
262264
confirm={confirm}
263265
reject={reject}
264-
>
266+
>
265267
{modalType === 'edit' ? (
266-
<AccountEditModal email={email} fname={fname} />
267-
) : modalType === 'roles' ? (
268-
<div className="input-field">
269-
<UserRoles value={this.state.role} />
268+
<AccountEditModal email={email} fname={fname} color={ state.isDark ? '#F5FAF8' : '#000000' } />
269+
) : modalType === 'roles' ? (
270+
<div className="input-field">
271+
<UserRoles value={this.state.role}
272+
color={ state.isDark ? '#F5FAF8' : '#000000' } />
270273
</div>
271274
) :
272275
modalType === 'pass' ? (
273276
<PasswordEdit password={password}
274-
passwordConfirm={passwordConfirm}
275-
validatePassword={this.validatePassword}
276-
confirmPassword={this.confirmPassword}
277-
error={error}
278-
/>
279-
) :
277+
passwordConfirm={passwordConfirm}
278+
validatePassword={this.validatePassword}
279+
confirmPassword={this.confirmPassword}
280+
error={error}
281+
color={ state.isDark ? '#F5FAF8' : '#000000' }
282+
/>
283+
) :
280284
<span />
281285
}
282286
</MainModal>
283287
<div className='m1' />
284-
<div className="col m9 s11">
288+
<div className="col m9 s11"
289+
style={{
290+
backgroundColor: state.isDark ? state.mainDark : '#FFFFFF',
291+
color: state.isDark ? '#F5FAF8' : '#000000',
292+
}}
293+
>
285294
<div className="row">
286295
<div>
287296
<h4>
@@ -292,17 +301,18 @@ export class ManageAccounts extends React.Component {
292301
<SearchField
293302
action={'/dashboard/accounts'}
294303
name={'accounts'}
304+
color={ state.isDark ? '#F5FAF8' : '#000000' }
295305
placeholder={'search user by name,email'}
296306
query={'q'}
297-
/>
307+
/>
298308
</div>
299309
</div>
300310
<div className="row">
301311
<div className="col m3 s3">
302312
<button
303313
className="btn red darken-3"
304314
onClick={e => this.openModal('delete', e)}
305-
>
315+
>
306316
{' '}
307317
<T>common.actions.delete</T>
308318
</button>
@@ -320,7 +330,7 @@ export class ManageAccounts extends React.Component {
320330
<button
321331
className="btn grey darken-3"
322332
onClick={e => this.openModal('suspend', e)}
323-
>
333+
>
324334
{' '}
325335
Suspend
326336
</button>
@@ -334,7 +344,7 @@ export class ManageAccounts extends React.Component {
334344
<button
335345
className="btn green darken-3"
336346
onClick={e => this.openModal('roles', e)}
337-
>
347+
>
338348
{' '}
339349
<T>common.actions.changeRole</T>
340350
</button>
@@ -343,7 +353,7 @@ export class ManageAccounts extends React.Component {
343353
<button
344354
className="btn teal "
345355
onClick={e => this.openModal('pass', e)}
346-
>
356+
>
347357
{' '}
348358
<T>Change Password</T>
349359
</button>
@@ -390,7 +400,7 @@ export class ManageAccounts extends React.Component {
390400
} else if (status === 2) {
391401
statusIcon = 'fa-ban ';
392402
}
393-
403+
394404
return (
395405
<tr key={user._id}>
396406
<td>{count++}</td>
@@ -408,7 +418,7 @@ export class ManageAccounts extends React.Component {
408418
href=""
409419
onClick={e => this.openModal('edit', user._id, email, user.profile.name, e)}
410420
className="fa fa-pencil"
411-
/>
421+
/>
412422
</td>
413423
<td onClick={handleCheckboxChange.bind(this, user._id)}>
414424
<label htmlFor={user._id}>
@@ -426,10 +436,13 @@ export class ManageAccounts extends React.Component {
426436
itemPerPage={limit}
427437
query={getQuery(queryParams, true)}
428438
totalResults={this.props.count}
429-
/>{' '}
439+
/>{' '}
430440
</div>
431441
{/* </div> */}
432442
</div>
443+
)
444+
}
445+
</ThemeContext.Consumer>
433446
);
434447
}
435448
}

0 commit comments

Comments
 (0)