summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-os/mock/ecomp/router.js
blob: 44db7160db9d77c02448fb35141a2f58dc0a689a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use strict';

let conf = require('../../client/configurations/mock.json');
let router = require('express').Router();
var concatRegex = /\/portalApi\/[\d,\w,\/,:,?]+$/;


//**Mock endpoints goes here:

//User apps home page
router.get(stripEndpoint(conf.api.userApps), function (req, res) {
    res.json(require('./data/applications/user-apps.json'));
});

//User widgets
router.get(stripEndpoint(conf.api.widgets), function (req, res) {
    res.json(require('./data/widgets/widgets.json'));
});

router.post(stripEndpoint(conf.api.widgets), function (req, res) {
    //res.status(409).json([{"errorCode": 1201, "fields": [{"name":"name"},{"name":"url"}]}]).send();
    res.json();
});

router.put(stripEndpoint(conf.api.widgets + '/:widgetId'), function (req, res) {
    res.json();
});

router.delete(stripEndpoint(conf.api.widgets + '/:widgetId'), function (req, res) {
    res.json();
});

//widget validation
router.post(stripEndpoint(conf.api.widgetsValidation), function (req, res) {
    //404 - not found in DB means valid
    res.status(404).send();
});

//Admins view
router.get(stripEndpoint(conf.api.accountAdmins), function (req, res) {
    res.json(require('./data/admins/account-admins.json'));
});

router.get(stripEndpoint(conf.api.availableApps), function (req, res) {
    res.json(require('./data/applications/available-apps.json'));
});

//Header
router.get(stripEndpoint(conf.api.userProfile), function (req, res) {
    res.json(require('./data/user-profile/user-profile.json'));
});

//New Admin + User adding dialogs
router.get(stripEndpoint(conf.api.queryUsers), function (req, res) {
    res.json(require('./data/users/query-users-results.json'));
});

//new admin dialog
router.get(stripEndpoint(conf.api.adminAppsRoles), function (req, res) {
    res.json(require('./data/admins/admin-app-roles.json'));
});

router.put(stripEndpoint(conf.api.adminAppsRoles), function (req, res) {
    res.send();
});

//Users view
router.get(stripEndpoint(conf.api.adminApps), function (req, res) {
    res.send(require('./data/applications/admin-apps.json'));
});

router.get(stripEndpoint(conf.api.accountUsers), function (req, res) {
    res.send(require('./data/users/account-users.json'));
});

//new user view
// router.get(stripEndpoint(conf.api.userAppsRoles), function (req, res) {
//     res.send(require('./data/users/user-apps-roles.json'));
// });
//
// router.put(stripEndpoint(conf.api.userAppsRoles), function (req, res) {
//     res.send();
// });

//apps onboarding view
router.get(stripEndpoint(conf.api.onboardingApps), function (req, res) {
    res.send(require('./data/applications/applications-onboarding.json'));
});

router.post(stripEndpoint(conf.api.onboardingApps), function (req, res) {
    //res.status(409).json([{"errorCode": 1201, "fields": [{"name":"name"},{"name":"url"}]}]).send();
    res.send();
});

router.put(stripEndpoint(conf.api.onboardingApps), function (req, res) {
    res.send();
});

router.get(stripEndpoint(conf.api.functionalMenuForAuthUser), function (req, res) {
    res.json(require('./data/functional-menu/menu-items.json'));
});
router.get(stripEndpoint(conf.api.functionalMenu), function (req, res) {
    res.json(require('./data/functional-menu/menu-items.json'));
});
router.get(stripEndpoint(conf.api.functionalMenuItemDetails), function (req, res) {
    res.json(require('./data/functional-menu/menu-item-details.json'));
});
router.get(stripEndpoint(conf.api.appRoles), function (req, res) {
    res.json(require('./data/functional-menu/app-roles.json'));
});
// create a new menu item
router.post(stripEndpoint(conf.api.functionalMenuItem), function (req, res) {
    res.send();
});
// edit a menu item
router.put(stripEndpoint(conf.api.functionalMenuItem), function (req, res) {
    res.send();
});
// delete a menu item
router.delete(stripEndpoint(conf.api.functionalMenuItem), function (req, res) {
    res.send();
});
router.get(stripEndpoint(conf.api.getFavoriteItems), function (req, res) {
    res.json(require('./data/functional-menu/favorites.json'));
});
// functionalMenuStaticInfo
router.get(stripEndpoint(conf.api.functionalMenuStaticInfo), function (req, res) {
    res.json(require('./data/user-profile/user-static-info.json'));
});
// Portal Admins
router.get(stripEndpoint(conf.api.portalAdmins), function (req, res) {
    res.json(require('./data/portal-admins/portal-admins.json'));
});
// Ping
router.get(stripEndpoint(conf.api.ping), function (req, res) {
    res.json(require('./data/ping/ping.json'));
});


function stripEndpoint(endpoint) {
    return endpoint.match(concatRegex)[0];
}

module.exports = router;