Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VILLASweb-backend-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ACS
Public
VILLASframework
VILLASweb-backend-node
Commits
6db52d74
Commit
6db52d74
authored
7 years ago
by
Markus Grigull
Browse files
Options
Downloads
Patches
Plain Diff
Remove unneeded widget model and route
parent
eadb7cd1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
models/visualization.js
+2
-25
2 additions, 25 deletions
models/visualization.js
models/widget.js
+0
-40
0 additions, 40 deletions
models/widget.js
routes/widgets.js
+0
-158
0 additions, 158 deletions
routes/widgets.js
server.js
+0
-2
0 additions, 2 deletions
server.js
with
2 additions
and
225 deletions
models/visualization.js
+
2
−
25
View file @
6db52d74
...
...
@@ -22,37 +22,14 @@
// include
var
mongoose
=
require
(
'
mongoose
'
);
//var Widget = require('./widget');
var
Schema
=
mongoose
.
Schema
;
// visualization model
var
visualizationSchema
=
new
Schema
({
name
:
{
type
:
String
,
required
:
true
},
project
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'
Project
'
/*, required: true*/
},
widgets
:
{
type
:
Array
,
default
:
[]
}
/*widgets: [{ type: Schema.Types.ObjectId, ref: 'Widget' }],
rows: { type: Number, default: 1 }*/
});
// execute before the visualization is deleted
visualizationSchema
.
pre
(
'
remove
'
,
function
(
callback
)
{
// delete all widgets belonging to this visualization
/*this.widgets.forEach(function(id) {
Widget.findOne({ _id: id }, function(err, widget) {
if (err) {
return console.log(err);
}
widget.remove(function(err) {
if (err) {
return console.log(err);
}
});
});
});*/
callback
();
widgets
:
{
type
:
Array
,
default
:
[]
},
grid
:
{
type
:
Number
,
default
:
1
}
});
module
.
exports
=
mongoose
.
model
(
'
Visualization
'
,
visualizationSchema
);
This diff is collapsed.
Click to expand it.
models/widget.js
deleted
100644 → 0
+
0
−
40
View file @
eadb7cd1
/**
* File: widget.js
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
* Date: 28.06.2016
*
* This file is part of VILLASweb-backend.
*
* VILLASweb-backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VILLASweb-backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VILLASweb-backend. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
// include
var
mongoose
=
require
(
'
mongoose
'
);
var
Schema
=
mongoose
.
Schema
;
// widget model
var
widgetSchema
=
new
Schema
({
name
:
{
type
:
String
},
widgetData
:
{
type
:
Schema
.
Types
.
Mixed
,
default
:
{}
},
width
:
{
type
:
Number
,
required
:
true
},
height
:
{
type
:
Number
,
required
:
true
},
type
:
{
type
:
String
,
required
:
true
},
x
:
{
type
:
Number
,
default
:
0
},
y
:
{
type
:
Number
,
default
:
0
},
z
:
{
type
:
Number
,
default
:
0
},
visualization
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'
Visualization
'
}
});
module
.
exports
=
mongoose
.
model
(
'
Widget
'
,
widgetSchema
);
This diff is collapsed.
Click to expand it.
routes/widgets.js
deleted
100644 → 0
+
0
−
158
View file @
eadb7cd1
/**
* File: widgets.js
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
* Date: 28.06.2016
*
* This file is part of VILLASweb-backend.
*
* VILLASweb-backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VILLASweb-backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VILLASweb-backend. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
// include
var
express
=
require
(
'
express
'
);
var
auth
=
require
(
'
../auth
'
);
var
logger
=
require
(
'
../utils/logger
'
);
// models
var
Widget
=
require
(
'
../models/widget
'
);
var
Visualization
=
require
(
'
../models/visualization
'
);
// create router
var
router
=
express
.
Router
();
// all widget routes need authentication
router
.
use
(
'
/widgets
'
,
auth
.
validateToken
);
// routes
router
.
get
(
'
/widgets
'
,
/*auth.validateRole('visualization', 'read'),*/
function
(
req
,
res
)
{
// get all widgets
Widget
.
find
(
function
(
err
,
widgets
)
{
if
(
err
)
{
logger
.
error
(
'
Unable to receive widgets
'
,
err
);
return
res
.
send
(
err
);
}
res
.
send
({
widgets
:
widgets
});
});
});
router
.
post
(
'
/widgets
'
,
/*auth.validateRole('visualization', 'create'),*/
function
(
req
,
res
)
{
// create new widget
var
widget
=
new
Widget
(
req
.
body
.
widget
);
widget
.
save
(
function
(
err
)
{
if
(
err
)
{
logger
.
error
(
'
Unable to create widget
'
,
err
);
return
res
.
send
(
err
);
}
res
.
send
({
widget
:
widget
});
});
// add widget to visualization
Visualization
.
findOne
({
_id
:
widget
.
visualization
},
function
(
err
,
visualization
)
{
if
(
err
)
{
logger
.
log
(
'
verbose
'
,
'
Unknown visualization for id:
'
+
widget
.
visualization
);
return
;
}
visualization
.
widgets
.
push
(
widget
.
_id
);
visualization
.
save
(
function
(
err
)
{
if
(
err
)
{
logger
.
error
(
'
Unable to save visualization
'
,
visualization
);
return
;
}
});
});
});
router
.
put
(
'
/widgets/:id
'
,
/*auth.validateRole('visualization', 'update'),*/
function
(
req
,
res
)
{
// get widget
Widget
.
findOne
({
_id
:
req
.
params
.
id
},
function
(
err
,
widget
)
{
if
(
err
)
{
logger
.
log
(
'
verbose
'
,
'
PUT Unknown widget for id:
'
+
req
.
params
.
id
);
return
res
.
send
(
err
);
}
// update all properties
for
(
property
in
req
.
body
.
widget
)
{
widget
[
property
]
=
req
.
body
.
widget
[
property
];
}
// save the changes
widget
.
save
(
function
(
err
)
{
if
(
err
)
{
logger
.
error
(
'
Unable to save widget
'
,
widget
);
return
res
.
send
(
err
);
}
res
.
send
({
widget
:
widget
});
});
});
});
router
.
get
(
'
/widgets/:id
'
,
/*auth.validateRole('visualization', 'read'),*/
function
(
req
,
res
)
{
Widget
.
findOne
({
_id
:
req
.
params
.
id
},
function
(
err
,
widget
)
{
if
(
err
)
{
logger
.
log
(
'
verbose
'
,
'
GET Unknown widget for id:
'
+
req
.
params
.
id
);
return
res
.
send
(
err
);
}
res
.
send
({
widget
:
widget
});
});
});
router
.
delete
(
'
/widgets/:id
'
,
/*auth.validateRole('visualization', 'delete'),*/
function
(
req
,
res
)
{
Widget
.
findOne
({
_id
:
req
.
params
.
id
},
function
(
err
,
widget
)
{
if
(
err
)
{
logger
.
log
(
'
verbose
'
,
'
DELETE Unknown widget for id:
'
+
req
.
params
.
id
);
return
res
.
send
(
err
);
}
// remove from visualization's list
Visualization
.
findOne
({
_id
:
widget
.
visualization
},
function
(
err
,
visualization
)
{
if
(
err
)
{
logger
.
log
(
'
verbose
'
,
'
Unknown visualization for id:
'
+
widget
.
visualization
);
return
;
}
for
(
var
i
=
0
;
i
<
visualization
.
widgets
.
length
;
i
++
)
{
var
id
=
String
(
visualization
.
widgets
[
i
]);
if
(
id
==
widget
.
_id
)
{
visualization
.
widgets
.
splice
(
i
,
1
);
}
}
visualization
.
save
(
function
(
err
)
{
if
(
err
)
{
logger
.
error
(
'
Unable to save visualization
'
,
visualization
);
return
;
}
});
});
widget
.
remove
(
function
(
err
)
{
if
(
err
)
{
logger
.
error
(
'
Unable to remove widget
'
,
widget
);
return
res
.
send
(
err
);
}
res
.
send
({});
});
});
});
module
.
exports
=
router
;
This diff is collapsed.
Click to expand it.
server.js
+
0
−
2
View file @
6db52d74
...
...
@@ -32,7 +32,6 @@ var logger = require('./utils/logger');
var
users
=
require
(
'
./routes/users
'
);
var
projects
=
require
(
'
./routes/projects
'
);
var
visualizations
=
require
(
'
./routes/visualizations
'
);
var
widgets
=
require
(
'
./routes/widgets
'
);
var
simulations
=
require
(
'
./routes/simulations
'
);
var
upload
=
require
(
'
./routes/upload
'
);
var
files
=
require
(
'
./routes/files
'
);
...
...
@@ -86,7 +85,6 @@ mongoose.connect(config.databaseURL + config.databaseName, { useMongoClient: tru
app
.
use
(
'
/api/v1
'
,
users
);
app
.
use
(
'
/api/v1
'
,
projects
);
app
.
use
(
'
/api/v1
'
,
visualizations
);
app
.
use
(
'
/api/v1
'
,
widgets
);
app
.
use
(
'
/api/v1
'
,
simulations
);
app
.
use
(
'
/api/v1
'
,
upload
);
app
.
use
(
'
/api/v1
'
,
files
);
...
...
This diff is collapsed.
Click to expand it.
Markus Grigull
@markatk
mentioned in issue
#21 (closed)
·
7 years ago
mentioned in issue
#21 (closed)
mentioned in issue #21
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment