Skip to content
This repository was archived by the owner on Jan 30, 2022. It is now read-only.

Commit e3c5911

Browse files
committed
Hiding talks now possible
1 parent 63a6087 commit e3c5911

File tree

7 files changed

+120
-11
lines changed

7 files changed

+120
-11
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@ app.get('/', (req, res) => {
2828
res.render('index');
2929
});
3030

31+
app.get('/all', (req, res) => {
32+
res.render('all');
33+
});
34+
35+
3136
// api to get talks from the db
3237
app.get('/api/talks', talksCtrl.getTalks);
3338

3439
// api to push talks into the db
3540
app.post('/api/postTalk', talksCtrl.createTalk);
3641

42+
// api to hide & unhide talks on the site
43+
app.post('/api/hideTalk', talksCtrl.updateTalk);
44+
app.post('/api/unhideTalk', talksCtrl.updateTalk);
45+
3746
// start the server
3847
app.listen(3000, () => {
3948
console.log('Server listening on port 3000, press ctrl-C to quit...');

public/css/app.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ td.hides button {
2323
display: inline;
2424
float: left;
2525
background: 0;
26-
border: 0;
27-
outline: 0;
26+
/*border: 0;
27+
outline: 0;*/
2828
color: white;
29+
30+
&:hover {
31+
background: white;
32+
color: #78909c;
33+
}
2934
}
3035

3136
h3 {

public/js/app.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ function postTalk($scope, $http) {
1717
});
1818
}
1919

20+
function hideTalk($scope, $http) {
21+
var data = {
22+
talkId: $scope.id,
23+
hiddenStatus: true
24+
};
25+
26+
$http.post("/api/hideTalk", data).then(response => {
27+
$scope.talks = response.data;
28+
});
29+
}
30+
31+
function unhideTalk($scope, $http) {
32+
var data = {
33+
talkId: $scope.id,
34+
hiddenStatus: false
35+
};
36+
37+
$http.post("/api/unhideTalk", data).then(response => {
38+
$scope.talks = response.data;
39+
});
40+
}
41+
2042
// The main controller for the page
2143
app.controller('talksController', ($scope, $http) => {
2244
getTalks($scope, $http); // Always load in talks at startup
@@ -28,12 +50,14 @@ app.controller('talksController', ($scope, $http) => {
2850
};
2951

3052
// Hide a certain talk
31-
$scope.hide = () => {
32-
53+
$scope.hide = (id) => {
54+
$scope.id = id;
55+
hideTalk($scope, $http);
3356
};
3457

3558
// unhide a certain talk
36-
$scope.unhide = () => {
37-
59+
$scope.unhide = (id) => {
60+
$scope.id = id;
61+
unhideTalk($scope, $http);
3862
};
3963
});

talks-ctrl.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,25 @@ module.exports.createTalk = function(req, res) {
2222
});
2323
};
2424

25+
module.exports.updateTalk = function(req, res) {
26+
console.log("UPDURTINGS");
27+
var sequelize = connectToServer();
28+
var talksModel = sequelize.import(__dirname + "/talks-model.js");
29+
30+
return talksModel.sync().then(() => {
31+
return talksModel.update(
32+
{ hidden: req.body.hiddenStatus },
33+
{ where: { id: req.body.talkId }}
34+
);
35+
}).then(() => {
36+
loadTalks(talksModel, res);
37+
});
38+
};
39+
2540
// Send a SELECT query to the database and return the response as JSON
2641
function loadTalks(model, res) {
2742
return model.findAll({
28-
attributes: ['id', 'name', 'type', 'desc']
43+
attributes: ['id', 'name', 'type', 'desc', 'hidden']
2944
}).then(result => {
3045
return res.json(result);
3146
});

talks-model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module.exports = function(sequelize, DataTypes) {
55
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
66
name: { type: DataTypes.STRING },
77
type: { type: DataTypes.STRING },
8-
desc: { type: DataTypes.STRING }
8+
desc: { type: DataTypes.STRING },
9+
hidden: { type: DataTypes.BOOLEAN, defaultValue: false }
10+
}, {
11+
timestamps: false,
12+
tableName: 'talks'
913
});
1014
};

views/all.jade

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
html(ng-app='talksApp')
2+
head
3+
title Talks
4+
meta(charset='utf-8')
5+
6+
link(rel='stylesheet' href='css/app.css')
7+
body
8+
#nav
9+
ul
10+
li: a(href="http://cosi.clarkson.edu/") CSLabs Homepage
11+
li: a(href="http://dubsdot.cosi.clarkson.edu/") Dubsdot
12+
li: a(href="http://docs.cosi.clarkson.edu/") Docs
13+
li: a(href="http://print.cosi.clarkson.edu/") Print
14+
li: a(href="http://mirror.clarkson.edu/") Mirror
15+
li: a(href="http://fsuvius.cosi.clarkson.edu/") Fsuvius
16+
li: a(href="http://talks.cosi.clarkson.edu/") Talks
17+
li: a(href="http://cosi-lab.github.io/meeting-minutes/") Meeting Minutes
18+
li: a(href="http://cosi-lab.github.io/project-updates/") Project Updates
19+
li: a(href="http://moodle.cosi.clarkson.edu/") COSI Moodle
20+
li: a(href="http://management.cosi.clarkson.edu/") Management
21+
22+
h1 Talks
23+
h3 Upcoming Events For The Clarkson Open Source Institute Meetings
24+
h3 Next Meeting: Mar. 23
25+
26+
table(ng-controller="talksController" id="talks-table")
27+
tr(class="event" ng-repeat="talk in talks | orderBy: ['type']")
28+
td.name {{ talk.name }}
29+
td.type {{ talk.type }}
30+
td.desc {{ talk.desc }}
31+
td.hides
32+
button(ng-click="hide(this.talk.id)") X
33+
button(ng-click="unhide(this.talk.id)") ↶
34+
tr
35+
th Talk Presenter
36+
th Type
37+
th Description
38+
tr
39+
form
40+
th: input(id="in_name" size=30 name="name" ng-model="newTalk.name" type="text" placeholder="Name")
41+
th: select(name="type" ng-model="newTalk.type")
42+
option(value="form topic") Forum Topic
43+
option(value="lightning talk") Lightning Talk
44+
option(value="project update") Project Update
45+
option(value="announcement") Announcement
46+
option(value="after meeting slot") After-Meeting Slot
47+
th: input(id="in_desc" size=50 name="desc" type="text" ng-model="newTalk.desc" placeholder="Description")
48+
th: button(ng-click="createTalk()") Create
49+
50+
script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js")
51+
script(src='js/app.js')
52+
p(style="text-align:center") V2.0 - Not powered by Fsuvius

views/index.jade

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ html(ng-app='talksApp')
2424
h3 Next Meeting: Mar. 23
2525

2626
table(ng-controller="talksController" id="talks-table")
27-
tr(class="event" ng-repeat="talk in talks | orderBy: ['type']")
27+
tr(class="event" ng-repeat="talk in talks | filter: {'hidden': false} | orderBy: ['type']")
2828
td.name {{ talk.name }}
2929
td.type {{ talk.type }}
3030
td.desc {{ talk.desc }}
3131
td.hides
32-
button(ng-click="hide()") X
33-
button(ng-click="unhide()") ↶
32+
button(ng-click="hide(this.talk.id)") X
33+
button(ng-click="unhide(this.talk.id)") ↶
3434
tr
3535
th Talk Presenter
3636
th Type

0 commit comments

Comments
 (0)