Skip to content

Commit 3f24d3e

Browse files
committed
Add mail hist view
1 parent 9482452 commit 3f24d3e

6 files changed

Lines changed: 188 additions & 5 deletions

File tree

OpenFlow/src/LoginProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ export class LoginProvider {
620620
} catch (error) {
621621
}
622622
const agent = req.headers['user-agent'];
623-
const UpdateDoc: any = { "$set": { "_modified": dt, "read": true }, "$push": { "opened": { dt, ip, domain, agent } } };
623+
const UpdateDoc: any = { "$set": { "_modified": dt, "read": true }, "$push": { "opened": { dt, ip, domain, agent } }, "$inc": { "readcount": 1 } };
624624
var res2 = await Config.db._UpdateOne({ id }, UpdateDoc, "mailhist", 1, true, Crypt.rootToken(), null);
625625
} catch (error) {
626626
Logger.instanse.error("LoginProvider", "/read", error);
@@ -815,7 +815,7 @@ export class LoginProvider {
815815
Logger.instanse.error("LoginProvider", "/forgotpassword", "Recevied wrong mail for id " + id);
816816
return res.end(JSON.stringify({ id }));
817817
}
818-
this.sendEmail("validate", user._id, email, 'Reset password request',
818+
this.sendEmail("pwreset", user._id, email, 'Reset password request',
819819
`Hi ${user.name}\nYour password for ${Config.domain} can be reset by using the below validation code\n\n${code}\n\nIf you did not request a new password, please ignore this email.`);
820820

821821
return res.end(JSON.stringify({ id }));
@@ -1641,6 +1641,7 @@ export class LoginProvider {
16411641
} else {
16421642
Logger.instanse.info("LoginProvider", "sendEmail", "Email sent to " + to + " " + info.response);
16431643
var item: any = new Base();
1644+
item.readcount = 0;
16441645
item._type = type;
16451646
item.id = id;
16461647
item.from = from;

OpenFlow/src/public/Controllers.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7249,3 +7249,94 @@ export class WorkitemQueueCtrl extends entityCtrl<WorkitemQueue> {
72497249
}
72507250

72517251

7252+
export class MailHistsCtrl extends entitiesCtrl<Role> {
7253+
constructor(
7254+
public $rootScope: ng.IRootScopeService,
7255+
public $scope: ng.IScope,
7256+
public $location: ng.ILocationService,
7257+
public $routeParams: ng.route.IRouteParamsService,
7258+
public $interval: ng.IIntervalService,
7259+
public WebSocketClientService: WebSocketClientService,
7260+
public api: api,
7261+
public userdata: userdata
7262+
) {
7263+
super($rootScope, $scope, $location, $routeParams, $interval, WebSocketClientService, api, userdata);
7264+
this.autorefresh = true;
7265+
console.debug("MailHistsCtrl");
7266+
this.basequery = {};
7267+
this.collection = "mailhist";
7268+
this.postloadData = this.processdata;
7269+
this.baseprojection = { _type: 1, name: 1, _created: 1, _modified: 1, read: 1, readcount: 1, userid: 1 };
7270+
if (this.userdata.data.MailHistsCtrl) {
7271+
this.basequery = this.userdata.data.MailHistsCtrl.basequery;
7272+
this.collection = this.userdata.data.MailHistsCtrl.collection;
7273+
this.baseprojection = this.userdata.data.MailHistsCtrl.baseprojection;
7274+
this.orderby = this.userdata.data.MailHistsCtrl.orderby;
7275+
this.searchstring = this.userdata.data.MailHistsCtrl.searchstring;
7276+
this.basequeryas = this.userdata.data.MailHistsCtrl.basequeryas;
7277+
this.skipcustomerfilter = this.userdata.data.MailHistsCtrl.skipcustomerfilter;
7278+
}
7279+
WebSocketClientService.onSignedin((user: TokenUser) => {
7280+
this.loadData();
7281+
});
7282+
}
7283+
processdata() {
7284+
if (!this.userdata.data.MailHistsCtrl) this.userdata.data.MailHistsCtrl = {};
7285+
this.userdata.data.MailHistsCtrl.basequery = this.basequery;
7286+
this.userdata.data.MailHistsCtrl.collection = this.collection;
7287+
this.userdata.data.MailHistsCtrl.baseprojection = this.baseprojection;
7288+
this.userdata.data.MailHistsCtrl.orderby = this.orderby;
7289+
this.userdata.data.MailHistsCtrl.searchstring = this.searchstring;
7290+
this.userdata.data.MailHistsCtrl.basequeryas = this.basequeryas;
7291+
this.userdata.data.MailHistsCtrl.skipcustomerfilter = this.skipcustomerfilter;
7292+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
7293+
}
7294+
}
7295+
7296+
7297+
export class MailHistCtrl extends entityCtrl<Base> {
7298+
constructor(
7299+
public $rootScope: ng.IRootScopeService,
7300+
public $scope: ng.IScope,
7301+
public $location: ng.ILocationService,
7302+
public $routeParams: ng.route.IRouteParamsService,
7303+
public $interval: ng.IIntervalService,
7304+
public WebSocketClientService: WebSocketClientService,
7305+
public api: api,
7306+
public userdata: userdata
7307+
) {
7308+
super($rootScope, $scope, $location, $routeParams, $interval, WebSocketClientService, api, userdata);
7309+
console.debug("MailHist");
7310+
this.collection = "mailhist";
7311+
this.postloadData = this.processData;
7312+
WebSocketClientService.onSignedin(async (user: TokenUser) => {
7313+
if (this.id !== null && this.id !== undefined) {
7314+
await this.loadData();
7315+
} else {
7316+
this.model = new Role();
7317+
}
7318+
});
7319+
}
7320+
async processData(): Promise<void> {
7321+
if (this.model) {
7322+
(this.model as any).opened = (this.model as any).opened.reverse();
7323+
}
7324+
this.loading = false;
7325+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
7326+
}
7327+
7328+
async submit(): Promise<void> {
7329+
try {
7330+
if (this.model._id) {
7331+
await NoderedUtil.UpdateOne({ collectionname: this.collection, item: this.model });
7332+
} else {
7333+
this.model = await NoderedUtil.InsertOne({ collectionname: this.collection, item: this.model });
7334+
}
7335+
this.$location.path("/MailHists");
7336+
} catch (error) {
7337+
console.error(error);
7338+
this.errormessage = error.message ? error.message : error;
7339+
}
7340+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
7341+
}
7342+
}

OpenFlow/src/public/MailHist.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<div class="row">
2+
<div class="col-sm-20">
3+
<h1 class="pagetitle" translate lib="web">role</h1>
4+
</div>
5+
</div>
6+
<style type="text/css">
7+
.list-group-item:hover {
8+
color: #337ab7;
9+
text-shadow: 0 0 1em #337ab7;
10+
cursor: pointer;
11+
}
12+
13+
.listgroupitemselected {
14+
border: 6px;
15+
border-color: black;
16+
background-color: #337ab7;
17+
color: white;
18+
cursor: pointer;
19+
}
20+
</style>
21+
22+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
23+
<form ng-submit="ctrl.submit()" class="form-horizontal" role="form" autocomplete="off">
24+
25+
<div class="form-group">
26+
<label for="name" class="col-sm-2 control-label" translate lib="web">name</label>
27+
<div class="col-sm-6">
28+
<input ng-model="ctrl.model.name" class="form-control input-md" ng-disabled="ctrl.loading==true" />
29+
</div>
30+
</div>
31+
<div class="form-group">
32+
<label for="name" class="col-sm-2 control-label" translate lib="web">read</label>
33+
<div class="col-sm-6">
34+
<div class="custom-switch">
35+
<input type="checkbox" id="rparole" ng-model="ctrl.model.read">
36+
<label for="read">read</label>
37+
</div>
38+
</div>
39+
</div>
40+
<div class="form-inline" ng-repeat="m in ctrl.model.opened">
41+
<label class="col-sm-1 control-label"><timesince ng-model="m.dt" /></label>
42+
<div class="col-sm-3">
43+
{{m.ip}} / {{m.domain}}
44+
</div>
45+
<div class="col-sm-7">
46+
{{m.agent}}
47+
</div>
48+
</div>
49+
50+
51+
</form>

OpenFlow/src/public/MailHists.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<div class="row">
2+
<h1 translate lib="web">Mail history</h1>
3+
</div>
4+
<div class="col-sm-12 text-right">
5+
<em class="fas fa-cog fa-spin" ng-show="ctrl.loading==true"></em>
6+
</div>
7+
<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
8+
<table id="table1" class="table table-striped" when-scrolled="ctrl.more()" style="width: 100%;">
9+
<thead class="thead-dark">
10+
<tr>
11+
<th ng-click="ctrl.ToggleOrder('name')"><b translate lib="web">name</b></th>
12+
<th class="w-150" ng-click="ctrl.ToggleOrder('_created')"><b translate lib="web">created</b></th>
13+
<th class="w-150" ng-click="ctrl.ToggleOrder('_modified')"><b translate lib="web">updated</b></th>
14+
<th class="w-150" ng-click="ctrl.ToggleOrder('read')"><b translate lib="web">readcount</b></th>
15+
<th class="w-150"></th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<tr ng-repeat="model in ctrl.models">
20+
<td><a style="color: inherit; text-decoration: inherit;" ng-href="#/MailHist/{{model._id}}">{{model.name}}</a></td>
21+
<td>
22+
<timesince ng-model="model._created" />
23+
</td>
24+
<td>
25+
<timesince ng-model="model._modified" />
26+
</td>
27+
<td>{{model.readcount}}</td>
28+
<td>
29+
<a ng-href="#/MailHist/{{model._id}}"><em class="fas fa-eye"></em></a>
30+
<a ng-href="#/Entity/users/{{model.userid}}"><em class="fas fa-edit"></em></a>
31+
</td>
32+
</tr>
33+
</tbody>
34+
</table>

OpenFlow/src/public/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MenuCtrl, ProvidersCtrl, MainCtrl, LoginCtrl, ProviderCtrl, UsersCtrl, UserCtrl, RolesCtrl, RoleCtrl, RPAWorkflowsCtrl, RPAWorkflowCtrl,
66
WorkflowsCtrl, ReportsCtrl, jslogCtrl, EditFormCtrl, FormsCtrl, FormCtrl, FilesCtrl, EntitiesCtrl, EntityCtrl, HistoryCtrl, SocketCtrl, NoderedCtrl,
77
hdrobotsCtrl, ClientsCtrl, AuditlogsCtrl, SignupCtrl, QueuesCtrl, SocketsCtrl, QueueCtrl, CredentialsCtrl, CredentialCtrl, DuplicatesCtrl,
8-
OAuthClientsCtrl, OAuthClientCtrl, DeletedCtrl, CustomerCtrl, EntityRestrictionsCtrl, EntityRestrictionCtrl, CustomersCtrl, ResourcesCtrl, ResourceCtrl, WorkitemsCtrl, WorkitemCtrl, WorkitemQueuesCtrl, WorkitemQueueCtrl
8+
OAuthClientsCtrl, OAuthClientCtrl, DeletedCtrl, CustomerCtrl, EntityRestrictionsCtrl, EntityRestrictionCtrl, CustomersCtrl, ResourcesCtrl, ResourceCtrl, WorkitemsCtrl, WorkitemCtrl, WorkitemQueuesCtrl, WorkitemQueueCtrl, MailHistCtrl, MailHistsCtrl
99
} from "./Controllers";
1010

1111
require('angular-route');
@@ -147,6 +147,9 @@ module openflow {
147147
.when('/WorkitemQueue', { templateUrl: 'WorkitemQueue.html', controller: WorkitemQueueCtrl, controllerAs: 'ctrl' })
148148
.when('/WorkitemQueue/:id', { templateUrl: 'WorkitemQueue.html', controller: WorkitemQueueCtrl, controllerAs: 'ctrl' })
149149

150+
.when('/MailHists', { templateUrl: 'MailHists.html', controller: MailHistsCtrl, controllerAs: 'ctrl' })
151+
.when('/MailHist/:id', { templateUrl: 'MailHist.html', controller: MailHistCtrl, controllerAs: 'ctrl' })
152+
150153
.otherwise({ redirectTo: '/main' });
151154
}
152155
])

