Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private sortMedia(list: IMetaDataExtended[]): IMetaDataExtended[] {
const linqList = new List([...list]);
console.log("orderBy", this._orderConfig);
// static order for torrents
if (this._showTorrents) {
linqList.OrderByDescending((x: IMetaDataExtended): any => x.id);
} else if (this._orderConfig.directionDescending) {
linqList.OrderByDescending((x: IMetaDataExtended): any => x[this._orderConfig.orderBy]);
} else {
linqList.OrderBy((x: IMetaDataExtended): any => x[this._orderConfig.orderBy]);
}
let mediaArray = linqList.ToArray();
if (this._orderConfig.showUnwatchedFirst) {
mediaArray = _.orderBy(mediaArray, ["isWatched"], ["desc"]);
}
return mediaArray;
ngOnInit() {
this.columns = new List(this.columns)
.Where(m => m.index && m.filterable && m.type !== 'date') // TODO: date 的UI未调好,暂不过滤
.ToArray();
}
onModuleWinSubmit() {
let moduleRoot = this.moduleTree.dataSource.data()[0];
let modules = [];
this.osharp.getTreeNodes(moduleRoot, modules);
let checkModuleIds = new List(modules).Where(m => m.checked).Select(m => m.Id).ToArray();
let params = { userId: this.winUser.Id, moduleIds: checkModuleIds };
this.http.post("api/admin/user/setmodules", params).subscribe(res => {
this.osharp.ajaxResult(res, () => {
this.grid.dataSource.read();
this.moduleWindow.close();
});
});
}
onRoleWinSubmit() {
let roles = this.roleTree.dataSource.data();
let checkRoleIds = new List(roles.slice(0)).Where(m => m.checked).Select(m => m.Id).ToArray();
let params = { userId: this.winUser.Id, roleIds: checkRoleIds };
this.http.post("api/admin/user/setroles", params).subscribe(res => {
this.osharp.ajaxResult(res, () => {
this.grid.dataSource.read();
this.roleWindow.close();
});
});
}
onWinSubmit() {
let moduleRoot = this.moduleTree.dataSource.data()[0];
let modules = [];
this.osharp.getTreeNodes(moduleRoot, modules);
let checkModuleIds = new List(modules).Where(m => m.checked).Select(m => m.Id).ToArray();
let body = { roleId: this.winRole.Id, moduleIds: checkModuleIds };
this.http.post("api/admin/role/SetModules", body).subscribe(res => {
this.osharp.ajaxResult(res, () => {
this.grid.dataSource.read();
this.window.close();
});
});
}
onWindowSubmit(win) {
let root = this.functionTree.dataSource.data()[0];
let functions = [];
this.osharp.getTreeNodes(root, functions);
let checkFuncIds = new List(functions).Where(m => m.checked).Select(m => m.Id).ToArray();
let body = { moduleId: this.winModule.Id, functionIds: checkFuncIds };
this.http.post("api/admin/module/setfunctions", body).subscribe(res => {
this.osharp.ajaxResult(res, () => {
$("#btn-refresh-function").click();
this.window.close();
});
});
}
//#endregion
onWinSubmit(win) {
let roles = this.roleTree.dataSource.data();
let checkRoleIds = new List(roles.slice(0)).Where(m => m.checked).Select(m => m.Id).ToArray();
let moduleRoot = this.moduleTree.dataSource.data()[0];
let modules = [];
this.osharp.getTreeNodes(moduleRoot, modules);
let checkModuleIds = new List(modules).Where(m => m.checked).Select(m => m.Id).ToArray();
let params = { userId: this.winUser.Id, roleIds: checkRoleIds, moduleIds: checkModuleIds };
this.http.post("/api/admin/user/setpermission", params).subscribe(res => {
this.osharp.ajaxResult(res, () => {
this.grid.dataSource.read();
this.window.close();
});
});
}
removeMenu(item: menuItem) {
let list = new List<menuitem>(this.menuItems);
this.menuItems = list.RemoveAll(m => m.text == item.text).ToArray();
}
</menuitem>
}
break;
case 'System.String':
this.operateEntries = this.getOperateEntries([FilterOperate.Equal, FilterOperate.NotEqual, FilterOperate.StartsWith, FilterOperate.EndsWith, FilterOperate.Contains, FilterOperate.NotContains]);
if (!this.rule.Value) {
this.rule.Value = '';
}
break;
default:
this.operateEntries = this.getOperateEntries([FilterOperate.Equal, FilterOperate.NotEqual, FilterOperate.Less, FilterOperate.LessOrEqual, FilterOperate.Greater, FilterOperate.GreaterOrEqual, FilterOperate.StartsWith, FilterOperate.EndsWith, FilterOperate.Contains, FilterOperate.NotContains]);
if (!this.rule.Value) {
this.rule.Value = '';
}
break;
}
if (!this.rule.Operate || !new List(this.operateEntries).Any(m => m.Operate == this.rule.Operate)) {
this.rule.Operate = this.operateEntries[0].Operate;
}
}
request({ url: slack.url + slack.api.channels_history, qs: { token: slack.token, channel: e, count: 1000 }, timeout: 5000, json: true }, (err, resp, reqData) => {
if (err || resp.statusCode != 200)
return err || new Error("Error: " + resp.statusCode);
if (reqData.ok || reqData.ok == "true") {
var messages = reqData.messages;
var messageList = new List(messages);
console.log(colors.debug(" >> Fetching the channel history. ID: " + e + " / Count: " + messageList.Count() + " " + (messageList.Count() == 0 ? "- " + colors.error("Data not available") : "")));
messageList.ToArray().forEach(k => {
_messageList.push({ channelId: e, message: k });
});
if (messageList.Count() > 0 && !start)
removeHistoryMessage(0);
var i = index + 1;
getHistoryMessage(data, i);
} else {
console.log(colors.error("Error: " + reqData.error));
}