Skip to content

Commit 26e89b0

Browse files
committed
fix perm
1 parent 3531151 commit 26e89b0

4 files changed

Lines changed: 40 additions & 39 deletions

File tree

OpenFlow/src/User.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export class User extends Base {
4646
user = await Config.db.InsertOne(user, "users", 0, false, jwt);
4747
user = User.assign(user);
4848
user.addRight(WellknownIds.admins, "admins", [Rights.full_control]);
49-
user.removeRight(WellknownIds.admins, [Rights.delete]);
5049
user.addRight(user._id, user.name, [Rights.full_control]);
5150
user.removeRight(user._id, [Rights.delete]);
5251
await user.Save(jwt);

OpenFlow/src/public/Controllers.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ module openflow {
842842
});
843843
}
844844
async loadUsers(): Promise<void> {
845-
this.allusers = await this.api.Query(this.collection, { $or: [{ _type: "user" }, { _type: "role" }] }, null, { _type: -1, name: 1 });
845+
this.allusers = await this.api.Query("users", { $or: [{ _type: "user" }, { _type: "role" }] }, null, { _type: -1, name: 1 });
846846
if (this.model.members === undefined) { this.model.members = []; }
847847
var ids: string[] = [];
848848
for (var i: number = 0; i < this.model.members.length; i++) {
@@ -1480,6 +1480,7 @@ module openflow {
14801480
public jsonmodel: string = "";
14811481
public newuser: openflow.TokenUser;
14821482
public usergroups: openflow.TokenUser[] = [];
1483+
public allusergroups: openflow.TokenUser[] = [];
14831484
constructor(
14841485
public $scope: ng.IScope,
14851486
public $location: ng.ILocationService,
@@ -1493,7 +1494,8 @@ module openflow {
14931494
this.collection = $routeParams.collection;
14941495
this.postloadData = this.processdata;
14951496
WebSocketClient.onSignedin(async (user: TokenUser) => {
1496-
this.usergroups = await this.api.Query("users", {});
1497+
// this.usergroups = await this.api.Query("users", {});
1498+
this.allusergroups = await this.api.Query("users", { $or: [{ _type: "user" }, { _type: "role" }] }, null, { _type: -1, name: 1 });
14971499
if (this.id !== null && this.id !== undefined) {
14981500
await this.loadData();
14991501
} else {
@@ -1509,26 +1511,12 @@ module openflow {
15091511
});
15101512
}
15111513
processdata() {
1512-
// $(document)
1513-
// .one('focus.autoExpand', 'textarea.autoExpand', function () {
1514-
// var savedValue = this.value;
1515-
// this.value = '';
1516-
// this.baseScrollHeight = this.scrollHeight;
1517-
// this.value = savedValue;
1518-
1519-
// var minRows = this.getAttribute('data-min-rows') | 0, rows;
1520-
// this.rows = minRows;
1521-
// rows = Math.ceil((this.scrollHeight - this.baseScrollHeight) / 16);
1522-
// this.rows = minRows + rows;
1523-
// })
1524-
// .on('input.autoExpand', 'textarea.autoExpand', function () {
1525-
// var minRows = this.getAttribute('data-min-rows') | 0, rows;
1526-
// // this.rows = minRows;
1527-
// rows = Math.ceil((this.scrollHeight - this.baseScrollHeight) / 16);
1528-
// if (this.rows < (minRows + rows)) {
1529-
// this.rows = minRows + rows;
1530-
// }
1531-
// });
1514+
var ids: string[] = [];
1515+
for (var i: number = 0; i < this.model._acl.length; i++) {
1516+
ids.push(this.model._acl[i]._id);
1517+
}
1518+
this.usergroups = this.allusergroups.filter(x => ids.indexOf(x._id) == -1);
1519+
this.newuser = this.usergroups[0];
15321520
if (!this.$scope.$$phase) { this.$scope.$apply(); }
15331521
}
15341522
togglejson() {
@@ -1576,6 +1564,13 @@ module openflow {
15761564
//this.model._acl = this.model._acl.splice(index, 1);
15771565
}
15781566
}
1567+
var ids: string[] = [];
1568+
for (var i: number = 0; i < this.model._acl.length; i++) {
1569+
ids.push(this.model._acl[i]._id);
1570+
}
1571+
this.usergroups = this.allusergroups.filter(x => ids.indexOf(x._id) == -1);
1572+
this.newuser = this.usergroups[0];
1573+
15791574
}
15801575
adduser() {
15811576
var ace = new Ace();
@@ -1584,6 +1579,13 @@ module openflow {
15841579
ace.name = this.newuser.name;
15851580
ace.rights = "//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8=";
15861581
this.model._acl.push(ace);
1582+
var ids: string[] = [];
1583+
for (var i: number = 0; i < this.model._acl.length; i++) {
1584+
ids.push(this.model._acl[i]._id);
1585+
}
1586+
this.usergroups = this.allusergroups.filter(x => ids.indexOf(x._id) == -1);
1587+
this.newuser = this.usergroups[0];
1588+
15871589
}
15881590
isBitSet(base64: string, bit: number): boolean {
15891591
bit--;

OpenFlow/src/public/Entity.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@ <h1 class="pagetitle"><span translate lib="web">detailsfor</span> {{ctrl.model.n
44
</div>
55
</div>
66

7+
<section>
8+
<div class="form-group">
9+
<div class="col-sm-9">
10+
<label class="control-label"><span translate lib="web">adduser</span>
11+
<select ng-model="ctrl.newuser"
12+
ng-options="item as (item.name + ' ' + item.username) for item in ctrl.usergroups">
13+
</select>
14+
<button type="button" ng-click="ctrl.adduser()" ng-disabled="ctrl.loading || ctrl.newuser==null"
15+
translate lib="web">insert</button>
16+
17+
</div>
18+
</div>
19+
</section>
720

821
<section ng-repeat="ace in ctrl.model._acl" ng-show="ctrl.collection!='files'">
922
<div class="form-group">
10-
<div class="col-sm-9">
11-
<label class="col-sm-3 control-label">{{ace.name}}: <a href="" ng-click="ctrl.removeuser(ace._id)" translate
12-
lib="web">delete</a></label>
23+
<div class="col-sm-9 input-group">
24+
<label class="col-sm-3 control-label">{{ace.name}}: </label>
1325
<input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace.rights, 1)"
1426
ng-click="ctrl.toogleBit(ace, 1)" value="1" id="{{ace._id}}" /> create
1527
<input ng-disabled="ctrl.loading==true" type="checkbox" ng-checked="ctrl.isBitSet(ace.rights, 2)"
@@ -25,18 +37,6 @@ <h1 class="pagetitle"><span translate lib="web">detailsfor</span> {{ctrl.model.n
2537
</div>
2638
</div>
2739
</section>
28-
<section>
29-
<div class="form-group">
30-
<div class="col-sm-9">
31-
<label class="control-label"><span translate lib="web">adduser</span>
32-
<select ng-model="ctrl.newuser" ng-options="item as item.name for item in ctrl.usergroups">
33-
</select>
34-
<button type="button" ng-click="ctrl.adduser()" ng-disabled="ctrl.loading || ctrl.newuser==null"
35-
translate lib="web">insert</button>
36-
37-
</div>
38-
</div>
39-
</section>
4040

4141

4242
<pre ng-show="ErrorMessage!=null">{{ ErrorMessage }}</pre>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.326
1+
0.0.327

0 commit comments

Comments
 (0)