OpenFlow/src/public/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ <h5 class="sidebar-title">Misc management</h5>
104104
<a class="sidebar-link" ng-class="{active: menuctrl.PathIs(['/hdrobots'])}" href="#/hdrobots"><span translate
105105
lib="web">hdrobots</span></a>
106106

107-
108-
<a class="sidebar-link" href="#/Customers"
107+
<a class="sidebar-link" href="#/Customers"
109108
ng-class="{active: menuctrl.PathIs(['/Customers', '/Customer', '/Customer/'])}"
110109
ng-show="menuctrl.WebSocketClientService.multi_tenant && menuctrl.hasrole('resellers')">
111110
<span translate lib="web">customers</span></a>
112111
<a class="sidebar-link" href="#/Resources"
113112
ng-class="{active: menuctrl.PathIs(['/Resources', '/Resource', '/Resource/'])}"
114113
ng-show="menuctrl.WebSocketClientService.multi_tenant && menuctrl.hasrole('admins')">
115114
<span translate lib="web">Resources</span></a>
115+
<a class="sidebar-link" href="#/MailHists"
116+
ng-class="{active: menuctrl.PathIs(['/MailHists', '/MailHist', '/MailHist/'])}"
117+
ng-show="menuctrl.hasrole('admins') && (menuctrl.WebSocketClientService.validate_emails || menuctrl.WebSocketClientService.forgot_pass_emails)">
118+
<span translate lib="web">Mail History</span></a>
116119

117120

118121
</div>

0 commit comments

Comments
 (0)